This instance will be upgraded to Heptapod 0.21.0rc3 on 2021-04-23 at 10:30 UTC+2 (a few minutes of down time)

Commit f57ce76d authored by Matti Picus's avatar Matti Picus

fix structseq attribute setter error message

parent f9accdf0a80c
......@@ -104,8 +104,11 @@ def structseq_reduce(self):
return type(self), (tuple(self), self.__dict__)
def structseq_setattr(self, attr, value):
raise AttributeError("%r object has no attribute %r" % (
self.__class__.__name__, attr))
if attr not in type(self).__dict__:
raise AttributeError("%r object has no attribute %r" % (
self.__class__.__name__, attr))
else:
raise TypeError("readonly attribute")
def structseq_repr(self):
fields = {}
......
......@@ -141,6 +141,16 @@ class AppTestAppSysTests:
exc = raises(SystemExit, sys.exit, (1, 2, 3))
assert exc.value.code == (1, 2, 3)
def test_sys_flags(self):
import sys
# sanity check
assert sys.flags.optimize is not None
# make sure the flags are read-only
exc = raises(TypeError, 'sys.flags.optimize = 3')
assert 'readonly' in str(exc.value)
raises(AttributeError, 'sys.flags.not_a_sys_flag = 2')
class AppTestSysModulePortedFromCPython:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment