Commit graph

46656 commits

Author SHA1 Message Date
Victor Stinner 9976834f80
bpo-35883: Py_DecodeLocale() escapes invalid Unicode characters (GH-24843)
Python no longer fails at startup with a fatal error if a command
line argument contains an invalid Unicode character.

The Py_DecodeLocale() function now escapes byte sequences which would
be decoded as Unicode characters outside the [U+0000; U+10ffff]
range.

Use MAX_UNICODE constant in unicodeobject.c.
2021-03-17 21:46:53 +01:00
tsukasa-au a8ef4572a6
bpo-43497: Emit SyntaxWarnings for assertions with tuple constants. (GH-24867)
* bpo-43497: Emit SyntaxWarnings for assertions with tuple constants.

Add a test that shows that a tuple constant (a tuple, where all of its
members are also compile-time constants) produces a SyntaxWarning. Then
fix this failure.

* Make SyntaxWarnings also work when "optimized".

* Split tests for SyntaxWarning to SyntaxError conversion

SyntaxWarnings emitted by the compiler when configured to be errors are
actually raised as SyntaxError exceptions.

Move these tests into their own method and add a test to ensure they are
raised. Previously we only tested that they were not raised for a
"valid" assertion statement.
2021-03-16 11:14:41 +00:00
Chavdar Yotov 0269ce87c9
bpo-41933: Clarify wording for s * n in Common Sequence Operations (GH-22570) 2021-03-15 23:50:49 +01:00
Gregory P. Smith 0ab152c6b5
bpo-43285 Make ftplib not trust the PASV response. (GH-24838)
bpo-43285: Make ftplib not trust the PASV response.

The IPv4 address value returned from the server in response to the PASV command
should not be trusted.  This prevents a malicious FTP server from using the
response to probe IPv4 address and port combinations on the client network.

Instead of using the returned address, we use the IP address we're
already connected to.  This is the strategy other ftp clients adopted,
and matches the only strategy available for the modern IPv6 EPSV command
where the server response must return a port number and nothing else.

For the rare user who _wants_ this ugly behavior, set a `trust_server_pasv_ipv4_address`
attribute on your `ftplib.FTP` instance to True.
2021-03-15 11:39:31 -07:00
Mark Shannon c5440937ef
Mark POP_TOP at end of expression statement as artificial, to conform to PEP 626. (GH-24860) 2021-03-15 14:24:25 +00:00
Jason R. Coombs 35d5068928
bpo-43428: Improve documentation for importlib.metadata changes. (GH-24858)
* bpo-43428: Sync with importlib_metadata 3.7.3 (16ac3a95)

* Add 'versionadded' for importlib.metadata.packages_distributions

* Add section in what's new for Python 3.10 highlighting most salient changes and relevant backport.
2021-03-14 22:20:49 -04:00
CAM Gerlach bd2fa3c416
bpo-29982: Add "ignore_cleanup_errors" param to tempfile.TemporaryDirectory() (GH-24793) 2021-03-14 11:06:56 -07:00
Mark Shannon d48848c83e
bpo-39316: Make sure that attribute accesses and stores, including method calls, conform to PEP 626. (GH-24859) 2021-03-14 18:01:30 +00:00
Pablo Galindo cd8dcbc851
bpo-43410: Fix crash in the parser when producing syntax errors when reading from stdin (GH-24763) 2021-03-14 04:38:40 +01:00
Kamil Turek 9923df9641
bpo-43245: Add keyword argument support to ChainMap.new_child() (GH-24788) 2021-03-13 19:15:44 -08:00
Jason R. Coombs f917efccf8
bpo-43428: Sync with importlib_metadata 3.7. (GH-24782)
* bpo-43428: Sync with importlib_metadata 3.7.2 (67234b6)

* Add blurb

* Reformat blurb to create separate paragraphs for each change included.
2021-03-13 11:31:45 -05:00
Géry Ogam b6884ad268
Update client.py (GH-24827) 2021-03-13 04:22:03 -08:00
Pandu E POLUAN 7591d9455e
bpo-27820: Fix AUTH LOGIN logic in smtplib.SMTP (GH-24118)
* Fix auth_login logic (bpo-27820)

* Also fix a longstanding bug in the SimSMTPChannel.found_terminator() method that causes inability to test
SMTP AUTH with initial_response_ok=False.
2021-03-12 15:25:49 -08:00
Antoine Pitrou ba251c2ae6
bpo-43356: Allow passing a signal number to interrupt_main() (GH-24755)
Also introduce a new C API ``PyErr_SetInterruptEx(int signum)``.
2021-03-11 23:35:45 +01:00
Chris Griffith b4fc44bb2d
bpo-43423 Fix IndexError in subprocess _communicate function (GH-24777)
Check to make sure stdout and stderr are not empty before selecting an item from them in Windows subprocess._communicate.

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2021-03-11 11:43:29 -08:00
Victor Stinner 1fa17e8cc6
bpo-43406: Fix test_signal.test_stress_modifying_handlers() (GH-24815)
Fix a race condition of test_stress_modifying_handlers() of
test_signal: only raise signals while we are in the
catch_unraisable_exception() context manager.
Moreover, don't check if we received at least one
signal if at least one signal got ignored.
2021-03-10 15:26:45 +01:00
Pablo Galindo b4f9089d4a
bpo-43439: Add audit hooks for gc functions (GH-24794) 2021-03-10 00:53:57 +00:00
Desmond Cheong 3abf6f0102
bpo-14678: Update zipimport to support importlib.invalidate_caches() (GH-24159)
Added an invalidate_caches() method to the zipimport.zipimporter class based on the implementation of importlib.FileFinder.invalidate_caches(). This was done by adding a get_files() method and an _archive_mtime attribute to zipimport.zipimporter to check for updates or cache invalidation whenever the cache of files and toc entry information in the zipimporter is accessed.
2021-03-08 12:06:02 -08:00
Mariusz Felisiak bbba28212c
bpo-43353: Document that logging.getLevelName() accepts string representation of logging level. (GH-24693)
[bpo-43353]()

Automerge-Triggered-By: GH:vsajip
2021-03-08 03:16:20 -08:00
Gregory P. Smith c25910a135
bpo-43332: Buffer proxy connection setup packets before sending. (GH-24780)
We now buffer the CONNECT request + tunnel HTTP headers into a single
send call.  This prevents the OS from generating multiple network
packets for connection setup when not necessary, improving efficiency.
2021-03-07 23:35:13 -08:00
Zackery Spytz 8aabfa8550
bpo-43405: Fix DeprecationWarnings in test_unicode (GH-24754)
DeprecationWarnings were being raised in the test_encode_decimal()
and test_transform_decimal() methods after 91a639a094.
2021-03-07 15:12:35 +09:00
Neil Schemenauer 87ec26b812
bpo-43372: Use _freeze_importlib for regen-frozen. (GH-24759)
This approach ensures the code matches the interpreter version.
Previously, PYTHON_FOR_REGEN was used to generate the code, which might
be wrong. The marshal format for code objects has changed with
bpo-42246, commit 877df851. Update the code and the expected code sizes
in ctypes test_frozentable.
2021-03-06 13:34:03 -08:00
Antoine Pitrou 68245b7a10
bpo-43406: Fix possible race condition where `PyErr_CheckSignals` tries to execute a non-Python signal handler (GH-24756)
We can receive signals (at the C level, in `trip_signal()` in signalmodule.c) while `signal.signal` is being called to modify the corresponding handler.  Later when `PyErr_CheckSignals()` is called to handle the given signal, the handler may be a non-callable object and would raise a cryptic asynchronous exception.
2021-03-05 10:32:50 +01:00
Jason R. Coombs 6714825414
bpo-42129: Add support for resources in namespaces (GH-24670)
* Unify behavior in ResourceReaderDefaultsTests and align with the behavior found in importlib_resources.
* Equip NamespaceLoader with a NamespaceReader.
* Apply changes from importlib_resources 5.0.4
2021-03-04 13:43:00 -05:00
Jason R. Coombs fbf75b9997
Revert "bpo-42405: fix C extensions build on Windows ARM64 (GH-23399)" (#24753)
This reverts commit cb7bc76409.
2021-03-04 13:41:49 -05:00
Kamil Turek b225d91f0a
bpo-43391: Remove the broken Python 2.4 link from the comment (GH-24736) 2021-03-04 10:24:42 -08:00
Adrian Vladu cb7bc76409
bpo-42405: fix C extensions build on Windows ARM64 (GH-23399)
The following changes are required:

      * add a new platform win-arm64
      * replace the emulated compiler executable paths
      * bump the linker base addressed as ARM64 requires more memory
        this change might not be needed (investigation required)

    On Windows 10 ARM64, VS compiler paths look like this:
    C:\Program Files (x86)\Microsoft Visual
    Studio\2019\Community\VC\Tools\MSVC\14.27.29110\bin\HostX86\ARM64\cl.exe

    Note that the cl.exe for ARM64 is an x32 binary, which can run emulated
    on Windows 10 ARM64 (it has builtin emulation for x32).

    The rc.exe and mc.exe paths have to also be changed, as the initial
    discovery has to be fixed.

    Work in progress to remove the hardcoded bits and to change the path
    query fixes to the proper location.

Automerge-Triggered-By: GH:jaraco
2021-03-04 08:59:12 -08:00
Erlend Egeberg Aasland e161ec5dd7
bpo-43369: sqlite3_column_{text,blob} failures now raise MemoryError (GH-24723) 2021-03-04 11:50:25 +02:00
Pablo Galindo 0632b1012d
bpo-42128: Add __match_args__ to structseq-based classes (GH-24732) 2021-03-04 00:03:44 +00:00
Eric L 9c7927400c
bpo-40701: tempfile mixes str and bytes in an inconsistent manner (GH-20442)
The case of tempfile.tempdir variable being bytes is now handled consistently.
The getters return the right type and no more error of mixing str and bytes unless explicitly caused by the user.

Adds a regression test.

Expands the documentation to clarify the behavior.

Co-authored-by: Eric L <ewl+git@lavar.de>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2021-03-03 12:36:22 -08:00
Ethan Furman 44e580f448
bpo-43162: [Enum] update docs, renable doc tests (GH-24487)
* update docs, renable doc tests
* make deprecation warning active for two releases
2021-03-03 09:54:30 -08:00
Noor Michael 04f6fbb696
bpo-43295: Fix error handling of datetime.strptime format string '%z' (GH-24627)
Previously, `datetime.strptime` would match `'z'` with the format string `'%z'` (for UTC offsets), throwing an `IndexError` by erroneously trying to parse `'z'` as a timestamp. As a special case, `'%z'` matches the string `'Z'` which is equivalent to the offset `'+00:00'`, however this behavior is not defined for lowercase `'z'`.

This change ensures a `ValueError` is thrown when encountering the original example, as follows:

```
>>> from datetime import datetime
>>> datetime.strptime('z', '%z')
ValueError: time data 'z' does not match format '%z'
```

Automerge-Triggered-By: GH:pganssle
2021-03-03 08:58:57 -08:00
Mariusz Felisiak 3b4b2cf418
bpo-43368: Fix fetching empty bytes in sqlite3 (GH-24706)
Regression introduced in 47feb1feb2.
2021-03-03 16:16:24 +02:00
Nathan Beals 3a87e562ea
bpo-42994: Add MIME types for opus, AAC, 3gpp and 3gpp2 (#24287)
Co-authored-by: Nathan Beals <ndbeals@users.noreply.github.com>
2021-03-02 16:20:18 -08:00
Winson Luk 132131b404
bpo-42782: Fail fast for permission errors in shutil.move() (GH-24001)
* Fail fast in shutil.move() to avoid creating destination directories on failure.

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
2021-03-02 12:53:15 -08:00
Peter Donis b36349a647
bpo-43049: Use io.IncrementalNewlineDecoder for doctest newline conversion (GH-24359)
Followup to bpo-1812 and GH-17385.
2021-03-02 11:06:20 -06:00
Inada Naoki 5bfa945605
bpo-41282: distutils: Fix stacklevel for DeprecationWarning (GH-24657)
DeprecationWarning is emit for `import distutils`, not for `distutils` itself.
2021-03-02 11:49:10 +09:00
Pablo Galindo cc12888f9b
Remove unused suspicious rule in the docs 2021-03-01 16:48:59 +00:00
Filipe Laíns 0d7ad9fb38
bpo-29753: fix merging packed bitfields in ctypes struct/union (GH-19850)
From the commit message:

> When the structure is packed we should always expand when needed,
> otherwise we will add some padding between the fields. This patch makes
> sure we always merge bitfields together. It also changes the field merging
> algorithm so that it handles bitfields correctly.

Automerge-Triggered-By: GH:jaraco
2021-02-28 14:43:19 -08:00
Pablo Galindo af5fa13ef6
bpo-37146: Deactivate opcode cache only when using huntrleaks in the test suite (GH-24643) 2021-02-28 22:41:09 +00:00
Dennis Sweeney 73a85c4e1d
bpo-41972: Use the two-way algorithm for string searching (GH-22904)
Implement an enhanced variant of Crochemore and Perrin's Two-Way string searching algorithm, which reduces worst-case time from quadratic (the product of the string and pattern lengths) to linear. This applies to forward searches (like``find``, ``index``, ``replace``); the algorithm for reverse searches (like ``rfind``) is not changed.

Co-authored-by: Tim Peters <tim.peters@gmail.com>
2021-02-28 12:20:50 -06:00
Brandt Bucher 145bf269df
bpo-42128: Structural Pattern Matching (PEP 634) (GH-22917)
Co-authored-by: Guido van Rossum <guido@python.org>
Co-authored-by: Talin <viridia@gmail.com>
Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
2021-02-26 14:51:55 -08:00
Alex cc02b4f2e8
bpo-38302: __pow__/__rpow__ now called when __ipow__ returns NotImplemented (#16459) 2021-02-26 11:58:39 -08:00
Ruben Vorderman 7956ef8849
bpo-43317: Use io.DEFAULT_BUFFER_SIZE instead of 1024 in gzip CLI (#24645)
This improves the performance slightly.
2021-02-26 21:17:51 +09:00
Ammar Askar c6ccdfb479
bpo-43144: Mark unicodedata's test_normalization as requiring network (GH-24650)
Co-authored-by: Arkadiusz Miśkiewicz <arekm@maven.pl>
2021-02-26 12:24:32 +09:00
Inada Naoki 9525a18b5b
bpo-43316: gzip: Fix sys.exit() usage. (GH-24652) 2021-02-26 11:09:06 +09:00
Ruben Vorderman cc3df6368d
bpo-43316: gzip: CLI uses non-zero return code on error. (GH-24647)
Exit code is now 1 instead of 0. A message is printed to stderr instead of stdout. This is
the proper behaviour for a tool that can be used in scripts.
2021-02-25 20:30:24 +09:00
Florian Bruhin 70f8ebe503
Remove comment about a private email.headerregistry (GH-24233)
It's been public since 2012: ea9766897b
2021-02-24 17:21:32 -04:00
Felix C. Stegerman 1f433406bd
bpo-42151: don't set specified_attributes=1 in pure Python ElementTree (GH-22987) 2021-02-24 11:25:31 +09:00
Terry Jan Reedy b9fe16a027
bpo-41841: Revise header (GH-24633) 2021-02-23 21:24:33 -05:00