]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Clear internal call error in 'L' format. Fixes #723201.
authorMartin v. Löwis <martin@v.loewis.de>
Thu, 3 Mar 2005 09:24:05 +0000 (09:24 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Thu, 3 Mar 2005 09:24:05 +0000 (09:24 +0000)
Lib/test/test_capi.py
Misc/NEWS
Python/getargs.c

index 1dd24616a25ff0e0df896cef589c8282335af77f..7196b7be0cfe0a42668284078efa5e88c2edfa7d 100644 (file)
@@ -1,7 +1,7 @@
 # Run the _testcapi module tests (tests for the Python/C API):  by defn,
 # these are all functions _testcapi exports whose name begins with 'test_'.
 
-import sys
+import sys, unittest
 from test import test_support
 import _testcapi
 
@@ -35,6 +35,12 @@ def TestThreadState():
         raise test_support.TestFailed, \
               "Couldn't find main thread correctly in the list"
 
+# Tests which use _testcapi helpers
+class OtherTests(unittest.TestCase):
+    def test_exc_L(self):
+        # This used to raise a SystemError(bad internal call)
+        self.assertRaises(TypeError, _testcapi.getargs_L, "String")
+
 try:
     _testcapi._test_thread_state
     have_thread_state = True
@@ -46,3 +52,9 @@ if have_thread_state:
     import threading
     t=threading.Thread(target=TestThreadState)
     t.start()
+
+def test_main():
+    test_support.run_unittest(OtherTests)
+
+if __name__=='__main__':
+    test_main()
index 08f9bedb508a04fb4f29a99cdd09c1e2d3c4f77f..79e4b71e21d40af0b0a8cc6dc541e13eb778e09e 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,8 @@ What's New in Python 2.4.1?
 Core and builtins
 -----------------
 
+- Bug #723201: Raise a TypeError for passing bad objects to 'L' format.
+
 - Bug #1124295: the __name__ attribute of file objects was
   inadvertently made inaccessible in restricted mode.
 
index 48f9dc481d0a9a5018d1fbe61ab821882edf26b5..0684e38e3b65d8390dcd4f65411e18fce57ce7dc 100644 (file)
@@ -610,6 +610,7 @@ convertsimple(PyObject *arg, char **p_format, va_list *p_va, char *msgbuf,
                PY_LONG_LONG *p = va_arg( *p_va, PY_LONG_LONG * );
                PY_LONG_LONG ival = PyLong_AsLongLong( arg );
                if( ival == (PY_LONG_LONG)-1 && PyErr_Occurred() ) {
+                       PyErr_Clear();
                        return converterr("long<L>", arg, msgbuf, bufsize);
                } else {
                        *p = ival;