Skip to content

Commit

Permalink
Merge branch '3.13' into backport-97b2cea-3.13
Browse files Browse the repository at this point in the history
  • Loading branch information
picnixz authored Nov 30, 2024
2 parents 120c2bc + 4cba0e6 commit c4cd138
Show file tree
Hide file tree
Showing 17 changed files with 71 additions and 19 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/reusable-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ jobs:
path: config.cache
key: ${{ github.job }}-${{ inputs.os }}-${{ env.IMAGE_VERSION }}-${{ inputs.config_hash }}
- name: Install Homebrew dependencies
run: brew install pkg-config [email protected] xz gdbm tcl-tk
run: |
brew install pkg-config [email protected] xz gdbm tcl-tk@8
# Because alternate versions are not symlinked into place by default:
brew link tcl-tk@8
- name: Configure CPython
run: |
GDBM_CFLAGS="-I$(brew --prefix gdbm)/include" \
Expand Down
2 changes: 1 addition & 1 deletion Doc/c-api/object.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Object Protocol
instead of the :func:`repr`.
.. c:function:: int PyObject_HasAttrWithError(PyObject *o, const char *attr_name)
.. c:function:: int PyObject_HasAttrWithError(PyObject *o, PyObject *attr_name)
Returns ``1`` if *o* has the attribute *attr_name*, and ``0`` otherwise.
This is equivalent to the Python expression ``hasattr(o, attr_name)``.
Expand Down
8 changes: 4 additions & 4 deletions Doc/library/asyncio-sync.rst
Original file line number Diff line number Diff line change
Expand Up @@ -259,16 +259,16 @@ Condition

Note that a task *may* return from this call spuriously,
which is why the caller should always re-check the state
and be prepared to :meth:`wait` again. For this reason, you may
prefer to use :meth:`wait_for` instead.
and be prepared to :meth:`~Condition.wait` again. For this reason, you may
prefer to use :meth:`~Condition.wait_for` instead.

.. coroutinemethod:: wait_for(predicate)

Wait until a predicate becomes *true*.

The predicate must be a callable which result will be
interpreted as a boolean value. The method will repeatedly
:meth:`wait` until the predicate evaluates to *true*. The final value is the
:meth:`~Condition.wait` until the predicate evaluates to *true*. The final value is the
return value.


Expand Down Expand Up @@ -434,7 +434,7 @@ Barrier
.. coroutinemethod:: abort()

Put the barrier into a broken state. This causes any active or future
calls to :meth:`wait` to fail with the :class:`BrokenBarrierError`.
calls to :meth:`~Barrier.wait` to fail with the :class:`BrokenBarrierError`.
Use this for example if one of the tasks needs to abort, to avoid infinite
waiting tasks.

Expand Down
6 changes: 3 additions & 3 deletions Doc/library/contextlib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ Functions and classes provided:
created by :func:`asynccontextmanager` to meet the requirement that context
managers support multiple invocations in order to be used as decorators.

.. versionchanged:: 3.10
Async context managers created with :func:`asynccontextmanager` can
be used as decorators.
.. versionchanged:: 3.10
Async context managers created with :func:`asynccontextmanager` can
be used as decorators.


.. function:: closing(thing)
Expand Down
7 changes: 7 additions & 0 deletions Doc/library/token.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ the :mod:`tokenize` module.
``type_comments=True``.


.. data:: EXACT_TOKEN_TYPES

A dictionary mapping the string representation of a token to its numeric code.

.. versionadded:: 3.8


.. versionchanged:: 3.5
Added :data:`!AWAIT` and :data:`!ASYNC` tokens.

Expand Down
6 changes: 5 additions & 1 deletion Lib/test/test_asyncio/test_eager_task_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,14 @@ async def fail():
await asyncio.sleep(0)
raise ValueError("no good")

async def blocked():
fut = asyncio.Future()
await fut

async def run():
winner, index, excs = await asyncio.staggered.staggered_race(
[
lambda: asyncio.sleep(2, result="sleep2"),
lambda: blocked(),
lambda: asyncio.sleep(1, result="sleep1"),
lambda: fail()
],
Expand Down
15 changes: 15 additions & 0 deletions Lib/test/test_free_threading/test_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,21 @@ def work():
for thread in threads:
thread.join()

def test_object_class_change(self):
class Base:
def __init__(self):
self.attr = 123
class ClassA(Base):
pass
class ClassB(Base):
pass

obj = ClassA()
# keep reference to __dict__
d = obj.__dict__
obj.__class__ = ClassB


def run_one(self, writer_func, reader_func):
writer = Thread(target=writer_func)
readers = []
Expand Down
13 changes: 13 additions & 0 deletions Lib/test/test_import/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1152,6 +1152,19 @@ def test_script_shadowing_stdlib_sys_path_modification(self):
stdout, stderr = popen.communicate()
self.assertRegex(stdout, expected_error)

def test_create_dynamic_null(self):
with self.assertRaisesRegex(ValueError, 'embedded null character'):
class Spec:
name = "a\x00b"
origin = "abc"
_imp.create_dynamic(Spec())

with self.assertRaisesRegex(ValueError, 'embedded null character'):
class Spec2:
name = "abc"
origin = "a\x00b"
_imp.create_dynamic(Spec2())


@skip_if_dont_write_bytecode
class FilePermissionTests(unittest.TestCase):
Expand Down
5 changes: 3 additions & 2 deletions Lib/test/test_os.py
Original file line number Diff line number Diff line change
Expand Up @@ -4124,12 +4124,13 @@ def test_eventfd_select(self):
os.eventfd_read(fd)

@unittest.skipUnless(hasattr(os, 'timerfd_create'), 'requires os.timerfd_create')
@unittest.skipIf(sys.platform == "android", "gh-124873: Test is flaky on Android")
@support.requires_linux_version(2, 6, 30)
class TimerfdTests(unittest.TestCase):
# 1 ms accuracy is reliably achievable on every platform except Android
# emulators, where we allow 100 ms (gh-124873).
# emulators, where we allow 10 ms (gh-108277).
if sys.platform == "android" and platform.android_ver().is_emulator:
CLOCK_RES_PLACES = 1
CLOCK_RES_PLACES = 2
else:
CLOCK_RES_PLACES = 3

Expand Down
3 changes: 2 additions & 1 deletion Lib/token.py

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

1 change: 1 addition & 0 deletions Misc/ACKS
Original file line number Diff line number Diff line change
Expand Up @@ -1149,6 +1149,7 @@ Mark Lutz
Taras Lyapun
Jim Lynch
Mikael Lyngvig
Ilya Lyubavski
Jeff MacDonald
John Machin
Andrew I MacIntyre
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix crash in finalization of dtoa state. Patch by Kumar Aditya.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Publicly expose :data:`~token.EXACT_TOKEN_TYPES` in :attr:`!token.__all__`.
2 changes: 1 addition & 1 deletion Objects/dictobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -7190,7 +7190,7 @@ _PyDict_DetachFromObject(PyDictObject *mp, PyObject *obj)

// We could be called with an unlocked dict when the caller knows the
// values are already detached, so we assert after inline values check.
_Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(mp);
ASSERT_WORLD_STOPPED_OR_OBJ_LOCKED(mp);
assert(mp->ma_values->embedded == 1);
assert(mp->ma_values->valid == 1);
assert(Py_TYPE(obj)->tp_flags & Py_TPFLAGS_INLINE_VALUES);
Expand Down
8 changes: 5 additions & 3 deletions Python/import.c
Original file line number Diff line number Diff line change
Expand Up @@ -1155,12 +1155,14 @@ del_extensions_cache_value(struct extensions_cache_value *value)
static void *
hashtable_key_from_2_strings(PyObject *str1, PyObject *str2, const char sep)
{
Py_ssize_t str1_len, str2_len;
const char *str1_data = PyUnicode_AsUTF8AndSize(str1, &str1_len);
const char *str2_data = PyUnicode_AsUTF8AndSize(str2, &str2_len);
const char *str1_data = _PyUnicode_AsUTF8NoNUL(str1);
const char *str2_data = _PyUnicode_AsUTF8NoNUL(str2);
if (str1_data == NULL || str2_data == NULL) {
return NULL;
}
Py_ssize_t str1_len = strlen(str1_data);
Py_ssize_t str2_len = strlen(str2_data);

/* Make sure sep and the NULL byte won't cause an overflow. */
assert(SIZE_MAX - str1_len - str2_len > 2);
size_t size = str1_len + 1 + str2_len + 1;
Expand Down
4 changes: 3 additions & 1 deletion Python/pylifecycle.c
Original file line number Diff line number Diff line change
Expand Up @@ -1869,7 +1869,6 @@ finalize_interp_clear(PyThreadState *tstate)
_PyXI_Fini(tstate->interp);
_PyExc_ClearExceptionGroupType(tstate->interp);
_Py_clear_generic_types(tstate->interp);
_PyDtoa_Fini(tstate->interp);

/* Clear interpreter state and all thread states */
_PyInterpreterState_Clear(tstate);
Expand All @@ -1891,6 +1890,9 @@ finalize_interp_clear(PyThreadState *tstate)

finalize_interp_types(tstate->interp);

/* Finalize dtoa at last so that finalizers calling repr of float doesn't crash */
_PyDtoa_Fini(tstate->interp);

/* Free any delayed free requests immediately */
_PyMem_FiniDelayed(tstate->interp);

Expand Down
3 changes: 2 additions & 1 deletion Tools/build/generate_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ def make_rst(infile, outfile='Doc/library/token-list.inc'):
# {AUTO_GENERATED_BY_SCRIPT}
'''
token_py_template += '''
__all__ = ['tok_name', 'ISTERMINAL', 'ISNONTERMINAL', 'ISEOF']
__all__ = ['tok_name', 'ISTERMINAL', 'ISNONTERMINAL', 'ISEOF',
'EXACT_TOKEN_TYPES']
%s
N_TOKENS = %d
Expand Down

0 comments on commit c4cd138

Please sign in to comment.