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.
........
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 @@
     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 @@
                           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 @@
         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 @@
         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")