Skip to content

Commit 39f52d1

Browse files
authored
Merge branch 'main' into windows-use-py-debug
2 parents 8284b0e + 03f6c8e commit 39f52d1

9 files changed

Lines changed: 62 additions & 49 deletions

File tree

Include/internal/mimalloc/mimalloc/atomic.h

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,9 @@ static inline void mi_atomic_yield(void) {
338338
_mm_pause();
339339
}
340340
#elif (defined(__GNUC__) || defined(__clang__)) && \
341-
(defined(__x86_64__) || defined(__i386__) || defined(__arm__) || defined(__armel__) || defined(__ARMEL__) || \
342-
defined(__aarch64__) || defined(__powerpc__) || defined(__ppc__) || defined(__PPC__)) || defined(__POWERPC__)
341+
(defined(__x86_64__) || defined(__i386__) || \
342+
defined(__aarch64__) || defined(__arm__) || \
343+
defined(__powerpc__) || defined(__ppc__) || defined(__PPC__) || defined(__POWERPC__))
343344
#if defined(__x86_64__) || defined(__i386__)
344345
static inline void mi_atomic_yield(void) {
345346
__asm__ volatile ("pause" ::: "memory");
@@ -348,10 +349,16 @@ static inline void mi_atomic_yield(void) {
348349
static inline void mi_atomic_yield(void) {
349350
__asm__ volatile("wfe");
350351
}
351-
#elif (defined(__arm__) && __ARM_ARCH__ >= 7)
352+
#elif defined(__arm__)
353+
#if __ARM_ARCH >= 7
352354
static inline void mi_atomic_yield(void) {
353355
__asm__ volatile("yield" ::: "memory");
354356
}
357+
#else
358+
static inline void mi_atomic_yield(void) {
359+
__asm__ volatile ("nop" ::: "memory");
360+
}
361+
#endif
355362
#elif defined(__powerpc__) || defined(__ppc__) || defined(__PPC__) || defined(__POWERPC__)
356363
#ifdef __APPLE__
357364
static inline void mi_atomic_yield(void) {
@@ -362,10 +369,6 @@ static inline void mi_atomic_yield(void) {
362369
__asm__ __volatile__ ("or 27,27,27" ::: "memory");
363370
}
364371
#endif
365-
#elif defined(__armel__) || defined(__ARMEL__)
366-
static inline void mi_atomic_yield(void) {
367-
__asm__ volatile ("nop" ::: "memory");
368-
}
369372
#endif
370373
#elif defined(__sun)
371374
// Fallback for other archs

Lib/test/test_traceback.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4619,7 +4619,31 @@ def test_levenshtein_distance_short_circuit(self):
46194619
@cpython_only
46204620
def test_suggestions_extension(self):
46214621
# Check that the C extension is available
4622-
import _suggestions # noqa: F401
4622+
import _suggestions
4623+
4624+
self.assertEqual(
4625+
_suggestions._generate_suggestions(
4626+
["hello", "world"],
4627+
"hell"
4628+
),
4629+
"hello"
4630+
)
4631+
self.assertEqual(
4632+
_suggestions._generate_suggestions(
4633+
["hovercraft"],
4634+
"eels"
4635+
),
4636+
None
4637+
)
4638+
4639+
# gh-131936: _generate_suggestions() doesn't accept list subclasses
4640+
class MyList(list):
4641+
pass
4642+
4643+
with self.assertRaises(TypeError):
4644+
_suggestions._generate_suggestions(MyList(), "")
4645+
4646+
46234647

46244648

46254649
class TestColorizedTraceback(unittest.TestCase):

Lib/textwrap.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -451,19 +451,20 @@ def indent(text, prefix, predicate=None):
451451
it will default to adding 'prefix' to all non-empty lines that do not
452452
consist solely of whitespace characters.
453453
"""
454-
if predicate is None:
455-
# str.splitlines(True) doesn't produce empty string.
456-
# ''.splitlines(True) => []
457-
# 'foo\n'.splitlines(True) => ['foo\n']
458-
# So we can use just `not s.isspace()` here.
459-
predicate = lambda s: not s.isspace()
460-
461454
prefixed_lines = []
462-
for line in text.splitlines(True):
463-
if predicate(line):
464-
prefixed_lines.append(prefix)
465-
prefixed_lines.append(line)
466-
455+
if predicate is None:
456+
# str.splitlines(keepends=True) doesn't produce the empty string,
457+
# so we need to use `str.isspace()` rather than a truth test.
458+
# Inlining the predicate leads to a ~30% performance improvement.
459+
for line in text.splitlines(True):
460+
if not line.isspace():
461+
prefixed_lines.append(prefix)
462+
prefixed_lines.append(line)
463+
else:
464+
for line in text.splitlines(True):
465+
if predicate(line):
466+
prefixed_lines.append(prefix)
467+
prefixed_lines.append(line)
467468
return ''.join(prefixed_lines)
468469

469470

Lib/typing.py

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,7 @@
2929
import operator
3030
import sys
3131
import types
32-
from types import (
33-
WrapperDescriptorType,
34-
MethodWrapperType,
35-
MethodDescriptorType,
36-
GenericAlias,
37-
)
32+
from types import GenericAlias
3833
import warnings
3934

4035
from _typing import (
@@ -354,26 +349,11 @@ def _deduplicate(params, *, unhashable_fallback=False):
354349
if not unhashable_fallback:
355350
raise
356351
# Happens for cases like `Annotated[dict, {'x': IntValidator()}]`
357-
return _deduplicate_unhashable(params)
358-
359-
def _deduplicate_unhashable(unhashable_params):
360-
new_unhashable = []
361-
for t in unhashable_params:
362-
if t not in new_unhashable:
363-
new_unhashable.append(t)
364-
return new_unhashable
365-
366-
def _compare_args_orderless(first_args, second_args):
367-
first_unhashable = _deduplicate_unhashable(first_args)
368-
second_unhashable = _deduplicate_unhashable(second_args)
369-
t = list(second_unhashable)
370-
try:
371-
for elem in first_unhashable:
372-
t.remove(elem)
373-
except ValueError:
374-
return False
375-
return not t
376-
352+
new_unhashable = []
353+
for t in params:
354+
if t not in new_unhashable:
355+
new_unhashable.append(t)
356+
return new_unhashable
377357

378358
def _flatten_literal_params(parameters):
379359
"""Internal helper for Literal creation: flatten Literals among parameters."""

Makefile.pre.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2090,7 +2090,7 @@ Python/frozen.o: $(FROZEN_FILES_OUT)
20902090
# an include guard, so we can't use a pipeline to transform its output.
20912091
Include/pydtrace_probes.h: $(srcdir)/Include/pydtrace.d
20922092
$(MKDIR_P) Include
2093-
$(DTRACE) $(DFLAGS) -o $@ -h -s $<
2093+
CC="$(CC)" CFLAGS="$(CFLAGS)" $(DTRACE) $(DFLAGS) -o $@ -h -s $<
20942094
: sed in-place edit with POSIX-only tools
20952095
sed 's/PYTHON_/PyDTrace_/' $@ > $@.tmp
20962096
mv $@.tmp $@
@@ -2100,7 +2100,7 @@ Python/gc.o: $(srcdir)/Include/pydtrace.h
21002100
Python/import.o: $(srcdir)/Include/pydtrace.h
21012101

21022102
Python/pydtrace.o: $(srcdir)/Include/pydtrace.d $(DTRACE_DEPS)
2103-
$(DTRACE) $(DFLAGS) -o $@ -G -s $< $(DTRACE_DEPS)
2103+
CC="$(CC)" CFLAGS="$(CFLAGS)" $(DTRACE) $(DFLAGS) -o $@ -G -s $< $(DTRACE_DEPS)
21042104

21052105
Objects/typeobject.o: Objects/typeslots.inc
21062106

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix mimalloc library builds for 32-bit ARM targets.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
The DTrace build now properly passes the ``CC`` and ``CFLAGS`` variables
2+
to the ``dtrace`` command when utilizing SystemTap on Linux.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Improved performance of :func:`textwrap.dedent` by an average of ~1.3x.
2+
Patch by Adam Turner.

Modules/_suggestions.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ _suggestions__generate_suggestions_impl(PyObject *module,
2121
/*[clinic end generated code: output=79be7b653ae5e7ca input=ba2a8dddc654e33a]*/
2222
{
2323
// Check if dir is a list
24-
if (!PyList_Check(candidates)) {
24+
if (!PyList_CheckExact(candidates)) {
2525
PyErr_SetString(PyExc_TypeError, "candidates must be a list");
2626
return NULL;
2727
}

0 commit comments

Comments
 (0)