Commit Graph

27498 Commits

Author SHA1 Message Date
Carey Metcalfe 798bcaa1eb
gh-103861: Fix Zip64 extensions not being properly applied in some cases (#103863)
Fix Zip64 extensions not being properly applied in some cases:

Fixes an issue where adding a small file to a `ZipFile`
object while forcing zip64 extensions causes an extra Zip64 record to be
added to the zip, but doesn't update the `min_version` or file sizes in
the primary central directory header.

Also fixed an edge case in checking if zip64 extensions are required:

This fixes an issue where if data requiring zip64 extensions was added
to an unseekable stream without specifying `force_zip64=True`, zip64
extensions would not be used and a RuntimeError would not be raised when
closing the file (even though the size would be known at that point).
This would result in successfully writing corrupt zip files.

Deciding if zip64 extensions are required outside of the `FileHeader`
function means that both `FileHeader` and `_ZipWriteFile` will always be
in sync. Previously, the `FileHeader` function could enable zip64
extensions without propagating that decision to the `_ZipWriteFile`
class, which would then not correctly write the data descriptor record
or check for errors on close.

If anyone is actually using `ZipInfo.FileHeader` as a public API without
explicitly passing True or False in for zip64, their own code may still be
susceptible to that kind of bug unless they make a similar change to
where the zip64 decision happens.

Fixes #103861

---------

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-05-16 00:43:44 -07:00
Alexey Namyotkin 85ec192ac4
gh-69152: add method get_proxy_response_headers to HTTPConnection class (#104248)
Add http.client.HTTPConnection method get_proxy_response_headers() - this is a followup to https://github.com/python/cpython/pull/26152 which added it as a non-public attribute. This way we don't pre-compute a headers dictionary that most users will never access. The new method is properly public and documented and triggers full proxy header parsing into a dict only when actually called.

---------

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-05-16 06:20:30 +00:00
Jelle Zijlstra 24d8b88420
gh-103763: Implement PEP 695 (#103764)
This implements PEP 695, Type Parameter Syntax. It adds support for:

- Generic functions (def func[T](): ...)
- Generic classes (class X[T](): ...)
- Type aliases (type X = ...)
- New scoping when the new syntax is used within a class body
- Compiler and interpreter changes to support the new syntax and scoping rules 

Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
Co-authored-by: Eric Traut <eric@traut.com>
Co-authored-by: Larry Hastings <larry@hastings.org>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-05-15 20:36:23 -07:00
Christopher Chavez fdafdc235e
gh-104461: Run tkinter test_configure_screen on X11 only (GH-104462) 2023-05-15 22:22:53 -04:00
Irit Katriel 8a3702f0c7
gh-104482: Fix error handling bugs in ast.c (#104483) 2023-05-15 21:53:55 +01:00
Barney Gale cb88ae635e
GH-102613: Fix recursion error from `pathlib.Path.glob()` (GH-104373)
Use `Path.walk()` to implement the recursive wildcard `**`. This method
uses an iterative (rather than recursive) walk - see GH-100282.
2023-05-15 18:33:32 +01:00
Erlend E. Aasland 186bf39f5c
gh-101819: Isolate `_io` (#101948)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2023-05-15 09:26:27 +00:00
Christopher Chavez 3cba61f111
gh-104494: Update certain Tkinter pack/place tests for Tk 8.7 errors (#104495)
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2023-05-15 04:54:41 -04:00
Gregory Szorc a6bcc8fb92
gh-104490: Consistently define phony make targets (#104491)
By convention make targets that don't refer to a file have a dependency
on the fake .PHONY target/file. This ensures that these targets are
always evaluated because there is no rule to create a .PHONY file
and that will force make to think the rule is out of date and needs
to be rebuilt.

This commit consistently associates virtual targets with .PHONY by
declaring the .PHONY dependency immediately above the make rule. This
should avoid race conditions and avoidable rebuilds across multiple make
invocations.
2023-05-15 08:48:34 +00:00
Irit Katriel b15a1a6ac6
gh-67056: document that registering/unregistering an atexit func from within an atexit func is undefined (#104473) 2023-05-15 09:12:52 +01:00
Erlend E. Aasland 146106a0f1
gh-104487: PYTHON_FOR_REGEN must be minimum Python 3.10 (#104488)
Also include Python 3.12 in the list of accepted versions.
2023-05-15 08:02:44 +00:00
Brandt Bucher 1eb950ca55
GH-104405: Add missing PEP 523 checks (GH-104406) 2023-05-12 22:23:13 +00:00
Charles Machalow 79b17f2cf0
gh-103333: Pickle the keyword attributes of AttributeError (#103352)
* Pickle the `name` and `args` attributes of AttributeError when present.

Co-authored-by: Gregory P. Smith <greg@krypto.org>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2023-05-12 13:33:23 -07:00
Ben Kallus cf720acfcb
gh-103204: `http.server` - Enforce that HTTP version numbers must consist only of digits (#103205)
Reject HTTP requests with invalid http/x.y version numbers: x or y being non-digits or too-long.

---------

Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-05-12 13:25:58 -07:00
Hugo van Kemenade 25db95d224
gh-103857: Update deprecation stacktrace to point to calling line (#104431) 2023-05-12 22:25:45 +04:00
Paul Ganssle d50c37d8ad
GH-86275: Implementation of hypothesis stubs for property-based tests, with zoneinfo tests (#22863)
These are stubs to be used for adding hypothesis (https://hypothesis.readthedocs.io/en/latest/) tests to the standard library.

When the tests are run in an environment where `hypothesis` and its various dependencies are not installed, the stubs will turn any tests with examples into simple parameterized tests and any tests without examples are skipped.

It also adds hypothesis tests for the `zoneinfo` module, and a Github Actions workflow to run the hypothesis tests as a non-required CI job.

The full hypothesis interface is not stubbed out — missing stubs can be added as necessary.

Co-authored-by: Zac Hatfield-Dodds <zac.hatfield.dodds@gmail.com>
2023-05-12 08:35:53 -04:00
Mark Shannon 45f5aa8fc7
GH-103082: Filter LINE events in VM, to simplify tool implementation. (GH-104387)
When monitoring LINE events, instrument all instructions that can have a predecessor on a different line.
Then check that the a new line has been hit in the instrumentation code.
This brings the behavior closer to that of 3.11, simplifying implementation and porting of tools.
2023-05-12 12:21:20 +01:00
Erlend E. Aasland b2c1b4da19
gh-104389: Add 'unused' keyword to Argument Clinic C converters (#104390)
Use the unused keyword param in the converter to explicitly
mark an argument as unused:

    /*[clinic input]
    SomeBaseClass.stubmethod
        flag: bool(unused=True)
    [clinic start generated code]*/
2023-05-12 10:34:00 +02:00
Jelle Zijlstra 37a5d256b9
gh-104392: Remove _paramspec_tvars from typing (#104393)
This does nothing.
2023-05-11 16:41:26 -07:00
James Gerity 0449ffe3a4
gh-104301: Allow leading whitespace in disambiguated pdb statements (#104342) 2023-05-11 18:12:02 +01:00
Carey Metcalfe 4abfe6a14b
GH-92184: Convert os.altsep to '/' in filenames when creating ZipInfo objects (#92185)
This causes the zipfile module to also consider the character defined by
`os.altsep` (if there is one) to be a path separator and convert it to a
forward slash, as defined by the zip specification.

A logical no-op on all known platforms today as os.altsep is currently only set to a meaningful value on Windows (where it is "/").
2023-05-11 07:25:16 +00:00
Barney Gale 94f30c7557
GH-90208: Suppress OSError exceptions from `pathlib.Path.glob()` (GH-104141)
`pathlib.Path.glob()` now suppresses all OSError exceptions, except
those raised from calling `is_dir()` on the top-level path.

Previously, `glob()` suppressed ENOENT, ENOTDIR, EBADF and ELOOP
errors and their Windows equivalents. PermissionError was also
suppressed unless it occurred when calling `is_dir()` on the
top-level path. However, the selector would abort prematurely
if a PermissionError was raised, and so `glob()` could return
incomplete results.
2023-05-11 01:01:39 +01:00
Alex Waygood 7b8d7f56b6
gh-103000: Optimise `dataclasses.asdict` for the common case (#104364)
Co-authored-by: David Ellis <ducksual@gmail.com>
2023-05-10 22:43:51 +01:00
Christopher Chavez e464ec9f4c
gh-103538: Remove unused TK_AQUA code (GH-103539) 2023-05-10 18:53:13 +00:00
Barney Gale a33ce66dca
GH-87695: Fix OSError from `pathlib.Path.glob()` (GH-104292)
Fix issue where `pathlib.Path.glob()` raised `OSError` when it encountered
a symlink to an overly long path.
2023-05-10 17:17:08 +00:00
Sebastian Berg 7a3b03509e
gh-104263: Rely on Py_NAN and introduce Py_INFINITY (GH-104202)
This PR removes `_Py_dg_stdnan` and `_Py_dg_infinity` in favour of
using the standard `NAN` and `INFINITY` macros provided by C99.
This change has the side-effect of fixing a bug on MIPS where the
hard-coded value used by `_Py_dg_stdnan` gave a signalling NaN
rather than a quiet NaN.
---------

Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
2023-05-10 17:44:52 +01:00
JohnJamesUtley 29f348e232
gh-103848: Adds checks to ensure that bracketed hosts found by urlsplit are of IPv6 or IPvFuture format (#103849)
* Adds checks to ensure that bracketed hosts found by urlsplit are of IPv6 or IPvFuture format

---------

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-05-10 00:18:35 +00:00
Carl Meyer c3b595e73e
gh-97933: (PEP 709) inline list/dict/set comprehensions (#101441)
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2023-05-09 11:02:14 -06:00
Sam Carroll 0aeda29793
gh-99889: Fix directory traversal security flaw in uu.decode() (#104096)
* Fix directory traversal security flaw in uu.decode()
* also check absolute paths and os.altsep
* Add a regression test.

---------

Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google]
2023-05-09 16:01:58 +00:00
Gregory P. Smith 82f789be3b
gh-104139: Add itms-services to uses_netloc urllib.parse. (#104312)
Teach unsplit to retain the `"//"` when assembling `itms-services://?action=generate-bugs` style
[Apple Platform Deployment](https://support.apple.com/en-gb/guide/deployment/depce7cefc4d/web) URLs.
2023-05-09 07:04:50 -07:00
Zhang Na 03029ace92
gh-90656: Add platform triplets for 64-bit LoongArch (LA64) (#30939)
Signed-off-by: Zhang Na <zhangna@loongson.cn>
Co-authored-by: WANG Xuerui <git@xen0n.name>
2023-05-09 09:19:40 +00:00
samschott 9a9b176eb7
gh-104180: Read SOCKS proxies from macOS System Configuration (#104181)
read SOCKS proxies from macOS System Configuration in ``urllib.request``.

---------

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
2023-05-09 10:24:29 +02:00
Nathaniel J. Smith faf196213e
GH-104308: socket.getnameinfo should release the GIL (#104307)
* socket.getnameinfo should release the GIL

* 📜🤖 Added by blurb_it.

---------

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2023-05-08 16:27:20 -07:00
Eric Snow 4541d1a0db
gh-104310: Add importlib.util.allowing_all_extensions() (gh-104311)
(I'll be adding docs for this separately.)
2023-05-08 16:56:01 -06:00
Eric Snow 5c9ee498c6
gh-99113: A Per-Interpreter GIL! (gh-104210)
This is the culmination of PEP 684 (and of my 8-year long multi-core Python project)!

Each subinterpreter may now be created with its own GIL (via Py_NewInterpreterFromConfig()).  If not so configured then the interpreter will share with the main interpreter--the status quo since subinterpreters were added decades ago.  The main interpreter always has its own GIL and subinterpreters from Py_NewInterpreter() will always share with the main interpreter.
2023-05-08 13:15:09 -06:00
Arjun 9af485436b
gh-89550: Buffer GzipFile.write to reduce execution time by ~15% (#101251)
Use `io.BufferedWriter` to buffer gzip writes.

---------

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-05-08 17:55:59 +00:00
Itamar Ostricher c2683fc46d
gh-97696: Improve and fix documentation for asyncio eager tasks (#104256) 2023-05-08 17:29:34 +05:30
Jonathan Protzenko 15665d896b
gh-99108: Replace SHA3 implementation HACL* version (#103597)
Replaces our built-in SHA3 implementation with a verified one from the HACL* project.

This implementation is used when OpenSSL does not provide SHA3 or is not present.

3.11 shiped with a very slow tiny sha3 implementation to get off of the <=3.10 reference implementation that wound up having serious bugs. This brings us back to a reasonably performing built-in implementation consistent with what we've just replaced our other guaranteed available standard hash algorithms with: code from the HACL* project.

---------

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-05-07 20:50:04 -07:00
chgnrdv 06c2a4858b
gh-104265 Disallow instantiation of `_csv.Reader` and `_csv.Writer` (#104266) 2023-05-07 21:15:44 +00:00
Barney Gale c0ece3dc97
GH-102613: Improve performance of `pathlib.Path.rglob()` (GH-104244)
Stop de-duplicating results in `_RecursiveWildcardSelector`. A new
`_DoubleRecursiveWildcardSelector` class is introduced which performs
de-duplication, but this is used _only_ for patterns with multiple
non-adjacent `**` segments, such as `path.glob('**/foo/**')`. By avoiding
the use of a set, `PurePath.__hash__()` is not called, and so paths do not
need to be stringified and case-normalised.

Also merge adjacent '**' segments in patterns.
2023-05-07 22:12:50 +01:00
Arthur Pastel 8d95012c95
gh-103650: Fix perf maps address format (#103651) 2023-05-07 20:42:26 +01:00
Erlend E. Aasland a05bad3254
gh-100370: fix OverflowError in sqlite3.Connection.blobopen for 32-bit builds (#103902) 2023-05-07 12:55:31 +02:00
Oleg Iarygin 42f54d1f92
gh-101640: Make argparse _print_message catch any write error (#101802)
* In particular, don't exit when trying to print to stderr = None.
* Add tests

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
2023-05-06 18:53:48 -04:00
Eric Snow fff193bbfe
gh-99113: Add a check for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED (gh-104206)
Py_MOD_PER_INTERPRETER_GIL_SUPPORTED is a new supported value for Py_mod_multiple_interpreters, added in gh-104205.
2023-05-06 21:57:35 +00:00
Barney Gale de7f694e3c
GH-103548: Improve performance of `pathlib.Path.[is_]absolute()` (GH-103549)
Improve performance of `pathlib.Path.absolute()` and `cwd()` by joining paths only when necessary. Also improve
performance of `PurePath.is_absolute()` on Posix by skipping path parsing and normalization.
2023-05-06 18:03:07 +00:00
Alex Waygood 376137f6ec
gh-90953: Emit deprecation warnings for `ast` features deprecated in Python 3.8 (#104199)
`ast.Num`, `ast.Str`, `ast.Bytes`, `ast.Ellipsis` and `ast.NameConstant` now all emit deprecation warnings on import, access, instantation or `isinstance()` checks.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-05-06 16:48:07 +00:00
Itamar Ostricher 263abd333d
gh-104144: Optimize gather to finish eagerly when all futures complete eagerly (#104138) 2023-05-06 15:15:27 +00:00
Terry Jan Reedy e407661e7a
gh-65772: Clean-up turtle module (#104218)
* Remove the unused, private, and undocumented name `_ver` and
the commented-out `print` call.

* Don't add math functions to `__all__`.  Beginners should learn
to `import math` to access them.

* Gregor Lindel, who wrote this version of turtle, dropped plans
to implement turtle on another toolkit at least a decade ago.
Drop `_dot` code preparing for this, but add a hint comment.

* `_Screen` is meant to be a singleton class.  To enforce that,
it needs either a `__new__` that returns the singleton or
`else...raise` in `__iter__`.  Merely removing the `if` clauses
as suggested might break something if a user were to call `_Screen`
directly.  Leave the code alone until a problem is evident.

* Turtledemo injects into _Screen both _root and _canvas,
configured as it needs them to be.  Making _canvas an `__init__`
option would require skipping some but not all of the lines under
'if _Screen._canvas is None:`.  Leave working code alone.
2023-05-06 11:04:41 -04:00
Itamar Ostricher 52d8f36e8c
gh-104144: Skip scheduling a done callback if a TaskGroup task completes eagerly (#104140)
Co-authored-by: Carl Meyer <carl@oddbird.net>
2023-05-05 16:44:03 -07:00
Eric Snow 1c420e138f
gh-104108: Add the Py_mod_multiple_interpreters Module Def Slot (gh-104148)
I'll be adding a value to indicate support for per-interpreter GIL in gh-99114.
2023-05-05 14:04:55 -06:00