Some of the tests in test_queue had a race condition in which a
non-sentinel value could be enqueued after the final sentinel value
leading to not all the inputs being processed (and test failures).
This changes feed() to enqueue a sentinel once the inputs are exhausted,
which guarantees that the final queued object is a sentinel. This
requires the number of feeder threads to match the number of consumer
threads, but that's already the case in the relevant tests.
(cherry picked from commit df3e53d86b)
Co-authored-by: Sam Gross <colesbury@gmail.com>
Unlike the other locks reinitialized by _PyRuntimeState_ReInitThreads,
the "interpreters.main->id_mutex" is not freed by _PyRuntimeState_Fini
and should not force the default raw allocator.
(cherry picked from commit 736684b1bb)
Co-authored-by: Sam Gross <colesbury@gmail.com>
so that
$ python -m json.tool foo.json foo.json
doesn't result in an empty foo.json.
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
(cherry picked from commit 815dad42d5)
Co-authored-by: Chris Wesseling <chris.wesseling@protonmail.com>
In order to fix a bug in the 3.9 branch in GH-29394, more tests were added to
``test_functools.py`` to ensure that ``singledispatchmethod`` still correctly
wrapped a target method, even if the target method had already been wrapped by
multiple other decorators. This PR brings the new tests into the 3.11 and 3.10
branches as well.
(cherry picked from commit 32f55d1a5d)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
* Don't stackoveflow on debug builds
* Also catch the pickletester case
(cherry picked from commit d56375a0dd)
Co-authored-by: Dennis Sweeney <36520290+sweeneyde@users.noreply.github.com>
Run test_shelve with all underlying dbm implementations and pickle protocols.
Also make test_shelve discoverable.
(cherry picked from commit b781cc3bfc)
the current test depended on integer sets being iterated on in a certain
fixed order. That order is different on PyPy (insertion based) and could
change in CPython in the future in theory. Make the test robust against
a different iteration order by sorting.
(cherry picked from commit 7401694807)
Co-authored-by: Carl Friedrich Bolz-Tereick <cfbolz@gmx.de>
The doctest module raised an error if a docstring contained an example that
attempted to access a classmethod property. (Stacking '@classmethod' on top of
`@property` has been supported since Python 3.9; see
https://docs.python.org/3/howto/descriptor.htmlGH-class-methods.)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
(cherry picked from commit b1302abcc8)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Use types.GenericAlias in inspect.formatannotation to correctly add
type arguments of builtin types to the string representation of
Signatures.
Co-authored-by: Martin Rückl <martin.rueckl@codecentric.de>
(cherry picked from commit d02ffd1b5c)
Co-authored-by: Martin Rueckl <enigma@nbubu.de>
* Use Py_EnterRecursiveCall() in issubclass()
Reviewed-by: Gregory P. Smith <greg@krypto.org> [Google]
(cherry picked from commit 423fa1c181)
Co-authored-by: Dennis Sweeney <36520290+sweeneyde@users.noreply.github.com>
Raise RLIMIT_NOFILE in test.libregrtest.
On macOS the default is often too low for our testsuite to succeed.
Co-authored by reviewer: Victor Stinner
(cherry picked from commit 843b890334)
Co-authored-by: Gregory P. Smith <greg@krypto.org>
An object implementing the os.PathLike protocol can represent a file
system path as a str or bytes object.
Therefore, _infer_return_type function should infer os.PathLike[str]
object as str type and os.PathLike[bytes] object as bytes type.
(cherry picked from commit 6270d3eeaf)
Co-authored-by: Kyungmin Lee <rekyungmin@gmail.com>
Since v8.6.11, a few configuration options seem to accept an empty value
where they did not previously; particularly the `type` of a `Menu`
widget, and the `compound` of any ttk widget with a label. Providing an
explicit expected error message to `checkEnumParam` bypasses the check
of an empty value, which no longer raises `TclError`.
(cherry picked from commit 4fe454c6f5)
Co-authored-by: Zachary Ware <zach@python.org>
In Python 3.8 and 3.9, stacking `@functools.singledispatchmethod` on top of
`@classmethod` or `@staticmethod` caused an exception to be raised if the
method was registered using type-annotations rather than
`@method.register(int)`. This was not caught by unit tests, however, as the
tests only tested the `@method.register(int)` way of registering additional
implementations. The bug is no longer present in Python 3.10+, but
`test_functools.py` is still lacking regression tests for these cases. This
commit adds these test cases.
(cherry picked from commit ad6d162e51)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
There are two errors that this commit fixes:
* The parser was not correctly computing the offset and the string
source for E_LINECONT errors due to the incorrect usage of strtok().
* The parser was not correctly unwinding the call stack when a tokenizer
exception happened in rules involving optionals ('?', [...]) as we
always make them return valid results by using the comma operator. We
need to check first if we don't have an error before continuing..
(cherry picked from commit a106343f63)
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
* Generate test classes at import time. It allows to filter them when
run with unittest. E.g: "./python -m unittest test.test_dbm.TestCase_gnu -v".
* Create a database class in a new directory which will be removed after
test. It guarantees that all created files and directories be removed
and will not conflict with other dbm tests.
* Restore dbm._defaultmod after tests. Previously it was set to the last
dbm module (dbm.dumb) which affected other tests.
* Enable the whichdb test for dbm.dumb.
* Move test_keys to the correct test class. It does not test whichdb().
* Remove some outdated code and comments..
(cherry picked from commit 975b94b9de)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Since the keyword list is frozen, only compute it once per
session. The colorizer already handles context keywords.
(cherry picked from commit 42ac06dcd2)
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Automerge-Triggered-By: GH:terryjreedy