Skip to content

Commit 0df1d11

Browse files
committed
Update Python inlined files: 3.12.7 (2.4.1)
1 parent 2d07043 commit 0df1d11

File tree

2 files changed

+26
-121
lines changed

2 files changed

+26
-121
lines changed

graalpython/com.oracle.graal.python.cext/modules/_testcapi.c

Lines changed: 0 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -2002,114 +2002,6 @@ parse_tuple_and_keywords(PyObject *self, PyObject *args)
20022002

20032003
static volatile int x;
20042004

2005-
#if USE_UNICODE_WCHAR_CACHE
2006-
/* Ignore use of deprecated APIs */
2007-
_Py_COMP_DIAG_PUSH
2008-
_Py_COMP_DIAG_IGNORE_DEPR_DECLS
2009-
2010-
/* Test the u and u# codes for PyArg_ParseTuple. May leak memory in case
2011-
of an error.
2012-
*/
2013-
static PyObject *
2014-
test_u_code(PyObject *self, PyObject *Py_UNUSED(ignored))
2015-
{
2016-
PyObject *tuple, *obj;
2017-
Py_UNICODE *value;
2018-
Py_ssize_t len;
2019-
2020-
/* issue4122: Undefined reference to _Py_ascii_whitespace on Windows */
2021-
/* Just use the macro and check that it compiles */
2022-
x = Py_UNICODE_ISSPACE(25);
2023-
2024-
tuple = PyTuple_New(1);
2025-
if (tuple == NULL)
2026-
return NULL;
2027-
2028-
obj = PyUnicode_Decode("test", strlen("test"),
2029-
"ascii", NULL);
2030-
if (obj == NULL)
2031-
return NULL;
2032-
2033-
PyTuple_SET_ITEM(tuple, 0, obj);
2034-
2035-
value = 0;
2036-
if (!PyArg_ParseTuple(tuple, "u:test_u_code", &value)) {
2037-
return NULL;
2038-
}
2039-
if (value != PyUnicode_AS_UNICODE(obj))
2040-
return raiseTestError("test_u_code",
2041-
"u code returned wrong value for u'test'");
2042-
value = 0;
2043-
if (!PyArg_ParseTuple(tuple, "u#:test_u_code", &value, &len)) {
2044-
return NULL;
2045-
}
2046-
if (value != PyUnicode_AS_UNICODE(obj) ||
2047-
len != PyUnicode_GET_SIZE(obj))
2048-
return raiseTestError("test_u_code",
2049-
"u# code returned wrong values for u'test'");
2050-
2051-
Py_DECREF(tuple);
2052-
Py_RETURN_NONE;
2053-
}
2054-
2055-
/* Test Z and Z# codes for PyArg_ParseTuple */
2056-
static PyObject *
2057-
test_Z_code(PyObject *self, PyObject *Py_UNUSED(ignored))
2058-
{
2059-
PyObject *tuple, *obj;
2060-
const Py_UNICODE *value1, *value2;
2061-
Py_ssize_t len1, len2;
2062-
2063-
tuple = PyTuple_New(2);
2064-
if (tuple == NULL)
2065-
return NULL;
2066-
2067-
obj = PyUnicode_FromString("test");
2068-
PyTuple_SET_ITEM(tuple, 0, obj);
2069-
Py_INCREF(Py_None);
2070-
PyTuple_SET_ITEM(tuple, 1, Py_None);
2071-
2072-
/* swap values on purpose */
2073-
value1 = NULL;
2074-
value2 = PyUnicode_AS_UNICODE(obj);
2075-
2076-
/* Test Z for both values */
2077-
if (!PyArg_ParseTuple(tuple, "ZZ:test_Z_code", &value1, &value2)) {
2078-
return NULL;
2079-
}
2080-
if (value1 != PyUnicode_AS_UNICODE(obj))
2081-
return raiseTestError("test_Z_code",
2082-
"Z code returned wrong value for 'test'");
2083-
if (value2 != NULL)
2084-
return raiseTestError("test_Z_code",
2085-
"Z code returned wrong value for None");
2086-
2087-
value1 = NULL;
2088-
value2 = PyUnicode_AS_UNICODE(obj);
2089-
len1 = -1;
2090-
len2 = -1;
2091-
2092-
/* Test Z# for both values */
2093-
if (!PyArg_ParseTuple(tuple, "Z#Z#:test_Z_code", &value1, &len1,
2094-
&value2, &len2))
2095-
{
2096-
return NULL;
2097-
}
2098-
if (value1 != PyUnicode_AS_UNICODE(obj) ||
2099-
len1 != PyUnicode_GET_SIZE(obj))
2100-
return raiseTestError("test_Z_code",
2101-
"Z# code returned wrong values for 'test'");
2102-
if (value2 != NULL ||
2103-
len2 != 0)
2104-
return raiseTestError("test_Z_code",
2105-
"Z# code returned wrong values for None'");
2106-
2107-
Py_DECREF(tuple);
2108-
Py_RETURN_NONE;
2109-
}
2110-
_Py_COMP_DIAG_POP
2111-
#endif /* USE_UNICODE_WCHAR_CACHE */
2112-
21132005
static PyObject *
21142006
test_widechar(PyObject *self, PyObject *Py_UNUSED(ignored))
21152007
{

graalpython/lib-python/3/test/test_capi/test_getargs.py

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1349,19 +1349,32 @@ def test_nested_tuple(self):
13491349
"argument 1 must be sequence of length 1, not 0"):
13501350
parse(((),), {}, '(' + f + ')', ['a'])
13511351

1352-
1353-
class Test_testcapi(unittest.TestCase):
1354-
locals().update((name, getattr(_testcapi, name))
1355-
for name in dir(_testcapi)
1356-
if name.startswith('test_') and name.endswith('_code'))
1357-
1358-
@warnings_helper.ignore_warnings(category=DeprecationWarning)
1359-
def test_u_code(self):
1360-
_testcapi.test_u_code()
1361-
1362-
@warnings_helper.ignore_warnings(category=DeprecationWarning)
1363-
def test_Z_code(self):
1364-
_testcapi.test_Z_code()
1352+
@unittest.skipIf(_testinternalcapi is None, 'needs _testinternalcapi')
1353+
def test_gh_119213(self):
1354+
rc, out, err = script_helper.assert_python_ok("-c", """if True:
1355+
from test import support
1356+
script = '''if True:
1357+
import _testinternalcapi
1358+
_testinternalcapi.gh_119213_getargs(spam='eggs')
1359+
'''
1360+
config = dict(
1361+
allow_fork=False,
1362+
allow_exec=False,
1363+
allow_threads=True,
1364+
allow_daemon_threads=False,
1365+
use_main_obmalloc=False,
1366+
gil=2,
1367+
check_multi_interp_extensions=True,
1368+
)
1369+
rc = support.run_in_subinterp_with_config(script, **config)
1370+
assert rc == 0
1371+
1372+
# The crash is different if the interpreter was not destroyed first.
1373+
#interpid = _testinternalcapi.create_interpreter()
1374+
#rc = _testinternalcapi.exec_interpreter(interpid, script)
1375+
#assert rc == 0
1376+
""")
1377+
self.assertEqual(rc, 0)
13651378

13661379

13671380
if __name__ == "__main__":

0 commit comments

Comments
 (0)