Skip to content

Instantly share code, notes, and snippets.

@davisagli
Created November 9, 2018 07:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davisagli/ee052842c1d6de28d1d935ad7f3efa7b to your computer and use it in GitHub Desktop.
Save davisagli/ee052842c1d6de28d1d935ad7f3efa7b to your computer and use it in GitHub Desktop.
# Change set.__module__ to 'builtins'
# so that it will pickle with the right module for Python 3
from ctypes import Structure, c_ssize_t, c_void_p, c_char_p
class PyTypeObject(Structure):
_fields_ = [
('ob_refcnt', c_ssize_t),
('ob_type', c_void_p),
('ob_size', c_ssize_t),
('tp_name', c_char_p),
]
set_type = PyTypeObject.from_address(id(set))
set_type.tp_name = 'builtins.set'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment