Commit Graph

29693 Commits

Author SHA1 Message Date
Alex Waygood 64d1b44a54
gh-104683: `clinic.py`: Improve coverage for the `parse_converter` method (#104729) 2023-05-21 23:00:47 +00:00
Serhiy Storchaka f3466bc040
gh-98836: Extend PyUnicode_FromFormat() (GH-98838)
* Support for conversion specifiers o (octal) and X (uppercase hexadecimal).
* Support for length modifiers j (intmax_t) and t (ptrdiff_t).
* Length modifiers are now applied to all integer conversions.
* Support for wchar_t C strings (%ls and %lV).
* Support for variable width and precision (*).
* Support for flag - (left alignment).
2023-05-22 00:32:39 +03:00
Mark Shannon 93923793f6
GH-101291: Add low level, unstable API for pylong (GH-101685)
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2023-05-21 14:45:48 +01:00
Zac Hatfield-Dodds 014dd301b5
gh-86275: improve Hypothesis configuration for CI and local runs (#104468) 2023-05-21 05:52:29 -06:00
gsallam be0c106789
gh-103295: expose API for writing perf map files (#103546)
Co-authored-by: Aniket Panse <aniketpanse@fb.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
Co-authored-by: Carl Meyer <carl@oddbird.net>
2023-05-21 11:12:24 +01:00
Dong-hee Na 2e91c7e626
gh-104469: Convert _testcapi/exceptions to use AC (gh-104502) 2023-05-21 18:39:45 +09:00
Alex Waygood b870b1fa75
gh-74690: Make a typing test more resilient (#104691) 2023-05-20 17:13:37 -07:00
Marta Gómez Macías 6715f91edc
gh-102856: Python tokenizer implementation for PEP 701 (#104323)
This commit replaces the Python implementation of the tokenize module with an implementation
that reuses the real C tokenizer via a private extension module. The tokenize module now implements
a compatibility layer that transforms tokens from the C tokenizer into Python tokenize tokens for backward
compatibility.

As the C tokenizer does not emit some tokens that the Python tokenizer provides (such as comments and non-semantic newlines), a new special mode has been added to the C tokenizer mode that currently is only used via
the extension module that exposes it to the Python layer. This new mode forces the C tokenizer to emit these new extra tokens and add the appropriate metadata that is needed to match the old Python implementation.

Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
2023-05-21 01:03:02 +01:00
Christian Heimes 3ed57e4995
gh-61460: Stronger HMAC in multiprocessing (#20380)
bpo-17258:  `multiprocessing` now supports stronger HMAC algorithms for inter-process connection authentication rather than only HMAC-MD5.

Signed-off-by: Christian Heimes <christian@python.org>

gpshead: I Reworked to be more robust while keeping the idea.

The protocol modification idea remains, but we now take advantage of the
message length as an indicator of legacy vs modern protocol version.  No
more regular expression usage.  We now default to HMAC-SHA256, but do so
in a way that will be compatible when communicating with older clients
or older servers. No protocol transition period is needed.

More integration tests to verify these claims remain true are required. I'm
unaware of anyone depending on multiprocessing connections between
different Python versions.

---------

Signed-off-by: Christian Heimes <christian@python.org>
Co-authored-by: Gregory P. Smith [Google] <greg@krypto.org>
2023-05-20 23:33:09 +00:00
Prince Roshan 12f1581b0c
gh-103606: raise RuntimeError if config file is invalid or empty (#104701)
(this adjusts new code) raise RuntimeError if provided config file is invalid or empty, not ValueError.
2023-05-20 22:26:49 +00:00
Cheryl Sabella 68ee8b3f15
gh-56276: Add tests to test_compare (#3199)
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
2023-05-20 12:07:40 -04:00
Pablo Galindo Salgado ff7f731632
gh-104658: Fix location of unclosed quote error for multiline f-strings (#104660) 2023-05-20 14:07:05 +01:00
Prince Roshan ceaa4c3476
gh-103987: fix several crashes in mmap module (#103990)
Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-05-19 20:34:12 -07:00
Matthias Görgens 6e39fa1955
gh-94906: Support multiple steps in math.nextafter (#103881)
This PR updates `math.nextafter` to add a new `steps` argument. The behaviour is as though `math.nextafter` had been called `steps` times in succession.

---------

Co-authored-by: Mark Dickinson <mdickinson@enthought.com>
2023-05-19 21:03:49 +01:00
chgnrdv c3f43bfb4b
gh-104472: Skip `test_subprocess.ProcessTestCase.test_empty_env` if ASAN is enabled (#104667)
Skip test_subprocess.ProcessTestCase.test_empty_env if ASAN is enabled.
2023-05-19 19:25:51 +00:00
Nikita Sobolev 27a7d5e1cd
gh-92248: Deprecate `type`, `choices`, `metavar` parameters of `argparse.BooleanOptionalAction` (#103678)
Co-authored-by: Kirill <80244920+Eclips4@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
2023-05-19 16:44:43 +00:00
Jelle Zijlstra 8f1f3b9abd
gh-104600: Make type.__type_params__ writable (#104634)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-05-19 09:04:47 -07:00
Jelle Zijlstra dbe171e609
gh-104602: Add additional test for listcomp with lambda (#104639)
This threw a SystemError before #104603. Adding a separate test
because this was a different failure mode than the other two new
tests from #104603, both of which used to segfault.
2023-05-19 09:16:39 -06:00
Jelle Zijlstra 8a8853af24
gh-104640: Disallow walrus in comprehension within type scopes (#104641) 2023-05-19 07:31:09 -07:00
Youfu Zhang 9c5aa8967b
gh-96522: Fix deadlock in pty.spawn (#96639) 2023-05-19 13:22:43 +00:00
Mark Shannon c26d03d5d6
GH-102818: Do not call `PyTraceBack_Here` in sys.settrace trampoline. (GH-104579) 2023-05-19 12:40:48 +01:00
Carl Meyer 70c7796477
gh-104619: never leak comprehension locals to outer locals() (#104637) 2023-05-18 18:50:24 -07:00
Carl Meyer 86e6f16ccb
gh-104602: ensure all cellvars are known up front (#104603)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-05-19 00:07:35 +00:00
Jelle Zijlstra 3fadd7d585
gh-104600: Make function.__type_params__ writable (#104601) 2023-05-18 16:45:37 -07:00
Alex Waygood f7835fc7e9
gh-74690: Don't set special protocol attributes on non-protocol subclasses of protocols (#104622)
Don't set special protocol attributes on non-protocol subclasses of protocols
2023-05-19 00:34:40 +01:00
Erlend E. Aasland 86ee49f469
gh-104629: Don't skip test_clinic if _testclinic is missing (#104630)
Just skip the tests that depend on the _testclinic extension module;
we can still run the Python tests.
2023-05-19 00:56:34 +02:00
Jelle Zijlstra b9dce3aec4
gh-104549: Set __module__ on TypeAliasType (#104550) 2023-05-18 15:56:15 -07:00
Carl Meyer 0589c6a4d3
gh-104615: don't make unsafe swaps in apply_static_swaps (#104620) 2023-05-18 21:22:03 +00:00
thirumurugan dcdc90d384
GH-104484: Add case_sensitive argument to `pathlib.PurePath.match()` (GH-104565)
Co-authored-by: Barney Gale <barney.gale@gmail.com>
2023-05-18 18:59:31 +01:00
Mark Shannon cfa517d5a6
GH-96803: Document and test new unstable internal frame API functions (GH-104211)
Weaken contract of PyUnstable_InterpreterFrame_GetCode to return PyObject*.
2023-05-18 10:10:15 +01:00
Jelle Zijlstra 662aede68b
gh-104374: Remove access to class scopes for inlined comprehensions (#104528)
Co-authored-by: Carl Meyer <carl@oddbird.net>
2023-05-18 05:22:17 +00:00
Prince Roshan 152227b569
gh-103606: Improve error message from logging.config.FileConfig (GH-103628) 2023-05-18 05:20:47 +01:00
Alex Waygood b27fe67f3c
gh-104555: Runtime-checkable protocols: Don't let previous calls to `isinstance()` influence whether `issubclass()` raises an exception (#104559)
Co-authored-by: Carl Meyer <carl@oddbird.net>
2023-05-17 23:43:12 +00:00
Jelle Zijlstra 26931944dd
typing: Add more tests for TypeVar (#104571)
During the PEP 695 implementation at one point I made
TypeVar.__name__ return garbage, and all of test_typing passed.
So I decided to add a few more tests. In the process I discovered
a minor incompatibility from the C implementation of TypeVar:
empty constraints were returned as None instead of an empty tuple.
2023-05-17 06:08:21 -07:00
Jelle Zijlstra 97db2f3e07
gh-104572: Improve error messages for invalid constructs in PEP 695 contexts (#104573) 2023-05-17 06:05:42 -07:00
Illia Volochii 2f630e1ce1
gh-102153: Start stripping C0 control and space chars in `urlsplit` (#102508)
`urllib.parse.urlsplit` has already been respecting the WHATWG spec a bit #25595.

This adds more sanitizing to respect the "Remove any leading C0 control or space from input" [rule](https://url.spec.whatwg.org/#url-parsing:~:text=Remove%20any%20leading%20and%20trailing%20C0%20control%20or%20space%20from%20input.) in response to [CVE-2023-24329](https://nvd.nist.gov/vuln/detail/CVE-2023-24329).

---------

Co-authored-by: Gregory P. Smith [Google] <greg@krypto.org>
2023-05-17 01:49:20 -07:00
Furkan Onder 5e9f471e7d
gh-75367: Fix data descriptor detection in inspect.getattr_static (#104517)
Co-authored-by: Carl Meyer <carl@oddbird.net>
2023-05-16 17:34:44 +00:00
Alex Waygood 1163782868
gh-104555: Fix isinstance() and issubclass() for runtime-checkable protocols that use PEP 695 (#104556)
Fixes #104555
2023-05-16 16:38:10 +00:00
Carl Meyer f40890b124
gh-103865: add monitoring support to LOAD_SUPER_ATTR (#103866) 2023-05-16 10:29:00 -06:00
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
Terry Jan Reedy 080a596152
GH-71383: IDLE - Document testing subsets of modules (#104463) 2023-05-13 23:55:20 -04:00
Alex Waygood c527eb1c2a
gh-91896: Revert some very noisy DeprecationWarnings for `ByteString` (#104424) 2023-05-13 09:55:35 +01:00
Carl Meyer 563c7dcba0
gh-104404: fix crasher with nested comprehensions plus lambdas (#104442) 2023-05-12 17:42:04 -07:00