diff options
author | Mark Dickinson <dickinsm@gmail.com> | 2010-04-06 15:44:57 (GMT) |
---|---|---|
committer | Mark Dickinson <dickinsm@gmail.com> | 2010-04-06 15:44:57 (GMT) |
commit | bee1fb0f75331bf5ba97579d75ac623c2edcaa25 (patch) | |
tree | 5141b33ce1e910e07ce323fc39be355a5a56a83b /Lib | |
parent | de33ffffed46521a7ffd62350ecfd8f5f7ec8943 (diff) | |
download | cpython-bee1fb0f75331bf5ba97579d75ac623c2edcaa25.zip cpython-bee1fb0f75331bf5ba97579d75ac623c2edcaa25.tar.gz cpython-bee1fb0f75331bf5ba97579d75ac623c2edcaa25.tar.bz2 |
Merged revisions 78918,78920 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r78918 | mark.dickinson | 2010-03-13 11:34:40 +0000 (Sat, 13 Mar 2010) | 4 lines
Issue #8014: Fix PyLong_As<c-integer-type> methods not to produce an
internal error on non-integer input: they now raise TypeError instead.
This is needed for attributes declared via PyMemberDefs.
........
r78920 | mark.dickinson | 2010-03-13 13:23:05 +0000 (Sat, 13 Mar 2010) | 3 lines
Issue #8014: Fix incorrect error checks in structmember.c, and re-enable
previously failing test_structmember.py tests.
........
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_structmembers.py | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/Lib/test/test_structmembers.py b/Lib/test/test_structmembers.py index 17ca2ac..9d82f38 100644 --- a/Lib/test/test_structmembers.py +++ b/Lib/test/test_structmembers.py @@ -3,7 +3,8 @@ from _testcapi import _test_structmembersType, \ SHRT_MAX, SHRT_MIN, USHRT_MAX, \ INT_MAX, INT_MIN, UINT_MAX, \ LONG_MAX, LONG_MIN, ULONG_MAX, \ - LLONG_MAX, LLONG_MIN, ULLONG_MAX + LLONG_MAX, LLONG_MIN, ULLONG_MAX, \ + PY_SSIZE_T_MAX, PY_SSIZE_T_MIN import warnings, unittest, sys from test import support @@ -17,6 +18,7 @@ ts=_test_structmembersType(False, # T_BOOL 6, # T_UINT 7, # T_LONG 8, # T_ULONG + 23, # T_PYSSIZET 9.99999,# T_FLOAT 10.1010101010, # T_DOUBLE "hi" # T_STRING_INPLACE @@ -63,6 +65,12 @@ class ReadWriteTests(unittest.TestCase): ts.T_ULONG = ULONG_MAX self.assertEquals(ts.T_ULONG, ULONG_MAX) + def test_py_ssize_t(self): + ts.T_PYSSIZET = PY_SSIZE_T_MAX + self.assertEquals(ts.T_PYSSIZET, PY_SSIZE_T_MAX) + ts.T_PYSSIZET = PY_SSIZE_T_MIN + self.assertEquals(ts.T_PYSSIZET, PY_SSIZE_T_MIN) + @unittest.skipUnless(hasattr(ts, "T_LONGLONG"), "long long not present") def test_longlong(self): ts.T_LONGLONG = LLONG_MAX @@ -79,6 +87,24 @@ class ReadWriteTests(unittest.TestCase): ts.T_ULONGLONG = 4 self.assertEquals(ts.T_ULONGLONG, 4) + def test_bad_assignments(self): + integer_attributes = [ + 'T_BOOL', + 'T_BYTE', 'T_UBYTE', + 'T_SHORT', 'T_USHORT', + 'T_INT', 'T_UINT', + 'T_LONG', 'T_ULONG', + 'T_PYSSIZET' + ] + if hasattr(ts, 'T_LONGLONG'): + integer_attributes.extend(['T_LONGLONG', 'T_ULONGLONG']) + + # issue8014: this produced 'bad argument to internal function' + # internal error + for nonint in None, 3.2j, "full of eels", {}, []: + for attr in integer_attributes: + self.assertRaises(TypeError, setattr, ts, attr, nonint) + def test_inplace_string(self): self.assertEquals(ts.T_STRING_INPLACE, "hi") self.assertRaises(TypeError, setattr, ts, "T_STRING_INPLACE", "s") |