Skip to content

Commit

Permalink
Merge branch 'main' into pythongh-127381-lstat
Browse files Browse the repository at this point in the history
  • Loading branch information
barneygale authored Nov 29, 2024
2 parents 9db3241 + 15d6506 commit 06356c0
Show file tree
Hide file tree
Showing 22 changed files with 390 additions and 236 deletions.
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
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
12 changes: 4 additions & 8 deletions Lib/test/clinic.test.c
Original file line number Diff line number Diff line change
Expand Up @@ -5303,9 +5303,7 @@ Test_meth_coexist_impl(TestObj *self)
Test.property
[clinic start generated code]*/

#if defined(Test_property_HAS_DOCSTR)
# define Test_property_DOCSTR Test_property__doc__
#else
#if !defined(Test_property_DOCSTR)
# define Test_property_DOCSTR NULL
#endif
#if defined(TEST_PROPERTY_GETSETDEF)
Expand All @@ -5326,16 +5324,14 @@ Test_property_get(TestObj *self, void *Py_UNUSED(context))

static PyObject *
Test_property_get_impl(TestObj *self)
/*[clinic end generated code: output=27b519719d992e03 input=2d92b3449fbc7d2b]*/
/*[clinic end generated code: output=7cadd0f539805266 input=2d92b3449fbc7d2b]*/

/*[clinic input]
@setter
Test.property
[clinic start generated code]*/

#if defined(TEST_PROPERTY_HAS_DOCSTR)
# define Test_property_DOCSTR Test_property__doc__
#else
#if !defined(Test_property_DOCSTR)
# define Test_property_DOCSTR NULL
#endif
#if defined(TEST_PROPERTY_GETSETDEF)
Expand All @@ -5360,7 +5356,7 @@ Test_property_set(TestObj *self, PyObject *value, void *Py_UNUSED(context))

static int
Test_property_set_impl(TestObj *self, PyObject *value)
/*[clinic end generated code: output=d51023f17c4ac3a1 input=3bc3f46a23c83a88]*/
/*[clinic end generated code: output=e4342fe9bb1d7817 input=3bc3f46a23c83a88]*/

/*[clinic input]
output push
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 @@ -124,6 +124,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 @@ -1133,6 +1133,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
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 @@ -1154,6 +1154,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,2 @@
Optimize decoding of short UTF-8 sequences containing non-ASCII characters
by approximately 15%.
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__`.
14 changes: 4 additions & 10 deletions Modules/_io/clinic/bufferedio.c.h

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

14 changes: 4 additions & 10 deletions Modules/_io/clinic/stringio.c.h

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

44 changes: 13 additions & 31 deletions Modules/_io/clinic/textio.c.h

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

Loading

0 comments on commit 06356c0

Please sign in to comment.