Commit Graph

28743 Commits

Author SHA1 Message Date
Victor Stinner b270b82f11
gh-91320: Argument Clinic uses _PyCFunction_CAST() (#32210)
Replace "(PyCFunction)(void(*)(void))func" cast with
_PyCFunction_CAST(func).
2022-05-03 20:25:41 +02:00
Humbled Drugman b295a92c50
bpo-29890: Test IPv*Interface construction with tuple argument (#30862)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-05-03 11:21:24 -06:00
Abhigyan Bose 77e7a04cd2
GH-91752: Skip test_freeze_simple_script when zlib is not available (#91758)
Fixes GH-91752.
2022-05-03 10:19:54 -07:00
Toshio Kuratomi 20490d5018
gh-88753: Make BooleanOptionalAction's addition of default to help more similar to other actions (#27808)
Help for other actions omit the default value if default is SUPPRESS or
already contains the special format string '%(default)'.  Add those
special cases to BooleanOptionalAction's help formatting too.

Fixes https://bugs.python.org/issue44587 so that default=SUPPRESS is not
emitted.

Fixes https://bugs.python.org/issue38956 as this code will detect
whether '%(default)s' has already been specified in the help string.

Signed-off-by: Micky Yun Chan (michiboo): <chanmickyyun@gmail.com>
Co-authored-by: Micky Yun Chan <michan@redhat.com>
2022-05-03 18:38:18 +02:00
Dennis Sweeney b156578bd6
gh-92031: Deoptimize Static Code at Finalization (GH-92039) 2022-05-03 08:59:12 -06:00
Samodya Abey f6f36cc269
bpo-44863: Allow generic typing.TypedDict (#27663)
Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
Co-authored-by: Yurii Karabas <1998uriyyo@gmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2022-05-03 07:21:42 -06:00
Carey Metcalfe 78e70be331
gh-70363: Implement `io.IOBase` interface for `SpooledTemporaryFile` (GH-29560)
Since the underlying file-like objects (either `io.BytesIO`,
or a true file object) all implement the `io.IOBase`
interface, the `SpooledTemporaryFile` should as well.

Additionally, since the underlying file object will either be an
instance of an `io.BufferedIOBase` (for binary mode) or an
`io.TextIOBase` (for text mode), methods for these classes were also
implemented.

In every case, the required methods and properties are simply delegated
to the underlying file object.

Co-authored-by: Gary Fernie <Gary.Fernie@skyscanner.net>
Co-authored-by: Inada Naoki <songofacandy@gmail.com>
2022-05-03 21:18:18 +09:00
Thomas Cellerier 52dc9c3066
bpo-46415: Use f-string for ValueError in ipaddress.ip_{address,network,interface} helper functions (#30642)
`IPv*Network` and `IPv*Interface` constructors accept a 2-tuple of
(address description, netmask) as the address parameter.
When the tuple-based address is used errors are not propagated
correctly through the `ipaddress.ip_*` helper because of the %-formatting now expecting several arguments:

	In [7]: ipaddress.ip_network(("192.168.100.0", "fooo"))
        ...
	TypeError: not all arguments converted during string formatting

Compared to:

	In [8]: ipaddress.IPv4Network(("192.168.100.0", "foo"))
        ...
	NetmaskValueError: 'foo' is not a valid netmask

Use an f-string to make sure the error is always properly formatted.

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-05-03 06:12:58 -06:00
Hugo van Kemenade 9b027d4cea
gh-92169: Use warnings_helper.import_deprecated() to import deprecated modules uniformly in tests (GH-92170) 2022-05-03 10:17:54 +03:00
Ruben Vorderman a73fc73ff7
bpo-46267: Test compresslevel in gzip.compress (#30416)
Fixes #90425
2022-05-02 23:11:06 -06:00
Itai Steinherz 39e6b8ae6a
bpo-46785: Fix race condition between os.stat() and unlink on Windows (GH-31858) 2022-05-03 00:19:13 +01:00
Shantanu ebb8b512e9
gh-91621: Fix typing.get_type_hints for collections.abc.Callable (#91656)
This mirrors logic in typing.get_args. The trickiness comes from how we
flatten args in collections.abc.Callable, see
https://bugs.python.org/issue42195
2022-05-02 17:08:28 -06:00
Ethan Smith aff8c4f488
gh-84461: Add ability for multiprocessed libregrtest to use a different Python executable (GH-91930) 2022-05-02 15:51:34 -07:00
Serhiy Storchaka b04e02c57f
bpo-43923: Add support for generic typing.NamedTuple (#92027) 2022-05-02 16:41:23 -06:00
Serhiy Storchaka 81fb3548be
gh-92106: Add test that subscription works on arbitrary TypedDicts (#92176) 2022-05-02 16:38:39 -06:00
kbeldan 4bed9c47bd
gh-92032: Add soft keywords to rlcompleter (#92029)
Let the interpreter autocomplete soft-keywords, ATM the PEP-634 'match'
/ 'case' / '_' (wildcard pattern).

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2022-05-02 16:36:29 -06:00
Jelle Zijlstra ff88f7e007
gh-87390: Add __unpacked__ attribute to types.GenericAlias (#92059) 2022-05-02 13:21:59 -06:00
Hugo van Kemenade 56f9844014
gh-90765: configparser test: Catch deprecation warning (#91480) 2022-05-02 11:22:26 -06:00
Mark Dickinson 0ed91a26fe
gh-90213: Speed up right shifts of negative integers (GH-30277) 2022-05-02 11:19:03 -06:00
Eric V. Smith 5f9c0f5ddf
Add weakref_slot to dataclass decorator, to allow instances with slots to be weakref-able. (#92160) 2022-05-02 10:36:39 -06:00
Irit Katriel 84b986ba10
gh-91276: revert the increase of dis output width (GH-92126) 2022-05-02 16:51:17 +01:00
Alex Waygood ab616d323d
gh-92128: Add `__class_getitem__` to `logging.LoggerAdapter` and `logging.StreamHandler` (#92129)
Closes #92128
2022-05-02 09:10:02 -06:00
Victor Stinner 031397063e
gh-92135: Fix _Py_reinterpret_cast() for const (#92138)
Fix C++ compiler warnings on cast macros, like _PyObject_CAST(), when
casting a constant expression to a non constant type: use
const_cast<> in C++.

* In C++, Py_SAFE_DOWNCAST() now uses static_cast<> rather than
  reinterpret_cast<>.
* Add tests to the _testcppext C++ extension.
* test_cppext no longer captures stdout in verbose mode.
2022-05-02 17:07:00 +02:00
Erlend Egeberg Aasland 721aa96540
gh-89301: Fix regression with bound values in traced SQLite statements (#92053) 2022-05-02 08:14:35 -06:00
Victor Stinner 79886e7b62
gh-91321: Add _testcppext C++ extension (#32175)
Build a basic C++ test extension to check that the Python C API is
compatible with C++ and does not emit C++ compiler warnings.

* Add Modules/_testcppext.cpp: C++ extension
* Add Lib/test/test_cppext.py: test building the C++ extension.
2022-05-02 14:09:22 +02:00
Serhiy Storchaka 18b07d773e
bpo-36819: Fix crashes in built-in encoders with weird error handlers (GH-28593)
If the error handler returns position less or equal than the starting
position of non-encodable characters, most of built-in encoders didn't
properly re-size the output buffer. This led to out-of-bounds writes,
and segfaults.
2022-05-02 12:37:48 +03:00
Serhiy Storchaka 4d10f703d7
gh-92114: Improve error message for types with __class_getitem__ = None (GH-92115) 2022-05-02 08:29:49 +03:00
Antony Lee ad5e8520f3
bpo-39716: Raise on conflicting subparser names. (GH-18605)
Raise an ArgumentError when the same subparser name is added twice to an
ArgumentParser.  This is consistent with the (default) behavior when the
same option string is added twice to an ArgumentParser.

(Support for `conflict_handler="resolve"` could be considered as a
followup feature, although real use cases seem even rarer than
"resolve"ing option-strings.)

Automerge-Triggered-By: GH:rhettinger
2022-04-30 23:04:50 -07:00
Dennis Sweeney b9636180b3
gh-91954: Use shell=True in test_subprocess.test_encoding_warning (GH-92090) 2022-04-30 20:38:19 -04:00
Dennis Sweeney 868b1afa05
gh-92063: Enforce types in specialized PRECALL opcodes (GH-92068)
* Check the types of PRECALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS

* fix PRECALL_NO_KW_METHOD_DESCRIPTOR_NOARGS as well

* fix PRECALL_NO_KW_METHOD_DESCRIPTOR_O

* fix PRECALL_NO_KW_METHOD_DESCRIPTOR_FAST
2022-04-30 12:35:33 -06:00
Erlend Egeberg Aasland 9ea9078ec7
gh-92019: Make sqlite3.Blob indexing conform with the norm (#92020)
- get index now returns an int
- set index now requires an int in range(0, 256)

Resolves #92019
2022-04-30 09:01:37 -06:00
Serhiy Storchaka e91dee87ed
bpo-43323: Fix UnicodeEncodeError in the email module (GH-32137)
It was raised if the charset itself contains characters not encodable
in UTF-8 (in particular \udcxx characters representing non-decodable
bytes in the source).
2022-04-30 13:17:23 +03:00
Serhiy Storchaka 3483299a24
gh-81548: Deprecate octal escape sequences with value larger than 0o377 (GH-91668) 2022-04-30 13:16:27 +03:00
Serhiy Storchaka 19dca04121
gh-91760: Deprecate group names and numbers which will be invalid in future (GH-91794)
Only sequence of ASCII digits will be accepted as a numerical reference.
The group name in bytes patterns and replacement strings could only
contain ASCII letters and digits and underscore.
2022-04-30 13:13:46 +03:00
Inada Naoki 354ace8b07
gh-91954: Emit EncodingWarning from locale and subprocess (GH-91977)
locale.getpreferredencoding() and subprocess.Popen() emit EncodingWarning
2022-04-30 15:53:29 +09:00
Serhiy Storchaka e8c2f72b94
bpo-43224: Implement substitution of unpacked TypeVarTuple in C (GH-31828)
Co-authored-by: Matthew Rahtz <mrahtz@gmail.com>
2022-04-30 08:22:46 +03:00
Dennis Sweeney a29aa76a3f
gh-92064: Fix global variable name collision in test_typing (#92067)
Fixes #92064
2022-04-29 21:18:38 -06:00
Brett Cannon c2b579741d
gh-91217: deprecate xdrlib (GH-92066)
Automerge-Triggered-By: GH:brettcannon
2022-04-29 18:22:10 -07:00
Serhiy Storchaka 81120b6754
bpo-44791: Accept ellipsis as the last argument of typing.Concatenate (#30969) 2022-04-29 15:01:40 -06:00
Matthew Rahtz f6656163de
gh-87390: Add tests demonstrating current type variable substitution behaviour (#32341) 2022-04-29 14:03:21 -06:00
Petr Viktorin 83bce8ef14
gh-91324: Convert the stable ABI manifest to TOML (GH-92026) 2022-04-29 16:18:08 +02:00
Eisuke Kawashima ea2f5bcda1
bpo-22276: Change pathlib.Path.glob not to ignore trailing path separator (GH-10349)
Now pathlib.Path.glob() **only** matches directories when the pattern ends in a path separator.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2022-04-28 12:45:03 -07:00
Yurii Karabas 0ef8d921f5
gh-91603: Speed up isinstance/issubclass on union types (GH-91631)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
2022-04-28 23:24:19 +08:00
Abhigyan Bose 4ed3900041
gh-91832: Add 'required' attr to argparse.Action repr (GH-91841)
# Adding 'required' to names in Lib.argparse.Action

gh-91832: 
Added 'required' to the list `names` in `Lib.argparse.Action`. 
Changed constant strings that test the Action object.

Automerge-Triggered-By: GH:merwok
2022-04-28 07:50:27 -07:00
Petr Viktorin 6dcbc08c95
gh-91324: List feature macros in the stable ABI manifest, improve tests (GH-32415) 2022-04-28 16:30:28 +02:00
Abhigyan Bose 88dd227959
gh-91984: Fix trailing spaces in multiline test strings in test_argparse (GH-91986) 2022-04-28 14:29:24 +03:00
Dennis Sweeney 37c6db60f9
gh-91869: Fix tracing of specialized instructions with extended args (GH-91945) 2022-04-27 22:36:34 -06:00
Brett Cannon 407c3afe19
gh-91217: deprecate uu (GH-92009)
Automerge-Triggered-By: GH:brettcannon
2022-04-27 20:26:33 -07:00
Serhiy Storchaka 43a8bf1ea4
gh-87999: Change warning type for numeric literal followed by keyword (GH-91980)
The warning emitted by the Python parser for a numeric literal
immediately followed by keyword has been changed from deprecation
warning to syntax warning.
2022-04-27 20:15:14 +03:00
Serhiy Storchaka f60b4c3d74
gh-91810: Expand ElementTree.write() tests to use non-ASCII data (GH-91989) 2022-04-27 19:16:20 +03:00
Victor Stinner 80de0273c0
gh-68966: Deprecate the mailcap module (#91951) 2022-04-26 22:43:50 +02:00
Brett Cannon 1af871eeee
gh-91217: deprecate telnetlib (GH-91958) 2022-04-26 10:45:08 -07:00
Serhiy Storchaka 4153f2cbcb
gh-91917: Fix test_zipfile on non-UTF-8 locale (GH-91921)
Skip the extraction test if file names are not encodable.
2022-04-26 08:01:33 +03:00
Serhiy Storchaka a568585069
gh-91916: Fix test_runpy on non-UTF-8 locale (GH-91920)
If use a non-builtin codec, partially implemented in Python
(e.g. ISO-8859-15), a new RecursionError (with empty error message)
can be raised while handle a RecursionError.

Testing for error message was needed to distinguish
a recursion error from arbitrary RuntimeError. After introducing
RecursionError, it became unnecessary.
2022-04-26 08:00:47 +03:00
Serhiy Storchaka f41c16bf51
gh-91914: Fix test_curses on non-UTF-8 locale (GH-91919) 2022-04-26 07:59:56 +03:00
Serhiy Storchaka 36306cf786
gh-91915: Fix test_netrc on non-UTF-8 locale (GH-91918) 2022-04-26 07:58:41 +03:00
Jelle Zijlstra 5397b5afc1
gh-91860: Add typing.dataclass_transform (PEP 681) (#91861)
Copied from typing-extensions (python/typing#1054, python/typing#1120).

Documentation is intentionally omitted, so we can focus on getting the
runtime part in before the feature freeze.
2022-04-25 20:30:25 -07:00
Brett Cannon d174ebe91e
gh-91217: deprecate sunau (GH-91866) 2022-04-25 16:26:43 -07:00
Gregory P. Smith cd5726fe67
gh-91401: Add a failsafe way to disable vfork. (#91490)
Just in case there is ever an issue with _posixsubprocess's use of
vfork() due to the complexity of using it properly and potential
directions that Linux platforms where it defaults to on could take, this
adds a failsafe so that users can disable its use entirely by setting
a global flag.

No known reason to disable it exists. But it'd be a shame to encounter
one and not be able to use CPython without patching and rebuilding it.

See the linked issue for some discussion on reasoning.

Also documents the existing way to disable posix_spawn.
2022-04-25 16:19:39 -07:00
Victor Stinner 20cc695286
gh-64783: Fix signal.NSIG value on FreeBSD (#91929)
Fix signal.NSIG value on FreeBSD to accept signal numbers greater
than 32, like signal.SIGRTMIN and signal.SIGRTMAX.

* Add Py_NSIG constant.
* Add pycore_signal.h internal header file.
* _Py_Sigset_Converter() now includes the range of valid signals in
  the error message.
2022-04-26 00:13:31 +02:00
David Hewitt 1cd8c29dac
gh-91880: add try/except around `signal.signal` (#91881)
Fixes gh-91880.
2022-04-25 08:56:20 -07:00
Serhiy Storchaka 54d068adfb
gh-91904: Fix setting envvar PYTHONREGRTEST_UNICODE_GUARD (GH-91905)
It always failed on non-UTF-8 locale and prevented running regrtests.
2022-04-25 17:35:14 +03:00
Jelle Zijlstra 93d280141c
gh-90633: Improve error and docs for typing.assert_never (#91720)
Closes #90633

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2022-04-25 06:40:18 -07:00
Christian Heimes 9ff2f12c87
gh-84461: Include _emscripten_info in pythoninfo output (GH-91907) 2022-04-25 12:58:25 +02:00
Barry Warsaw 4403320727
Rewrite audio.py to jive with image.py (#91886)
Similar to the rewrite of email/mime/image.py and associated test after the
deprecation of imghdr.py, thisrewrites email/mime/audio.py and associated
tests after the deprecation of sndhdr.py.

Closes #91885
2022-04-24 15:50:07 -07:00
Jelle Zijlstra e93d2fbdda
gh-91821: Make decimal test succeed consistently (#91825)
The test relies on precision being set to 9, but some ways of
invoking this test leave it set to 28 instead. I don't know
exactly how it happens, but setting the precision directly should
make the behavior consistent.
2022-04-24 15:02:57 -07:00
Serhiy Storchaka 090721721b
Simplify testing the warning filename (GH-91868)
The context manager result has the "filename" attribute.
2022-04-24 10:23:59 +03:00
Zac Hatfield-Dodds b4e048411f
gh-91230: Concise catch_warnings with simplefilter (#91435) 2022-04-23 17:55:22 -07:00
Brett Cannon 692e9078a1
gh-91217: deprecate spwd (#91846)
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2022-04-23 14:48:17 -07:00
Serhiy Storchaka 6b45076bd6
RE: Add more tests for inline flag "x" and re.VERBOSE (GH-91854) 2022-04-23 12:49:06 +03:00
Christian Heimes 9b5ca5405e
gh-84461: Add sys._emscripten_info, improve docs and build (gh-91781) 2022-04-23 09:52:16 +02:00
Pablo Galindo Salgado 0daa99f68b
gh-88116: Enhance the inspect frame APIs to use the extended position information (GH-91531) 2022-04-23 03:16:48 +01:00
Brett Cannon e7929cba16
gh-91217: deprecate-sndhdr (#91806)
Also inline necessary functionality from `sndhdr` into `email.mime.audio` for `MIMEAudio`.

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2022-04-22 15:48:03 -07:00
Géry Ogam 5576ddbbbc
bpo-46720: Add support for path-like objects to multiprocessing.set_executable for Windows (GH-31279)
This bring the API to be on a par with Unix-like systems.
2022-04-22 15:47:09 -07:00
Serhiy Storchaka 48ec61a89a
gh-91700: Validate the group number in conditional expression in RE (GH-91702)
In expression (?(group)...) an appropriate re.error is now
raised if the group number refers to not defined group.

Previously it raised RuntimeError: invalid SRE code.
2022-04-22 19:53:10 +03:00
Serhiy Storchaka 6ccfa31421
gh-90568: Fix exception type for \N with a named sequence in RE (GH-91665)
re.error is now raised instead of TypeError.
2022-04-22 18:35:28 +03:00
Sam Ezeh bcf14ae433
gh-91291: Accept attributes as keyword arguments in decimal.localcontext (#32242)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-04-21 21:27:15 -07:00
Matthew Rahtz 5e130a8da4
bpo-43224: Implement pickling of TypeVarTuples (#32119)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-04-21 21:22:53 -07:00
Brett Cannon 2551a6c92f
gh-91217: deprecate-pipes (GH-91779) 2022-04-21 19:28:34 -07:00
Erlend Egeberg Aasland 29afb7d2ef
gh-69093: Add indexing and slicing support to sqlite3.Blob (#91599)
Authored-by: Aviv Palivoda <palaviv@gmail.com>
Co-authored-by: Erlend E. Aasland <erlend.aasland@innova.no>
2022-04-21 18:45:16 -07:00
Inada Naoki 1317b70f89
gh-91156: Use `locale.getencoding()` instead of getpreferredencoding (GH-91732)
Co-authored-by: Victor Stinner <vstinner@python.org>
2022-04-22 10:39:24 +09:00
Victor Stinner 364ed94092
gh-89373: _Py_Dealloc() checks tp_dealloc exception (#32357)
If Python is built in debug mode, _Py_Dealloc() now ensures that the
tp_dealloc function leaves the current exception unchanged.
2022-04-21 23:04:01 +02:00
Mark Shannon d44815cabc
GH-88116: Document that PyCodeNew is dangerous, and make PyCode_NewEmpty less dangerous. (GH-91790) 2022-04-21 19:08:36 +01:00
Mark Shannon 944fffee89
GH-88116: Use a compact format to represent end line and column offsets. (GH-91666)
* Stores all location info in linetable to conform to PEP 626.

* Remove column table from code objects.

* Remove end-line table from code objects.

* Document new location table format
2022-04-21 16:10:37 +01:00
Dennis Sweeney f2b4e458b3
gh-91636: Don't clear required fields of function objects (GH-91651) 2022-04-21 02:06:35 -04:00
Iman Kermani 615b24c80b
bpo-42066: CookieJar cookies should not be sorted (GH-22745) 2022-04-20 20:45:24 -05:00
Nick b6d5e3c3c9
bpo-46075: Store localhost cookies in CookieJar (#30108)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-04-19 13:08:06 -07:00
Ma Lin e4e8895ae3
gh-91616: re module, fix .fullmatch() mismatch when using Atomic Grouping or Possessive Quantifiers (GH-91681)
These jumps should use DO_JUMP0() instead of DO_JUMP():
- JUMP_POSS_REPEAT_1
- JUMP_POSS_REPEAT_2
- JUMP_ATOMIC_GROUP
2022-04-19 17:49:36 +03:00
Victor Stinner 061a8bf77c
gh-91231: Add shutdown_timeout to multiprocessing BaseManager (#32112)
Add an optional keyword 'shutdown_timeout' parameter to the
multiprocessing.BaseManager constructor. Kill the process if
terminate() takes longer than the timeout.

Multiprocessing tests pass test.support.SHORT_TIMEOUT
to BaseManager.shutdown_timeout.
2022-04-19 16:27:00 +02:00
Serhiy Storchaka 74070085da
Add more tests for group names and refs in RE (GH-91695) 2022-04-19 16:56:51 +03:00
penguin_wwy e590379197
gh-90997: bpo-46841: Disassembly of quickened code (GH-32099) 2022-04-19 09:45:08 +01:00
Inada Naoki 6fdb62b1fa
gh-91526: io: Remove device encoding support from TextIOWrapper (GH-91529)
`TextIOWrapper.__init__()` called `os.device_encoding(file.fileno())` if fileno is 0-2 and encoding=None.
But it is very rarely works, and never documented behavior.
2022-04-19 11:44:36 +09:00
Irit Katriel 39a54ba638
gh-74166: Add option to get all errors from socket.create_connection (GH-91586) 2022-04-18 23:15:41 +01:00
Bryan Weber 0860b26a4f
gh-91670: Removes `SO` config variable in `sysconfig.py` (#91671)
* Removes SO config variable in sysconfig

Per @warsaw in https://github.com/python/cpython/issues/63754, this was
deprecated in Python 3.4 and was suggested for removal in Python 3.5.

* Add NEWS

* Update Misc/NEWS.d/next/Library/2022-04-18-15-23-24.gh-issue-91670.6eyChw.rst

Co-authored-by: Éric <merwok@netwok.org>

Co-authored-by: Barry Warsaw <barry@python.org>
Co-authored-by: Éric <merwok@netwok.org>
2022-04-18 14:01:18 -07:00
Kumar Aditya 8c54c3dacc
gh-91576: Speed up iteration of strings (#91574) 2022-04-18 07:18:27 -07:00
Serhiy Storchaka 1c2fcebf3c
gh-91575: Update case-insensitive matching in re to the latest Unicode version (GH-91580) 2022-04-18 12:26:30 +03:00
Brett Cannon ceea0715df
gh-91217: deprecate ossaudiodev (GH-91641)
Automerge-Triggered-By: GH:brettcannon
2022-04-17 15:02:36 -07:00
Dennis Sweeney cec5d858f5
gh-91625: Don't ignore extended args of adaptive opcodes (GH-91626) 2022-04-17 14:04:29 -04:00
Jason R. Coombs 7659681556
gh-91298: Refine traversable (apply changes from importlib_resources 5.7.1) (#91623)
* bpo-47142: Refine traversable (apply changes from importlib_resources 5.7.1)

* Replace changelog referencing github issue.
2022-04-17 11:10:36 -04:00
Jason R. Coombs 67712e71b3
bpo-46126: Restore docstrings in importlib.metadata tests. (#32288) 2022-04-17 11:10:26 -04:00
Dennis Sweeney 37965d2fb4
gh-78607: Replace __ltrace__ with __lltrace__ (GH-91619) 2022-04-16 18:57:00 -04:00
Dennis Sweeney 8560f4a0f2
gh-91462: Make lltrace output human-readable. (GH-91463)
* Transform opcodes into opnames
* Print the whole stack at each opcode, and eliminate prtrace output at each (push/pop/stackadj)
* Display info about the function at each resume_frame
2022-04-16 17:36:29 -04:00
Brett Cannon 9f06ff96cc
gh-91217: deprecate nis (GH-91606)
Automerge-Triggered-By: GH:brettcannon
2022-04-16 13:17:30 -07:00
Irit Katriel d4c4a76ed1
gh-89770: Implement PEP-678 - Exception notes (GH-31317) 2022-04-16 19:59:52 +01:00
Gregory P. Smith 7fa3a5a219
gh-91607: Fix several test_concurrent_futures tests to actually test what they claim (#91600)
* Fix test_concurrent_futures to actually test what it says.

Many ProcessPoolExecutor based tests were ignoring the mp_context
and using the default instead.  This meant we lacked proper test
coverage of all of them.

Also removes the old _prime_executor() worker delay seeding code
as it appears to have no point and causes 20-30 seconds extra
latency on this already long test.  It also interfered with some
of the refactoring to fix the above to not needlessly create their
own executor when setUp has already created an appropriate one.

* Don't import the name from multiprocessing directly to avoid confusion.

* 📜🤖 Added by blurb_it.

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2022-04-16 11:46:33 -07:00
Jelle Zijlstra 055760ed9e
gh-89263: Add typing.get_overloads (GH-31716)
Based on suggestions by Guido van Rossum, Spencer Brown, and Alex Waygood.

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>
Co-authored-by: Ken Jin <kenjin4096@gmail.com>
2022-04-16 09:01:43 -07:00
Matthew Rahtz f2bc12f0d5
bpo-43224: Add tests for TypeVarTuple substitution in Annotated (GH-31846) 2022-04-15 21:24:28 -07:00
Erlend Egeberg Aasland a861756675
gh-69093: Add context manager support to sqlite3.Blob (GH-91562) 2022-04-15 21:21:12 -07:00
Brett Cannon c9e231de85
gh-91217: deprecate nntplib (GH-91543) 2022-04-15 12:32:56 -07:00
Irit Katriel 5d421d7342
gh-90501: Add PyErr_GetHandledException and PyErr_SetHandledException (GH-30531) 2022-04-15 19:57:47 +01:00
Erlend Egeberg Aasland d104f4d21f
gh-69093: Don't allow instantiation of sqlite3.Blob objects (GH-91570) 2022-04-15 09:25:03 -07:00
Jelle Zijlstra b7f83bdd0e
gh-69093: Expose sqlite3.Blob as a class (GH-91550)
I noticed this was missing while writing typeshed stubs. It's
useful to expose it for use in annotations and for exploration.
2022-04-15 06:29:57 -07:00
Oleg Iarygin 6217864fe5
gh-79156: Add start_tls() method to streams API (#91453)
The existing event loop `start_tls()` method is not sufficient for
connections using the streams API. The existing StreamReader works
because the new transport passes received data to the original protocol.
The StreamWriter must then write data to the new transport, and the
StreamReaderProtocol must be updated to close the new transport
correctly.

The new StreamWriter `start_tls()` updates itself and the reader
protocol to the new SSL transport.

Co-authored-by: Ian Good <icgood@gmail.com>
2022-04-15 14:23:14 +02:00
Barry Warsaw 1fcb39ea64
gh-91520: Rewrite imghdr inlining for clarity and completeness (#91521)
* Rewrite imghdr inlining for clarity and completeness

* Move MIMEImage class back closer to the top of the file since it's the
  important thing.
* Use a decorate to mark a given rule function and simplify the rule function
  names for clarity.
* Copy over all the imghdr test data files into the email package's test data
  directory.  This way when imghdr is actually removed, it won't affect the
  MIMEImage guessing tests.
* Rewrite and extend the MIMEImage tests to test for all supported
  auto-detected MIME image subtypes.
* Remove the now redundant PyBanner048.gif data file.

* See https://github.com/python/cpython/pull/91461#discussion_r850313336

Co-authored-by: Oleg Iarygin <dralife@yandex.ru>

Co-authored-by: Oleg Iarygin <dralife@yandex.ru>
2022-04-14 17:48:59 -07:00
Erlend Egeberg Aasland ee475430d4
gh-69093: Support basic incremental I/O to blobs in `sqlite3` (GH-30680)
Authored-by: Aviv Palivoda <palaviv@gmail.com>
Co-authored-by: Erlend E. Aasland <erlend.aasland@innova.no>
Co-authored-by: palaviv <palaviv@gmail.com>
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-04-14 17:02:56 -07:00
Brett Cannon 1b6cd872f4
gh-91217: deprecate msilib (GH-91515) 2022-04-14 12:50:11 -07:00
Inada Naoki 13b17e2a0a
gh-91156: Fix `encoding="locale"` in UTF-8 mode (GH-70056) 2022-04-14 16:00:35 +09:00
Alix Lourme 325d6f5035
gh-87497: Document that urllib.request sends headers in camel case (GH-24661)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-04-13 19:19:16 -07:00
Brett Cannon 3fc57e8f6f
gh-91217: deprecate imghdr (#91461)
* Deprecate imghdr

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>

* Update Doc/whatsnew/3.11.rst

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>

* Inline `imghdr` into `email.mime.image`

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
Co-authored-by: Barry Warsaw <barry@python.org>
2022-04-13 10:47:41 -07:00
Dustin Rodrigues 54f67ad543
bpo-43218: Prevent venv creation when the target directory contains a PATH separator. (GH-24530) 2022-04-13 09:07:10 +01:00
Serhiy Storchaka 15537c51c1
bpo-43224: Forbid TypeVar substitution with Unpack (GH-32031) 2022-04-12 20:08:49 -07:00
Jelle Zijlstra ac6c3de03c
gh-91243: Add typing.Required and NotRequired (PEP 655) (GH-32419)
I talked to @davidfstr and I offered to implement the runtime part of PEP 655
to make sure we can get it in before the feature freeze. We're going to defer
the documentation to a separate PR, because it can wait until after the feature
freeze.

The runtime implementation conveniently already exists in typing-extensions,
so I largely copied that.

Co-authored-by: David Foster <david@dafoster.net>
2022-04-12 12:31:02 -07:00
Irit Katriel e44f988b26
gh-91276: make space for longer opcodes in dis output (GH-91444) 2022-04-12 14:35:56 +01:00
Erlend Egeberg Aasland 9ebcece82f
gh-79097: Add support for aggregate window functions in sqlite3 (GH-20903) 2022-04-11 17:55:59 -07:00
Brett Cannon f45aa8f304
gh-91217: deprecate crypt (GH-91459) 2022-04-11 17:02:19 -07:00
Dennis Sweeney 8be8949116
gh-91117: Ensure integer mod and pow operations use cached small ints (GH-31843) 2022-04-11 16:07:09 -04:00
Adrian Garcia Badaracco 5f2abae61e
bpo-44807: Allow Protocol classes to define __init__ (GH-31628)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-04-11 07:51:25 -07:00
John Belmonte b0b836b20c
bpo-45995: add "z" format specifer to coerce negative 0 to zero (GH-30049)
Add "z" format specifier to coerce negative 0 to zero.

See https://github.com/python/cpython/issues/90153 (originally https://bugs.python.org/issue45995) for discussion.
This covers `str.format()` and f-strings.  Old-style string interpolation is not supported.

Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
2022-04-11 15:34:18 +01:00
Irit Katriel dd207a6ac5
bpo-47120: make POP_JUMP_IF_TRUE/FALSE/NONE/NOT_NONE relative (GH-32400) 2022-04-11 10:40:24 +01:00
Inada Naoki 6773203487
bpo-47000: Add `locale.getencoding()` (GH-32068) 2022-04-09 09:54:54 +09:00
Brett Cannon cd29bd13ef
bpo-47061: deprecate cgi and cgitb (GH-32410)
Part of PEP 594.
2022-04-08 17:15:35 -07:00
Petr Viktorin 1c2fddddae
Add feature macro PY_HAVE_THREAD_NATIVE_ID to the stable ABI definition (GH-32365) 2022-04-08 14:35:11 +02:00
Mark Shannon 5b4a4b6f09
Add new PyFrame_GetLasti C-API function (GH-32413) 2022-04-08 12:18:57 +01:00
Brett Cannon 87eec70d97
Deprecate audioop (GH-32392) 2022-04-07 12:27:35 -07:00
Christian Heimes 2b16a08bc7
bpo-40280: Detect missing threading on WASM platforms (GH-32352)
Co-authored-by: Brett Cannon <brett@python.org>
2022-04-07 09:22:47 +02:00
Steve Dower 2390b2236d
bpo-47239: Fixes py.exe output when run in a virtual environment. (GH-32364) 2022-04-07 00:09:54 +01:00
Jeremy Kloth 612e422c6e
bpo-46576: Speed up test_peg_generator by using a static library for shared sources (GH-32338)
Speed up test_peg_generator by using a static library for shared sources to avoid recompiling as much code.
2022-04-06 14:55:58 -07:00
Serhiy Storchaka 884eba3c76
bpo-26579: Add object.__getstate__(). (GH-2821)
Copying and pickling instances of subclasses of builtin types
bytearray, set, frozenset, collections.OrderedDict, collections.deque,
weakref.WeakSet, and datetime.tzinfo now copies and pickles instance attributes
implemented as slots.
2022-04-06 20:00:14 +03:00
Serhiy Storchaka b09184bf05
bpo-47211: Remove function re.template() and flag re.TEMPLATE (GH-32300)
They were undocumented and never working.
2022-04-06 19:53:50 +03:00
Ken Jin da922409ac
Fix whitespace/indentation issues in test_sys (GH-32369) 2022-04-06 23:40:51 +08:00
Victor Stinner 14a9b4895b
bpo-40421: test_capi uses assertEqual(), not assertEquals() (GH-32361)
unittest.TestCase.assertEquals() alias is depracated. Fix the
warning:

Lib/test/test_capi.py:1100: DeprecationWarning: Please use assertEqual instead.
  self.assertEquals(frame.f_locals, _testcapi.frame_getlocals(frame))
2022-04-06 15:12:38 +02:00
Steve Dower 074da78802
bpo-47103: Copy pgort140.dll into output directory when building PGInstrument on Windows (GH-32083) 2022-04-06 11:56:31 +01:00
Brett Cannon c1d93b6411
bpo-47061: deprecate the `aifc` module (GH-32134)
Co-authored-by: Christian Heimes <christian@python.org>
2022-04-05 12:05:48 -07:00
Sam Ezeh 050a8f94c6
bpo-4833: Add ZipFile.mkdir (GH-32160) 2022-04-05 11:41:38 -07:00
Hugo van Kemenade 75280944e5
bpo-46607: Add DeprecationWarning for LegacyInterpolation, deprecated in docs since 3.2 (GH-30927) 2022-04-05 08:15:11 -07:00
Jelle Zijlstra cfb849a326
bpo-47088: Add typing.LiteralString (PEP 675) (GH-32064)
Co-authored-by: Nick Pope <nick@nickpope.me.uk>
2022-04-05 07:21:03 -07:00
Erlend Egeberg Aasland a7551247e7
bpo-41930: Add support for SQLite serialise/deserialise API (GH-26728)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2022-04-05 07:15:25 -07:00
Matthieu Dartiailh aa0f056a00
bpo-47212: Improve error messages for un-parenthesized generator expressions (GH-32302) 2022-04-05 14:47:13 +01:00
Irit Katriel 0aa8d5cbd8
bpo-47120: make JUMP_NO_INTERRUPT relative (GH-32221) 2022-04-05 12:49:08 +01:00
Ronald Oussoren 6aaf4cd866
bpo-46890: Fix setting of sys._base_executable with framework builds on macOS (GH-31958)
The side effect of this bug was that venv environments directly
used the main interpreter instead of the intermediate stub executable,
which can cause problems when a script uses system APIs that
require the use of an application bundle.
2022-04-05 02:05:36 -04:00
Matthew Rahtz 772d8080c9
bpo-43224: typing: Add tests for pickling and copying of unpacked native tuple (GH-32159) 2022-04-04 19:52:42 -07:00
Shantanu 5a4973e29f
bpo-46998: Allow subclassing Any at runtime (GH-31841)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-04-04 19:35:29 -07:00
180909 48269ea9fd
bpo-46484:Add test for Calendar.iterweekdays (GH-30825) 2022-04-04 18:16:56 +01:00
Inada Naoki 4216dce04b
bpo-47000: Make `io.text_encoding()` respects UTF-8 mode (GH-32003)
Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
2022-04-04 11:46:57 +09:00
Jason R. Coombs 84acb5cad1
bpo-46126: Restore 'descriptions' when running tests internally. (GH-32128)
This reverts commit a941e5927f (GH-30194).

Automerge-Triggered-By: GH:jaraco
2022-04-03 12:33:28 -07:00
Ma Lin 6e3eee5c11
bpo-23689: re module, fix memory leak when a match is terminated by a signal or memory allocation failure (GH-32283) 2022-04-03 19:16:20 +03:00
Christian Heimes b82cdd1dac
bpo-47205: Skip error check of sched_get/setaffinity on FreeBSD (GH-32285) 2022-04-03 17:03:49 +02:00
Serhiy Storchaka 1be3260a90
bpo-47152: Convert the re module into a package (GH-32177)
The sre_* modules are now deprecated.
2022-04-02 11:35:13 +03:00
Christian Heimes 4ed8a9a589
bpo-40280: Enable most file-at() and nanosleep APIs again (GH-32238) 2022-04-02 10:13:44 +02:00
Christian Heimes 59be9cd748
bpo-40280: Detect if WASM platform supports threading (GH-32243)
Automerge-Triggered-By: GH:tiran
2022-04-02 01:12:44 -07:00
Jeremy Kloth 0f68c208fa
bpo-47131: Speedup AST comparisons in test_unparse by using node traversal (GH-32132) 2022-04-02 02:54:04 +01:00
Christian Heimes 082d3495d0
bpo-40280: Emscripten fork_exec now fails early (GH-32224) 2022-04-01 21:20:56 +02:00
Jeremy Kloth 76b8a075b8
bpo-47089: Avoid test_compileall failures on Windows (GH-32037) 2022-04-01 20:13:01 +02:00
Irit Katriel 04e07c258f
bpo-47186: Replace JUMP_IF_NOT_EXC_MATCH by CHECK_EXC_MATCH + jump (GH-32231) 2022-04-01 13:59:38 +01:00
Andrew Svetlov d4bb38f82b
bpo-47167: Allow overriding a future compliance check in asyncio.Task (GH-32197) 2022-04-01 04:25:15 +03:00
Mark Shannon 74b95d86e0
bpo-40421: Add missing getters for frame object attributes to C-API. (GH-32114) 2022-03-31 17:13:25 +01:00
Christian Heimes 44e915028d
bpo-47182: Fix crash by named unicode characters after interpreter reinitialization (GH-32212)
Automerge-Triggered-By: GH:tiran
2022-03-31 08:14:50 -07:00
Irit Katriel a00518d9ad
bpo-47120: Replace the JUMP_ABSOLUTE opcode by the relative JUMP_BACKWARD (GH-32115) 2022-03-31 14:14:15 +01:00
Steve Dower f3d5715492
bpo-46566: Make test_launcher more robust to a variety of installs (GH-32204) 2022-03-30 22:18:40 +01:00
Oleg Iarygin a03a09e068
Replace with_traceback() with exception chaining and reraising (GH-32074) 2022-03-30 15:28:20 +03:00
Andrew Svetlov f08a191882
bpo-39622: Interrupt the main asyncio task on Ctrl+C (GH-32105)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2022-03-30 15:15:06 +03:00
Hugo van Kemenade 6881ea936e
bpo-47126: Update to canonical PEP URLs specified by PEP 676 (GH-32124) 2022-03-30 12:00:27 +01:00
Irit Katriel 63f32fae79
bpo-26120: do not exclude __future__ import in pydoc of the __future__ module itself (GH-32180) 2022-03-29 23:07:15 +01:00
Ma Lin 356997cccc
bpo-35859: Fix a few long-standing bugs in re engine (GH-12427)
In rare cases, capturing group could get wrong result.

Regular expression engines in Perl and Java have similar bugs.
The new behavior now matches the behavior of more modern
RE engines: in the regex module and in PHP, Ruby and Node.js.
2022-03-29 17:31:01 +03:00
Steve Dower bad86a621a
bpo-46566: Add new py.exe launcher implementation (GH-32062) 2022-03-29 00:21:08 +01:00
Maciej Górski 7b44ade018
bpo-47129: Add more informative messages to f-string syntax errors (32127)
* Add more informative messages to f-string syntax errors

* 📜🤖 Added by blurb_it.

* Fix whitespaces

* Change error message

* Remove the 'else' statement (as sugested in review)

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2022-03-28 17:08:36 -04:00
Irit Katriel 15ba8167d7
bpo-26120: make pydoc exclude __future__ imports from the data block of the module (GH-30888) 2022-03-28 22:02:57 +01:00
Jouke Witteveen c12ba6b2ff
bpo-45171: Remove tests of deprecated logger.warn(). (GH-32139) 2022-03-27 19:22:05 +01:00
Jouke Witteveen 5ca6d7469b
bpo-45171: Fix stacklevel handling in logging. (GH-28287) 2022-03-27 14:49:28 +01:00
Matthew Rahtz e8e737bcf6
bpo-43224: Implement PEP 646 grammar changes (GH-31018)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-03-26 09:55:35 -07:00
Andrew Svetlov bad6ffaa64
bpo-47062: Rename factory argument to loop_factory (GH-32113) 2022-03-26 00:26:23 +02:00
Duprat d03acd7270
bpo-43352: Add a Barrier object in asyncio lib (GH-24903)
Co-authored-by: Yury Selivanov <yury@edgedb.com>
Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
2022-03-26 00:01:21 +02:00
Andrew Svetlov 20e6e5636a
bpo-47118: Fix asyncio.Runner tests error (32117) 2022-03-25 19:59:29 +02:00
Andrew Svetlov 4119d2d7c9
bpo-47062: Implement asyncio.Runner context manager (GH-31799)
Co-authored-by: Zachary Ware <zach@python.org>
2022-03-24 21:51:16 +02:00
Andrew Svetlov ff619c7dfe
bpo-47104: Rewrite asyncio.to_thread tests to use IsolatedAsyncioTestCase (GH-32086) 2022-03-23 23:17:07 +02:00
Christian Heimes 48e2010d92
bpo-47101: list only activated algorithms in hashlib.algorithms_available (GH-32076) 2022-03-23 13:30:05 -07:00
Andrew Svetlov 0360e9f346
bpo-46829: Deprecate passing a message into Future.cancel() and Task.cancel() (GH-31840)
After a long deliberation we ended up feeling that the message argument for Future.cancel(), added in 3.9, was a bad idea, so we're deprecating it in 3.11 and plan to remove it in 3.13.
2022-03-23 08:43:05 -07:00
Daniël van Noord 7ba7eae508
bpo-2604: Make doctest.DocTestCase reset globs in teardown (GH-31932)
Co-authored-by: Piet Delport
Co-authored-by: Hugo Lopes Tavares
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-03-22 14:01:15 -07:00
Christian Heimes e03db6d5be
bpo-45150: Fix testing under FIPS mode (GH-32046) 2022-03-22 16:40:43 +01:00
Serhiy Storchaka 492d4109f4
bpo-42885: Optimize search for regular expressions starting with "\A" or "^" (GH-32021)
Affected functions are re.search(), re.split(), re.findall(), re.finditer()
and re.sub().
2022-03-22 17:27:55 +02:00
Andrew Svetlov 32e77154dd
bpo-45997: Fix asyncio.Semaphore re-acquiring order (GH-31910)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2022-03-22 16:02:51 +02:00
Andrew Svetlov 673755bfba
bpo-47076: Make asyncio.Queue stable on slow test boxes (GH-32040) 2022-03-22 16:00:23 +02:00
Jeremy Kloth 88872a29f1
bpo-47084: Clear Unicode cached representations on finalization (GH-32032) 2022-03-22 13:53:51 +01:00
Pablo Galindo Salgado 7d810b6a4e
bpo-46838: Syntax error improvements for function definitions (GH-31590) 2022-03-22 11:38:41 +00:00
Christian Heimes deeaac49e2
bpo-40280: Skip socket, fork, subprocess tests on Emscripten (GH-31986)
- Add requires_fork and requires_subprocess to more tests
- Skip extension import tests if dlopen is not available
- Don't assume that _testcapi is a shared extension
- Skip a lot of socket tests that don't work on Emscripten
- Skip mmap tests, mmap emulation is incomplete
- venv does not work yet
- Cannot get libc from executable

The "entire" test suite is now passing on Emscripten with EMSDK from git head (91 suites are skipped).
2022-03-22 03:04:36 -07:00
Serhiy Storchaka a25a985535
bpo-28080: Add support for the fallback encoding in ZIP files (GH-32007)
* Add the metadata_encoding parameter in the zipfile.ZipFile constructor.
* Add the --metadata-encoding option in the zipfile CLI.

Co-authored-by: Stephen J. Turnbull <stephen@xemacs.org>
2022-03-22 11:52:55 +02:00
Serhiy Storchaka c6cd3cc93c
bpo-47081: Replace "qualifiers" with "quantifiers" in the re module documentation (GH-32028)
It is a more commonly used term.
2022-03-22 11:44:47 +02:00
Christian Heimes 4f97d64c83
bpo-45150: Add hashlib.file_digest() for efficient file hashing (GH-31930) 2022-03-22 02:37:00 -07:00
Jeremy Kloth 19058b9f62
bpo-44336: Prevent tests hanging on child process handles on Windows (GH-26578)
Replace the child process `typeperf.exe` with a daemon thread that reads the performance counters directly.  This prevents the issues that arise from inherited handles in grandchild processes (see issue37531 for discussion).

We only use the load tracker when running tests in multiprocess mode. This prevents inadvertent interactions with tests expecting a single threaded environment.  Displaying load is really only helpful for buildbots running in multiprocess mode anyway.
2022-03-22 00:06:55 +00:00
Tim Peters 5c3201e146
bpo-47080: Use atomic groups to simplify fnmatch (GH-32029)
Use re's new atomic groups to greatly simplify the construction of worst-case linear-time patterns.
2022-03-21 12:49:43 -05:00
Serhiy Storchaka 345b390ed6
bpo-433030: Add support of atomic grouping in regular expressions (GH-31982)
* Atomic grouping: (?>...).
* Possessive quantifiers: x++, x*+, x?+, x{m,n}+.
  Equivalent to (?>x+), (?>x*), (?>x?), (?>x{m,n}).

Co-authored-by: Jeffrey C. Jacobs <timehorse@users.sourceforge.net>
2022-03-21 18:28:22 +02:00
Brandt Bucher 2bde6827ea
bpo-46841: Quicken code in-place (GH-31888)
* Moves the bytecode to the end of the corresponding PyCodeObject, and quickens it in-place.

* Removes the almost-always-unused co_varnames, co_freevars, and co_cellvars member caches

* _PyOpcode_Deopt is a new mapping from all opcodes to their un-quickened forms.

* _PyOpcode_InlineCacheEntries is renamed to _PyOpcode_Caches

* _Py_IncrementCountAndMaybeQuicken is renamed to _PyCode_Warmup

* _Py_Quicken is renamed to _PyCode_Quicken

* _co_quickened is renamed to _co_code_adaptive (and is now a read-only memoryview).

* Do not emit unused nonzero opargs anymore in the compiler.
2022-03-21 11:11:17 +00:00
Gregory P. Smith 9d1c4d69db
bpo-38256: Fix binascii.crc32() when inputs are 4+GiB (GH-32000)
When compiled with `USE_ZLIB_CRC32` defined (`configure` sets this on POSIX systems), `binascii.crc32(...)` failed to compute the correct value when the input data was >= 4GiB. Because the zlib crc32 API is limited to a 32-bit length.

This lines it up with the `zlib.crc32(...)` implementation that doesn't have that flaw.

**Performance:** This also adopts the same GIL releasing for larger inputs logic that `zlib.crc32` has, and causes the Windows build to always use zlib's crc32 instead of our slow C code as zlib is a required build dependency on Windows.
2022-03-20 12:28:15 -07:00
Oleg Iarygin 3ae975f1ac
bpo-47015: Update test_os from asyncore to asyncio (GH-31876) 2022-03-20 16:39:12 +02:00
Arie Bovenberg 82e9b0bb0a
bpo-46382 dataclass(slots=True) now takes inherited slots into account (GH-31980)
Do not include any members in __slots__ that are already in a base class's __slots__.
2022-03-19 17:01:17 -04:00
Serhiy Storchaka 92a6abf72e
bpo-47066: Convert a warning about flags not at the start of the regular expression into error (GH-31994) 2022-03-19 16:10:44 +02:00
Serhiy Storchaka 4142961b9f
bpo-39394: Improve warning message in the re module (GH-31988)
A warning about inline flags not at the start of the regular
expression now contains the position of the flag.
2022-03-19 14:13:31 +02:00
Jelle Zijlstra 3a2b89580d
bpo-43224: Add TypeVarTuple.__name__ (GH-31954)
I noticed that TypeVar and ParamSpec put their name in a __name__
attribute, but TypeVarTuple doesn't. Let's be consistent.
2022-03-18 10:56:36 -07:00
Christian Heimes d190a9351b
bpo-47037: Don't test for strftime('%4Y') on Windows (GH-31945) 2022-03-18 11:27:20 +00:00
Miro Hrončok 48d9262699
bpo-45413: Define "posix_venv", "nt_venv" and "venv" sysconfig installation schemes (GH-31034)
Define *posix_venv* and *nt_venv* sysconfig installation schemes
to be used for bootstrapping new virtual environments.
Add *venv* sysconfig installation scheme to get the appropriate one of the above.
The schemes are identical to the pre-existing
*posix_prefix* and *nt* install schemes.
The venv module now uses the *venv* scheme to create new virtual environments
instead of hardcoding the paths depending only on the platform. Downstream
Python distributors customizing the *posix_prefix* or *nt* install
scheme in a way that is not compatible with the install scheme used in
virtual environments are encouraged not to customize the *venv* schemes.
When Python itself runs in a virtual environment,
sysconfig.get_default_scheme and
sysconfig.get_preferred_scheme with `key="prefix"` returns
*venv*.
2022-03-18 10:53:29 +01:00
Serhiy Storchaka cd44afc573
bpo-40296: Fix supporting generic aliases in pydoc (GH-30253) 2022-03-18 11:05:18 +02:00
Bader Zaidan a0db11b10f
bpo-46421: Fix unittest filename evaluation when called as a module (GH-30654) 2022-03-17 16:37:52 -07:00
Andrew Svetlov 903f0a02c1
bpo-34790: Remove passing coroutine objects to asyncio.wait() (GH-31964)
Co-authored-by: Yury Selivanov <yury@edgedb.com>
2022-03-17 22:51:40 +02:00
Serhiy Storchaka a5d246066b
bpo-47042: Fix testing the HTML output in test_pydoc (GH-31959)
Previously it tested that that the actual output contains every non-whitespace
character from the expected output (ignoring order and repetitions).

Now it will test that the actual output contains the same lines as the expected
output, in the same order, ignoring indentation and empty lines.
2022-03-17 18:32:53 +02:00
Mark Shannon 3011a097bd
Use low bit of LOAD_GLOBAL's oparg to indicate whether it should push an additional NULL. (GH-31933) 2022-03-17 16:14:57 +00:00
Christian Heimes ef1327e3b6
bpo-40280: Skip more tests on Emscripten (GH-31947)
- lchmod, lchown are not fully implemented
- skip umask tests
- cannot fstat unlinked or renamed files yet
- ignore musl libc issues that affect Emscripten
2022-03-17 12:09:57 +01:00
Serhiy Storchaka c2e3c06139
bpo-46996: Remove support of Tcl/Tk < 8.5.12 (GH-31839) 2022-03-17 13:05:52 +02:00
Inada Naoki 7aeb06f78e
Do not run test_gdb when gdb embeds Python 2. (GH-31956) 2022-03-17 18:00:56 +09:00
Serhiy Storchaka 15df8f8d89
bpo-46981: Remove typing._TypingEmpty (GH-31836)
* get_args(Tuple[()]) now returns () instead of ((),).
* Tuple[Unpack[Ts]][()] now returns the result equal to Tuple[()].
2022-03-17 09:52:24 +02:00
Erlend Egeberg Aasland 4674fd4e93
bpo-44859: Raise more accurate exceptions in `sqlite3` (GH-27695)
* Improve exception compliance with PEP 249
* Raise InterfaceError instead of ProgrammingError for SQLITE_MISUSE.
  If SQLITE_MISUSE is raised, it is a sqlite3 module bug. Users of the
  sqlite3 module are not responsible for using the SQLite C API correctly.
* Don't overwrite BufferError with ValueError when conversion to BLOB fails.
* Raise ProgrammingError instead of Warning if user tries to execute() more
  than one SQL statement.
* Raise ProgrammingError instead of ValueError if an SQL query contains null characters.
* Make sure `_pysqlite_set_result` raises an exception if it returns -1.
2022-03-16 22:58:25 -07:00
Jelle Zijlstra 96568e995d
bpo-46480: add typing.assert_type (GH-30843)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: David Foster <david@dafoster.net>
2022-03-16 20:02:26 -07:00
Andrew Svetlov a7c5414832
bpo-47038: Increase a test timeout for slow CI machines (GH-31951) 2022-03-17 02:54:36 +02:00
Andrew Svetlov 3dd9bfac04
bpo-47038: Rewrite missed asyncio.wait_for test to use IsolatedAnsyncioTestCase (GH-31946) 2022-03-17 01:20:29 +02:00
Andrew Svetlov dd0082c627
bpo-47038: Rewrite asyncio.wait_for test to use IsolatedAsyncioTestCase (GH-31942) 2022-03-16 21:49:18 +02:00
Andrew Svetlov e707ceb6e4
Rewrite asyncio.Queue tests with IsolatedAsyncioTestCace (#31935) 2022-03-16 16:59:12 +02:00
Christian Heimes a4674f0194
bpo-40280: Detect presence of time.tzset and thread_time clock (GH-31898) 2022-03-15 21:55:35 +01:00
Christian Heimes b43b9b49be
bpo-40280: Skip wakeup_fd pipe tests on Emscripten (GH-31909) 2022-03-15 17:14:15 +01:00
Maximilian Hils 70155412f1
bpo-43253: Don't call shutdown() for invalid socket handles (GH-31892) 2022-03-15 16:59:02 +02:00
Kumar Aditya 5dd7ec52b8
bpo-20392: Fix inconsistency with uppercase file extensions in mimetypes.guess_type (GH-30229) 2022-03-15 15:25:43 +02:00
Christian Heimes 2cf7f865f0
bpo-46587: Skip tests if strftime does not support glibc extension (GH-31873)
Co-authored-by: Victor Stinner <vstinner@python.org>
2022-03-15 10:41:04 +01:00
Christian Heimes f00ced8396
bpo-40280: select: Use NULL for empty fdset (GH-31865)
wasm32-emscripten does not support exceptfds and requires NULL. Python
now passes NULL instead of a fdset pointer when the input list is empty.
This works fine on all platforms and might even be a tiny bit faster.
2022-03-14 14:40:28 +01:00
Andrew Svetlov 9523c0d84f
bpo-46994: Accept explicit contextvars.Context in asyncio create_task() API (GH-31837) 2022-03-14 13:54:13 +02:00
Jason R. Coombs b1e2868607
bpo-47004: Sync with importlib_metadata 4.11.3. (#31854) 2022-03-13 15:53:29 -04:00
Alex Grönholm 9f04ee569c
bpo-46805: Add low level UDP socket functions to asyncio (GH-31455) 2022-03-13 18:42:29 +02:00
Andrew Svetlov 7e473e94a5
bpo-46995: Deprecate missing asyncio.Task.set_name() for third-party task implementations (GH-31838)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2022-03-13 18:34:46 +02:00
andrei kulakov d9db07a310
bpo-37529: Add test for guessing extensions (GH-28243)
Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
2022-03-12 19:26:17 +02:00
Matthew Rahtz af2277e461
bpo-43224: Implement PEP 646 changes to genericaliasobject.c (GH-31019)
Specifically, prepare for starring of tuples via a new genericalias iter type. GenericAlias also partially supports the iterator protocol after this change.

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
2022-03-12 20:20:12 +08:00
Jelle Zijlstra 75174371e6
bpo-46644: Fix test_typing test broken by GH-31151 due to a merge race (GH-31833) 2022-03-11 18:17:45 -08:00
Gregory Beauregard 870b22b9c4
bpo-46644: Remove callable() requirement from typing._type_check (GH-31151)
We also remove all the tests that check for integer literals.
2022-03-11 17:12:17 -08:00
Victor Stinner 882d8096c2
bpo-46906: Add PyFloat_Pack8() to the C API (GH-31657)
Add new functions to pack and unpack C double (serialize and
deserialize):

* PyFloat_Pack2(), PyFloat_Pack4(), PyFloat_Pack8()
* PyFloat_Unpack2(), PyFloat_Unpack4(), PyFloat_Unpack8()

Document these functions and add unit tests.

Rename private functions and move them from the internal C API
to the public C API:

* _PyFloat_Pack2() => PyFloat_Pack2()
* _PyFloat_Pack4() => PyFloat_Pack4()
* _PyFloat_Pack8() => PyFloat_Pack8()
* _PyFloat_Unpack2() => PyFloat_Unpack2()
* _PyFloat_Unpack4() => PyFloat_Unpack4()
* _PyFloat_Unpack8() => PyFloat_Unpack8()

Replace the "unsigned char*" type with "char*" which is more common
and easy to use.
2022-03-12 00:10:02 +01:00
Serhiy Storchaka 5b1b9eacb9
bpo-43224: Implement substitution of unpacked TypeVarTuple (GH-31800) 2022-03-11 21:43:58 +02:00
Serhiy Storchaka b6a5d8590c
bpo-44796: Unify TypeVar and ParamSpec substitution (GH-31143)
Add methods __typing_subst__() in TypeVar and ParamSpec.
Simplify code by using more object-oriented approach, especially
the C code for types.GenericAlias and the Python code for
collections.abc.Callable.
2022-03-11 10:47:26 +02:00
Alex Waygood 4052dd2296
bpo-46198: Fix `test_asyncio.test_sslproto` (GH-31801)
GH-30297 removed a duplicate `from test import support` statement from `test_asyncio.test_sslproto`. However, in between that PR being filed and it being merged, GH-31275 removed the _other_ `from test import support` statement. This means that `support` is now undefined in `test_asyncio.test_sslproto`, causing the CI to fail on all platforms for all PRS.
2022-03-10 13:36:22 -08:00
Nikita Sobolev 6c83c8e6b5
bpo-46198: rename duplicate tests and remove unused code (GH-30297) 2022-03-10 08:20:11 -08:00
Andrew Svetlov f537b2a4fb
bpo-46771: Implement asyncio context managers for handling timeouts (GH-31394)
Example:

async with asyncio.timeout(5):
    await some_task()

Will interrupt the await and raise TimeoutError if some_task() takes longer than 5 seconds.

Co-authored-by: Guido van Rossum <guido@python.org>
2022-03-10 08:05:20 -08:00
Matt Bogosian 32bf359792
bpo-46581: Propagate private vars via _GenericAlias.copy_with (GH-31061)
GH-26091 added the _typevar_types and _paramspec_tvars instance
variables to _GenericAlias. However, they were not propagated
consistently. This commit addresses the most prominent deficiency
identified in bpo-46581 (namely their absence from
_GenericAlias.copy_with), but there could be others.

Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2022-03-10 16:42:15 +02:00
Christian Heimes de554d6e02
bpo-40280: Skip more tests/features that don't apply to Emscripten (GH-31791)
- fd inheritance can't be modified because Emscripten doesn't support subprocesses anyway.
- setpriority always fails
- geteuid no longer causes problems with latest emsdk
- umask is a stub
- geteuid / getuid always return 0, but process cannot chown to random uid.
2022-03-10 13:43:40 +01:00
Erlend Egeberg Aasland e801e88744
bpo-45138: Revert GH-28240: Expand traced SQL statements (GH-31788)
This reverts commit d1777515f9.

Automerge-Triggered-By: GH:JelleZijlstra
2022-03-09 09:39:49 -08:00
Serhiy Storchaka 02fbaf4887
bpo-46245: Add optional parameter dir_fd in shutil.rmtree() (GH-30365) 2022-03-09 14:29:33 +02:00
Erlend Egeberg Aasland d1777515f9
bpo-45138: Expand traced SQL statements in `sqlite3` trace callback (GH-28240) 2022-03-08 18:46:40 -08:00
Christian Heimes 95ba723c54
bpo-40280: Skip dysfunctional pipe tests on Emscripten (GH-31770) 2022-03-08 23:15:26 +01:00
Christian Heimes 5081e78efd
bpo-40280: Block more non-working syscalls in Emscripten (GH-31757)
- getgroups always fails.
- geteuid and getegid always return 0 (root), which confuse tarfile and
  tests.
- hardlinks (link, linkat) always fails.
- non-encodable file names are not supported by NODERAWFS layer.
- mark more tests with dependency on subprocess and multiprocessing.
  Mocking does not work if the module fails to import.
2022-03-08 12:17:30 +01:00
Ma Lin 36dd7396fc
bpo-44439: _ZipWriteFile.write() handle buffer protocol correctly (GH-29468)
Co-authored-by: Marco Ribeiro <marcoffee@users.noreply.github.com>
2022-03-08 11:33:56 +02:00
Taneli Hukkinen 591f6754b5
bpo-40059: Add tomllib (PEP-680) (GH-31498)
This adds a new standard library module, `tomllib`, for parsing TOML.

The implementation is based on Tomli (https://github.com/hukkin/tomli).

## Steps taken (converting `tomli` to `tomllib`)

- Move everything in `tomli:src/tomli` to `Lib/tomllib`. Exclude `py.typed`.
- Remove `__version__ = ...` line from `Lib/tomllib/__init__.py`
- Move everything in `tomli:tests` to `Lib/test/test_tomllib`. Exclude the following test data dirs recursively:
  - `tomli:tests/data/invalid/_external/`
  - `tomli:tests/data/valid/_external/`
- Create `Lib/test/test_tomllib/__main__.py`:

  ```python
  import unittest

  from . import load_tests


  unittest.main()
  ```


- Add the following to `Lib/test/test_tomllib/__init__.py`:

  ```python
  import os
  from test.support import load_package_tests

  def load_tests(*args):
      return load_package_tests(os.path.dirname(__file__), *args)
  ```

  Also change `import tomli as tomllib` to `import tomllib`.

- In `cpython/Lib/tomllib/_parser.py` replace `__fp` with `fp` and `__s` with
  `s`. Add the `/` to `load` and `loads` function signatures.

- Run `make regen-stdlib-module-names`

- Create `Doc/library/tomllib.rst` and reference it in `Doc/library/fileformats.rst`
2022-03-08 09:26:13 +01:00
Matthew Rahtz 7a793a388b
bpo-43224: Implement PEP 646 changes to typing.py (GH-31021)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-03-07 20:02:55 -08:00
James Hilton-Balfe f391f9bf28
bpo-46170: Improve the error message when subclassing NewType (GH-30268)
Co-authored-by: Alex Waygood <alex.waygood@gmail.com>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
2022-03-07 19:50:46 -08:00
Brandt Bucher f193631387
bpo-46841: Use inline caching for calls (GH-31709) 2022-03-07 11:45:00 -08:00
Niklas Rosenstein b465b60604
bpo-41370: Evaluate strings as forward refs in PEP 585 generics (GH-30900)
This removes discrepancy between list["int"] and List["int"].

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2022-03-07 10:02:59 -08:00
Christian Heimes ca9689f8da
bpo-46933: Make pwd module optional (GH-31700)
Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
2022-03-07 13:36:47 +01:00
Pablo Galindo Salgado 3b3be05a16
bpo-46940: Don't override existing AttributeError suggestion information (GH-31710)
When an exception is created in a nested call to PyObject_GetAttr, any
external calls will override the context information of the
AttributeError that we have already placed in the most internal call.
This will cause the suggestions we create to nor work properly as the
attribute name and object that we will be using are the incorrect ones.

To avoid this, we need to check first if these attributes are already
set and bail out if that's the case.
2022-03-07 12:23:11 +00:00
Jacob Walls 496c428de3
bpo-43292: Fix file leak in `ET.iterparse()` when not exhausted (GH-31696)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2022-03-07 11:31:46 +02:00
Dennis Sweeney b748a36696
Use assertEqual, not assertEquals, in test_unicode (GH-31718)
Fixes a DeprecationWarning
2022-03-07 02:32:51 -05:00
MojoVampire eafec26ae5
bpo-14156: Make argparse.FileType work correctly for binary file modes when argument is '-' (GH-13165)
Also made modes containing 'a' or 'x' act the same as a mode containing 'w' when argument is '-'
(so 'a'/'x' return sys.stdout like 'w', and 'ab'/'xb' return sys.stdout.buffer like 'wb').
2022-03-06 13:49:42 +02:00
Ken Jin 602024e6e1
bpo-46921: Vectorcall support for `super()` (GH-31687)
Co-Authored-By: Dong-hee Na <donghee.na@python.org>
2022-03-06 14:21:28 +08:00
Serhiy Storchaka 6927632492
Remove trailing spaces (GH-31695) 2022-03-05 17:47:00 +02:00
Serhiy Storchaka ab9301a28f
bpo-46927: Include the type's name in the error message for subscripting non-generic types (GH-31694) 2022-03-05 15:59:24 +02:00
Mark Shannon 03c2a36b2b
bpo-46903: Handle str-subclasses in virtual instance dictionaries. (GH-31658) 2022-03-04 11:31:29 +00:00
Victor Stinner 6d0d7d2b8c
bpo-46913: test_hashlib skips _sha3 tests on UBSan (GH-31673)
If Python is built with UBSan, test_hashlib skips tests on the _sha3
extension which currently has undefined behaviors.

This change allows to run test_hashlib to check for new UBSan regression,
but the known _sha3 undefined behavior must be fixed.
2022-03-04 00:41:34 +01:00
Brandt Bucher 05a8bc1c94
bpo-46841: Use inline caching for attribute accesses (GH-31640) 2022-03-03 15:31:00 -08:00
Erlend Egeberg Aasland 88567a9970
bpo-46874: Speed up sqlite3 user-defined aggregate 'step' method (GH-31604) 2022-03-03 22:54:36 +09:00
Mark Shannon 751c9ed801
bpo-46891: Fix creating a new instance of a module subclass with slots (GH-31643) 2022-03-03 10:38:27 +00:00
Inada Naoki 3c4abfab0d
Fix EncodingWarning in libregrtest (GH-31654) 2022-03-03 16:19:56 +09:00
Inada Naoki 4f74052b45
bpo-40116: dict: Add regression test for iteration order. (GH-31550) 2022-03-03 13:06:29 +09:00
Gregory Beauregard 75d2d945b4
bpo-46643: Fix stringized P.args/P.kwargs with get_type_hints (GH-31238) 2022-03-02 17:14:52 -08:00
Nikita Sobolev 20a1c8ee4b
bpo-46195: Do not add `Optional` in `get_type_hints` (GH-30304)
Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-03-01 21:29:46 -08:00
Inada Naoki 9833bb91e4
bpo-46845: Reduce dict size when all keys are Unicode (GH-31564) 2022-03-02 08:09:28 +09:00
Mark Shannon 3b0f1c5a71
bpo-46841: Use inline cache for `BINARY_SUBSCR`. (GH-31618) 2022-03-01 16:00:34 +00:00
Victor Stinner 9204bb72a2
bpo-46633: Skip tests on ASAN and/or MSAN builds (GH-31632)
Skip tests on ASAN and/or MSAN builds:

* multiprocessing tests
* test___all__
* test_concurrent_futures
* test_decimal
* test_peg_generator
* test_tools

The ASAN job of GitHub Actions no longer excludes these tests.
2022-03-01 15:44:08 +01:00
Brandt Bucher 7820a5897e
bpo-46841: Use inline caching for `COMPARE_OP` (GH-31622) 2022-03-01 13:53:13 +00:00
Guido van Rossum 7d611b4cab
bpo-46771: Remove two controversial lines from Task.cancel() (GH-31623)
Also from the _asyncio C accelerator module,
and adjust one test that the change caused to fail.

For more discussion see the discussion starting here:
https://github.com/python/cpython/pull/31394#issuecomment-1053545331

(Basically, @asvetlov proposed to return False from cancel()
when there is already a pending cancellation, and I went along,
even though it wasn't necessary for the task group implementation,
and @agronholm has come up with a counterexample that fails
because of this change.  So now I'm changing it back to the old
semantics (but still bumping the counter) until we can have a
proper discussion about this.)
2022-02-28 15:15:56 -08:00
Mark Shannon 4558af5a8f
bpo-46841: Move the cache for `LOAD_GLOBAL` inline. (GH-31575) 2022-02-28 12:56:29 +00:00
Jannis Vajen 345572a1a0
bpo-46786: Make ElementTree write the HTML tags embed, source, track, wbr as empty tags (GH-31406)
See https://html.spec.whatwg.org/multipage/syntax.html#void-elements
for reference.
2022-02-27 15:25:54 +01:00
Victor Stinner 5a1c637ec6
bpo-46852: Restore test_getformat() test (GH-31601) 2022-02-27 01:12:33 +01:00
Victor Stinner ad56919c5e
bpo-46857: Fix refleak in OSError INIT_ALIAS() (GH-31594)
_Py_GetRefTotal() no longer decrements _PySet_Dummy refcount.
2022-02-27 00:28:24 +01:00
Tin Tvrtković edbee56d69
Taskgroup tweaks (GH-31559)
Now uses .cancel()/.uncancel(), for even fewer broken edge cases.
2022-02-26 08:18:48 -08:00
Charlie Zhao e466faa9df
bpo-45735: Promise the long-time truth that `args=list` works (GH-30982)
For threads, and for multiprocessing, it's always been the case that ``args=list`` works fine when passed to ``Process()`` or ``Thread()``, and such code is common in the wild. But, according to the docs, only a tuple can be used. This brings the docs into synch with reality.

Doc changes by Charlie Zhao.
Co-authored-by: Tim Peters <tim.peters@gmail.com>
2022-02-25 22:17:13 -06:00
Victor Stinner 5ab745fc51
bpo-46852: Remove the float.__set_format__() method (GH-31585)
Remove the undocumented private float.__set_format__() method,
previously known as float.__set_format__() in Python 3.7. Its
docstring said: "You probably don't want to use this function. It
exists mainly to be used in Python's test suite."
2022-02-26 00:53:27 +01:00
Victor Stinner ea9612a17b
bpo-46857: Fix test_embed.test_no_memleak() on Windows (GH-31589)
Tolerate a leak of 1 reference and 1 memory block until it's fixed.
2022-02-25 18:24:25 +01:00
Brandt Bucher 0f41aac109
bpo-46841: Use *inline* caching for `BINARY_OP` (GH-31543) 2022-02-25 12:11:34 +00:00
Serhiy Storchaka e2e72567a1
bpo-46756: Fix authorization check in urllib.request (GH-31353)
Fix a bug in urllib.request.HTTPPasswordMgr.find_user_password() and
urllib.request.HTTPPasswordMgrWithPriorAuth.is_authenticated() which
allowed to bypass authorization. For example, access to URI "example.org/foobar"
was allowed if the user was authorized for URI "example.org/foo".
2022-02-25 13:31:03 +02:00
Serhiy Storchaka 98c3bea4d1
bpo-46820: Refactor tests for ambiguous end of numerical literal (GH-31494) 2022-02-25 10:25:12 +02:00
Victor Stinner 9475dc0b8d
bpo-46623: Skip two test_zlib tests on s390x (GH-31096)
Skip test_pair() and test_speech128() of test_zlib on s390x since
they fail if zlib uses the s390x hardware accelerator.
2022-02-25 00:32:02 +01:00
Victor Stinner c9c178fdb1
bpo-1635741: test_embed cheks that Python does not leak (GH-31555) 2022-02-25 00:03:20 +01:00
Eric V. Smith 288af845a3
bpo-46757: Add a test to verify dataclass's __post_init__ isn't being automatically added. (GH-31523) 2022-02-23 00:14:35 -05:00
Andrew Svetlov cff4d5c5d2
Inherit asyncio proactor datagram transport from asyncio.DatagramTransport (#31512) 2022-02-23 01:39:24 +02:00
Victor Stinner b899126094
bpo-46659: Deprecate locale.getdefaultlocale() (GH-31206)
The locale.getdefaultlocale() function is deprecated and will be
removed in Python 3.13. Use locale.setlocale(),
locale.getpreferredencoding(False) and locale.getlocale() functions
instead.
2022-02-22 22:06:43 +01:00
Victor Stinner ccbe8045fa
bpo-46659: Fix the MBCS codec alias on Windows (GH-31218) 2022-02-22 22:04:07 +01:00
Thomas Grainger 8fb94893e4
bpo-46827: pass sock.type to getaddrinfo in sock_connect (GH-31499)
Co-authored-by: Thomas Grainger <tagrain@gmail.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
2022-02-22 22:35:57 +02:00
Irit Katriel 38b5acf867
bpo-46729: add number of sub-exceptions in str() of BaseExceptionGroup (GH-31294) 2022-02-22 18:28:58 +00:00
Pablo Galindo Salgado 7fb94fd7a8
bpo-46725: Document starred expressions in for statements (GH-31481)
Automerge-Triggered-By: GH:pablogsal
2022-02-22 09:26:46 -08:00
Steve Dower 77f31a91d5
bpo-46822: Increase timeout for test_create_server_ssl_over_ssl to match underlying timeouts (GH-31502) 2022-02-22 16:25:05 +00:00
Serhiy Storchaka 090e5c4b94
bpo-46820: Fix a SyntaxError in a numeric literal followed by "not in" (GH-31479)
Fix parsing a numeric literal immediately (without spaces) followed by
"not in" keywords, like in "1not in x". Now the parser only emits
a warning, not a syntax error.
2022-02-22 09:51:51 +02:00
Andrew Svetlov 4140bcb1cd
bpo-45390: Propagate CancelledError's message from cancelled task to its awaiter (GH-31383)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2022-02-21 22:59:04 +02:00
Mark Shannon 59585d6b2e
bpo-46329: Streamline calling sequence a bit. (GH-31465)
* Move handling of bound-methods to PRECALL.

* Remove call_shape.postcall_shrink

* Remove call_shape.callable

* Remove call_shape.callable. Change CALL oparg to match PRECALL oparg.

* Move KW_NAMES before PRECALL.

* Update opcode docs in dis.rst
2022-02-21 18:26:47 +00:00
Sebastian Pipping 2cae93832f
bpo-46811: Make test suite support Expat >=2.4.5 (GH-31453)
Curly brackets were never allowed in namespace URIs
according to RFC 3986, and so-called namespace-validating
XML parsers have the right to reject them a invalid URIs.

libexpat >=2.4.5 has become strcter in that regard due to
related security issues; with ET.XML instantiating a
namespace-aware parser under the hood, this test has no
future in CPython.

References:
- https://datatracker.ietf.org/doc/html/rfc3968
- https://www.w3.org/TR/xml-names/

Also, test_minidom.py: Support Expat >=2.4.5
2022-02-21 15:48:32 +01:00
Serhiy Storchaka 195a46d6ff
bpo-46796: Simplify handling of removed parameter "loop" in asyncio (GH-31431) 2022-02-21 13:25:52 +02:00
Nikita Sobolev 4ab8167b9c
bpo-46672: fix `NameError` in `asyncio.gather` if type check fails (GH-31187)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2022-02-20 12:24:00 +02:00
Jelle Zijlstra 0a8a8e7454
bpo-46066: Check DeprecationWarning in test_typing (GH-31428) 2022-02-19 17:44:51 -08:00
Dennis Sweeney 7a4791e036
Use raw string to avoid deprecation warning (GH-31427) 2022-02-19 00:57:36 -05:00
Nikita Sobolev 32e3e0bea6
bpo-46685: improve test coverage of `Self` and `Never` in `typing` (GH-31222) 2022-02-18 17:56:30 -08:00
Nikita Sobolev 25c0b9d243
bpo-46603: improve coverage of `typing._strip_annotations` (GH-31063) 2022-02-18 17:54:01 -08:00
Nikita Sobolev 395029b0bd
bpo-46571: improve `typing.no_type_check` to skip foreign objects (GH-31042)
There are several changes:
1. We now don't explicitly check for any base / sub types, because new name check covers it
2. I've also checked that `no_type_check` do not modify foreign functions. It was the same as with `type`s
3. I've also covered `except TypeError` in `no_type_check` with a simple test case, it was not covered at all
4. I also felt like adding `lambda` test is a good idea: because `lambda` is a bit of both in class bodies: a function and an assignment

<!-- issue-number: [bpo-46571](https://bugs.python.org/issue46571) -->
https://bugs.python.org/issue46571
<!-- /issue-number -->
2022-02-18 17:53:29 -08:00
Guido van Rossum 80a9ba537f
Reduce flakiness of taskgroups test 13 (GH-31411) 2022-02-18 09:28:56 -08:00
Mark Shannon cf345e945f
bpo-46329: Change calling sequence (again) (GH-31373)
* Change calling sequence: Add PUSH_NULL. Merge PRECALL_FUNCTION and PRECALL_METHOD into PRECALL.
2022-02-18 17:19:08 +00:00
Saul Shanabrook c3ce7781e3
bpo-46724: Fix dis support for overflow args (GH-31285) 2022-02-18 09:56:23 +00:00
Guido van Rossum d85121660e
bpo-46752: Slight improvements to TaskGroup API (GH-31398)
* Remove task group names (for now)

We're not sure that they are needed, and once in the code
we would never be able to get rid of them.

Yury wrote:

> Ideally, there should be a way for someone to build a "trace"
> of taskgroups/task leading to the current running task.
> We could do that using contextvars, but I'm not sure we should
> do that in 3.11.

* Pass optional name on to task in create_task()

* Remove a bunch of unused stuff
2022-02-17 21:30:44 -08:00
Patrick Reader 5f1c205dce
Fix mistake in barry_as_FLUFL test (GH-31392)
Use assertEqual(), not assertTrue(lineno, 2)
2022-02-17 20:45:35 -05:00
Brian Faherty fc115c9bde
bpo-41086: Add exception for uninstantiated interpolation (configparser) (GH-21062)
* Add exception for uninstantiated interpolation (configparser)

The current feedback when users try to pass an uninstantiated
interpolation into a ConfigParser is an error message that does not help
users solve the problem. This current error of `TypeError: before_set()
missing 1 required positional argument: 'value'` does not display until
the parser is used, which usually results in the assumption that
instantiation of the parser was done correctly. The new exception of
InterpolationTypeError, will be raised on the line where the
ConfigParser is instantiated. This will result in users see the line
that has the error in their backtrace for faster debugging.

There have been a number of bugs created in the issue tracker, which
could have been addressed by:
https://bugs.python.org/issue26831 and https://bugs.python.org/issue26469

* 📜🤖 Added by blurb_it.

* Replace custom Error with TypeError

Per feedback from @iritkatriel, the custom InterpolationTypeError has
been dropped in favour of a TypeError with a custom message, and the
unittests have been expanded.

* More verbose message

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2022-02-17 13:17:43 +01:00
aha79 6e7b813195
bpo-46333: Honor `module` parameter in ForwardRef (GH-30536)
The `module` parameter carries semantic information about the forward ref.
Forward refs are different if they refer to different module even if they
have the same name. This affects the `__eq__`, `__repr__` and `__hash__` methods.

Co-authored-by: Andreas Hangauer <andreas.hangauer@siemens.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
2022-02-16 19:28:18 -08:00
97littleleaf11 de6043e596
bpo-46066: Deprecate kwargs syntax for TypedDict definitions (GH-31126)
Closes python/typing#981

https://bugs.python.org/issue46066
2022-02-16 19:26:07 -08:00
Hakan Çelik 562c13f573
bpo-29418: Implement inspect.ismethodwrapper and fix inspect.isroutine for cases where methodwrapper is given (GH-19261)
Automerge-Triggered-By: GH:isidentical
2022-02-16 04:46:20 -08:00
Mark Shannon 3954fcb83f
Remove offsets from expected output in test.test_dis (GH-31369) 2022-02-16 12:19:09 +00:00
Eric V. Smith ffd9f8ff84
bpo-46762: Fix an assert failure in f-strings where > or < is the last character if the f-string is missing a trailing right brace. (#31365) 2022-02-16 05:54:09 -05:00
Alex-Blade 0cb765b2ce
bpo-46730: Add more info to @property AttributeError messages (GH-31311)
On `obj.read_only_property = x`, raise `AttributeError: property 'read_only_property' of 'A' object has no setter`.
2022-02-16 02:07:34 -05:00
Guido van Rossum 602630ac18
bpo-46752: Add TaskGroup; add Task..cancelled(),.uncancel() (GH-31270)
asyncio/taskgroups.py is an adaptation of taskgroup.py from EdgeDb, with the following key changes:

- Allow creating new tasks as long as the last task hasn't finished
- Raise [Base]ExceptionGroup (directly) rather than TaskGroupError deriving from MultiError
- Instead of monkey-patching the parent task's cancel() method,
  add a new public API to Task

The Task class has a new internal flag, `_cancel_requested`, which is set when `.cancel()` is called successfully. The `.cancelling()` method returns the value of this flag. Further `.cancel()` calls while this flag is set return False. To reset this flag, call `.uncancel()`.

Thus, a Task that catches and ignores `CancelledError` should call `.uncancel()` if it wants to be cancellable again; until it does so, it is deemed to be busy with uninterruptible cleanup.

This new Task API helps solve the problem where TaskGroup needs to distinguish between whether the parent task being cancelled "from the outside" vs. "from inside".

Co-authored-by: Yury Selivanov <yury@edgedb.com>
Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
2022-02-15 15:42:04 -08:00
Zackery Spytz 08ec80113b
bpo-46737: Add default arguments to random.gauss and normalvariate (GH-31360) 2022-02-15 17:12:15 -06:00
Kumar Aditya 13c10bfb77
bpo-44011: New asyncio ssl implementation (#31275)
* bpo-44011: New asyncio ssl implementation

Co-Authored-By: Andrew Svetlov <andrew.svetlov@gmail.com>

* fix warning

* fix typo

Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
2022-02-15 15:04:00 +02:00
Mark Shannon 3be1a443ca
bpo-46724: Use `JUMP_ABSOLUTE` for all backward jumps. (GH-31326)
* Make sure all backward jumps use JUMP_ABSOLUTE.

* Add news.

* Fix up news item.

* Make test use consistent style.
2022-02-15 09:35:16 +00:00
aha79 b70690bb37
bpo-46333: include `module` in `ForwardRef.__repr__` (#31283)
The module parameter carries semantic information about the forward ref.
Show to the user that forward refs with same argument but different
module are different.

Co-authored-by: Andreas Hangauer <andreas.hangauer@siemens.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2022-02-12 07:35:57 -08:00
Jacob Walls 168fd6453b
bpo-45948: Remove constructor discrepancy in C version of ElementTree.XMLParser (GH-31152)
Both implementations accept target=None now.
2022-02-12 10:27:02 +02:00
Dennis Sweeney 4a66615ba7
bpo-46615: Don't crash when set operations mutate the sets (GH-31120)
Ensure strong references are acquired whenever using `set_next()`. Added randomized test cases for `__eq__` methods that sometimes mutate sets when called.
2022-02-11 11:25:08 -05:00
Petr Viktorin 204946986f
bpo-46613: Add PyType_GetModuleByDef to the public API (GH-31081)
* Make PyType_GetModuleByDef public (remove underscore)

Co-authored-by: Victor Stinner <vstinner@python.org>
2022-02-11 17:22:11 +01:00
Arie Bovenberg dd76b3f7d3
bpo-46246: add missing __slots__ to importlib.metadata.DeprecatedList (GH-30452)
Confirmed with @jaraco that this indeed needs a fix.

A question that came up while I was digging into the code: I think `SelectableGroups` could similarly use `__slots__ = ()`, since its purpose seems only for convenience around `dict`, not to have attributes of its own.

Automerge-Triggered-By: GH:jaraco
2022-02-10 16:56:21 -08:00
Pablo Galindo Salgado 390459de6d
Allow the parser to avoid nested processing of invalid rules (GH-31252) 2022-02-10 13:12:14 +00:00
Andrew Svetlov 012e77eb5c
Fix warning: asyncio.events._event_loop_policy was modified by test_asyncio (GH-31253) 2022-02-10 14:57:20 +02:00
Pablo Galindo Salgado b71dc71905
bpo-46707: Avoid potential exponential backtracking in some syntax errors (GH-31241) 2022-02-10 03:37:17 +00:00
Brandt Bucher 78ae4cc6dc
bpo-46528: Attempt SWAPs at compile-time (GH-30970) 2022-02-09 15:15:36 -08:00
Joshua Root bf2d44ffb0
bpo-45863: tarfile: don't zero out header fields unnecessarily (GH-29693)
Numeric fields of type float, notably mtime, can't be represented
exactly in the ustar header, so the pax header is used. But it is
helpful to set them to the nearest int (i.e. second rather than
nanosecond precision mtimes) in the ustar header as well, for the
benefit of unarchivers that don't understand the pax header.

Add test for tarfile.TarInfo.create_pax_header to confirm correct
behaviour.
2022-02-09 18:06:19 +01:00
Andrzej Mateja 128ab092ca
bpo-44289: Keep argument file object's current position in tarfile.is_tarfile (GH-26488) 2022-02-09 08:19:16 -08:00
Nikita Sobolev d2d1d49eac
bpo-46685: cover `TypeError` of `ForwardRef(1)` in `test_typing` (GH-31223) 2022-02-09 23:23:07 +09:00
Barney Gale 06e1701ad3
bpo-46556: emit `DeprecationWarning` from `pathlib.Path.__enter__()` (GH-30971)
In Python 3.9, Path.__exit__() was made a no-op and has never been documented.

Co-authored-by: Brett Cannon <brett@python.org>
2022-02-08 13:01:37 -08:00
Jelle Zijlstra 243436f377
bpo-46475: Add typing.Never and typing.assert_never (GH-30842) 2022-02-08 10:50:26 -08:00
Mark Shannon 25db2b361b
bpo-46675: Allow object value arrays and split key dictionaries larger than 16 (GH-31191) 2022-02-08 11:50:38 +00:00
Gregory Beauregard c8b62bbe46
bpo-46676: Make ParamSpec args and kwargs equal to themselves (GH-31203) 2022-02-08 09:46:58 +02:00
Jason Wilkes da576e0829
bpo-46678: Fix Invalid cross device link in Lib/test/support/import_helper.py (GH-31204)
In [Lib/test/support/import_helper.py](https://github.com/python/cpython/blob/master/Lib/test/support/import_helper.py), the function `make_legacy_pyc` makes a call to `os.rename` which can fail when the source and target live on different devices. This happens (for example) when `PYTHONPYCACHEPREFIX` is set to a directory anywhere on disk, while a ramdisk is mounted on `/tmp` (the latter of which is the default on various Linux distros). Replacing `os.rename` with `shutil.move` fixes this.

Automerge-Triggered-By: GH:brettcannon
2022-02-07 17:09:07 -08:00
Victor Stinner 7a0486eaa9
bpo-46659: calendar uses locale.getlocale() (GH-31166)
The calendar.LocaleTextCalendar and calendar.LocaleHTMLCalendar
classes module now use locale.getlocale(), instead of using
locale.getdefaultlocale(), if no locale is specified.
2022-02-08 00:24:09 +01:00
James Hilton-Balfe 7ba1cc8049
bpo-46534: Implement PEP 673 Self in typing.py (GH-30924)
Co-authored-by: Pradeep Kumar Srinivasan <gohanpra@gmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-02-07 12:47:48 -08:00
Nikita Sobolev 8e98175a03
bpo-46648: Rewrite test_urllib2.test_issue16464() with a local HTTP server (GH-31186)
Re-enable test_issue16464() of test_urllib2, move it to urllib2_localnet
and use the local HTTP server rather than an external HTTP server.
2022-02-07 13:48:43 +01:00
Nikita Sobolev 067c03bf40
bpo-46611: add coverage to instance and class checks in `typing.py` (GH-31078) 2022-02-06 17:35:48 -08:00
Gregory Beauregard 77b025be4a
bpo-46655: allow stringized TypeAlias with get_type_hints (GH-31156) 2022-02-06 15:16:22 -08:00
Victor Stinner 06b8f1615b
bpo-46659: test.support avoids locale.getdefaultlocale() (GH-31167)
skip_if_buggy_ucrt_strfptime() of test.support now uses
locale.getpreferredencoding(False) instead of
locale.getdefaultlocale() to get the Windows code page.
2022-02-06 21:51:56 +01:00
Victor Stinner 04dd60e50c
bpo-46659: Update the test on the mbcs codec alias (GH-31168)
encodings registers the _alias_mbcs() codec search function before
the search_function() codec search function. Previously, the
_alias_mbcs() was never used.

Fix the test_codecs.test_mbcs_alias() test: use the current ANSI code
page, not a fake ANSI code page number.

Remove the test_site.test_aliasing_mbcs() test: the alias is now
implemented in the encodings module, no longer in the site module.
2022-02-06 21:50:09 +01:00
Serhiy Storchaka 3da5526136
Add more tests for variable substitution in generics (GH-31170) 2022-02-06 21:52:39 +02:00
Victor Stinner 1578de2fcd
bpo-46648: Skip test_urllib2.test_issue16464() (GH-31161)
POST requests to http://www.example.com/ fail randomly.
2022-02-06 15:08:54 +01:00
Christian Heimes 96b344c2f1
bpo-40280: Address more test failures on Emscripten (GH-31050)
Co-authored-by: Brett Cannon <brett@python.org>
2022-02-05 20:52:01 +01:00
Manish Kumar ⛄ ba650af7d6
Optimize images by IMGbot (GH-21348)
Co-authored-by: ImgBotApp <ImgBotHelp@gmail.com>
2022-02-04 15:49:43 +09:00
Miro Hrončok 6baa98e538
bpo-46624: Defer to 3.12: "Remove deprecated support for non-integer values" (GH-31098) 2022-02-03 07:48:13 -06:00
Zackery Spytz b4bd1e1422
bpo-44977: Deprecate delegation of int to __trunc__ (GH-31031)
Calling int(a) when type(a) implements __trunc__ but not __int__
or __index__ now raises a DeprecationWarning.
2022-02-03 11:43:25 +02:00
Nikita Sobolev 7ffe7ba30f
bpo-46483: Remove `__class_getitem__` from `pathlib.PurePath` (GH-30848)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2022-02-03 11:25:10 +02:00
Nikita Sobolev 0cbdd21311
bpo-46565: `del` loop vars that are leaking into module namespaces (GH-30993) 2022-02-03 11:20:08 +02:00
Gregory P. Smith 8726067ace
bpo-45629: Improve test.support.skip_if_buildbot (GH-31094)
It was added as part of #29222 to avoid running freeze tool tests on the
buildbots but the logic was wrong so it did not skip tests on typical posix
setup buildbots where the worker is launched from cron via an @reboot task and
thus have no USER environment variable.  This uses the canonical
`getpass.getuser()` API rather than rolling its own attempt.
2022-02-02 21:36:16 -08:00
Steve Dower 89a0a90c2e
bpo-46616: Ensures test_importlib.test_windows cleans up registry keys after completion (GH-31086) 2022-02-02 19:54:27 +00:00
Hugo van Kemenade e8659b47de
bpo-45173: Keep configparser deprecations until Python 3.12 (GH-30952)
* Revert "bpo-45173 Remove configparser deprecations"

This reverts commit df2284bc41.

* bpo-45173: Note these configparser deprecations will be removed in 3.12
2022-02-02 08:59:39 -08:00
Petr Viktorin 0ef0853012
bpo-46433: _PyType_GetModuleByDef: handle static types in MRO (GH-30696)
Automerge-Triggered-By: GH:encukou
2022-02-02 07:57:51 -08:00
Christian Heimes f66c857572
bpo-45459: Add Py_buffer to limited API (GH-29991)
- [x] ``Py_buffer`` struct
- [x] ``PyBuffer_*()`` API functions
- [x] ``PyBUF_*`` constants
- [x] ``Py_bf_getbuffer`` and ``Py_bf_releasebuffer`` type slots
- [x] ``PyMemoryView_FromBuffer()`` API
- [x] tests for limited API
- [x] ``make regen-limited-abi``
- [x] documentation update
- [ ] export ``PyPickleBuffer*()`` API ???
2022-02-02 07:03:10 -08:00
Barney Gale 08f8301b21
bpo-43012: remove `pathlib._Accessor` (GH-25701)
Per Pitrou:

> The original intent for the “accessor” thing was to have a variant that did all accesses under a filesystem tree in a race condition-free way using openat and friends. It turned out to be much too hairy to actually implement, so was entirely abandoned, but the accessor abstraction was left there.

https://discuss.python.org/t/make-pathlib-extensible/3428/2

Accessors are:

- Lacking any internal purpose - '_NormalAccessor' is the only implementation
- Lacking any firm conceptual difference to `Path` objects themselves (inc. subclasses)
- Non-public, i.e. underscore prefixed - '_Accessor' and '_NormalAccessor' 
- Unofficially used to implement customized `Path` objects, but once once [bpo-24132]() is addressed there will be a supported route for that.

This patch preserves all existing behaviour.
2022-02-02 04:38:25 -08:00
Jelle Zijlstra abcc3d75f6
bpo-46414: Add typing.reveal_type (#30646)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2022-02-01 18:48:55 -08:00
Victor Stinner 0611eafc70
bpo-44359: Fix test_ftplib unhandled thread exceptions (GH-31069)
test_ftplib now silently ignores socket errors to prevent logging
unhandled threading exceptions.
2022-02-02 02:47:40 +01:00
Brandt Bucher a0e55a571c
bpo-46528: Simplify BUILD_TUPLE/UNPACK_SEQUENCE folding (GH-31039) 2022-02-01 13:41:32 -08:00
Victor Stinner bebaa95fd0
bpo-46600: Fix test_gdb.test_pycfunction() for clang -Og (GH-31058)
Fix test_gdb.test_pycfunction() for Python built with clang -Og.
Tolerate inlined functions in the gdb traceback.

When _testcapimodule.c is built by clang -Og, _null_to_none() is
inlined in meth_varargs() and so gdb returns _null_to_none() as
the frame #1. If it's not inlined, meth_varargs() is the frame #1.
2022-02-01 18:12:26 +01:00
Irit Katriel 108e66b6d2
bpo-44031: fix test_tabnanny failure in non-ascii CWD (GH-31014) 2022-02-01 10:31:57 +00:00
Nikita Sobolev 4c0612ad00
bpo-46482: add a test for `typing.Annotation.__new__` (GH-30821) 2022-02-01 17:58:41 +08:00
Brett Cannon 8b1b27f193
Fix a `UnboundLocalError` bug in `test_sysconfig` (GH-31000)
Accidentally introduced by GH-24502
2022-01-29 00:43:36 +00:00
Barney Gale 18cb2ef46c
bpo-29688: document and test `pathlib.Path.absolute()` (GH-26153)
Co-authored-by: Brett Cannon <brett@python.org>
Co-authored-by: Brian Helba <brian.helba@kitware.com>
2022-01-28 15:40:55 -08:00
Natanael Copa 1f036ede59
bpo-43112: detect musl as a separate SOABI (GH-24502)
musl libc and gnu libc are not ABI compatible so we need set different
SOABI for musl and not simply assume that all linux is linux-gnu.

Replace linux-gnu with the detected os for the build from config.guess
for linux-musl*.
2022-01-28 15:02:54 -08:00
Kumar Aditya 24cc6411ad
bpo-26552: Fixed case where failing `asyncio.ensure_future` did not close the coroutine (#30288) 2022-01-28 14:24:35 -08:00
Irit Katriel 36f538c809
bpo-46458: Add tests for context of exception in finally block (GH-30986) 2022-01-28 20:41:58 +00:00
Gregory Beauregard 5445e173e7
bpo-46553: allow bare typing.ClassVar annotations (#30983)
These are used in the wild and covered by dataclasses unit tests.
Several static type checkers support this pattern.
2022-01-28 08:58:39 -08:00
Mark Shannon 89fd7c3452
bpo-46329: Split calls into precall and call instructions. (GH-30855)
* Add PRECALL_FUNCTION opcode.

* Move 'call shape' varaibles into struct.

* Replace CALL_NO_KW and CALL_KW with KW_NAMES and CALL instructions.

* Specialize for builtin methods taking using the METH_FASTCALL | METH_KEYWORDS protocol.

* Allow kwnames for specialized calls to builtin types.

* Specialize calls to tuple(arg) and str(arg).
2022-01-28 12:42:30 +00:00
Nikita Sobolev c27a33132b
bpo-46530: add `"thread_time"` to `test_time.test_get_clock_info` (#30913) 2022-01-27 21:43:00 -08:00
Victor Stinner e7a6285f1b
bpo-46542: test_json uses support.infinite_recursion() (GH-30972)
Fix test_json tests checking for RecursionError: modify these tests
to use support.infinite_recursion().
2022-01-28 01:35:13 +01:00
Russel Webber 183f8d57fa
bpo-46098: Add test for multiline syntax error traceback (GH-30695) 2022-01-27 14:13:12 +00:00
Karolina Surma aa78287bc6
bpo-44734: Fix floating point precision in test_turtle (GH-30910) 2022-01-27 14:57:55 +01:00
Irit Katriel 3d2ce34716
bpo-46458: emit code for else of a try block immediately after the try body (GH-30751) 2022-01-27 13:40:44 +00:00
Serhiy Storchaka ecfacc362d
bpo-44791: Fix substitution of ParamSpec in Concatenate with different parameter expressions (GH-27518)
* Substitution with a list of types returns now a tuple of types.
* Substitution with Concatenate returns now a Concatenate with
  concatenated lists of arguments.
* Substitution with Ellipsis is not supported.
2022-01-27 14:34:55 +02:00
Kinshuk Dua 08c0ed2d9c
bpo-23556: [doc] Fix inaccuracy in documentation for raise without args. Improve tests for context in nested except handlers. (GH-29236) 2022-01-27 10:24:48 +00:00
Gregory Beauregard ced50051bb
bpo-46539: Pass status of special typeforms to forward references (GH-30926)
Previously this didn't matter because there weren't any valid code paths
that could trigger a type check with a special form, but after the bug
fix for `Annotated` wrapping special forms it's now possible to annotate
something like `Annotated['ClassVar[int]', (3, 4)]`. This change would
also be needed for proposed future changes, such as allowing `ClassVar`
and `Final` to nest each other in dataclasses.
2022-01-26 19:11:51 -08:00
Brandt Bucher 8548366864
bpo-46528: Simplify the VM's stack manipulations (GH-30902) 2022-01-26 12:47:45 -08:00
Erlend Egeberg Aasland 3eb3b4f270
bpo-43853: Expand test suite for SQLite UDF's (GH-27642) 2022-01-26 08:26:16 -08:00
Jelle Zijlstra ac0c6e128c
bpo-46527: allow calling enumerate(iterable=...) again (GH-30904) 2022-01-27 00:46:48 +09:00
Nikita Sobolev d0c690b5f8
bpo-46529: increase coverage of `typing.Union.__repr__` method (GH-30911) 2022-01-26 18:13:02 +08:00
Nikita Sobolev 84f093918a
bpo-45578: add a test case for `dis.findlabels` (GH-30058) 2022-01-26 19:05:35 +09:00
Irit Katriel 072f4a473e
bpo-46431: use raw string for regex in test (GH-30901) 2022-01-25 23:52:43 +00:00
Pablo Galindo Salgado a27505345e
Add skips to crashing tests under sanitizers instead of manually skipping them (GH-30897) 2022-01-25 23:14:03 +00:00
Pablo Galindo Salgado a0efc0c196
bpo-46091: Correctly calculate indentation levels for whitespace lines with continuation characters (GH-30130) 2022-01-25 22:12:14 +00:00
Pablo Galindo Salgado b1cb843050
Refactor sanitiser skip tests into test.support (GH-30889)
* Refactor sanitizer skip tests into test.support

* fixup! Refactor sanitizer skip tests into test.support

* fixup! fixup! Refactor sanitizer skip tests into test.support
2022-01-25 22:01:10 +00:00
Victor Stinner cef0a5458f
bpo-45382: test.pythoninfo: set wmic.exe encoding to OEM (GH-30890) 2022-01-25 20:02:23 +01:00
Irit Katriel ec7c17ea23
bpo-46510: Add missing test for types.TracebackType/FrameType. Calculate them directly from the caught exception. (GH-30880) 2022-01-25 18:00:57 +00:00
Raymond Hettinger ee60550e9b
Move doctests to the main docs. Eliminate duplication. Improve coverage. (GH-30869) 2022-01-25 06:56:53 -06:00
Christian Heimes 8464fbc42e
bpo-40280: Skip subprocess-based tests on wasm32-emscripten (GH-30615) 2022-01-25 08:09:06 +01:00
Gregory Beauregard e1abffca45
bpo-46491: Allow Annotated on outside of Final/ClassVar (GH-30864)
We treat Annotated type arg as class-level annotation. This exempts it from checks against Final and ClassVar in order to allow using them in any nesting order.

Automerge-Triggered-By: GH:gvanrossum
2022-01-24 22:37:15 -08:00
Eric V. Smith 0daf72194b
bpo-46503: Prevent an assert from firing when parsing some invalid \N sequences in f-strings. (GH-30865)
* bpo-46503: Prevent an assert from firing.  Also fix one nearby tiny PEP-7 nit.

* Added blurb.
2022-01-24 21:53:27 -05:00
Irit Katriel 573b545157
bpo-46431: improve error message on invalid calls to BaseExceptionGroup.__new__ (GH-30854) 2022-01-24 21:47:40 +00:00
Kumar Aditya 1c705fda8f
fixed flaky test (GH-30845) 2022-01-24 21:04:47 +00:00
Mario Corchero d7c6863979
bpo-41906: Accept built filters in dictConfig (GH-30756)
When configuring the logging stack, accept already built filters (or
just callables) in the filters array of loggers and handlers.
This facilitates passing quick callables as filters.

Automerge-Triggered-By: GH:vsajip
2022-01-24 04:39:50 -08:00
Nikita Sobolev 58f3d98098
bpo-46422: use `dis.Positions` in `dis.Instruction` (GH-30716)
Co-authored-by: Batuhan Taskaya <isidentical@gmail.com>
2022-01-24 14:09:20 +03:00
Raymond Hettinger 270a09184d
Improve grouper() recipe to demonstrate all forms of zip() (GH-30837) 2022-01-23 14:31:10 -06:00
Weipeng Hong 691506f4e9
bpo-46103: Fix inspect.getmembers to only get __bases__ from class (GH-30147) 2022-01-23 09:40:38 -08:00
Dong-hee Na 76dc047a0e
bpo-46481: Implement vectorcall for weakref.ref.__call__ method. (GH-30820) 2022-01-24 00:39:45 +09:00
Nikita Sobolev 1f715d5bd3
bpo-46483: change `PurePath.__class_getitem__` to return `GenericAlias` (GH-30822) 2022-01-23 17:48:43 +03:00
Victor Stinner b0898f4aa9
bpo-45382: test.pythoninfo logs more Windows versions (GH-30817)
Add the following info to test.pythoninfo:

* windows.ver: output of the shell "ver" command
* windows.version and windows.version_caption: output of the
  "wmic os get Caption,Version /value" command.
2022-01-23 04:03:43 +01:00
Jason R. Coombs 443dec6c9a
bpo-46474: Apply changes from importlib_metadata 4.10.0 (GH-30802) 2022-01-22 21:39:00 -05:00
Jason R. Coombs d888ff5381
bpo-46425: Partially revert "bpo-46425: fix direct invocation of `test_importlib` (GH-30682)" (GH-30799)
This reverts commit 57316c52ba for files pertaining to importlib.metadata and importlib.resources.
2022-01-22 21:38:26 -05:00
Ethan Furman 353e3b2820
bpo-46477: [Enum] ensure Flag subclasses have correct bitwise methods (GH-30816) 2022-01-22 18:27:52 -08:00
Victor Stinner 12f4ac3bc8
bpo-46417: Clear symtable identifiers at exit (GH-30809)
Add _PySymtable_Fini() function, called by finalize_interp_clear().

Update test_cmd_line.test_showrefcount() to tolerate negative
reference count.
2022-01-23 00:06:56 +01:00
Nikita Sobolev 1ded8ed8e8
bpo-41682: Skip unstable test_asyncio sendfile test on Windows (GH-30801) 2022-01-22 23:52:26 +01:00
Victor Stinner f1bcdeaca6
bpo-46417: Factorize _PyExc_InitTypes() code (GH-30804)
Add 'static_exceptions' list to factorize code between
_PyExc_InitTypes() and _PyBuiltins_AddExceptions().

_PyExc_InitTypes() does nothing if it's not the main interpreter.

Sort exceptions in Lib/test/exception_hierarchy.txt.
2022-01-22 21:48:56 +01:00
Jason R. Coombs a941e5927f
bpo-46126: Disable 'descriptions' when running tests internally. (GH-30194) 2022-01-22 10:49:38 -08:00
Nikita Sobolev 1f8014c5b4
bpo-46425: fix direct invocation of `test_fileutils` and `test_zoneinfo` (GH-30792) 2022-01-22 18:05:43 +02:00
Nikita Sobolev 57316c52ba
bpo-46425: fix direct invocation of `test_importlib` (GH-30682) 2022-01-22 18:05:05 +02:00
Nikita Sobolev 55f4ec460e
bpo-46425: use absolute imports in `test_sqlite3` (GH-30676) 2022-01-22 18:03:56 +02:00
Nikita Sobolev 101a184d49
bpo-46425: fix direct invocation of `test_traceback` (GH-30746) 2022-01-22 18:03:13 +02:00
Victor Stinner 2d03b73cc9
bpo-46417: remove_subclass() clears tp_subclasses (GH-30793)
The remove_subclass() function now deletes the dictionary when
removing the last subclass (if the dictionary becomes empty) to save
memory: set PyTypeObject.tp_subclasses to NULL. remove_subclass() is
called when a type is deallocated.

_PyType_GetSubclasses() no longer holds a reference to tp_subclasses:
its loop cannot modify tp_subclasses.
2022-01-22 16:53:30 +01:00
Kumar Aditya ea5b96842e
bpo-46469: Make asyncio generic classes return GenericAlias (GH-30777)
* bpo-46469: Make asyncio generic classes return GenericAlias

* 📜🤖 Added by blurb_it.

* Update Misc/NEWS.d/next/Library/2022-01-22-05-05-08.bpo-46469.plUab5.rst

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-01-22 13:28:53 +02:00
Kumar Aditya ab8fe22e5e
fix DeprecationWarning when running asyncio tests (GH-30486) 2022-01-22 13:20:10 +02:00
Nikita Sobolev 5a5340044c
bpo-46425: fix direct invocation of `asyncio` tests (#30725) 2022-01-22 13:06:27 +02:00
Yellow Dusk 82c53229e1
bpo-46442: improve and rename testExceptionCleanupNames (GH-30758)
The test tested that explicitly deleting the local variable bound to the exception
did not cause problems, but it did not test what it actually claimed to test, i.e.
that the variable is deleted automatically.
2022-01-22 02:09:34 -05:00
Nikita Sobolev 65b88d5e01
bpo-46445: Cover multiple inheritance of `TypedDict` in `test_typing` (GH-30719) 2022-01-21 13:38:23 -08:00
Weipeng Hong 881a763cfe
bpo-43118: Fix bug in inspect.signature around 'base.__text_signature__' (GH-30285) 2022-01-21 13:24:33 -08:00
Tom Sparrow 60705cff70
bpo-46434: Handle missing docstrings in pdb help (GH-30705) 2022-01-21 17:00:48 +00:00
Serhiy Storchaka 54610bb448
bpo-46426: Improve tests for the dir_fd argument (GH-30668)
Ensure that directory file descriptors refer to directories different
from the current directory, and that src_dir_fd and dst_dir_fd refer
to different directories.

Add context manager open_dir_fd() in test.support.os_helper.
2022-01-21 09:54:50 +02:00
andrei kulakov cfadcc31ea
bpo-21987: Fix TarFile.getmember getting a dir with a trailing slash (GH-30283) 2022-01-21 09:40:32 +02:00
Nikita Sobolev 22f73bd9f1
bpo-46425: Fix direct invocation of `test_contextlib` (GH-30681) 2022-01-21 09:36:19 +02:00
Victor Stinner 1781d55eb3
bpo-46417: _curses uses PyStructSequence_NewType() (GH-30736)
The _curses module now creates its ncurses_version type as a heap
type using PyStructSequence_NewType(), rather than using a static
type.

* Move _PyStructSequence_FiniType() definition to pycore_structseq.h.
* test.pythoninfo: log curses.ncurses_version.
2022-01-21 03:30:20 +01:00
Victor Stinner 6415e2ee49
bpo-46417: _testembed.c avoids Py_SetProgramName() (GH-30732)
* _testembed_Py_Initialize() now uses the PyConfig API, rather than
  deprecated Py_SetProgramName().
* Reduce INIT_LOOPS from 16 to 4: test_embed now takes 8.7 seconds
  rather than 14.7 seconds.
2022-01-21 02:12:18 +01:00
Victor Stinner e9e3eab0b8
bpo-46417: Finalize structseq types at exit (GH-30645)
Add _PyStructSequence_FiniType() and _PyStaticType_Dealloc()
functions to finalize a structseq static type in Py_Finalize().
Currrently, these functions do nothing if Python is built in release
mode.

Clear static types:

* AsyncGenHooksType: sys.set_asyncgen_hooks()
* FlagsType: sys.flags
* FloatInfoType: sys.float_info
* Hash_InfoType: sys.hash_info
* Int_InfoType: sys.int_info
* ThreadInfoType: sys.thread_info
* UnraisableHookArgsType: sys.unraisablehook
* VersionInfoType: sys.version
* WindowsVersionType: sys.getwindowsversion()
2022-01-21 01:42:25 +01:00
Felix Fontein 9e87c0e03f
bpo-46080: fix argparse help generation exception in edge case (GH-30111)
Fix an uncaught exception during help text generation when
argparse.BooleanOptionalAction is used with default=argparse.SUPPRESS
and help is specified.
2022-01-21 00:48:48 +02:00
Batuhan Taskaya 30fb6d073d
bpo-46441: Add a boilerplate to test syntax errors in interactive mode (GH-30720) 2022-01-20 23:07:43 +03:00
Christian Heimes c02e860ee7
bpo-40280: Misc fixes for wasm32-emscripten (GH-30722) 2022-01-20 18:56:33 +01:00
Mark Shannon b04dfbbe4b
bpo-46409: Make generators in bytecode (GH-30633)
* Add RETURN_GENERATOR and JUMP_NO_INTERRUPT opcodes.

* Trim frame and generator by word each.

* Minor refactor of frame.c

* Update test.test_sys to account for smaller frames.

* Treat generator functions as normal functions when evaluating and specializing.
2022-01-20 11:46:39 +00:00
Nikita Sobolev 263c0dd160
bpo-46437: remove useless `hasattr` from `test_typing` (#30704) 2022-01-19 13:24:27 -08:00
Nikita Sobolev 0a49148e87
bpo-46413: properly test `__{r}or__` code paths in `_SpecialGenericAlias` (GH-30640)
Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
2022-01-19 23:32:25 +08:00
Nikita Sobolev 2792d6d18e
bpo-46416: Allow direct invocation of `Lib/test/test_typing.py` (GH-30641)
Use `__name__`
2022-01-19 22:13:38 +08:00
Victor Stinner a847785b40
bpo-43869: Time Epoch is the same on all platforms (GH-30664) 2022-01-19 11:27:11 +01:00
Ethan Furman 7c0914d35e
bpo-45535: [Enum] include special dunders in dir() (GH-30677)
Include the `__dunders__` in `dir()` that make `Enum` special:

- `__contains__`
- `__getitem__`
- `__iter__`
- `__len__`
- `__members__`
2022-01-18 15:13:13 -08:00
Géry Ogam 16bf9bd157
bpo-44024: Improve the TypeError message in getattr and hasattr (GH-25863)
Use common error message for non-string attribute name in the builtin
functions getattr and hasattr.
The special check no longer needed since Python 3.0.
2022-01-18 22:46:26 +02:00
Nikita Sobolev 1292aa6db5
bpo-46425: Fix direct invocation of multiple test modules (GH-30666) 2022-01-18 21:28:18 +02:00
Steve Dower 7407fe4c25
bpo-46028: Calculate base_executable by resolving symlinks in a venv (GH-30144) 2022-01-18 15:46:26 +00:00
Nikita Sobolev 32398294fb
bpo-46424: [typing] cover `Annotation[arg]` invalid usage in tests (GH-30663) 2022-01-18 22:43:51 +08:00
Raymond Hettinger 243c31667c
bpo-42161: Hoist the _PyLong_GetOne() call out of the inner loop. (GH-30656) 2022-01-18 00:02:35 -08:00