When creating an Enum, `type.__new__` calls `__init_subclass__`, but at that point the members have not been added.
This patch suppresses the initial call, then manually calls the ancestor `__init_subclass__` before returning the new Enum class.
(cherry picked from commit 6bd94de168)
Export the Py_FrozenMain() function: fix a Python 3.9.0 regression.
Python 3.9 uses -fvisibility=hidden and the function was not exported
explicitly and so not exported.
(cherry picked from commit b5c7b38f5e)
Add positional only args support to lib2to3 pgen2.
This adds 3.8's PEP-570 support to lib2to3's pgen2. lib2to3, while
being deprecated is still used by things to parse all versions of Python
code today. We need it to support parsing modern 3.8 and 3.9 constructs.
Also add tests for complex *expr and **expr's.
(cherry picked from commit 42c9f0fd0a)
Co-authored-by: Gregory P. Smith <greg@krypto.org>
Check if NonCallableMock's spec_arg is not None instead of call its __bool__ function
(cherry picked from commit c598a04dd2)
Co-authored-by: idanw206 <31290383+idanw206@users.noreply.github.com>
This is invalid in C99 and later and is an error with some compilers
(e.g. clang in Xcode 12), and can thus cause configure checks to
produce incorrect results.
(cherry picked from commit 674fa0a740)
Co-authored-by: Joshua Root <jmr@macports.org>
Fix the wording in the documentation of `async for` to correctly describe asynchronous iterables. This fix is relevant for version 3.7 onward.
(cherry picked from commit 4b8cdfcb22)
Co-authored-by: Nick Gaya <nicholasgaya+github@gmail.com>
Fix encoding name when running a ".pyc" file on Windows:
PyRun_SimpleFileExFlags() now uses the correct encoding to decode the
filename.
* Add pyrun_file() subfunction.
* Add pyrun_simple_file() subfunction.
* PyRun_SimpleFileExFlags() now calls _Py_fopen_obj() rather than
_Py_fopen().
(cherry picked from commit b6d98c10ff)
Several built-in and standard library types now ensure that their internal result tuples are always tracked by the garbage collector:
- collections.OrderedDict.items
- dict.items
- enumerate
- functools.reduce
- itertools.combinations
- itertools.combinations_with_replacement
- itertools.permutations
- itertools.product
- itertools.zip_longest
- zip
Previously, they could have become untracked by a prior garbage collection.
(cherry picked from commit 226a012d1c)
(cherry picked from commit 752cdf21eb)
Co-authored-by: Raymond Hettinger <rhettinger@users.noreply.github.com>
Co-authored-by: Raymond Hettinger <rhettinger@users.noreply.github.com>
Remove obsolete workaround that prevented running files with
shortcuts when using new universal2 installers built on macOS 11.
Ignore buggy 2nd run_module_event call.
(cherry picked from commit 57e5113610)
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Use `_PyArg_NoKeywords` instead of `_PyArg_NoKwnames` when checking the `kwds` tuple when creating `GenericAlias`. This fixes an interpreter crash when passing in keyword arguments to `GenericAlias`'s constructor.
Needs backport to 3.9.
Automerge-Triggered-By: GH:gvanrossum
(cherry picked from commit 804d6893b8)
Co-authored-by: kj <28750310+Fidget-Spinner@users.noreply.github.com>
If no explicit macOS SDK was specified, setup.py should check for
Tcl and TK frameworks in /Library/Frameworks; the previous commit
inadvertently broke that test.
(cherry picked from commit 29afab6c5f)
Co-authored-by: Ned Deily <nad@python.org>
This can happen when a file was edited after it was imported.
(cherry picked from commit 2e0760bb2e)
Co-authored-by: Irit Katriel <iritkatriel@yahoo.com>
Fix test_asyncio.test_call_later() race condition: don't measure
asyncio performance in the call_later() unit test. The test failed
randomly on the CI.
(cherry picked from commit 7e5e13d113)
Co-authored-by: Victor Stinner <vstinner@python.org>
macOS releases numbering has changed as of macOS 11 Big Sur. Previously, major releases were of the form 10.x, 10.x+1, 10.x+2, etc; as of Big Sur, they are now x, x+1, etc, so, for example, 10.15, 10.15.1, ..., 10.15.7, 11, 11.0.1, 11.1, ..., 12, 12.1, etc. Allow Python to build with single-digit deployment target values. Patch provided by FX Coudert.
(cherry picked from commit 5291639e61)
Co-authored-by: FX Coudert <fxcoudert@gmail.com>
restart_subprocess is a method of self, the pyshell.InteractiveInterpreter instance. The latter does not have an interp attribute redundantly referring to itself. (The PyShell instance does have an interp attribute, referring to the InteractiveInterpreter instance.)
(cherry picked from commit e41bfd15dd)
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Instead of using wait_visibility() which waits event <VisibilityNotify> in dead loop
use update() which should proceed all queued events.
(cherry picked from commit 6cc2c419f6)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>