diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2005-03-03 09:24:38 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2005-03-03 09:24:38 (GMT) |
commit | ff232d723089eb0c743265821db528494a661099 (patch) | |
tree | 432c52a79a39e0578e0792df979a3b245cd56a98 | |
parent | f2a8d63e4fac18c794ab99fd46999b36de35d11d (diff) | |
download | cpython-ff232d723089eb0c743265821db528494a661099.zip cpython-ff232d723089eb0c743265821db528494a661099.tar.gz cpython-ff232d723089eb0c743265821db528494a661099.tar.bz2 |
Clear internal call error in 'L' format. Fixes #723201.
Backported to 2.4.
-rw-r--r-- | Lib/test/test_capi.py | 14 | ||||
-rw-r--r-- | Misc/NEWS | 2 | ||||
-rw-r--r-- | Python/getargs.c | 1 |
3 files changed, 16 insertions, 1 deletions
diff --git a/Lib/test/test_capi.py b/Lib/test/test_capi.py index 1dd2461..7196b7b 100644 --- a/Lib/test/test_capi.py +++ b/Lib/test/test_capi.py @@ -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() @@ -10,6 +10,8 @@ What's New in Python 2.5 alpha 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. diff --git a/Python/getargs.c b/Python/getargs.c index 48f9dc4..0684e38 100644 --- a/Python/getargs.c +++ b/Python/getargs.c @@ -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; |