[Python-3000-checkins] r54602 - in python/branches/p3yk: Lib/test/test_csv.py Lib/test/test_descr.py Lib/test/test_generators.py Lib/test/test_os.py Python/structmember.c
collin.winter
python-3000-checkins at python.org
Wed Mar 28 23:44:57 CEST 2007
Author: collin.winter
Date: Wed Mar 28 23:44:53 2007
New Revision: 54602
Modified:
python/branches/p3yk/Lib/test/test_csv.py
python/branches/p3yk/Lib/test/test_descr.py
python/branches/p3yk/Lib/test/test_generators.py
python/branches/p3yk/Lib/test/test_os.py
python/branches/p3yk/Python/structmember.c
Log:
Make readonly members defined in C throw an AttributeError on modification. This brings them into sync with Python-level attributes. Fixes bug #1687163.
Modified: python/branches/p3yk/Lib/test/test_csv.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_csv.py (original)
+++ python/branches/p3yk/Lib/test/test_csv.py Wed Mar 28 23:44:53 2007
@@ -53,8 +53,8 @@
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)
Modified: python/branches/p3yk/Lib/test/test_descr.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_descr.py (original)
+++ python/branches/p3yk/Lib/test/test_descr.py Wed Mar 28 23:44:53 2007
@@ -1857,13 +1857,13 @@
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):
Modified: python/branches/p3yk/Lib/test/test_generators.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_generators.py (original)
+++ python/branches/p3yk/Lib/test/test_generators.py Wed Mar 28 23:44:53 2007
@@ -400,7 +400,7 @@
>>> i.gi_running = 42
Traceback (most recent call last):
...
-TypeError: readonly attribute
+AttributeError: readonly attribute
>>> def g():
... yield me.gi_running
>>> me = g()
Modified: python/branches/p3yk/Lib/test/test_os.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_os.py (original)
+++ python/branches/p3yk/Lib/test/test_os.py Wed Mar 28 23:44:53 2007
@@ -143,7 +143,7 @@
try:
result.st_mode = 1
self.fail("No exception thrown")
- except TypeError:
+ except AttributeError:
pass
try:
@@ -201,7 +201,7 @@
try:
result.f_bfree = 1
self.fail("No exception thrown")
- except TypeError:
+ except AttributeError:
pass
try:
Modified: python/branches/p3yk/Python/structmember.c
==============================================================================
--- python/branches/p3yk/Python/structmember.c (original)
+++ python/branches/p3yk/Python/structmember.c Wed Mar 28 23:44:53 2007
@@ -164,7 +164,7 @@
if ((l->flags & READONLY) || l->type == T_STRING)
{
- PyErr_SetString(PyExc_TypeError, "readonly attribute");
+ PyErr_SetString(PyExc_AttributeError, "readonly attribute");
return -1;
}
if ((l->flags & WRITE_RESTRICTED) && PyEval_GetRestricted()) {
More information about the Python-3000-checkins
mailing list