Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ff232d7

Browse files
committed
Clear internal call error in 'L' format. Fixes #723201.
Backported to 2.4.
1 parent f2a8d63 commit ff232d7

3 files changed

Lines changed: 16 additions & 1 deletion

File tree

Lib/test/test_capi.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Run the _testcapi module tests (tests for the Python/C API): by defn,
22
# these are all functions _testcapi exports whose name begins with 'test_'.
33

4-
import sys
4+
import sys, unittest
55
from test import test_support
66
import _testcapi
77

@@ -35,6 +35,12 @@ def callback():
3535
raise test_support.TestFailed, \
3636
"Couldn't find main thread correctly in the list"
3737

38+
# Tests which use _testcapi helpers
39+
class OtherTests(unittest.TestCase):
40+
def test_exc_L(self):
41+
# This used to raise a SystemError(bad internal call)
42+
self.assertRaises(TypeError, _testcapi.getargs_L, "String")
43+
3844
try:
3945
_testcapi._test_thread_state
4046
have_thread_state = True
@@ -46,3 +52,9 @@ def callback():
4652
import threading
4753
t=threading.Thread(target=TestThreadState)
4854
t.start()
55+
56+
def test_main():
57+
test_support.run_unittest(OtherTests)
58+
59+
if __name__=='__main__':
60+
test_main()

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ What's New in Python 2.5 alpha 1?
1010
Core and builtins
1111
-----------------
1212

13+
- Bug #723201: Raise a TypeError for passing bad objects to 'L' format.
14+
1315
- Bug #1124295: the __name__ attribute of file objects was
1416
inadvertently made inaccessible in restricted mode.
1517

Python/getargs.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,7 @@ convertsimple(PyObject *arg, char **p_format, va_list *p_va, char *msgbuf,
610610
PY_LONG_LONG *p = va_arg( *p_va, PY_LONG_LONG * );
611611
PY_LONG_LONG ival = PyLong_AsLongLong( arg );
612612
if( ival == (PY_LONG_LONG)-1 && PyErr_Occurred() ) {
613+
PyErr_Clear();
613614
return converterr("long<L>", arg, msgbuf, bufsize);
614615
} else {
615616
*p = ival;

0 commit comments

Comments
 (0)