Commit Graph

49877 Commits

Author SHA1 Message Date
Kumar Aditya 5369bba8c5
add tests for `asyncio` transport sockets (#100263) 2022-12-28 10:07:55 +05:30
Kumar Aditya 7cf164ad5e
GH-100342: check for allocation failure in AC `*args` parsing (#100343) 2022-12-28 09:46:28 +05:30
Kumar Aditya e97afefda5
GH-100192: add more `asyncio` subprocess tests (#100194) 2022-12-28 09:42:16 +05:30
Nikita Sobolev 3dc48dabd4
gh-100553: Improve accuracy of sqlite3.Row iter test (#100555) 2022-12-28 01:58:05 +01:00
Nikita Sobolev ce39aaffee
gh-99509: Add `__class_getitem__` to `multiprocessing.queues.Queue` (#99511) 2022-12-26 20:50:55 -08:00
Nikita Sobolev 199507b81a
gh-100520: Fix `rst` markup in `configparser` docstrings (#100524) 2022-12-26 17:08:49 +05:30
Glyph b9aa14a484
gh-100519: simplification to `eff_request_host` in cookiejar.py (#99588)
`IPV4_RE` includes a `.`, and the `.find(".") == -1` included here is already testing to make sure there's no dot, so this part of the expression is tautological. Instead use more modern `in` syntax to make it clear what the check is doing here. The simplified implementation more clearly matches the wording in RFC 2965.

Co-authored-by: hauntsaninja <hauntsaninja@gmail.com>
2022-12-24 18:14:51 -06:00
MonadChains f5b7b19bf1
gh-99535: Add test for inheritance of annotations and update documentation (#99990) 2022-12-24 12:07:14 -08:00
Shantanu e4b43ebb3a
gh-100287: Fix unittest.mock.seal with AsyncMock (#100496) 2022-12-24 19:39:39 +00:00
James Frost 46e6a28308
gh-100474: Fix handling of dirs named index.html in http.server (GH-100475)
If you had a directory called index.html or index.htm within a directory, it would cause http.server to return a 404 Not Found error instead of the directory listing. This came about due to not checking that the index was a regular file.

I have also added a test case for this situation.

Automerge-Triggered-By: GH:merwok
2022-12-24 10:28:59 -08:00
Nikita Sobolev c6dac12861
Remove wrong comment about `repr` in `test_unicode` (#100495) 2022-12-24 06:48:43 -08:00
Kumar Aditya c122390a55
GH-91166: Implement zero copy writes for `SelectorSocketTransport` in asyncio (#31871)
Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>
2022-12-24 11:21:11 +05:30
Shantanu 3e46f9fe05
gh-100268: Add is_integer method to int (#100439)
This improves the lives of type annotation users of `float` - which type checkers implicitly treat as `int|float` because that is what most code actually wants. Before this change a `.is_integer()` method could not be assumed to exist on things annotated as `: float` due to the method not existing on both types.
2022-12-23 18:30:27 -08:00
Nikita Sobolev 7ca45e5ddd
gh-94808: improve test coverage of number formatting (#99472) 2022-12-23 18:03:31 -06:00
Sebastian Berg 474220e3a5
gh-99947: Ensure unreported errors are chained for SystemError during import (GH-99946) 2022-12-23 15:43:19 -08:00
Barney Gale a68e585c8b
gh-68320, gh-88302 - Allow for private `pathlib.Path` subclassing (GH-31691)
Users may wish to define subclasses of `pathlib.Path` to add or modify
existing methods. Before this change, attempting to instantiate a subclass
raised an exception like:

    AttributeError: type object 'PPath' has no attribute '_flavour'

Previously the `_flavour` attribute was assigned as follows:

    PurePath._flavour        = xxx not set!! xxx
    PurePosixPath._flavour   = _PosixFlavour()
    PureWindowsPath._flavour = _WindowsFlavour()

This change replaces it with a `_pathmod` attribute, set as follows:

    PurePath._pathmod        = os.path
    PurePosixPath._pathmod   = posixpath
    PureWindowsPath._pathmod = ntpath

Functionality from `_PosixFlavour` and `_WindowsFlavour` is moved into
`PurePath` as underscored-prefixed classmethods. Flavours are removed.

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Brett Cannon <brett@python.org>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Eryk Sun <eryksun@gmail.com>
2022-12-23 14:52:23 -08:00
Raymond Hettinger 5d84966cce
GH-100425: Improve accuracy of builtin sum() for float inputs (GH-100426) 2022-12-23 14:35:58 -08:00
Filipe Laíns 1ecfd1ebf1
bpo-40447: accept all path-like objects in compileall.compile_file (#19883)
Signed-off-by: Filipe Laíns <lains@archlinux.org>
Signed-off-by: Filipe Laíns <lains@riseup.net>
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
2022-12-23 14:19:16 -06:00
Nikita Sobolev 745545b5bb
gh-99482: remove `jython` compatibility parts from stdlib and tests (#99484) 2022-12-23 14:17:24 -06:00
Carl Meyer c5726b727e
gh-83076: 3.8x speed improvement in (Async)Mock instantiation (#100252) 2022-12-23 19:41:37 +00:00
Dennis Sweeney a98d9ea56e
gh-94155: Reduce hash collisions for code objects (#100183)
* Uses a better hashing algorithm to get better dispersion and remove commutativity.

* Incorporates `co_firstlineno`, `Py_SIZE(co)`, and bytecode instructions.

* This is now the entire set of criteria used in `code_richcompare`, except for `_PyCode_ConstantKey` (which would incorporate the types of `co_consts` rather than just their values).
2022-12-23 13:15:47 -05:00
Ken Jin 36d358348d
Revert "gh-100288: Specialise LOAD_ATTR_METHOD for managed dictionaries (GH-100289)" (#100468)
This reverts commit c3c7848a48.
2022-12-24 01:48:43 +08:00
Ken Jin c3c7848a48
gh-100288: Specialise LOAD_ATTR_METHOD for managed dictionaries (GH-100289) 2022-12-24 00:26:42 +08:00
Bill Fisher 88d565f32a
gh-99110: Initialize `frame->previous` in init_frame to fix segmentation fault when accessing `frame.f_back` (#100182) 2022-12-23 20:15:53 +05:30
Eric Wieser 84bc6a4f25
gh-76963: PEP3118 itemsize of an empty ctypes array should not be 0 (GH-5576)
The itemsize returned in a memoryview of a ctypes array is now computed from the item type, instead of dividing the total size by the length and assuming that the length is not zero.
2022-12-23 08:23:19 +00:00
Shantanu ad23da0e77
gh-57762: fix misleading tkinter.Tk docstring (#98837)
Mentioned as a desired change by terryjreedy on the corresponding issue,
since Tk is not a subclass of Toplevel.
2022-12-22 16:35:32 -06:00
Alex Waygood 9cdb642997
gh-85432: Harmonise parameter names between C and pure-Python implementations of `datetime.time.strftime`, `datetime.datetime.fromtimestamp` (#99993) 2022-12-22 15:57:18 -06:00
Itamar Ostricher 4cc63e0d4e
gh-100344: Add C implementation for `asyncio.current_task` (#100345)
Co-authored-by: pranavtbhat
2022-12-22 19:08:12 +05:30
Eli Schwartz aa878f086b
gh-78997: fix bad rebase of moved test file (#100424) 2022-12-22 13:28:25 +00:00
david-why 68981578ec
Correct typo in typing.py (#100423)
In the docstring of `ParamSpec`, the name of `P = ParamSpec('P')` was
mistakenly written as `'T'`.
2022-12-22 11:20:52 +00:00
Hai Shi d713c54ac8
gh-78878: Fix crash when creating an instance of `_ctypes.CField` (#14837) 2022-12-21 23:01:17 +05:30
Nikita Sobolev e0b4d966a8
Remove unused variable from `dis._find_imports` (#100396) 2022-12-21 22:25:02 +05:30
Serhiy Storchaka b98d2d31bf
gh-100129: Add tests for pickling all builtin types and functions (GH-100142) 2022-12-21 16:31:22 +02:00
Dominic Socular 12be23cf3c
gh-100374: Fixed a bug in socket.getfqdn() (gh-100375) 2022-12-21 22:25:04 +09:00
Kumar Aditya a7715ccfba
GH-100133: fix `asyncio` subprocess losing `stderr` and `stdout` output (#100154) 2022-12-21 15:20:26 +05:30
Kumar Aditya 4994f2488f
GH-100363: Speed up `asyncio.get_running_loop` (#100364) 2022-12-21 15:19:44 +05:30
Shantanu 79311cbfe7
gh-85267: Improvements to inspect.signature __text_signature__ handling (#98796)
This makes a couple related changes to inspect.signature's behaviour
when parsing a signature from `__text_signature__`.

First, `inspect.signature` is documented as only raising ValueError or
TypeError. However, in some cases, we could raise RuntimeError.  This PR
changes that, thereby fixing #83685.

(Note that the new ValueErrors in RewriteSymbolics are caught and then
reraised with a message)

Second, `inspect.signature` could randomly drop parameters that it
didn't understand (corresponding to `return None` in the `p` function).
This is the core issue in #85267. I think this is very surprising
behaviour and it seems better to fail outright.

Third, adding this new failure broke a couple tests. To fix them (and to
e.g. allow `inspect.signature(select.epoll.register)` as in #85267), I
add constant folding of a couple binary operations to RewriteSymbolics.

(There's some discussion of making signature expression evaluation
arbitrary powerful in #68155. I think that's out of scope. The
additional constant folding here is pretty straightforward, useful, and
not much of a slippery slope)

Fourth, while #85267 is incorrect about the cause of the issue, it turns
out if you had consecutive newlines in __text_signature__, you'd get
`tokenize.TokenError`.

Finally, the `if name is invalid:` code path was dead, since
`parse_name` never returned `invalid`.
2022-12-20 19:29:02 -08:00
Nikita Sobolev 44892d45b0
gh-99576: Fix cookiejar file that was not truncated for some classes (GH-99616)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2022-12-20 17:51:26 +01:00
František Nesveda d98ca8172c
gh-99925: Fix inconsistency in `json.dumps()` error messages (GH-99926) 2022-12-20 12:54:56 +02:00
Richard Kojedzinszky a6331b605e
gh-100348: Fix ref cycle in `asyncio._SelectorSocketTransport` with `_read_ready_cb` (#100349) 2022-12-20 16:10:56 +05:30
Thomas Grainger 79ccc03b62
gh-89051: Add ssl.OP_LEGACY_SERVER_CONNECT (#93927)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
Fixes https://github.com/python/cpython/issues/89051
2022-12-20 09:10:30 +02:00
Jon Burdo 797edb28c3
gh-89727: Fix os.walk RecursionError on deep trees (#99803)
Use a stack to implement os.walk iteratively instead of recursively to
avoid hitting recursion limits on deeply nested trees.
2022-12-19 10:59:01 -08:00
Carlton Gibson 532aa4e4e0
gh-94912: Added marker for non-standard coroutine function detection (#99247)
This introduces a new decorator `@inspect.markcoroutinefunction`,
which, applied to a sync function, makes it appear async to
`inspect.iscoroutinefunction()`.
2022-12-18 11:13:24 -08:00
Serhiy Storchaka 0fe61d0838
gh-100272: Fix JSON serialization of OrderedDict (GH-100273)
It now preserves the order of keys.
2022-12-17 14:32:48 +02:00
Erlend E. Aasland 2b38a9aa74
gh-93649: Split tracemalloc tests from _testcapimodule.c (#99551) 2022-12-17 09:53:36 +01:00
colorfulappl efbb1eb9f5
gh-99240: Reset pointer to NULL when the pointed memory is freed in argument parsing (#99890)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2022-12-17 12:07:44 +05:30
Barney Gale 5a991da329
gh-78707: deprecate passing >1 argument to `PurePath.[is_]relative_to()` (GH-94469)
This brings `relative_to()` and `is_relative_to()` more in line with other pathlib methods like `rename()` and `symlink_to()`.

Resolves #78707.
2022-12-16 16:14:27 -08:00
Ethan Furman a5a7cea202
gh-100039: enhance __signature__ to work with str and callables (GH-100168)
Callables should be either class- or static-methods.
Enum now uses the classmethod version to greatly improve the help
given for enums and flags.
2022-12-16 12:30:47 -08:00
Ateeq Sharfuddin 101cfe679f
gh-78997: AttributeError if loading fails in LibraryLoader.__getattr__
Co-authored-by: Zachary Ware <zachary.ware@gmail.com>
Co-authored-by: Filipe Laíns <filipe.lains@gmail.com>
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
2022-12-15 22:59:37 +00:00
Raymond Hettinger b430399d41
GH-100234: Set a default value for random.expovariate() (GH-100235) 2022-12-15 12:40:45 -06:00
Hugo van Kemenade 3192c00a3c
gh-100176: venv: Remove redundant compat code for Python <= 3.2 (#100177)
gh-100176: Remove redundant compat code for Python 3.2 and older

Python 3.2 has been EOL since 2016-02-20 and 2.7 since 2020-01-01, so we
can remove this old compatibility check and unindent the old else-block.

Also, in the unindented block, replace a .format() call with an f-string.

Plus similar changes in the documentation.
2022-12-14 11:37:11 +00:00
Yesung(Isaac) Lee 54289f85b2
gh-99688: Fix outdated tests in test_unary (#99712)
* Remove duplicates from "L" suffix removal
* test_invert now tests `~`.
2022-12-11 18:44:29 -05:00
Gregory P. Smith 2e279e85fe
gh-88500: Reduce memory use of `urllib.unquote` (#96763)
`urllib.unquote_to_bytes` and `urllib.unquote` could both potentially generate `O(len(string))` intermediate `bytes` or `str` objects while computing the unquoted final result depending on the input provided. As Python objects are relatively large, this could consume a lot of ram.

This switches the implementation to using an expanding `bytearray` and a generator internally instead of precomputed `split()` style operations.

Microbenchmarks with some antagonistic inputs like `mess = "\u0141%%%20a%fe"*1000` show this is 10-20% slower for unquote and unquote_to_bytes and no different for typical inputs that are short or lack much unicode or % escaping. But the functions are already quite fast anyways so not a big deal.  The slowdown scales consistently linear with input size as expected.

Memory usage observed manually using `/usr/bin/time -v` on `python -m timeit` runs of larger inputs. Unittesting memory consumption is difficult and does not seem worthwhile.

Observed memory usage is ~1/2 for `unquote()` and <1/3 for `unquote_to_bytes()` using `python -m timeit -s 'from urllib.parse import unquote, unquote_to_bytes; v="\u0141%01\u0161%20"*500_000' 'unquote_to_bytes(v)'` as a test.
2022-12-10 16:17:39 -08:00
DarioDaF 1bb68ba6d9
gh-99941: Ensure that asyncio.Protocol.data_received receives immutable bytes (#100053) 2022-12-10 15:07:02 -08:00
Fantix King 50b08d5b5f
Fix potential flakiness in `test_run_until_complete_baseexception` (#100148) 2022-12-10 15:34:22 +05:30
andrei kulakov d0679c1239
bpo-44512: Fix handling of extrasactions arg to csv.DictWriter with mixed or upper case (#26924) 2022-12-09 16:14:33 +00:00
Shreyan Avigyan a29a7b9b78
bpo-43984: Allow winreg.SetValueEx to set -1 without treating it as an error (GH-25775) 2022-12-09 12:47:18 +00:00
Ken Jin 748c6c0921
GH-100110: Specialize FOR_ITER for tuples (GH-100109)
* Specialize FOR_ITER for tuples
2022-12-09 10:27:01 +00:00
Kumar Aditya 0448deac70
GH-100113: remove remaining `yield from` usage from `asyncio` tests (#100114) 2022-12-09 09:22:18 +05:30
Eric Snow cda9f0236f
gh-81057: Move OS-Related Globals to _PyRuntimeState (gh-100082)
https://github.com/python/cpython/issues/81057
2022-12-08 15:38:06 -07:00
Raymond Hettinger 35cc0ea736
GH-98363: Have batched() return tuples (GH-100118) 2022-12-08 15:08:16 -06:00
Victor Stinner cd67c1bb30
test_ast uses infinite_recursion() to prevent crash (#100104)
test.test_ast_recursion_limit() now uses infinite_recursion() of
test.support to prevent crashes on debug builds.

Before this change, the test crashed on ARM64 Windows 3.x buildbot
worker which builds Python in debug mode.
2022-12-08 09:26:38 +01:00
Fantix King e8fff515f0
Fix `test_run_until_complete_baseexception` test to check for `KeyboardInterrupt` in asyncio (#24477) 2022-12-08 13:51:04 +05:30
Ethan Furman ded02ca54d
gh-100098: [Enum] insist on actual tuples, no subclasses, for auto (GH-100099)
When checking for auto() instances, only top-level usage is supported,
which means either alone or as part of a regular tuple. Other
containers, such as lists, dicts, or namedtuples, will not have auto()
transformed into a value.
2022-12-07 22:58:08 -08:00
Takeshi KOMIYA 90d5c9b195
gh-92120: The docstring of enum.Enum is invalid in reST (GH-92122)
Closes #92120
2022-12-07 18:24:52 -08:00
Dong-hee Na dc8a86893d
gh-98778: Update HTTPError to initialize properly even if fp is None (gh-99966) 2022-12-08 11:20:34 +09:00
Victor Stinner 3c89202247
gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
2022-12-08 01:38:47 +01:00
Irit Katriel f3e97c90ed
gh-100077: make test_code.test_invalid_bytecode more robust and maintainable (#100078) 2022-12-07 18:09:05 +00:00
Carl Meyer 68e41295b8
gh-83035: handle decorator with nested parens in inspect.getsource (#99654) 2022-12-07 08:55:12 -08:00
Matěj Cepl 7031275776
gh-93018: Fix for the compatibility problems with expat (gh-93900) 2022-12-07 15:55:49 +09:00
Nikita Sobolev 889b0b9bf9
[Enum] Remove unused code from `test_enum.py` (GH-96986) 2022-12-06 18:44:47 -08:00
Pablo Galindo Salgado 97e7004cfe
gh-100050: Fix an assertion error when raising unclosed parenthesis errors in the tokenizer (GH-100065)
Automerge-Triggered-By: GH:pablogsal
2022-12-06 15:09:56 -08:00
Ethan Furman 679efbb080
gh-94943: [Enum] improve repr() when inheriting from a dataclass (GH-99740)
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
2022-12-06 13:43:41 -08:00
Thomas Wouters b6bd7ffcbc Python 3.12.0a3 2022-12-06 19:33:02 +01:00
Serhiy Storchaka fd38a2f0ec
gh-93453: No longer create an event loop in get_event_loop() (#98440)
asyncio.get_event_loop() now always return either running event loop or
the result of get_event_loop_policy().get_event_loop() call. The latter
should now raise an RuntimeError if no current event loop was set
instead of creating and setting a new event loop.

It affects also a number of asyncio functions and constructors which
call get_event_loop() implicitly: ensure_future(), shield(), gather(),
etc.

DeprecationWarning is no longer emitted if there is no running event loop but
the current event loop was set.

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2022-12-06 18:42:12 +01:00
Brandt Bucher b72014c783
GH-99729: Unlink frames before clearing them (GH-100030) 2022-12-06 14:01:38 +00:00
Erik De Bonte 5c19050546
gh-99957: Add `frozen_default` parameter on `dataclass_transform` (#99958) 2022-12-05 19:35:43 -08:00
Gregory P. Smith 7e29398407
gh-100001: Also escape \s in http.server log messages. (#100038)
Also \ escape \s in the http.server BaseHTTPRequestHandler.log_message so
that it is technically possible to parse the line and reconstruct what the
original data was.  Without this a \xHH is ambiguious as to if it is a hex
replacement we put in or the characters r"\x" came through in the original
request line.
2022-12-05 14:27:55 -08:00
Gregory P. Smith d8ab0a4dfa
gh-100001: Omit control characters in http.server stderr logs. (#100002)
Replace control characters in http.server.BaseHTTPRequestHandler.log_message with an escaped \xHH sequence to avoid causing problems for the terminal the output is printed to.
2022-12-05 12:55:45 -08:00
Eric Snow 530cc9dbb6
gh-99741: Implement Multi-Phase Init for the _xxsubinterpreters Module (gh-99742)
_xxsubinterpreters is an internal module used for testing.

https://github.com/python/cpython/issues/99741
2022-12-05 13:40:20 -07:00
Michael Förderer 124ecd6576
bpo-44817: Ignore additional errors in ntpath.realpath (GH-27574) 2022-12-05 17:34:00 +00:00
Serhiy Storchaka 922a6cf6c2
gh-60203: Revert changes in cycle.__setstate__ (#99982)
In case if only True/False be supported as boolean arguments in future,
we should continue to support 1/0 here.
2022-12-05 17:27:40 +01:00
Victor Stinner 2488c1e1b6
gh-99892: test_unicodedata: skip test on download failure (#100011)
Skip test_normalization() of test_unicodedata if it fails to download
NormalizationTest.txt file from pythontest.net.
2022-12-05 16:37:40 +01:00
Victor Stinner 038b151963
gh-100005: Skip test_script_as_dev_fd() on FreeBSD (#100006)
On FreeBSD, skip test_script_as_dev_fd() of test_cmd_line_script if
fdescfs is not mounted (at /dev/fd).
2022-12-05 14:23:35 +01:00
Felix Ye 854a878e4f
gh-98248: Normalizing the error messages in function struct.pack (GH-98252)
Provide consistent and informative error messages in function struct.pack when its integral arguments are not in range.
2022-12-04 20:24:18 +00:00
AlexTate 72ec518203
gh-98458: unittest: bugfix for infinite loop while handling chained exceptions that contain cycles (#98459)
* Bugfix addressing infinite loop while handling self-referencing chained exception in TestResult._clean_tracebacks()
* Bugfix extended to properly handle exception cycles in _clean_tracebacks. The "seen" set follows the approach used in the TracebackException class (thank you @iritkatriel for pointing it out)
* adds a test for a single chained exception that holds a self-loop in its __cause__ and __context__ attributes
2022-12-04 11:37:55 -08:00
Itamar Ostricher 1012dc1b43
GH-91054: Reset static events counts in code watchers tests (#99978) 2022-12-04 12:38:21 +00:00
Serhiy Storchaka 76f43fc09a
gh-60203: Always pass True/False as boolean arguments in tests (GH-99983)
Unless we explicitly test non-bool values.
2022-12-04 14:28:56 +02:00
Serhiy Storchaka a87c46eab3
bpo-15999: Accept arbitrary values for boolean parameters. (#15609)
builtins and extension module functions and methods that expect boolean values for parameters now accept any Python object rather than just a bool or int type. This is more consistent with how native Python code itself behaves.
2022-12-03 11:52:21 -08:00
Alexander Kanavin c68573b339
gh-99934: test_marshal.py: add more elements in test_deterministic_sets (GH-99935)
Existing elements do produce different output on x86_64, but they
do not on x86. Let's make the data longer to ensure it differs.
2022-12-03 10:53:20 -06:00
Kumar Aditya ee60156500
GH-66285: remove redundant `time.sleep` from `test_fork_signal_handling` (GH-99963) 2022-12-02 22:15:36 -08:00
Eric Snow 0547a981ae
gh-99741: Clean Up the _xxsubinterpreters Module (gh-99940)
This cleanup up resolves a few subtle bugs and makes the implementation for multi-phase init much cleaner.

https://github.com/python/cpython/issues/99741
2022-12-02 11:36:57 -07:00
Itamar Ostricher 3c137dc613
GH-91054: Add code object watchers API (GH-99859)
* Add API to allow extensions to set callback function on creation and destruction of PyCodeObject

Co-authored-by: Ye11ow-Flash <janshah@cs.stonybrook.edu>
2022-12-02 17:28:27 +00:00
Pablo Galindo Salgado 0563be23a5
gh-99894: Ensure the local names don't collide with the test file in traceback suggestion error checking (#99895)
Co-authored-by: Victor Stinner <vstinner@python.org>
2022-12-01 14:05:56 +01:00
Serhiy Storchaka f08e52ccb0
gh-99612: Fix PyUnicode_DecodeUTF8Stateful() for ASCII-only data (GH-99613)
Previously *consumed was not set in this case.
2022-12-01 14:54:51 +02:00
Serhiy Storchaka 787764219f
gh-89189: More compact range iterator (GH-27986) 2022-11-30 23:04:30 +02:00
Arne de Laat a694b8222e
Fix typo in exception message in `multiprocessing.pool` (#99900) 2022-11-30 20:57:28 +05:30
Pablo Galindo Salgado 417206a05c
gh-99891: Fix infinite recursion in the tokenizer when showing warnings (GH-99893)
Automerge-Triggered-By: GH:pablogsal
2022-11-30 03:36:06 -08:00
dmjohnsson23 59665d0280
Improve zip64 limit error message (#95892) 2022-11-30 16:44:41 +05:30
Wenzel Jakob c314198fad
gh-98253: Break potential reference cycles in external code worsened by typing.py lru_cache (#98591) 2022-11-30 08:33:32 +00:00
Dong-hee Na 8bb2303fd7
gh-99127: Allow some features of syslog to the main interpreter only (gh-99128) 2022-11-30 07:58:20 +09:00
Pete Wicken ed391090cc
gh-82836: fix private network check (#97733)
Fixes private checks for network objects. The previous method would incorrectly return True for a private check in cases such as "0.0.0.0/0".
2022-11-29 13:32:18 -08:00
Serhiy Storchaka deaa8dee48
gh-99593: Add tests for Unicode C API (part 1) (GH-99651)
Add tests for functions corresponding to the str class methods.
2022-11-29 09:59:56 +02:00
Serhiy Storchaka 8f2fb7dfe7
gh-99344, gh-99379, gh-99382: Fix issues in substitution of ParamSpec and TypeVarTuple (GH-99412)
* Fix substitution of TypeVarTuple and ParamSpec together in user generics.

* Fix substitution of ParamSpec followed by TypeVarTuple in generic aliases.

* Check the number of arguments in substitution in user generics containing a
  TypeVarTuple and one or more TypeVar.
2022-11-29 09:46:52 +02:00
cemysce 1d1bb95abd
gh-99811: Use correct variable to search for time in format string (GH-99812)
Use correct variable to search for asctime
2022-11-28 18:25:03 +00:00
Zackery Spytz 53eef27133
bpo-31718: Fix io.IncrementalNewlineDecoder SystemErrors and segfaults (#18640)
Co-authored-by: Oren Milman <orenmn@gmail.com>
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2022-11-28 16:16:40 +05:30
Furkan Onder 594de165bf
gh-51524: Fix bug when calling trace.CoverageResults with valid infile (#99629)
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
2022-11-28 01:49:10 -05:00
Nikita Sobolev 2653b82c1a
gh-99677: Deduplicate self-type in `mro` in `inspect._getmembers` (#99678)
Closes #99677
2022-11-27 16:45:26 +05:30
Anthony Sottile ac115b51e7
gh-99815: remove unused 'invalid' sentinel value and code that checks for it in inspect.signature parsing (GH-21104) 2022-11-27 11:01:02 +00:00
Ronald Oussoren d08fb25769
GH-87235: Make sure "python /dev/fd/9 9</path/to/script.py" works on macOS (#99768)
On macOS all file descriptors for a particular file in /dev/fd
share the same file offset, that is ``open("/dev/fd/9", "r")`` behaves
more like ``dup(9)`` than a regular open.

This causes problems when a user tries to run "/dev/fd/9" as a script
because zipimport changes the file offset to try to read a zipfile
directory. Therefore change zipimport to reset the file offset after
trying to read the zipfile directory.
2022-11-27 11:56:14 +01:00
Yonatan Goldschmidt 9c9f085e9a
Remove unused local variables in inspect.py (#24218) 2022-11-27 16:09:23 +05:30
Kumar Aditya 191708c56c
GH-66285: fix forking in asyncio (#99769)
Closes #66285
2022-11-27 11:24:48 +05:30
Nick Drozd 024ac542d7
bpo-45975: Simplify some while-loops with walrus operator (GH-29347) 2022-11-26 14:33:25 -08:00
Jason R. Coombs 93f22d30eb
gh-98108: Add limited pickleability to zipfile.Path (GH-98109)
* gh-98098: Move zipfile into a package.

* Moved test_zipfile to a package

* Extracted module for test_path.

* Add blurb

* Add jaraco as owner of zipfile.Path.

* Synchronize with minor changes found at jaraco/zipp@d9e7f4352d.

* gh-98108: Sync with zipp 3.9.1 adding pickleability.
2022-11-26 13:05:41 -05:00
Jason R. Coombs 003f341e99
Fix zipfile packaging after GH-98103 (GH-99797)
* Add zipfile and test_zipfile to list of packages. Fixes regression introduced in #98103.

* Restore support for py -m test.test_zipfile
2022-11-26 13:00:05 -05:00
Sam Ezeh 78365b8e28
gh-91078: Return None from TarFile.next when the tarfile is empty (GH-91850)
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
2022-11-26 09:57:05 -08:00
Jason R. Coombs 7796d3179b
gh-98098: Create packages from zipfile and test_zipfile (gh-98103)
* gh-98098: Move zipfile into a package.

* Moved test_zipfile to a package

* Extracted module for test_path.

* Add blurb

* Add jaraco as owner of zipfile.Path.

* Synchronize with minor changes found at jaraco/zipp@d9e7f4352d.
2022-11-26 09:44:13 -05:00
Jason R. Coombs dc063a25d2
gh-97966: Restore prior expectation that uname_result._fields and ._asdict would include the processor. (gh-98343) 2022-11-26 08:28:49 -05:00
Barney Gale ae234fbc5c
gh-99029: Fix handling of `PureWindowsPath('C:\<blah>').relative_to('C:')` (GH-99031)
`relative_to()` now treats naked drive paths as relative. This brings its
behaviour in line with other parts of pathlib, and with `ntpath.relpath()`,
and so allows us to factor out the pathlib-specific implementation.
2022-11-25 11:15:57 -08:00
Gary Donovan 5d4d83130c
Fix typo on inline comment for email.generator (GH-98210)
Trivial change to comment - no issue or new entry necessary
2022-11-25 10:03:20 -08:00
Zackery Spytz 85c128e34d
bpo-40882: Fix a memory leak in SharedMemory on Windows (GH-20684)
In multiprocessing.shared_memory.SharedMemory(), the temporary view
returned by MapViewOfFile() should be unmapped when it is no longer
needed.
2022-11-25 17:39:48 +00:00
Zackery Spytz d386115039
bpo-38031: Fix a possible assertion failure in _io.FileIO() (#GH-5688) 2022-11-25 12:55:26 +00:00
Zackery Spytz b1dcdefc3a
bpo-41260: C impl of datetime.date.strftime() takes different keyword arg (GH-21712) 2022-11-25 09:21:25 +00:00
colorfulappl 0da728387c
gh-64490: Fix bugs in argument clinic varargs processing (#32092) 2022-11-24 20:56:50 +01:00
Kumar Aditya 351842b46a
GH-66285: Revert "fix forking in asyncio" (#99756) 2022-11-24 23:04:21 +05:30
Kumar Aditya 679d963fc8
GH-66285: skip asyncio fork tests for platforms without md5 hash (#99745)
Such buildbots (at the time of writing, only "AMD64 RHEL8 FIPS Only Blake2 Builtin Hash 3.x") cannot use multiprocessing with a fork server, so just skip the test there.
2022-11-24 08:06:06 -08:00
Guido van Rossum 5d09d11aa0
GH-79033: Fix asyncio.Server.wait_closed() (#98582)
It was a no-op when used as recommended (after close()).

I had to debug one test (test__sock_sendfile_native_failure) --
the cleanup sequence for the test fixture was botched.

Hopefully that's not a portend of problems in user code --
this has never worked so people may well be doing this wrong. :-(

Co-authored-by: kumar aditya
2022-11-24 08:32:58 -07:00
colorfulappl 8dbe08eb7c
gh-99240: Fix double-free bug in Argument Clinic str_converter generated code (GH-99241)
Fix double-free bug mentioned at https://github.com/python/cpython/issues/99240,
by moving memory clean up out of "exit" label.

Automerge-Triggered-By: GH:erlend-aasland
2022-11-24 06:01:26 -08:00
colorfulappl 69f6cc77d0
gh-64490: Fix refcount error when arguments are packed to tuple in argument clinic (#99233) 2022-11-24 17:54:18 +05:30
Irit Katriel ae185fdcca
gh-99708: fix bug where compiler crashes on if expression with an empty body block (GH-99732) 2022-11-24 10:59:07 +00:00
zhanpon 5f4ae86a63
gh-94808: [coverage] Add an asynchronous generator test where the generator is already running (#97672) 2022-11-24 14:40:38 +05:30
Kumar Aditya 0c1fbc17b4
GH-66285: fix forking in `asyncio` (#99539)
`asyncio` now does not shares event loop and signal wakeupfd in forked processes.
2022-11-24 09:10:27 +05:30
Nikita Sobolev c69cfcdb11
closes gh-99508: fix `TypeError` in `Lib/importlib/_bootstrap_external.py` (GH-99635) 2022-11-23 16:47:31 -06:00
Charles Machalow 1b2de89bce
gh-99547: Add isjunction methods for checking if a path is a junction (GH-99548) 2022-11-22 17:19:34 +00:00
Serhiy Storchaka c2102136be
gh-99645: Fix a bug in handling class cleanups in unittest.TestCase (GH-99646)
Now addClassCleanup() uses separate lists for different TestCase subclasses,
and doClassCleanups() only cleans up the particular class.
2022-11-22 17:49:37 +02:00
Dong Uk, Kang 995f6170c7
gh-88863: Clear ref cycles to resolve leak when asyncio.open_connection raises (#95739)
Break reference cycles to resolve memory leak, by
removing local exception and future instances from the frame
2022-11-22 07:06:20 -08:00
mpage 3db0a21f73
gh-91053: Add an optional callback that is invoked whenever a function is modified (#98175) 2022-11-22 13:06:44 +01:00
Batuhan Taskaya 1acdfec359
gh-99341: Cover type ignore nodes when incrementing line numbers (GH-99422) 2022-11-22 02:41:14 -08:00
Petr Viktorin 4d82f628c4
gh-47146: Soft-deprecate structmember.h, expose its contents via Python.h (GH-99014)
The ``structmember.h`` header is deprecated, though it continues to be available
and there are no plans to remove it. There are no deprecation warnings. Old code
can stay unchanged (unless the extra include and non-namespaced macros bother
you greatly). Specifically, no uses in CPython are updated -- that would just be
unnecessary churn.
The ``structmember.h`` header is deprecated, though it continues to be
available and there are no plans to remove it.

Its contents are now available just by including ``Python.h``,
with a ``Py`` prefix added if it was missing:

- `PyMemberDef`, `PyMember_GetOne` and`PyMember_SetOne`
- Type macros like `Py_T_INT`, `Py_T_DOUBLE`, etc.
  (previously ``T_INT``, ``T_DOUBLE``, etc.)
- The flags `Py_READONLY` (previously ``READONLY``) and
  `Py_AUDIT_READ` (previously all uppercase)

Several items are not exposed from ``Python.h``:

- `T_OBJECT` (use `Py_T_OBJECT_EX`)
- `T_NONE` (previously undocumented, and pretty quirky)
- The macro ``WRITE_RESTRICTED`` which does nothing.
- The macros ``RESTRICTED`` and ``READ_RESTRICTED``, equivalents of
  `Py_AUDIT_READ`.
- In some configurations, ``<stddef.h>`` is not included from ``Python.h``.
  It should be included manually when using ``offsetof()``.

The deprecated header continues to provide its original
contents under the original names.
Your old code can stay unchanged, unless the extra include and non-namespaced
macros bother you greatly.

There is discussion on the issue to rename `T_PYSSIZET` to `PY_T_SSIZE` or
similar. I chose not to do that -- users will probably copy/paste that with any
spelling, and not renaming it makes migration docs simpler.


Co-Authored-By: Alexander Belopolsky <abalkin@users.noreply.github.com>
Co-Authored-By: Matthias Braun <MatzeB@users.noreply.github.com>
2022-11-22 08:25:43 +01:00
Łukasz Langa 2781ec9b0e
gh-99659: Use correct exceptions in sqlite3 bigmem tests (#99660)
The tests in question were added in 0eec6276fd by Serhiy. Apparently,
sqlite3 changed exceptions raised in those cases in the mean time but
the tests never ran because they require a high `-M` setting in the
test runner.
2022-11-21 21:44:17 +01:00
colorfulappl c450c8c9ed
gh-96002: Add functional test for Argument Clinic (#96178)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2022-11-21 15:08:45 +01:00
Serhiy Storchaka 653e563d80
Add more details in test_unittest (GH-99626) 2022-11-21 13:57:30 +02:00
Victor Stinner cb2ef8b2ac
gh-99578: Fix refleak in _imp.create_builtin() (#99642)
Fix a reference bug in _imp.create_builtin() after the creation of
the first sub-interpreter for modules "builtins" and "sys".
2022-11-21 12:14:54 +01:00
Lysandros Nikolaou 6d8da238cc
gh-90994: Improve error messages upon call arguments syntax errors (GH-96893) 2022-11-21 00:15:05 +01:00
Pablo Galindo Salgado e13d1d9dda
gh-99581: Fix a buffer overflow in the tokenizer when copying lines that fill the available buffer (#99605) 2022-11-20 20:20:03 +00:00
Gregory P. Smith abf5b6ff43
gh-61460: Add a comment describing the multiprocessing.connection protocol (gh-99623)
Describe the multiprocessing connection protocol.

It isn't a good protocol, but it is what it is.  This way we can more
easily reason about making changes to it in a backwards compatible way.
2022-11-20 10:20:04 -08:00
Lysandros Nikolaou 9c4232ae89
gh-99211: Point to except/except* on syntax errors when mixing them (GH-99215)
Automerge-Triggered-By: GH:lysnikolaou
2022-11-20 09:11:02 -08:00
Filipe Laíns b0e1f9c241
gh-99201: fix IndexError when initializing sysconfig config variables 2022-11-19 20:47:09 +00:00
Irit Katriel c8c6113398
gh-99553: fix bug where an ExceptionGroup subclass can wrap a BaseException (GH-99572) 2022-11-18 15:44:43 +00:00
Steve Dower a220c6d1ee
gh-99442: Fix handling in py.exe launcher when argv[0] does not include a file extension (GH-99542) 2022-11-18 14:14:56 +00:00
Brandt Bucher 8555dee5ae
GH-98686: Get rid of BINARY_OP_GENERIC and COMPARE_OP_GENERIC (GH-99399) 2022-11-17 11:36:57 -08:00
Steve Dower 5fdd49dc65
gh-99377: Revert audit events for thread state creation and free, because the GIL is not properly held at these times (GH-99543) 2022-11-17 00:24:16 +00:00
Steve Dower 7c57857340
gh-99370: Prefer LIBDIR from sysconfig when locating libpython for test (GH-99523) 2022-11-16 21:41:13 +00:00
Erlend E. Aasland 51d10354f4
gh-93649: Split watcher API tests from _testcapimodule.c (#99532) 2022-11-16 20:13:32 +01:00
Steve Dower 19c1462e8d
gh-99377: Add audit events for thread creation and clear (GH-99378) 2022-11-16 17:15:52 +00:00
Nikita Sobolev 5cfb7d19f5
gh-99518: Fix escape symbol in `test_enum` (#99519) 2022-11-16 15:06:37 +01:00
Ethan Furman 65dab1506e
gh-92647: [Enum] use final status to determine lookup or create (GH-99500)
* use final status to determine lookup or create

* 📜🤖 Added by blurb_it.

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2022-11-15 08:49:22 -08:00
Thomas Wouters 73943cbc4c Merge the 3.12.0a2 release into main. 2022-11-15 13:38:09 +01:00
Kai Zhang 1df0752b4d
gh-99370: fix test_zippath_from_non_installed_posix (GH-99483)
When build with shared enabled, we need to set `LD_LIBRARY_PATH`
for the non-installed python environment in
test_zippath_from_non_installed_posix so that the python binary
and find and link the libpython.so.
2022-11-15 01:01:01 +00:00
Steve Dower 4e4b13e8f6
gh-87604: Avoid publishing list of active per-interpreter audit hooks via the gc module (GH-99373) 2022-11-14 21:39:18 +00:00
Kumar Aditya 619cadcda6
GH-98219: reduce sleep time in `asyncio` subprocess test (#99464) 2022-11-14 11:53:11 -08:00
Kumar Aditya f63002755d
GH-99388: add `loop_factory` parameter to `asyncio.run` (#99462) 2022-11-14 10:18:51 -08:00
Kai Zhang e3d4fed074
gh-99370: Calculate zip path from prefix when in a venv (GH-99371)
Before python3.11, when in a venv the zip path is calculated
from prefix on POSIX platforms. In python3.11 the behavior is
accidentally changed to calculating from default prefix. This
change will break venv created from a non-installed python
with a stdlib zip file. This commit restores the behavior back
to before python3.11.
2022-11-14 15:05:14 +00:00
Irit Katriel a3ac9232f8
gh-87092: expose the compiler's codegen to python for unit tests (GH-99111) 2022-11-14 13:56:40 +00:00
Serhiy Storchaka 06d4e02c3b
gh-78453: Move Unicode C API tests from test_unicode to test_capi.test_unicode (GH-99431) 2022-11-14 15:32:02 +02:00
Thomas Wouters 3b9d793efc Python 3.12.0a2 2022-11-14 12:18:11 +01:00
Ethan Furman db115682bd
[Enum] update version TODO comment (GH-99458) 2022-11-13 20:52:30 -08:00
Christoph Anton Mitterer 367f552129
gh-96192: fix os.ismount() to use a path that is str or bytes (#96194)
Signed-off-by: Christoph Anton Mitterer <mail@christoph.anton.mitterer.name>
Co-authored-by: Eryk Sun <eryksun@gmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-11-13 20:12:32 -08:00
Nikita Sobolev 343eb0f94b
gh-99275: Fix `SystemError` in `ctypes` during `__initsubclass__` (#99283) 2022-11-13 11:22:45 -08:00
Nikita Sobolev d329f859b9
gh-99430: Remove duplicated tests for old-styled classes (#99432)
python 1 & 2 were a loong time ago.
2022-11-13 10:30:00 -08:00
Ben Kallus 439b9cfaf4
gh-99418: Make urllib.parse.urlparse enforce that a scheme must begin with an alphabetical ASCII character. (#99421)
Prevent urllib.parse.urlparse from accepting schemes that don't begin with an alphabetical ASCII character.

RFC 3986 defines a scheme like this: `scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )`
RFC 2234 defines an ALPHA like this: `ALPHA = %x41-5A / %x61-7A`

The WHATWG URL spec defines a scheme like this:
`"A URL-scheme string must be one ASCII alpha, followed by zero or more of ASCII alphanumeric, U+002B (+), U+002D (-), and U+002E (.)."`
2022-11-13 10:25:55 -08:00
Victor Stinner 6788303f5c
gh-91248: Optimize PyFrame_GetVar() (#99252)
PyFrame_GetVar() no longer creates a temporary dictionary to get a
variable.
2022-11-13 15:37:03 +01:00
Batuhan Taskaya 57be545959
gh-99103: Normalize specialized traceback anchors against the current line (GH-99145)
Automerge-Triggered-By: GH:isidentical
2022-11-12 15:37:25 -08:00
Erlend E. Aasland c95f554a40
gh-83638: Add sqlite3.Connection.autocommit for PEP 249 compliant behaviour (#93823)
Introduce the autocommit attribute to Connection and the autocommit
parameter to connect() for PEP 249-compliant transaction handling.

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
Co-authored-by: Géry Ogam <gery.ogam@gmail.com>
2022-11-12 23:44:41 +01:00
Xiao Chen 99972dc745
gh-99357: Close the event loop when it is no longer used in test_uncancel_structured_blocks (#99414) 2022-11-12 12:16:44 -08:00
Irit Katriel fb844e1931
gh-98762: Fix locations of match sub-patterns (GH-98775) 2022-11-12 18:42:17 +00:00
Kumar Aditya aa874326d8
GH-94597: add deprecation warnings for subclassing `AbstractChildWatcher` (#99386) 2022-11-11 23:17:53 -08:00
Hai Shi e02cc6d42a
gh-80448: argparse: Fix IndexError on store_true action (#15656)
Co-authored-by: Rémi Lapeyre <remi.lapeyre@henki.fr>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
2022-11-11 17:51:38 -08:00
NewUserHa 55c96e8053
gh-99305: Speed up secrets.token_hex() ~2x (#99306)
simple code modernization.

Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
2022-11-11 14:45:24 -08:00
Irit Katriel 3dd6ee2c00
gh-99254: remove all unused consts from code objects (GH-99255) 2022-11-11 10:53:43 +00:00
Nikita Sobolev faf7dfa656
gh-99325: Remove unused `NameError` handling (#99326) 2022-11-11 09:56:57 +00:00
Nikita Sobolev 67b4d2772c
gh-98086: Now ``patch.dict`` can decorate async functions (#98095) 2022-11-11 08:04:30 +00:00
Vincent Fazio c41b13d39c
gh-99204: Calculate base_executable by alternate names in POSIX venvs (GH-99206)
Check to see if `base_executable` exists. If it does not, attempt
to use known alternative names of the python binary to find an
executable in the path specified by `home`.

If no alternative is found, previous behavior is preserved.

Signed-off-by: Vincent Fazio <vfazio@gmail.com>

Signed-off-by: Vincent Fazio <vfazio@gmail.com>
2022-11-10 16:26:42 +00:00
Carlo f1680c3fbf
gh-99277: remove older version of `get_write_buffer_limits` (#99280)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2022-11-10 08:07:17 -08:00
Mark Shannon 1e197e63e2
GH-96421: Insert shim frame on entry to interpreter (GH-96319)
* Adds EXIT_INTERPRETER instruction to exit PyEval_EvalDefault()

* Simplifies RETURN_VALUE, YIELD_VALUE and RETURN_GENERATOR instructions as they no longer need to check for entry frames.
2022-11-10 12:34:57 +00:00
Anton Ryzhov dbf2faf579
gh-74044: inspect.signature for wrappers around decorated bound methods (GH-736) 2022-11-10 12:32:01 +00:00
Brandt Bucher 9d69284169
GH-99257: Check the owner's type when specializing slots (GH-99258) 2022-11-10 11:50:34 +00:00
Nikita Sobolev 26726c7649
gh-99320: remove tests for old-style class from `test_complex` (#99321) 2022-11-10 10:51:22 +00:00
Nikita Sobolev d6f2767997
gh-99281: [csv] remove try/except, `complex` always exists (#99282) 2022-11-10 10:37:57 +00:00
Serhiy Storchaka f883b7f8ee
bpo-34272: Reorganize C API tests. (GH-8551)
Move some C API tests into Lib/test/test_capi/.
2022-11-10 08:54:37 +02:00
Nikita Sobolev 87f5180cd7
gh-98832: Change wording in docstring of `pathlib.Path.iterdir` (GH-98833)
Found while working on https://github.com/python/cpython/issues/98829

Automerge-Triggered-By: GH:AlexWaygood
2022-11-09 14:05:07 -08:00
Brandt Bucher c7f5708714
GH-98686: Get rid of "adaptive" and "quick" instructions (GH-99182) 2022-11-09 10:50:09 -08:00
Carl Meyer 027bc7e6bb
gh-94445: add compiler test for another case of excessive stack use (GH-99237) 2022-11-08 20:39:32 +00:00
Ethan Furman 0b4ffb08cc
gh-99248: [Enum] fix negative number infinite loop (GH-99256)
[Enum] fix negative number infinite loop

- _iter_bits_lsb() now raises a ValueError if a negative number
  is passed in

- verify() now skips checking negative numbers for named flags
2022-11-08 12:00:19 -08:00
Eric Snow d45cc80452
gh-98627: Add the _testsinglephase Module (gh-99039)
This makes it more clear that a given test is definitely testing against a single-phase init (legacy) extension module.  The new module is a companion to _testmultiphase.

https://github.com/python/cpython/issues/98627
2022-11-08 09:58:11 -07:00
Victor Stinner 4d5fcca273
gh-91248: Add PyFrame_GetVar() function (#95712)
Add PyFrame_GetVar() and PyFrame_GetVarString() functions to get a
frame variable by its name.

Move PyFrameObject C API tests from test_capi to test_frame.
2022-11-08 17:40:27 +01:00
Brandt Bucher c7065ce019
GH-93143: Don't turn LOAD_FAST into LOAD_FAST_CHECK (GH-99075) 2022-11-08 07:50:46 -08:00
Nikita Sobolev e56e33d271
gh-72719: Remove asyncore and asynchat modules (#96580)
Remove modules asyncore and asynchat, which were deprecated by PEP 594.

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-11-08 16:48:58 +01:00
Irit Katriel c43714fbcd
gh-99181: fix except* on unhashable exceptions (GH-99192) 2022-11-08 09:32:20 +00:00
Kamil Turek b9dedfe61d
gh-92119: ctypes: Print exception class name instead of its representation (#98302) 2022-11-07 20:53:59 -08:00
Nikita Sobolev a309ad9f76
gh-98513: Test abstract methods of some `collections` types (#98516) 2022-11-07 17:48:23 -08:00
Nikita Sobolev c32bc1bffd
gh-99124: use concrete exception types in `test_builtin` (#99125) 2022-11-07 17:47:32 -08:00
Gregory P. Smith d315722564
gh-98433: Fix quadratic time idna decoding. (#99092)
There was an unnecessary quadratic loop in idna decoding. This restores
the behavior to linear.

This also adds an early length check in IDNA decoding to outright reject
huge inputs early on given the ultimate result is defined to be 63 or fewer
characters.
2022-11-07 16:54:41 -08:00
Mark Shannon 4a1c58d504
GH-96793: Specialize FOR_ITER for generators. (GH-98772) 2022-11-07 14:49:51 +00:00
Zackery Spytz 5ff81da6d3
bpo-38523: ignore_dangling_symlinks does not apply recursively (GH-22937) 2022-11-07 11:45:16 +00:00
andrei kulakov c6325b1c9f
gh-91803: Mock - fix error when using autospec methods with seal (#92213)
Fixes https://github.com/python/cpython/issues/91803.

Co-authored-by: Karthikeyan Singaravelan <tir.karthi@gmail.com>
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
2022-11-07 07:24:46 +00:00
Nikita Sobolev bef9efabc3
GH-99155: Fix `NormalDist` pickle with `0` and `1` protocols (GH99156) 2022-11-06 20:56:41 -06:00
Anh71me bd221c01dd
gh-98139: enhance namespace package repr 2022-11-06 22:13:40 +00:00
Terry Jan Reedy 5eff82fdde
bpo-33964: IDLE macosx - removed unused local dict. (GH-7926) 2022-11-06 20:10:22 +00:00
Ethan Furman a71b117c3d
[Enum] add built-in property to test_test_simple_enum (GH-98453) 2022-11-06 12:03:42 -08:00
Nikita Sobolev 8463cb55da
gh-99051: remove duplicated test from `test_weakref` (GH-99052) 2022-11-06 19:28:44 +00:00
Irit Katriel 61b6c40b64
gh-99153: set location on SyntaxError for try with both except and except* (GH-99160) 2022-11-06 15:36:19 +00:00
Pablo Galindo Salgado 99e2e60cb2
gh-99139: Improve NameError error suggestion for instances (#99140) 2022-11-06 13:52:06 +00:00
Nikita Sobolev a0bc75e2fd
`test_typing`: use all pickle protocols (#99154) 2022-11-06 11:53:57 +00:00
Ethan Furman 8feb7ab77c
gh-93464: [Enum] fix auto() failure during multiple assignment (GH-99148)
* fix auto() failure during multiple assignment

i.e. `ONE = auto(), 'text'` will now have `ONE' with the value of `(1,
'text')`.  Before it would have been `(<an auto instance>, 'text')`
2022-11-05 18:01:08 -07:00
Paul Moore 47ab8480e7
gh-99134: Update bundled pip to 22.3.1 (gh-99135)
Update bundled pip to 22.3.1
2022-11-05 17:50:39 +00:00
Nikita Sobolev 317acb8038
gh-94808: add tests covering `PyFunction_GetKwDefaults` and `PyFunction_SetKwDefaults` (GH-98809) 2022-11-05 17:08:47 +00:00
Nikita Sobolev c5c40773cb
gh-94808: add tests covering `PySequence_{Set,Del}Slice` (GH-99123) 2022-11-05 17:08:00 +00:00
Kaushik Kulkarni 67ade403a2
gh-98284: better error message for undefined abstractmethod (#97971) 2022-11-05 09:31:57 -07:00
Nikita Sobolev b5f711185b
gh-94808: add tests covering `PyEval_GetFuncDesc` function (GH-98300) 2022-11-05 13:07:59 +00:00
Victor Stinner f09da28768
gh-90867: test.support.wait_process() uses LONG_TIMEOUT (#99071)
The test.support.wait_process() function now uses a timeout of
LONG_TIMEOUT seconds by default, instead of SHORT_TIMEOUT.  It
doesn't matter if a Python buildbot is slower, it only matters that
the process completes. The timeout should just be shorter than
"forever".
2022-11-04 14:41:33 +01:00
Nikita Sobolev 044bcc1771
gh-94808: Cover `LOAD_GLOBAL` for custom dict subtypes (GH-96767) 2022-11-04 09:58:38 +00:00
Gregory P. Smith 4c4b5ce2e5
gh-90716: bugfixes and more tests for _pylong. (#99073)
* Properly decref on _pylong import error.
* Improve the error message on _pylong TypeError.
* Fix the assertion error in pydebug builds to be a TypeError.
* Tie the return value comments together.

These are minor followups to issues not caught among the reviewers on
https://github.com/python/cpython/pull/96673.
2022-11-03 16:18:38 -07:00
Victor Stinner 0faa0ba240
gh-92584: Remove the distutils package (#99061)
Remove the distutils package. It was deprecated in Python 3.10 by PEP
632 "Deprecate distutils module". For projects still using distutils
and cannot be updated to something else, the setuptools project can
be installed: it still provides distutils.

* Remove Lib/distutils/ directory
* Remove test_distutils
* Remove references to distutils
* Skip test_check_c_globals and test_peg_generator since they use
  distutils
2022-11-03 19:27:27 +01:00
Victor Stinner ef0e72b31d
gh-94172: Remove keyfile, certfile and check_hostname parameters (#94173)
Remove the keyfile, certfile and check_hostname parameters,
deprecated since Python 3.6, in modules: ftplib, http.client,
imaplib, poplib and smtplib. Use the context parameter (ssl_context
in imaplib) instead.

Parameters following the removed parameters become keyword-only
parameters.

ftplib: Remove the FTP_TLS.ssl_version class attribute: use the
context parameter instead.
2022-11-03 18:32:25 +01:00
Victor Stinner 9c4ae037b9
gh-90716: Remove _pylong._DEBUG flag (#99063)
To debug the _pylong module, it's trivial to add this code again
locally. There is not need to keep it in Python releases.
2022-11-03 18:16:28 +01:00
Nikita Sobolev e3b9832e57
gh-98884: [pathlib] remove `hasattr` check for `lru_cache` (#98885) 2022-11-03 17:14:12 +00:00
Victor Stinner e99c507013
gh-92584: Remove references to removed _bootsubprocess (#99062)
The _bootsubprocess module was removed in gh-93939
by commit 81dca70d70.
2022-11-03 18:12:45 +01:00
Victor Stinner a60ddd31be
gh-98401: Invalid escape sequences emits SyntaxWarning (#99011)
A backslash-character pair that is not a valid escape sequence now
generates a SyntaxWarning, instead of DeprecationWarning.  For
example, re.compile("\d+\.\d+") now emits a SyntaxWarning ("\d" is an
invalid escape sequence), use raw strings for regular expression:
re.compile(r"\d+\.\d+"). In a future Python version, SyntaxError will
eventually be raised, instead of SyntaxWarning.

Octal escapes with value larger than 0o377 (ex: "\477"), deprecated
in Python 3.11, now produce a SyntaxWarning, instead of
DeprecationWarning. In a future Python version they will be
eventually a SyntaxError.

codecs.escape_decode() and codecs.unicode_escape_decode() are left
unchanged: they still emit DeprecationWarning.

* The parser only emits SyntaxWarning for Python 3.12 (feature
  version), and still emits DeprecationWarning on older Python
  versions.
* Fix SyntaxWarning by using raw strings in Tools/c-analyzer/ and
  wasm_build.py.
2022-11-03 17:53:25 +01:00
Victor Stinner b8a9f13abb
gh-97616: test_list_resize_overflow() uses sys.maxsize (#99057) 2022-11-03 15:56:12 +01:00
Mark Shannon f4adb97506
GH-96793: Implement PEP 479 in bytecode. (GH-99006)
* Handle converting StopIteration to RuntimeError in bytecode.

* Add custom instruction for converting StopIteration into RuntimeError.
2022-11-03 11:38:51 +00:00
Serhiy Storchaka e9ac890c02
gh-98740: Fix validation of conditional expressions in RE (GH-98764)
In very rare circumstances the JUMP opcode could be confused with the
argument of the opcode in the "then" part which doesn't end with the
JUMP opcode. This led to incorrect detection of the final JUMP opcode
and incorrect calculation of the size of the subexpression.

NOTE: Changed return value of functions _validate_inner() and
_validate_charset() in Modules/_sre/sre.c.  Now they return 0 on success,
-1 on failure, and 1 if the last op is JUMP (which usually is a failure).
Previously they returned 1 on success and 0 on failure.
2022-11-03 09:23:46 +02:00
Nikita Sobolev 2cfcaf5af6
gh-98999: Raise `ValueError` in `_pyio` on closed buffers (gh-99009) 2022-11-03 12:03:12 +09:00
Nikita Sobolev 29e027c3e6
gh-98512: Add more tests for `ValuesView` (#98515) 2022-11-02 19:10:42 -07:00
Victor Stinner f3007ac370
gh-98393: Update test_os for bytes-like types (#98487)
Address Serhiy Storchaka's review.
2022-11-02 20:45:58 +01:00
Chaim Sanders e3ec272f57
gh-98415: Fix uuid.getnode() ifconfig implementation (#98423)
The uuid.getnode() function has multiple implementations, tested sequentially.
The ifconfig implementation was incorrect and always failed: fix it.

In practice, functions of libuuid library are preferred, if available:
uuid_generate_time_safe(), uuid_create() or uuid_generate_time().

Co-authored-by: Dong-hee Na <donghee.na92@gmail.com>
2022-11-02 19:41:20 +01:00
Steve Dower 3d889dc0a0
gh-98790: When DLLs directory is missing on Windows, assume executable_dir contains PYD files instead (GH-98936) 2022-11-02 18:38:40 +00:00
Brandt Bucher 276d77724f
GH-98686: Quicken everything (GH-98687) 2022-11-02 10:42:57 -07:00
Victor Stinner c76db37c0d
gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.

* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
2022-11-02 15:37:40 +01:00
Brett Cannon 9711265182
gh-98925: Lower marshal recursion depth for WASI (GH-98938)
For wasmtime 2.0, the stack depth cost is 6% higher. This causes the default max `marshal` recursion depth to blow the stack.

As the default marshal depth is 2000 and Windows is set to 1000, split the difference and choose 1500 for WASI to be safe.
2022-11-01 15:51:05 -07:00
Pablo Galindo Salgado 395d4285bf
gh-98931: Improve error message when the user types 'import x from y' instead of 'from y import x' (#98932) 2022-11-01 13:01:20 +00:00
Serhiy Storchaka 0e15c31c7e
gh-98852: Fix subscription of type aliases (GH-98920)
Fix subscription of type aliases containing bare generic types or types
like TypeVar: for example tuple[A, T][int] and tuple[TypeVar, T][int],
where A is a generic type, and T is a type variable.
2022-11-01 09:33:09 +02:00
Raymond Hettinger f5afb7f233
GH-98766: Modest speed-up from ChainMap.__iter__ (GH-98946) 2022-10-31 23:44:40 -05:00
Jelle Zijlstra 5cf317ade1
gh-98658: Add __class_getitem__ to array.array (#98661)
Closes #98658
2022-10-31 21:10:18 -07:00
Kumar Aditya ab57505070
GH-98897: fix memory leak if `math.dist` raises exception (GH-98898) 2022-10-31 21:18:32 -05:00
Steve Dower 88297e2a8a
gh-98692: Enable treating shebang lines as executables in py.exe launcher (GH-98732) 2022-10-31 21:05:50 +00:00
Eric Snow 4702552885
gh-98610: Adjust the Optional Restrictions on Subinterpreters (GH-98618)
Previously, the optional restrictions on subinterpreters were: disallow fork, subprocess, and threads.  By default, we were disallowing all three for "isolated" interpreters.  We always allowed all three for the main interpreter and those created through the legacy `Py_NewInterpreter()` API.

Those settings were a bit conservative, so here we've adjusted the optional restrictions to: fork, exec, threads, and daemon threads.  The default for "isolated" interpreters disables fork, exec, and daemon threads.  Regular threads are allowed by default.  We continue always allowing everything For the main interpreter and the legacy API.

In the code, we add `_PyInterpreterConfig.allow_exec` and  `_PyInterpreterConfig.allow_daemon_threads`.  We also add `Py_RTFLAGS_DAEMON_THREADS` and `Py_RTFLAGS_EXEC`.
2022-10-31 12:35:54 -07:00
Batuhan Taskaya a41de32942
gh-98878: Use builtins from the bound frame when offering a suggestion (#98880) 2022-10-31 13:27:13 +00:00
Irit Katriel 39448adc9d
gh-98811: use full source location to simplify __future__ imports error checking. This also fixes an incorrect error offset. (GH-98812) 2022-10-31 13:08:03 +00:00
Shantanu 29f98b46b7
gh-96151: Use a private name for passing builtins to dataclass. This now allows for a field named BUILTIN (gh-98143) 2022-10-31 08:31:01 -04:00
Nick Coghlan 05e48865be
gh-96853: Restore test coverage for Py_Initialize(Ex) (GH-98212)
* As most of `test_embed` now uses `Py_InitializeFromConfig`, add
  a specific test case to cover `Py_Initialize` (and `Py_InitializeEx`)
* Rename `_testembed` init helper to clarify the API used
* Add a `PyConfig_Clear` call in `Py_InitializeEx` to make
  the code more obviously correct (it already didn't leak as
  none of the dynamically allocated config fields were being
  populated, but it's clearer if the wrappers follow the
  documented API usage guidelines)
2022-10-30 22:01:30 +10:00
Nikita Sobolev 76f989dc3e
gh-98783: Fix crashes when `str` subclasses are used in `_PyUnicode_Equal` (#98806) 2022-10-30 02:23:20 -04:00
Charlie Zhao 3ac8c0ab6e
gh-98793: Fix typecheck in `overlapped.c` (#98835)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2022-10-29 21:34:46 -07:00
Kumar Aditya 9bdec0aa45
GH-90352: fix _SelectorDatagramTransport to inherit from DatagramTransport (#98844) 2022-10-29 09:43:42 -07:00
Batuhan Taskaya c0f2a5ef91
gh-98744: Prevent column-level decoding crashes on traceback module (#98824) 2022-10-29 13:28:20 +01:00
FC Stegerman 7ea10567af
gh-98286: handle empty filename in ZipFile/ZipInfo properly (#98346)
effectively code modernization and a meaningful exception.
2022-10-28 22:45:46 -07:00
domragusa e089f23bbb
gh-84538: add strict argument to pathlib.PurePath.relative_to (GH-19813)
By default, :meth:`pathlib.PurePath.relative_to` doesn't deal with paths that are not a direct prefix of the other, raising an exception in that instance. This change adds a *walk_up* parameter that can be set to allow for using ``..`` to calculate the relative path.

example:
```
>>> p = PurePosixPath('/etc/passwd')
>>> p.relative_to('/etc')
PurePosixPath('passwd')
>>> p.relative_to('/usr')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "pathlib.py", line 940, in relative_to
    raise ValueError(error_message.format(str(self), str(formatted)))
ValueError: '/etc/passwd' does not start with '/usr'
>>> p.relative_to('/usr', strict=False)
PurePosixPath('../etc/passwd')
```


https://bugs.python.org/issue40358

Automerge-Triggered-By: GH:brettcannon
2022-10-28 16:20:14 -07:00
Gareth Rees 7ee3aca00a
gh-92452: Avoid race in initialization of sysconfig._CONFIG_VARS
Co-authored-by: Filipe Laíns <lains@riseup.net>
2022-10-28 19:17:04 +01:00
noah-weingarden 0346eddbe9
gh-98624 Add mutex to unittest.mock.NonCallableMock (#98688)
* Added lock to NonCallableMock in unittest.mock

* Add blurb

* Nitpick blurb

* Edit comment based on @Jason-Y-Z's review

* Add link to GH issue
2022-10-28 08:51:18 +01:00
Mark Shannon 22863df7ca
GH-96793: Change `FOR_ITER` to not pop the iterator on exhaustion. (GH-96801)
Change FOR_ITER to have the same stack effect regardless of whether it branches or not.
Performance is unchanged as FOR_ITER (and specialized forms jump over the cleanup code).
2022-10-27 11:55:03 +01:00
Wenzel Jakob e60892f9db
gh-98586: Add vector call APIs to the Limited API (GH-98587)
Expose the facilities for making vector calls through Python's limited API.
2022-10-27 11:45:42 +02:00
Kumar Aditya 96ae80f1d0
gh-98703: Add tests for closing `_ProactorSocketTransport` with proactor event loop (GH-98730) 2022-10-27 11:07:31 +08:00
Ken Jin 8a755423eb
gh-98703: Fix asyncio proactor_events calling _call_connection_lost multiple times (GH-98704)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2022-10-27 10:37:12 +08:00
Nikita Sobolev 7b24333fff
gh-94808: cover `PyFunction_GetDefaults` and `PyFunction_SetDefaults` (#98449) 2022-10-26 17:47:29 -07:00
Henry Schreiner a508631b3c
gh-98741: Remove useless check_home usage from is_python_build usage (GH-98743) 2022-10-26 22:40:47 +01:00
Nikita Sobolev 6777e09166
gh-98727: Remove old style classes from `test_cmath` (GH-98728) 2022-10-26 19:08:34 +01:00
Eric Snow f32369480d
gh-98608: Change _Py_NewInterpreter() to _Py_NewInterpreterFromConfig() (gh-98609)
(see https://github.com/python/cpython/issues/98608)

This change does the following:

1. change the argument to a new `_PyInterpreterConfig` struct
2. rename the function to `_Py_NewInterpreterFromConfig()`, inspired by `Py_InitializeFromConfig()` (takes a `_PyInterpreterConfig`  instead of `isolated_subinterpreter`)
3. split up the boolean `isolated_subinterpreter` into the corresponding multiple granular settings
   * allow_fork
   * allow_subprocess
   * allow_threads
4. add `PyInterpreterState.feature_flags` to store those settings
5. add a function for checking if a feature is enabled on an opaque `PyInterpreterState *`
6. drop `PyConfig._isolated_interpreter`

The existing default (see `Py_NewInterpeter()` and `Py_Initialize*()`) allows fork, subprocess, and threads and the optional "isolated" interpreter (see the `_xxsubinterpreters` module) disables all three.  None of that changes here; the defaults are preserved.

Note that the given `_PyInterpreterConfig` will not be used outside `_Py_NewInterpreterFromConfig()`, nor preserved.  This contrasts with how `PyConfig` is currently preserved, used, and even modified outside `Py_InitializeFromConfig()`.  I'd rather just avoid that mess from the start for `_PyInterpreterConfig`.  We can preserve it later if we find an actual need.

This change allows us to follow up with a number of improvements (e.g. stop disallowing subprocess and support disallowing exec instead).

(Note that this PR adds "private" symbols.  We'll probably make them public, and add docs, in a separate change.)
2022-10-26 11:16:30 -06:00
Nikita Sobolev 9495360c72
gh-98713: Use `@cpython_only` for a test that fails on PyPy (#98714)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2022-10-26 14:15:39 +01:00
Neil Schemenauer de6981680b
gh-90716: add _pylong.py module (#96673)
Add Python implementations of certain longobject.c functions. These use
asymptotically faster algorithms that can be used for operations on
integers with many digits. In those cases, the performance overhead of
the Python implementation is not significant since the asymptotic
behavior is what dominates runtime. Functions provided by this module
should be considered private and not part of any public API.

Co-author: Tim Peters <tim.peters@gmail.com>
Co-author: Mark Dickinson <dickinsm@gmail.com>
Co-author: Bjorn Martinsson
2022-10-25 22:00:50 -07:00
Nikita Sobolev 5d30544485
gh-94808: cover `PyMapping_HasKeyString` and `PyMapping_HasKey` (#98486) 2022-10-25 21:33:32 -07:00
Nikita Sobolev b1783bc124
gh-94808: Improve coverage of `unicode_find` and `unicode_rfind` (#98648) 2022-10-25 16:37:53 -07:00
Pablo Galindo Salgado 7cfbb49fcd
gh-91058: Add error suggestions to 'import from' import errors (#98305) 2022-10-25 23:56:59 +01:00
Matthew Rahtz cb95cc24ef
GH-87390: Add remaining tests for PEP 646 (#98267)
Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>
2022-10-25 07:44:30 -07:00
Nikita Sobolev 45c89358b7
Use more precise exception types in `assertRaises` in typing tests (#98650) 2022-10-25 06:33:34 -07:00
James Gerity d91de288e7
gh-93696: Locate frozen module source with __file__ (#93697)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2022-10-25 06:22:53 -07:00
Irit Katriel a1a8828e42
gh-98461: Fix location of RETURN_VALUE in async generator bytecode. compiler_jump_if no longer needs a pointer to the loc. (GH-98494) 2022-10-25 12:26:26 +01:00
Thomas Wouters 4ae1a0ecaf Python 3.12.0a1 2022-10-25 00:08:22 +02:00
Kumar Aditya ad1dc3ebb6
GH-89237: fix hang in proactor `subprocess.wait_closed()` (#98572) 2022-10-24 13:21:42 -07:00
Kumar Aditya 3b2724abcf
GH-98407: fix `test_kill_issue43884` to not leak child processes (#98491) 2022-10-24 10:50:35 -07:00
Serhiy Storchaka 75a6fadf36
gh-91524: Speed up the regular expression substitution (#91525)
Functions re.sub() and re.subn() and corresponding re.Pattern methods
are now 2-3 times faster for replacement strings containing group references.

Closes #91524

Primarily authored by serhiy-storchaka Serhiy Storchaka
Minor-cleanups-by: Gregory P. Smith [Google] <greg@krypto.org>
2022-10-23 15:57:30 -07:00
Kumar Aditya 62bf5d8d0a
GH-98539: fix ref cycle in `_SSLProtocolTransport` after close (#98540) 2022-10-22 09:11:27 -07:00
Kumar Aditya f4a14941e6
GH-98543: Fix `asyncio.TaskGroup` to not keep reference to errors after raising ExceptionGroup (#98544) 2022-10-22 09:05:11 -07:00
Stanley d9407b174c
gh-51511: Note that codecs.open()'s encoding parameter affects automatic conversion to binary mode (#94370) 2022-10-21 16:01:05 -07:00
Raymond Hettinger a5ff80c8bc
GH-98363: Fix exception handling in batched() (GH-98523) 2022-10-21 12:31:52 -05:00
Victor Stinner ec1f6f5f13
gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
2022-10-21 16:21:36 +02:00
Carl Meyer 82ccbf69a8
gh-91051: allow setting a callback hook on PyType_Modified (GH-97875) 2022-10-21 14:41:51 +01:00
Gregory P. Smith 49f61068f4
gh-97514: Don't use Linux abstract sockets for multiprocessing (#98501)
Linux abstract sockets are insecure as they lack any form of filesystem
permissions so their use allows anyone on the system to inject code into
the process.

This removes the default preference for abstract sockets in
multiprocessing introduced in Python 3.9+ via
https://github.com/python/cpython/pull/18866 while fixing
https://github.com/python/cpython/issues/84031.

Explicit use of an abstract socket by a user now generates a
RuntimeWarning.  If we choose to keep this warning, it should be
backported to the 3.7 and 3.8 branches.
2022-10-20 15:30:09 -07:00
Dennis Sweeney 39bc70e267
gh-97912: Avoid quadratic behavior when adding LOAD_FAST_CHECK (GH-97952)
* The compiler analyzes the usage of the first 64 local variables all at once using bit masks.

* Local variables beyond the first 64 are only partially analyzed, achieving linear time.
2022-10-20 18:27:41 -04:00
Ben Kallus 6f15ca8c7a
gh-96035: Make urllib.parse.urlparse reject non-numeric ports (#98273)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-10-20 14:00:56 -07:00
Irit Katriel 4ec9ed8fde
gh-98461: Fix source location in comprehensions bytecode (GH-98464) 2022-10-20 16:58:37 +01:00
Steve Dower e48f9b2b7e
gh-98360: multiprocessing now spawns children on Windows with correct argv[0] in virtual environments (GH-98462) 2022-10-20 14:53:38 +01:00
Serhiy Storchaka ff173ed2f6
Add more tkinter.Canvas tests (GH-98475)
It is a prerequisite for #94473. Add tests for the coords() method and
for creation of some Canvas items.
2022-10-20 13:43:12 +03:00
Noam Cohen a371a7e03e
gh-95023: Added os.setns and os.unshare functions (#95046)
Added os.setns and os.unshare to easily switch between namespaces
on Linux.

Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: CAM Gerlach <CAM.Gerlach@Gerlach.CAM>
Co-authored-by: Victor Stinner <vstinner@python.org>
2022-10-20 11:08:54 +02:00
Dong-hee Na 4156b2fc13
gh-98374: Suppress ImportError for invalid query for help() command. (gh-98450) 2022-10-20 10:56:21 +09:00
Nikita Sobolev 1ca6647f22
typing tests: `_overload_dummy` raises `NotImplementedError`, not `RuntimeError` (#98351) 2022-10-19 17:53:36 -07:00
chgnrdv 1f369ad07f
gh-98354: Add unicode check for 'name' attribute in _imp_create_builtin (GH-98412)
Fixes #98354
2022-10-19 17:25:10 -07:00
Victor Stinner a8fe4bbd6b
gh-98257: Make _PyEval_SetTrace() reentrant (#98258)
Make sys.setprofile() and sys.settrace() functions reentrant.  They
can no long fail with: RuntimeError("Cannot install a trace function
while another trace function is being installed").

Make _PyEval_SetTrace() and _PyEval_SetProfile() functions reentrant,
rather than detecting and rejecting reentrant calls. Only delete the
reference to function arguments once the new function is fully set,
when a reentrant call is safe. Call also _PySys_Audit() earlier.
2022-10-20 00:31:47 +02:00
Steve Dower 4bd63f66cd
gh-98414: py.exe launcher does not use defaults for -V:company/ option (GH-98460) 2022-10-19 23:00:09 +01:00
Jack Hindmarch b6e59d76c0
gh-92886: Replace assertion statements in `handlers.BaseHandler` to support running with optimizations (`-O`) (GH-93231) 2022-10-19 11:38:59 +01:00
Jack Hindmarch a3be874334
gh-92886: Fix tests that fail when running with optimizations (`-O`) in `_test_multiprocessing.py` (GH-93233) 2022-10-19 11:07:07 +01:00
Jack Hindmarch 602ea40d89
gh-92886: Fix tests that fail when running with optimizations (`-O`) in `test_py_compile.py` (GH-93235) 2022-10-19 11:05:08 +01:00
Irit Katriel 9be05df399
gh-98398: Fix source locations for 'assert' bytecode (GH-98405) 2022-10-19 10:48:50 +01:00
Serhiy Storchaka e4ec8de6fa
gh-97928: Fix handling options starting with "-" in tkinter.Text.count() (GH-98436)
Previously they were silently ignored. Now they are errors.
2022-10-19 12:30:14 +03:00
Serhiy Storchaka 1b684c8f5f
gh-97928: Add tests for tkinter.Text.count() (GH-98269) 2022-10-19 09:17:45 +03:00
Irit Katriel c051d55ddb
gh-98390: Fix source locations of boolean sub-expressions (GH-98396) 2022-10-18 17:18:38 +01:00
Jack Hindmarch debacd9ad5
gh-92886: Fixing tests that fail when running with optimizations (`-O`) in `test_sys_settrace.py` (GH-93234) 2022-10-18 16:59:05 +01:00
Victor Stinner db03c8066a
gh-98393: os module reject bytes-like, only accept bytes (#98394)
The os module and the PyUnicode_FSDecoder() function no longer accept
bytes-like paths, like bytearray and memoryview types: only the exact
bytes type is accepted for bytes strings.
2022-10-18 17:52:31 +02:00
Paul Moore 9da5215000
gh-98331: Update bundled pip to 22.3 (#98332) 2022-10-18 15:48:14 +01:00
Alex Zvorygin 6ccca69d0d
gh-98378: Add small format string example to strftime comments (GH-98379)
A small example of what a full date and time would look like would help a lot of developers who may not realize that they should investigate `time.h`'s `strftime`, run `man strftime`, or click through a series of docs on the python docs before they get to the actual [definition here](https://docs.python.org/3/library/datetime.html#strftime-and-strptime-format-codes) which still doesn't have an obvious copy-pastable example of "what the heck format does this thing actually expect?".

Automerge-Triggered-By: GH:rhettinger
2022-10-18 06:42:10 -07:00
Raymond Hettinger de3ece769a
GH-98363: Add itertools.batched() (GH-98364) 2022-10-17 18:53:45 -05:00
fancidev 3e82ad05b1
gh-98174: Handle EPROTOTYPE under macOS in test_sendfile_fallback_close_peer_in_the_middle_of_receiving (#98316)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2022-10-17 08:45:38 -07:00
Kumar Aditya 72c10d3f1a
GH-98327: Reduce scope of catch_warnings() in _make_subprocess_transport (#98333)
Alas, warnings.catch_warnings() has global scope, not thread scope, so this is still not perfect, but it reduces the time during which warnings are ignored. Better solution welcome.
2022-10-17 08:27:02 -07:00
Victor Stinner 1863302d61
gh-97669: Create Tools/build/ directory (#97963)
Create Tools/build/ directory. Move the following scripts from
Tools/scripts/ to Tools/build/:

* check_extension_modules.py
* deepfreeze.py
* freeze_modules.py
* generate_global_objects.py
* generate_levenshtein_examples.py
* generate_opcode_h.py
* generate_re_casefix.py
* generate_sre_constants.py
* generate_stdlib_module_names.py
* generate_token.py
* parse_html5_entities.py
* smelly.py
* stable_abi.py
* umarshal.py
* update_file.py
* verify_ensurepip_wheels.py

Update references to these scripts.
2022-10-17 12:01:00 +02:00
Ruben Vorderman eae7dad402
gh-95534: Improve gzip reading speed by 10% (#97664)
Change summary:
+ There is now a `gzip.READ_BUFFER_SIZE` constant that is 128KB. Other programs that read in 128KB chunks: pigz and cat. So this seems best practice among good programs. Also it is faster than 8 kb chunks.
+ a zlib._ZlibDecompressor was added. This is the _bz2.BZ2Decompressor ported to zlib. Since the zlib.Decompress object is better for in-memory decompression, the _ZlibDecompressor is hidden. It only makes sense in file decompression, and that is already implemented now in the gzip library. No need to bother the users with this.
+ The ZlibDecompressor uses the older Cpython arrange_output_buffer functions, as those are faster and more appropriate for the use case. 
+ GzipFile.read has been optimized. There is no longer a `unconsumed_tail` member to write back to padded file. This is instead handled by the ZlibDecompressor itself, which has an internal buffer. `_add_read_data` has been inlined, as it was just two calls.

EDIT: While I am adding improvements anyway, I figured I could add another one-liner optimization now to the python -m gzip application. That read chunks in io.DEFAULT_BUFFER_SIZE previously, but has been updated now to use READ_BUFFER_SIZE chunks.
2022-10-16 19:10:58 -07:00
Jason R. Coombs cea910ebf1
gh-97930: Merge with importlib_resources 5.9 (GH-97929)
* Merge with importlib_resources 5.9

* Update changelog
2022-10-16 15:00:39 -04:00
Terry Jan Reedy 35fa5d5e7f
gh-97527: IDLE - fix buggy macosx patch (#98313)
#97530 fixed IDLE tests possibly crashing on a Mac without a GUI.
But it resulted in IDLE not starting in 3.10.8, 3.12.0a1, and
Microsoft Python 3.10.2288.0 when test/* is not installed.
After this patch, test.* is only imported when testing on Mac.
2022-10-16 10:23:11 -04:00
Vinay Sajip f6b1e4048d
gh-98307: Add docstring and documentation for SysLogHandler.createSocket (GH-98319)
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
2022-10-16 09:15:46 +01:00
Nikita Sobolev 7b48d02933
gh-94808: Cover `PyFunction_GetCode`, `PyFunction_GetGlobals`, `PyFunction_GetModule` (#98158) 2022-10-15 21:18:59 -07:00
Kumar Aditya 660f10248b
GH-94597: Deprecate child watcher getters and setters (#98215)
This is the next step for deprecating child watchers.

Until we've removed the API completely we have to use it, so this PR is mostly suppressing a lot of warnings when using the API internally.

Once the child watcher API is totally removed, the two child watcher implementations we actually use and need (Pidfd and Thread) will be turned into internal helpers.
2022-10-15 16:09:30 -07:00
Pablo Galindo Salgado bb56dead33
gh-98254: Include stdlib module names in error messages for NameErrors (#98255) 2022-10-15 23:13:33 +01:00
Nikita Sobolev b7dd2cad18
gh-94808: Cover `str.rsplit` for UCS1, UCS2 or UCS4 (#98228) 2022-10-15 11:40:22 -07:00
Nikita Sobolev f01b56c7bd
gh-94808: Cover `PyEval_GetFuncName` (#98246) 2022-10-15 08:20:39 -07:00
Jakub Kuczys 120b4ab2b6
gh-95731: Fix module docstring extraction in pygettext (#95732) 2022-10-15 07:57:53 -07:00
Jeong YunWon 07b5c4699e
gh-95971: Turn @writes_bytecode_files to skip when not running (#95972)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-10-15 07:57:06 -07:00
Joannah Nanjekye bf786e6901
gh-85455: Add missing doc strings and improve docs (#21573)
* Add missing doc strings and improve docs

* Use imperative form

* Modify docstring wording
2022-10-15 09:31:06 -04:00
Joannah Nanjekye 05c042e707
gh-85525: Indicate supported sound header formats (#21575)
* Indicate supported sound header formats

* modify file names

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-10-15 09:30:05 -04:00
Steve Dower 2fe44f728a
gh-98251: Allow venv to pass along PYTHON* variables to pip and ensurepip when they do not impact path resolution (GH-98259) 2022-10-14 16:58:54 +01:00
Tony Solomonik b863b9cd4b
Bpo-41246: IOCP Proactor avoid callback code duplication (#21399)
Use the same callback function for overlapped operations recv, recv_into, recvfrom, sendto, send, and sendfile inside IocpProactor.
2022-10-13 11:05:16 -07:00
Christoph Hamsen c9ed0327a9
bpo-46364: Use sockets for stdin of asyncio only on AIX (#30596)
Signed-off-by: Christoph Hamsen <hamsen.christoph@posteo.de>
Co-authored-by: July Tikhonov <july.tikh@gmail.com>
2022-10-13 09:11:15 -07:00
Nikita Sobolev ccab67ba79
gh-97982: Factorize PyUnicode_Count() and unicode_count() code (#98025)
Add unicode_count_impl() to factorize PyUnicode_Count()
and unicode_count() code.
2022-10-12 18:27:53 +02:00
Victor Stinner a8c8526fd8
gh-97669: Fix test_tools reference leak (#98216)
test_tools.test_sundry() now uses an unittest mock to prevent the
logging module to register a real "atfork" function which kept the
logging module dictionary alive. So the logging module can be
properly unloaded. Previously, the logging module was loaded before
test_sundry(), but it's no longer the case since recent test_tools
sub-tests removals.
2022-10-12 17:26:21 +02:00
Victor Stinner 0895c2a066
gh-97669: Create Tools/patchcheck/ directory (#98186)
Move patchcheck.py, reindent.py and untabify.py scripts to a new
Tools/patchcheck/ directory.
2022-10-12 10:09:21 +02:00
Victor Stinner e0ae9ddffe
gh-97669: Remove outdated example scripts (#97675) (#98167)
Remove outdated example scripts of the Tools/scripts/ directory:

* gprof2html.py
* md5sum.py
* nm2def.py
* pathfix.py
* win_add2path.py

Remove test_gprof2html, test_md5sum and test_pathfix of test_tools.
2022-10-11 10:07:57 +02:00
Michael Droettboom dfcdee4a18
gh-94808: Add coverage for bytesarray_setitem (#95802) 2022-10-10 08:28:41 -07:00
Carl Meyer ad817cd5c4
bpo-43564: preserve original exception in args of FTP URLError (#24938)
* bpo-43564: preserve original error in args of FTP URLError

* Add NEWS blurb

Co-authored-by: Carl Meyer <carljm@instagram.com>
2022-10-09 18:59:07 -07:00
Kumar Aditya d8765284f3
GH-94597: deprecate `SafeChildWatcher`, `FastChildWatcher` and `MultiLoopChildWatcher` child watchers (#98089) 2022-10-08 13:52:19 -07:00
Pablo Galindo Salgado 83eb827247
gh-97922: Run the GC only on eval breaker (#97920) 2022-10-08 07:57:09 -07:00
Carl Meyer e82d977eb0
gh-91052: Add PyDict_Unwatch for unwatching a dictionary (#98055) 2022-10-07 17:37:46 -07:00
Kumar Aditya 8ba9378b16
GH-98023: Change default child watcher to PidfdChildWatcher on supported systems (#98024) 2022-10-07 17:29:09 -07:00
Thomas Grainger 3d8b224547
GH-94182: Run the PidfdChildWatcher on the running loop (#94184)
There is no reason for this watcher to be attached to any particular loop.
This should make it safe to use regardless of the lifetime of the event loop running in the main thread
(relative to other loops).

Co-authored-by: Yury Selivanov <yury@edgedb.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-10-07 17:24:01 -07:00
Irit Katriel 27ce45d8e1
gh-92886: make test_ast pass with -O (assertions off) (GH-98058)
-O does not strip docstrings.

Automerge-Triggered-By: GH:iritkatriel
2022-10-07 16:30:23 -07:00
Irit Katriel 45f21472da
gh-92886: make test_coroutines pass with -O (assertions off) (GH-98060)
Automerge-Triggered-By: GH:iritkatriel
2022-10-07 16:12:28 -07:00
Stanley 0f498f1a95
gh-57179: Add note on symlinks for os.walk (#94799) 2022-10-07 15:51:50 -07:00
Jelle Zijlstra a54a69989e
gh-94808: Fix regex on exotic platforms (#98036)
The test failed on a buildbot because the pointer was only 7 hex characters. To be safe,
I bumped it down to 3: 4 in case we have 32-bit platforms, and 3 in case the pointer is very small.
2022-10-07 15:39:53 -07:00
Shantanu cb4615fd43
gh-90085: Remove vestigial -t and -c timeit options (#94941)
See bpo-28240. The functionality was removed in 3d7feb9ac2.
The options had been deprecated since Python 3.3
2022-10-07 15:38:20 -07:00
Frazer McLean f4f8133387
GH-83901: Improve Signature.bind error message for missing keyword-only params (#95347)
Fixes GH-83901
2022-10-07 15:24:17 -07:00
Irit Katriel 34e6f3567e
gh-92886: [clinic.py] raise exception on invalid input instead of assertion (GH-98051)
Tests should pass with -O (assertions off).

Automerge-Triggered-By: GH:iritkatriel
2022-10-07 14:41:35 -07:00
Guido van Rossum c06276402b
GH-88968: Reject socket that is already used as a transport (#98010) 2022-10-07 12:56:50 -07:00
Serhiy Storchaka c11b667a1d
gh-96346: Use double caching for re._compile() (#96347) 2022-10-07 12:21:42 -07:00
Noam Cohen 2a168355f0
gh-97646: Change `.js` and `.mjs` files mimetype to conform to RFC 9239 (#97934) 2022-10-07 12:00:53 -07:00