New submission from sjpalt:
I ran into a strange bug while experimenting with metaclasses that implement a
custom mro() method. It only seems to occur in interactive mode, either
returning completely unrelated values or causing a segfault. Python 2 appears
unaffected. I have been able to reproduce this with the following code:
# $ python -i weird.py
# >>> proxy.x
# 52011448
# >>> proxy.x
# 6160
# ...
class Foo:
pass
class Meta(type):
def mro(cls):
return (cls, Foo, object)
def __setattr__(cls, name, value):
setattr(Foo, name, value)
proxy = Meta('FooProxy', (), {})
proxy.x = 300
proxy.x # don't omit
proxy.x = 0
----------
components: Interpreter Core
files: weird.py
messages: 282344
nosy: sjpalt
priority: normal
severity: normal
status: open
title: Unexpected behavior resulting from mro() and __setattr__ in interactive
mode
type: crash
versions: Python 3.4, Python 3.5
Added file: http://bugs.python.org/file45752/weird.py
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue28866>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com