Skip to content

Commit

Permalink
Merge branch 'main' into fix-complex_pow-117999
Browse files Browse the repository at this point in the history
  • Loading branch information
skirpichev authored Jan 20, 2025
2 parents 5d4f11a + 38c3cf6 commit 802df3e
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 39 deletions.
3 changes: 3 additions & 0 deletions Lib/sysconfig/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions Lib/test/test_ctypes/test_c_simple_type_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand All @@ -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)
2 changes: 1 addition & 1 deletion Lib/test/test_ctypes/test_loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
6 changes: 3 additions & 3 deletions Lib/test/test_ctypes/test_repr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("<X object at", repr(typ(42))[:12])
self.assertStartsWith(repr(base(42)), base.__name__)
self.assertStartsWith(repr(typ(42)), "<X object at")

def test_char(self):
self.assertEqual("c_char(b'x')", repr(c_char(b'x')))
self.assertEqual("<X object at", repr(X(b'x'))[:12])
self.assertStartsWith(repr(X(b'x')), "<X object at")


if __name__ == "__main__":
Expand Down
2 changes: 0 additions & 2 deletions Lib/test/test_embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion Lib/test/test_long.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix a :exc:`NameError` in :func:`!sysconfig.expand_makefile_vars`. Patch by
Bénédikt Tran.
46 changes: 23 additions & 23 deletions Objects/clinic/exceptions.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Objects/exceptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 802df3e

Please sign in to comment.