Last active
November 4, 2015 11:08
-
-
Save kezabelle/5de40cb08bd6d155b417 to your computer and use it in GitHub Desktop.
how the hell does one debug this
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def _lol(value): | |
vt = type(value) | |
isuuid = isinstance(value, UUID) | |
isuuidsub = None | |
cls = None | |
def idhashs(): | |
from uuid import uuid4, UUID | |
return id(uuid4), id(UUID), hash(uuid4), hash(UUID) | |
uuid4id, uuidid, uuid4hash, uuidhash = idhashs() | |
ourid, ourhash = None, None | |
thedir = dir(value) | |
clsdir = None | |
mro = -1 | |
getfile = -1 | |
if hasattr(value, '__class__'): | |
cls = value.__class__ | |
mro = inspect.getmro(cls) | |
getfile = inspect.getfile(cls) | |
ourid = id(value.__class__) | |
ourhash = hash(value.__class__) | |
isuuidsub = issubclass(value.__class__, UUID) | |
clsdir = dir(value.__class__) | |
ledict = None | |
rep = repr(value) | |
ledict = getattr(value, '__dict__', -1) | |
mod = getattr(value, '__module__', -1) | |
bases = getattr(value, '__bases__', -1) | |
name = getattr(value, '__name__', -1) | |
return { | |
'type': vt, | |
'is_instance': isuuid, | |
'is_subclass': isuuidsub, | |
'rep': rep, | |
'bases': bases, | |
'cls': cls, | |
'dict': ledict, | |
'module': mod, | |
'hashes_and_ids': { | |
'broken': { | |
'id': ourid, | |
'hash': ourhash | |
}, | |
'UUID': { | |
'id': uuidid, | |
'hash': uuidhash | |
}, | |
}, | |
'dir': { | |
'instance': thedir, | |
'class': clsdir | |
}, | |
'inspect': { | |
'getfile': getfile, | |
'getmro': mro, | |
'func_code': getattr(value, 'func_code', -1) | |
}, | |
} | |
def lol(value): | |
from pprint import pprint | |
return pprint(_lol(value)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{'bases': -1, | |
'cls': <class 'uuid.UUID'>, | |
'dict': {'int': 146029937343130886346045844241709238468L}, | |
'dir': {'class': ['__class__', | |
'__cmp__', | |
'__delattr__', | |
'__dict__', | |
'__doc__', | |
'__format__', | |
'__getattribute__', | |
'__hash__', | |
'__init__', | |
'__int__', | |
'__module__', | |
'__new__', | |
'__reduce__', | |
'__reduce_ex__', | |
'__repr__', | |
'__setattr__', | |
'__sizeof__', | |
'__str__', | |
'__subclasshook__', | |
'__weakref__', | |
'bytes', | |
'bytes_le', | |
'clock_seq', | |
'clock_seq_hi_variant', | |
'clock_seq_low', | |
'fields', | |
'get_bytes', | |
'get_bytes_le', | |
'get_clock_seq', | |
'get_clock_seq_hi_variant', | |
'get_clock_seq_low', | |
'get_fields', | |
'get_hex', | |
'get_node', | |
'get_time', | |
'get_time_hi_version', | |
'get_time_low', | |
'get_time_mid', | |
'get_urn', | |
'get_variant', | |
'get_version', | |
'hex', | |
'node', | |
'time', | |
'time_hi_version', | |
'time_low', | |
'time_mid', | |
'urn', | |
'variant', | |
'version'], | |
'instance': ['__class__', | |
'__cmp__', | |
'__delattr__', | |
'__dict__', | |
'__doc__', | |
'__format__', | |
'__getattribute__', | |
'__hash__', | |
'__init__', | |
'__int__', | |
'__module__', | |
'__new__', | |
'__reduce__', | |
'__reduce_ex__', | |
'__repr__', | |
'__setattr__', | |
'__sizeof__', | |
'__str__', | |
'__subclasshook__', | |
'__weakref__', | |
'bytes', | |
'bytes_le', | |
'clock_seq', | |
'clock_seq_hi_variant', | |
'clock_seq_low', | |
'fields', | |
'get_bytes', | |
'get_bytes_le', | |
'get_clock_seq', | |
'get_clock_seq_hi_variant', | |
'get_clock_seq_low', | |
'get_fields', | |
'get_hex', | |
'get_node', | |
'get_time', | |
'get_time_hi_version', | |
'get_time_low', | |
'get_time_mid', | |
'get_urn', | |
'get_variant', | |
'get_version', | |
'hex', | |
'int', | |
'node', | |
'time', | |
'time_hi_version', | |
'time_low', | |
'time_mid', | |
'urn', | |
'variant', | |
'version']}, | |
'hashes_and_ids': {'UUID': {'hash': 8777548736292, 'id': 140440779780672}, | |
'broken': {'hash': 8777548736292, 'id': 140440779780672}}, | |
'inspect': {'func_code': -1, | |
'getfile': '/path//lib/python2.7/uuid.pyc', | |
'getmro': (<class 'uuid.UUID'>, <type 'object'>)}, | |
'is_instance': True, | |
'is_subclass': True, | |
'module': 'uuid', | |
'rep': "UUID('6ddc57c8-fd6b-41dc-babb-f0a5e2fb88c4')", | |
'type': <class 'uuid.UUID'>} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# type(...) returns uuid.UUID? | |
# isinstance(...) is False | |
EncodeError: Can't pickle <class 'uuid.UUID'>: it's not the same object as uuid.UUID | |
# and also I think ... | |
TypeError: UUID('11111111-1111-1111-1111-111111111111') is not JSON serializable |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
And somehow, hey look, isinstance failure: