mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Make readonly members defined in C throw an AttributeError on modification. This brings them into sync with Python-level attributes. Fixes bug #1687163.
This commit is contained in:
parent
d84da1b67a
commit
42dae6a89b
5 changed files with 9 additions and 9 deletions
|
@ -1857,13 +1857,13 @@ def properties():
|
|||
for attr in "__doc__", "fget", "fset", "fdel":
|
||||
try:
|
||||
setattr(raw, attr, 42)
|
||||
except TypeError as msg:
|
||||
except AttributeError as msg:
|
||||
if str(msg).find('readonly') < 0:
|
||||
raise TestFailed("when setting readonly attr %r on a "
|
||||
"property, got unexpected TypeError "
|
||||
"property, got unexpected AttributeError "
|
||||
"msg %r" % (attr, str(msg)))
|
||||
else:
|
||||
raise TestFailed("expected TypeError from trying to set "
|
||||
raise TestFailed("expected AttributeError from trying to set "
|
||||
"readonly %r attr on a property" % attr)
|
||||
|
||||
class D(object):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue