New submission from ppperry:

If you try to set the __class__ of a type which doesn't support "__class__" 
assignments, you get the error message:

    TypeError: __class__ assignment only supported for heap types or ModuleType 
subclasses

However, the actual restriction doesn't require a subclass of "ModuleType"; the 
below code works:

    import random
    class M(type(random)):pass
    random.__class__ = M

Thus the error message is incorrect.

----------
components: Interpreter Core
messages: 289448
nosy: ppperry
priority: normal
severity: normal
status: open
title: Incorrect error message on invalid __class__ assignments
type: behavior
versions: Python 3.6

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29794>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to