summaryrefslogtreecommitdiff
path: root/Lib
diff options
context:
space:
mode:
authorCollin Winter <collinw@gmail.com>2007-03-28 21:44:53 +0000
committerCollin Winter <collinw@gmail.com>2007-03-28 21:44:53 +0000
commitae9840c1c4fd443356bf266e4839235f207c6908 (patch)
treea55a2454257f08126db64d4555f2cbca3ead947d /Lib
parentd1a15a19ae9c31e99c529da34ddf4c1b6ac89361 (diff)
downloadcpython-ae9840c1c4fd443356bf266e4839235f207c6908.tar.gz
Make readonly members defined in C throw an AttributeError on modification. This brings them into sync with Python-level attributes. Fixes bug #1687163.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_csv.py4
-rw-r--r--Lib/test/test_descr.py6
-rw-r--r--Lib/test/test_generators.py2
-rw-r--r--Lib/test/test_os.py4
4 files changed, 8 insertions, 8 deletions
diff --git a/Lib/test/test_csv.py b/Lib/test/test_csv.py
index 46361c8254..2cdc807444 100644
--- a/Lib/test/test_csv.py
+++ b/Lib/test/test_csv.py
@@ -53,8 +53,8 @@ class Test_Csv(unittest.TestCase):
self.assertEqual(obj.dialect.skipinitialspace, False)
self.assertEqual(obj.dialect.strict, False)
# Try deleting or changing attributes (they are read-only)
- self.assertRaises(TypeError, delattr, obj.dialect, 'delimiter')
- self.assertRaises(TypeError, setattr, obj.dialect, 'delimiter', ':')
+ self.assertRaises(AttributeError, delattr, obj.dialect, 'delimiter')
+ self.assertRaises(AttributeError, setattr, obj.dialect, 'delimiter', ':')
self.assertRaises(AttributeError, delattr, obj.dialect, 'quoting')
self.assertRaises(AttributeError, setattr, obj.dialect,
'quoting', None)
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index 6cd8ccd8c3..eec4e40f5b 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -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):
diff --git a/Lib/test/test_generators.py b/Lib/test/test_generators.py
index 7999034fe7..12276be0d9 100644
--- a/Lib/test/test_generators.py
+++ b/Lib/test/test_generators.py
@@ -400,7 +400,7 @@ And more, added later.
>>> i.gi_running = 42
Traceback (most recent call last):
...
-TypeError: readonly attribute
+AttributeError: readonly attribute
>>> def g():
... yield me.gi_running
>>> me = g()
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py
index 93e530c22c..a7fc1da7de 100644
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -143,7 +143,7 @@ class StatAttributeTests(unittest.TestCase):
try:
result.st_mode = 1
self.fail("No exception thrown")
- except TypeError:
+ except AttributeError:
pass
try:
@@ -201,7 +201,7 @@ class StatAttributeTests(unittest.TestCase):
try:
result.f_bfree = 1
self.fail("No exception thrown")
- except TypeError:
+ except AttributeError:
pass
try: