Skip to content

Instantly share code, notes, and snippets.

@mwhudson
Created April 15, 2017 19:31
Show Gist options
  • Save mwhudson/71f47be52ea722506f0a42d3dba53746 to your computer and use it in GitHub Desktop.
Save mwhudson/71f47be52ea722506f0a42d3dba53746 to your computer and use it in GitHub Desktop.
pathological python
mwhudson@aeglos:~$ cat mro.py
class T(type):
def mro(self):
return []
class X(object,metaclass=T):
pass
class Y(object):
pass
x = Y()
x.__class__ = X
print(isinstance(x, object))
mwhudson@aeglos:~$ python3 mro.py
False
@DRMacIver
Copy link

On Python 3.6.x:

Traceback (most recent call last):
  File "pathological.py", line 5, in <module>
    class X(object,metaclass=T):
TypeError: super(type, obj): obj must be an instance or subtype of type

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment