From da0f47ceabd5c3f334265d8abe5ce1ba3d5bcf0e Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Mon, 20 Jan 2025 13:46:30 +0100 Subject: [PATCH 1/4] gh-111178: Regen clinic and fix exceptions.c post gh-128447 (#129060) --- Objects/clinic/exceptions.c.h | 46 +++++++++++++++++------------------ Objects/exceptions.c | 2 +- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/Objects/clinic/exceptions.c.h b/Objects/clinic/exceptions.c.h index caa5b0c63e53c5..3bd9a8553ab2fc 100644 --- a/Objects/clinic/exceptions.c.h +++ b/Objects/clinic/exceptions.c.h @@ -17,12 +17,12 @@ static PyObject * BaseException___reduce___impl(PyBaseExceptionObject *self); static PyObject * -BaseException___reduce__(PyBaseExceptionObject *self, PyObject *Py_UNUSED(ignored)) +BaseException___reduce__(PyObject *self, PyObject *Py_UNUSED(ignored)) { PyObject *return_value = NULL; Py_BEGIN_CRITICAL_SECTION(self); - return_value = BaseException___reduce___impl(self); + return_value = BaseException___reduce___impl((PyBaseExceptionObject *)self); Py_END_CRITICAL_SECTION(); return return_value; @@ -45,7 +45,7 @@ BaseException___setstate__(PyBaseExceptionObject *self, PyObject *state) PyObject *return_value = NULL; Py_BEGIN_CRITICAL_SECTION(self); - return_value = BaseException___setstate___impl(self, state); + return_value = BaseException___setstate___impl((PyBaseExceptionObject *)self, state); Py_END_CRITICAL_SECTION(); return return_value; @@ -69,7 +69,7 @@ BaseException_with_traceback(PyBaseExceptionObject *self, PyObject *tb) PyObject *return_value = NULL; Py_BEGIN_CRITICAL_SECTION(self); - return_value = BaseException_with_traceback_impl(self, tb); + return_value = BaseException_with_traceback_impl((PyBaseExceptionObject *)self, tb); Py_END_CRITICAL_SECTION(); return return_value; @@ -88,7 +88,7 @@ static PyObject * BaseException_add_note_impl(PyBaseExceptionObject *self, PyObject *note); static PyObject * -BaseException_add_note(PyBaseExceptionObject *self, PyObject *arg) +BaseException_add_note(PyObject *self, PyObject *arg) { PyObject *return_value = NULL; PyObject *note; @@ -99,7 +99,7 @@ BaseException_add_note(PyBaseExceptionObject *self, PyObject *arg) } note = arg; Py_BEGIN_CRITICAL_SECTION(self); - return_value = BaseException_add_note_impl(self, note); + return_value = BaseException_add_note_impl((PyBaseExceptionObject *)self, note); Py_END_CRITICAL_SECTION(); exit: @@ -120,12 +120,12 @@ static PyObject * BaseException_args_get_impl(PyBaseExceptionObject *self); static PyObject * -BaseException_args_get(PyBaseExceptionObject *self, void *Py_UNUSED(context)) +BaseException_args_get(PyObject *self, void *Py_UNUSED(context)) { PyObject *return_value = NULL; Py_BEGIN_CRITICAL_SECTION(self); - return_value = BaseException_args_get_impl(self); + return_value = BaseException_args_get_impl((PyBaseExceptionObject *)self); Py_END_CRITICAL_SECTION(); return return_value; @@ -145,12 +145,12 @@ static int BaseException_args_set_impl(PyBaseExceptionObject *self, PyObject *value); static int -BaseException_args_set(PyBaseExceptionObject *self, PyObject *value, void *Py_UNUSED(context)) +BaseException_args_set(PyObject *self, PyObject *value, void *Py_UNUSED(context)) { int return_value; Py_BEGIN_CRITICAL_SECTION(self); - return_value = BaseException_args_set_impl(self, value); + return_value = BaseException_args_set_impl((PyBaseExceptionObject *)self, value); Py_END_CRITICAL_SECTION(); return return_value; @@ -170,12 +170,12 @@ static PyObject * BaseException___traceback___get_impl(PyBaseExceptionObject *self); static PyObject * -BaseException___traceback___get(PyBaseExceptionObject *self, void *Py_UNUSED(context)) +BaseException___traceback___get(PyObject *self, void *Py_UNUSED(context)) { PyObject *return_value = NULL; Py_BEGIN_CRITICAL_SECTION(self); - return_value = BaseException___traceback___get_impl(self); + return_value = BaseException___traceback___get_impl((PyBaseExceptionObject *)self); Py_END_CRITICAL_SECTION(); return return_value; @@ -196,12 +196,12 @@ BaseException___traceback___set_impl(PyBaseExceptionObject *self, PyObject *value); static int -BaseException___traceback___set(PyBaseExceptionObject *self, PyObject *value, void *Py_UNUSED(context)) +BaseException___traceback___set(PyObject *self, PyObject *value, void *Py_UNUSED(context)) { int return_value; Py_BEGIN_CRITICAL_SECTION(self); - return_value = BaseException___traceback___set_impl(self, value); + return_value = BaseException___traceback___set_impl((PyBaseExceptionObject *)self, value); Py_END_CRITICAL_SECTION(); return return_value; @@ -221,12 +221,12 @@ static PyObject * BaseException___context___get_impl(PyBaseExceptionObject *self); static PyObject * -BaseException___context___get(PyBaseExceptionObject *self, void *Py_UNUSED(context)) +BaseException___context___get(PyObject *self, void *Py_UNUSED(context)) { PyObject *return_value = NULL; Py_BEGIN_CRITICAL_SECTION(self); - return_value = BaseException___context___get_impl(self); + return_value = BaseException___context___get_impl((PyBaseExceptionObject *)self); Py_END_CRITICAL_SECTION(); return return_value; @@ -247,12 +247,12 @@ BaseException___context___set_impl(PyBaseExceptionObject *self, PyObject *value); static int -BaseException___context___set(PyBaseExceptionObject *self, PyObject *value, void *Py_UNUSED(context)) +BaseException___context___set(PyObject *self, PyObject *value, void *Py_UNUSED(context)) { int return_value; Py_BEGIN_CRITICAL_SECTION(self); - return_value = BaseException___context___set_impl(self, value); + return_value = BaseException___context___set_impl((PyBaseExceptionObject *)self, value); Py_END_CRITICAL_SECTION(); return return_value; @@ -272,12 +272,12 @@ static PyObject * BaseException___cause___get_impl(PyBaseExceptionObject *self); static PyObject * -BaseException___cause___get(PyBaseExceptionObject *self, void *Py_UNUSED(context)) +BaseException___cause___get(PyObject *self, void *Py_UNUSED(context)) { PyObject *return_value = NULL; Py_BEGIN_CRITICAL_SECTION(self); - return_value = BaseException___cause___get_impl(self); + return_value = BaseException___cause___get_impl((PyBaseExceptionObject *)self); Py_END_CRITICAL_SECTION(); return return_value; @@ -298,14 +298,14 @@ BaseException___cause___set_impl(PyBaseExceptionObject *self, PyObject *value); static int -BaseException___cause___set(PyBaseExceptionObject *self, PyObject *value, void *Py_UNUSED(context)) +BaseException___cause___set(PyObject *self, PyObject *value, void *Py_UNUSED(context)) { int return_value; Py_BEGIN_CRITICAL_SECTION(self); - return_value = BaseException___cause___set_impl(self, value); + return_value = BaseException___cause___set_impl((PyBaseExceptionObject *)self, value); Py_END_CRITICAL_SECTION(); return return_value; } -/*[clinic end generated code: output=58afcfd60057fc39 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=8be99f8a7e527ba4 input=a9049054013a1b77]*/ diff --git a/Objects/exceptions.c b/Objects/exceptions.c index 4df89edfaf3953..d23b7f7c76c3e7 100644 --- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -4256,7 +4256,7 @@ _PyException_AddNote(PyObject *exc, PyObject *note) Py_TYPE(exc)->tp_name); return -1; } - PyObject *r = BaseException_add_note(_PyBaseExceptionObject_cast(exc), note); + PyObject *r = BaseException_add_note(exc, note); int res = r == NULL ? -1 : 0; Py_XDECREF(r); return res; From 59fcae793f94be977c56c1f3c2988bd93d6b1564 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A9n=C3=A9dikt=20Tran?= <10796600+picnixz@users.noreply.github.com> Date: Mon, 20 Jan 2025 13:50:10 +0100 Subject: [PATCH 2/4] Remove duplicated dict keys in `test_{embed,long}.py` fixtures (#128727) --- Lib/test/test_embed.py | 2 -- Lib/test/test_long.py | 1 - 2 files changed, 3 deletions(-) diff --git a/Lib/test/test_embed.py b/Lib/test/test_embed.py index a2400aa96c3ddd..6d1b4cce498276 100644 --- a/Lib/test/test_embed.py +++ b/Lib/test/test_embed.py @@ -1049,7 +1049,6 @@ def test_init_compat_env(self): 'use_hash_seed': True, 'hash_seed': 42, 'tracemalloc': 2, - 'perf_profiling': 0, 'import_time': True, 'code_debug_ranges': False, 'malloc_stats': True, @@ -1086,7 +1085,6 @@ def test_init_python_env(self): 'use_hash_seed': True, 'hash_seed': 42, 'tracemalloc': 2, - 'perf_profiling': 0, 'import_time': True, 'code_debug_ranges': False, 'malloc_stats': True, diff --git a/Lib/test/test_long.py b/Lib/test/test_long.py index 19978118c80dba..f336d49fa4f008 100644 --- a/Lib/test/test_long.py +++ b/Lib/test/test_long.py @@ -1470,7 +1470,6 @@ def equivalent_python(byte_array, byteorder, signed=False): b'\x00': 0, b'\x00\x00': 0, b'\x01': 1, - b'\x00\x01': 256, b'\xff': -1, b'\xff\xff': -1, b'\x81': -127, From df66ff14b49f4388625212f6bc86b754cb51d4eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A9n=C3=A9dikt=20Tran?= <10796600+picnixz@users.noreply.github.com> Date: Mon, 20 Jan 2025 14:27:14 +0100 Subject: [PATCH 3/4] gh-128978: Fix a `NameError` in `sysconfig.expand_makefile_vars` (#128979) This fixes a regression introduced by 4a53a397c311567f05553bc25a28aebaba4f6f65. --- Lib/sysconfig/__init__.py | 3 +++ .../Library/2025-01-18-11-04-44.gh-issue-128978.hwg7-w.rst | 2 ++ 2 files changed, 5 insertions(+) create mode 100644 Misc/NEWS.d/next/Library/2025-01-18-11-04-44.gh-issue-128978.hwg7-w.rst diff --git a/Lib/sysconfig/__init__.py b/Lib/sysconfig/__init__.py index 7a4a8f65a5eb3e..ec9bb705925cdb 100644 --- a/Lib/sysconfig/__init__.py +++ b/Lib/sysconfig/__init__.py @@ -718,6 +718,9 @@ def expand_makefile_vars(s, vars): """ import re + _findvar1_rx = r"\$\(([A-Za-z][A-Za-z0-9_]*)\)" + _findvar2_rx = r"\${([A-Za-z][A-Za-z0-9_]*)}" + # This algorithm does multiple expansion, so if vars['foo'] contains # "${bar}", it will expand ${foo} to ${bar}, and then expand # ${bar}... and so forth. This is fine as long as 'vars' comes from diff --git a/Misc/NEWS.d/next/Library/2025-01-18-11-04-44.gh-issue-128978.hwg7-w.rst b/Misc/NEWS.d/next/Library/2025-01-18-11-04-44.gh-issue-128978.hwg7-w.rst new file mode 100644 index 00000000000000..521496d6a2f8c2 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2025-01-18-11-04-44.gh-issue-128978.hwg7-w.rst @@ -0,0 +1,2 @@ +Fix a :exc:`NameError` in :func:`!sysconfig.expand_makefile_vars`. Patch by +Bénédikt Tran. From 38c3cf6320bfc15e6a69f73724a49df5280d8269 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Mon, 20 Jan 2025 15:30:00 +0200 Subject: [PATCH 4/4] gh-71339: Use new assertion methods in test_ctypes (GH-129054) --- Lib/test/test_ctypes/test_c_simple_type_meta.py | 16 ++++++++-------- Lib/test/test_ctypes/test_loading.py | 2 +- Lib/test/test_ctypes/test_repr.py | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Lib/test/test_ctypes/test_c_simple_type_meta.py b/Lib/test/test_ctypes/test_c_simple_type_meta.py index eb77d6d7782478..e8f347a0d0c57b 100644 --- a/Lib/test/test_ctypes/test_c_simple_type_meta.py +++ b/Lib/test/test_ctypes/test_c_simple_type_meta.py @@ -54,9 +54,9 @@ class Sub2(Sub): pass self.assertIsInstance(POINTER(Sub2), p_meta) - self.assertTrue(issubclass(POINTER(Sub2), Sub2)) - self.assertTrue(issubclass(POINTER(Sub2), POINTER(Sub))) - self.assertTrue(issubclass(POINTER(Sub), POINTER(CtBase))) + self.assertIsSubclass(POINTER(Sub2), Sub2) + self.assertIsSubclass(POINTER(Sub2), POINTER(Sub)) + self.assertIsSubclass(POINTER(Sub), POINTER(CtBase)) def test_creating_pointer_in_dunder_new_2(self): # A simpler variant of the above, used in `CoClass` of the `comtypes` @@ -84,7 +84,7 @@ class Sub(CtBase): pass self.assertIsInstance(POINTER(Sub), p_meta) - self.assertTrue(issubclass(POINTER(Sub), Sub)) + self.assertIsSubclass(POINTER(Sub), Sub) def test_creating_pointer_in_dunder_init_1(self): class ct_meta(type): @@ -120,9 +120,9 @@ class Sub2(Sub): pass self.assertIsInstance(POINTER(Sub2), p_meta) - self.assertTrue(issubclass(POINTER(Sub2), Sub2)) - self.assertTrue(issubclass(POINTER(Sub2), POINTER(Sub))) - self.assertTrue(issubclass(POINTER(Sub), POINTER(CtBase))) + self.assertIsSubclass(POINTER(Sub2), Sub2) + self.assertIsSubclass(POINTER(Sub2), POINTER(Sub)) + self.assertIsSubclass(POINTER(Sub), POINTER(CtBase)) def test_creating_pointer_in_dunder_init_2(self): class ct_meta(type): @@ -149,4 +149,4 @@ class Sub(CtBase): pass self.assertIsInstance(POINTER(Sub), p_meta) - self.assertTrue(issubclass(POINTER(Sub), Sub)) + self.assertIsSubclass(POINTER(Sub), Sub) diff --git a/Lib/test/test_ctypes/test_loading.py b/Lib/test/test_ctypes/test_loading.py index fc1eecb77e17e3..13ed813ad98c31 100644 --- a/Lib/test/test_ctypes/test_loading.py +++ b/Lib/test/test_ctypes/test_loading.py @@ -135,7 +135,7 @@ def test_1703286_B(self): 'test specific to Windows') def test_load_hasattr(self): # bpo-34816: shouldn't raise OSError - self.assertFalse(hasattr(ctypes.windll, 'test')) + self.assertNotHasAttr(ctypes.windll, 'test') @unittest.skipUnless(os.name == "nt", 'test specific to Windows') diff --git a/Lib/test/test_ctypes/test_repr.py b/Lib/test/test_ctypes/test_repr.py index e7587984a92c45..8c85e6cbe70cea 100644 --- a/Lib/test/test_ctypes/test_repr.py +++ b/Lib/test/test_ctypes/test_repr.py @@ -22,12 +22,12 @@ class ReprTest(unittest.TestCase): def test_numbers(self): for typ in subclasses: base = typ.__bases__[0] - self.assertTrue(repr(base(42)).startswith(base.__name__)) - self.assertEqual("