{"id":31782407,"url":"https://github.com/zopefoundation/zodbpickle","last_synced_at":"2025-10-10T09:20:19.859Z","repository":{"id":6956480,"uuid":"8208647","full_name":"zopefoundation/zodbpickle","owner":"zopefoundation","description":"Fork of Python's pickle module to work with ZODB","archived":false,"fork":false,"pushed_at":"2025-02-11T12:55:28.000Z","size":603,"stargazers_count":18,"open_issues_count":4,"forks_count":15,"subscribers_count":65,"default_branch":"master","last_synced_at":"2025-02-11T13:43:54.106Z","etag":null,"topics":["maintained"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zopefoundation.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGES.rst","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-02-14T22:05:01.000Z","updated_at":"2024-12-29T05:13:09.000Z","dependencies_parsed_at":"2023-01-13T16:23:33.081Z","dependency_job_id":"a191fdaa-e4aa-4742-9d27-5828f379c1d5","html_url":"https://github.com/zopefoundation/zodbpickle","commit_stats":{"total_commits":195,"total_committers":13,"mean_commits":15.0,"dds":0.7538461538461538,"last_synced_commit":"1d2d9804407f78b31d7907234d3eb3ed75e1d940"},"previous_names":[],"tags_count":36,"template":false,"template_full_name":null,"purl":"pkg:github/zopefoundation/zodbpickle","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zopefoundation%2Fzodbpickle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zopefoundation%2Fzodbpickle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zopefoundation%2Fzodbpickle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zopefoundation%2Fzodbpickle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zopefoundation","download_url":"https://codeload.github.com/zopefoundation/zodbpickle/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zopefoundation%2Fzodbpickle/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279003411,"owners_count":26083581,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["maintained"],"created_at":"2025-10-10T09:20:18.621Z","updated_at":"2025-10-10T09:20:19.853Z","avatar_url":"https://github.com/zopefoundation.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"``zodbpickle`` README\n=====================\n\n.. image:: https://github.com/zopefoundation/zodbpickle/actions/workflows/tests.yml/badge.svg\n        :target: https://github.com/zopefoundation/zodbpickle/actions/workflows/tests.yml\n\n.. image:: https://coveralls.io/repos/github/zopefoundation/zodbpickle/badge.svg\n   :target: https://coveralls.io/github/zopefoundation/zodbpickle\n   :alt: Coverage status\n\n.. image:: https://img.shields.io/pypi/v/zodbpickle.svg\n        :target: https://pypi.python.org/pypi/zodbpickle\n        :alt: PyPI\n\n.. image:: https://img.shields.io/pypi/pyversions/zodbpickle.svg\n        :target: https://pypi.python.org/pypi/zodbpickle\n        :alt: Python versions\n\nThis package presents a uniform pickling interface for ZODB:\n\n- Under Python2, this package forks both Python 2.7's ``pickle`` and\n  ``cPickle`` modules, adding support for the ``protocol 3`` opcodes.\n  It also provides a new subclass of ``bytes``, ``zodbpickle.binary``,\n  which Python2 applications can use to pickle binary values such that\n  they will be unpickled as ``bytes`` under Py3k.\n\n- Under Py3k, this package forks the ``pickle`` module (and the supporting\n  C extension) from both Python 3.2 and Python 3.3.  The fork add support\n  for the ``noload`` operations used by ZODB.\n\nCaution\n-------\n\n``zodbpickle`` relies on Python's ``pickle`` module.\nThe ``pickle`` module is not intended to be secure against erroneous or\nmaliciously constructed data. Never unpickle data received from an\nuntrusted or unauthenticated source as arbitrary code might be executed.\n\nAlso see https://docs.python.org/3.6/library/pickle.html\n\nGeneral Usage\n-------------\n\nTo get compatibility between Python 2 and 3 pickling, replace::\n\n    import pickle\n\nby::\n\n    from zodbpickle import pickle\n\nThis provides compatibility, but has the effect that you get the fast implementation\nin Python 3, while Python 2 uses the slow version.\n\nTo get a more deterministic choice of the implementation, use one of::\n\n    from zodbpickle import fastpickle # always C\n    from zodbpickle import slowpickle # always Python\n\nBoth modules can co-exist which is helpful for comparison.\n\nBut there is a bit more to consider, so please read on!\n\nLoading/Storing Python 2 Strings\n--------------------------------\n\nIn all their wisdom, the Python developers have decided that Python 2 ``str``\ninstances should be loaded as Python 3 ``str`` objects (i.e. unicode\nstrings). Patches were proposed in Python `issue 6784`__ but were never\napplied. This code base contains those patches.\n\n.. __: http://bugs.python.org/issue6784\n\nExample 1: Loading Python 2 pickles on Python 3 ::\n\n    $ python2\n    \u003e\u003e\u003e import pickle\n    \u003e\u003e\u003e pickle.dumps('\\xff', protocol=0)\n    \"S'\\\\xff'\\np0\\n.\"\n    \u003e\u003e\u003e pickle.dumps('\\xff', protocol=1)\n    'U\\x01\\xffq\\x00.'\n    \u003e\u003e\u003e pickle.dumps('\\xff', protocol=2)\n    '\\x80\\x02U\\x01\\xffq\\x00.'\n\n    $ python3\n    \u003e\u003e\u003e from zodbpickle import pickle\n    \u003e\u003e\u003e pickle.loads(b\"S'\\\\xff'\\np0\\n.\", encoding='bytes')\n    b'\\xff'\n    \u003e\u003e\u003e pickle.loads(b'U\\x01\\xffq\\x00.', encoding='bytes')\n    b'\\xff'\n    \u003e\u003e\u003e pickle.loads(b'\\x80\\x02U\\x01\\xffq\\x00.', encoding='bytes')\n    b'\\xff'\n\nExample 2: Loading Python 3 pickles on Python 2 ::\n\n    $ python3\n    \u003e\u003e\u003e from zodbpickle import pickle\n    \u003e\u003e\u003e pickle.dumps(b\"\\xff\", protocol=0)\n    b'c_codecs\\nencode\\np0\\n(V\\xff\\np1\\nVlatin1\\np2\\ntp3\\nRp4\\n.'\n    \u003e\u003e\u003e pickle.dumps(b\"\\xff\", protocol=1)\n    b'c_codecs\\nencode\\nq\\x00(X\\x02\\x00\\x00\\x00\\xc3\\xbfq\\x01X\\x06\\x00\\x00\\x00latin1q\\x02tq\\x03Rq\\x04.'\n    \u003e\u003e\u003e pickle.dumps(b\"\\xff\", protocol=2)\n    b'\\x80\\x02c_codecs\\nencode\\nq\\x00X\\x02\\x00\\x00\\x00\\xc3\\xbfq\\x01X\\x06\\x00\\x00\\x00latin1q\\x02\\x86q\\x03Rq\\x04.'\n\n    $ python2\n    \u003e\u003e\u003e import pickle\n    \u003e\u003e\u003e pickle.loads('c_codecs\\nencode\\np0\\n(V\\xff\\np1\\nVlatin1\\np2\\ntp3\\nRp4\\n.')\n    '\\xff'\n    \u003e\u003e\u003e pickle.loads('c_codecs\\nencode\\nq\\x00(X\\x02\\x00\\x00\\x00\\xc3\\xbfq\\x01X\\x06\\x00\\x00\\x00latin1q\\x02tq\\x03Rq\\x04.')\n    '\\xff'\n    \u003e\u003e\u003e pickle.loads('\\x80\\x02c_codecs\\nencode\\nq\\x00X\\x02\\x00\\x00\\x00\\xc3\\xbfq\\x01X\\x06\\x00\\x00\\x00latin1q\\x02\\x86q\\x03Rq\\x04.')\n    '\\xff'\n\nExample 3: everything breaks down ::\n\n    $ python2\n    \u003e\u003e\u003e class Foo(object):\n    ...     def __init__(self):\n    ...         self.x = 'hello'\n    ...\n    \u003e\u003e\u003e import pickle\n    \u003e\u003e\u003e pickle.dumps(Foo(), protocol=0)\n    \"ccopy_reg\\n_reconstructor\\np0\\n(c__main__\\nFoo\\np1\\nc__builtin__\\nobject\\np2\\nNtp3\\nRp4\\n(dp5\\nS'x'\\np6\\nS'hello'\\np7\\nsb.\"\n    \u003e\u003e\u003e pickle.dumps(Foo(), protocol=1)\n    'ccopy_reg\\n_reconstructor\\nq\\x00(c__main__\\nFoo\\nq\\x01c__builtin__\\nobject\\nq\\x02Ntq\\x03Rq\\x04}q\\x05U\\x01xq\\x06U\\x05helloq\\x07sb.'\n    \u003e\u003e\u003e pickle.dumps(Foo(), protocol=2)\n    '\\x80\\x02c__main__\\nFoo\\nq\\x00)\\x81q\\x01}q\\x02U\\x01xq\\x03U\\x05helloq\\x04sb.'\n\n    $ python3\n    \u003e\u003e\u003e from zodbpickle import pickle\n    \u003e\u003e\u003e class Foo(object): pass\n    ...\n    \u003e\u003e\u003e foo = pickle.loads(\"ccopy_reg\\n_reconstructor\\np0\\n(c__main__\\nFoo\\np1\\nc__builtin__\\nobject\\np2\\nNtp3\\nRp4\\n(dp5\\nS'x'\\np6\\nS'hello'\\np7\\nsb.\", encoding='bytes')\n    \u003e\u003e\u003e foo.x\n    Traceback (most recent call last):\n      File \"\u003cstdin\u003e\", line 1, in \u003cmodule\u003e\n    AttributeError: 'Foo' object has no attribute 'x'\n\nwait what? ::\n\n    \u003e\u003e\u003e foo.__dict__\n    {b'x': b'hello'}\n\noooh.  So we use ``encoding='ASCII'`` (the default) and ``errors='bytes'`` and\nhope it works::\n\n    \u003e\u003e\u003e foo = pickle.loads(\"ccopy_reg\\n_reconstructor\\np0\\n(c__main__\\nFoo\\np1\\nc__builtin__\\nobject\\np2\\nNtp3\\nRp4\\n(dp5\\nS'x'\\np6\\nS'hello'\\np7\\nsb.\", errors='bytes')\n    \u003e\u003e\u003e foo.x\n    'hello'\n\nfalling back to bytes if necessary ::\n\n    \u003e\u003e\u003e pickle.loads(b'\\x80\\x02U\\x01\\xffq\\x00.', errors='bytes')\n    b'\\xff'\n\n\nSupport for ``noload()``\n------------------------\n\nThe ZODB uses `cPickle`'s ``noload()`` method to retrieve all persistent\nreferences from a pickle without loading any objects. This feature was removed\nfrom Python 3's pickle. Unfortuantely, this unnecessarily fills the pickle\ncache.\n\nThis module provides a ``noload()`` method again.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzopefoundation%2Fzodbpickle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzopefoundation%2Fzodbpickle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzopefoundation%2Fzodbpickle/lists"}