Commit Graph

3785 Commits

Author SHA1 Message Date
Gregory P. Smith b44b9d9900
gh-113971: Make `zipfile.ZipInfo._compresslevel` public as `.compress_level` (#113969)
Make zipfile.ZipInfo.compress_level public.

A property is used to retain the behavior of the ._compresslevel.

People constructing zipfile.ZipInfo instances to pass into existing APIs to control per-file compression levels already treat this as public, there was never a reason for it not to be.

I used the more modern name compress_level instead of compresslevel as the keyword argument on other ZipFile APIs is called to be consistent with compress_type and a general long term preference of not runningwordstogether without a separator in names.
2024-01-12 20:15:05 +00:00
Ronald Oussoren 79970792fd
gh-113868: Add a number of MAP_* flags from macOS to module mmap (#113869)
The new flags were extracted from the macOS 14.2 SDK.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-01-12 16:56:18 +01:00
Mariusz Felisiak de777e490f
gh-108364: In sqlite3, disable foreign keys before dumping SQL schema (#113957)
sqlite3.Connection.iterdump now ensures that foreign key support is
disabled before dumping the database schema, if there is any foreign key
violation.

Co-authored-by: Erlend E. Aasland <erlend@python.org>
2024-01-12 10:50:37 +01:00
Nikita Sobolev 2ac4cf4743
gh-112640: Add `kwdefaults` parameter to `types.FunctionType.__new__` (#112641) 2024-01-11 00:42:30 -08:00
Serhiy Storchaka 66363b9a7b
gh-109858: Protect zipfile from "quoted-overlap" zipbomb (GH-110016)
Raise BadZipFile when try to read an entry that overlaps with other entry or
central directory.
2024-01-10 15:55:36 +02:00
Serhiy Storchaka 89cee94b31
gh-89850: Add default C implementations of persistent_id() and persistent_load() (GH-113579)
Previously the C implementation of pickle.Pickler and pickle.Unpickler
classes did not have such methods and they could only be used if
they were overloaded in subclasses or set as instance attributes.

Fixed calling super().persistent_id() and super().persistent_load() in
subclasses of the C implementation of pickle.Pickler and pickle.Unpickler
classes. It no longer causes an infinite recursion.
2024-01-10 15:30:37 +02:00
Serhiy Storchaka e9d5b6ea2d
gh-113594: Fix UnicodeEncodeError in TokenList.fold() (GH-113730)
It occurred when try to re-encode an unknown-8bit part combined with non-unknown-8bit part.
2024-01-10 14:54:36 +02:00
Serhiy Storchaka aef4a1203c
gh-96037: Always insert TimeoutError when exit an expired asyncio.timeout() block (GH-113819)
If other exception was raised during exiting an expired
asyncio.timeout() block, insert TimeoutError in the exception context
just above the CancelledError.
2024-01-10 12:50:31 +02:00
Serhiy Storchaka 1b7e0024a1
gh-113877: Fix Tkinter method winfo_pathname() on 64-bit Windows (GH-113900)
winfo_id() converts the result of "winfo id" command to integer, but
"winfo pathname" command requires an argument to be a hexadecimal number
on Win64.
2024-01-10 12:36:03 +02:00
Jamie Phan 4826d52338
gh-112182: Replace StopIteration with RuntimeError for future (#113220)
When an `StopIteration` raises into `asyncio.Future`, this will cause
a thread to hang. This commit address this by not raising an exception
and silently transforming the `StopIteration` with a `RuntimeError`,
which the caller can reconstruct from `fut.exception().__cause__`
2024-01-09 21:21:00 -08:00
Stefano Rivera 3a9096c337
GH-113661: unittest runner: Don't exit 5 if tests were skipped (#113856)
The intention of exiting 5 was to detect issues where the test suite
wasn't discovered at all. If we skipped tests, it was correctly
discovered.
2024-01-09 19:50:01 +00:00
Serhiy Storchaka 0297418cac
gh-113781: Silence AttributeError in warning module during Python finalization (GH-113813)
The tracemalloc module can already be cleared.
2024-01-09 21:44:05 +02:00
Serhiy Storchaka a5db6a3351
gh-113848: Handle CancelledError subclasses in asyncio TaskGroup() and timeout() (GH-113850) 2024-01-09 21:41:31 +02:00
Kristján Valur Jónsson 52161781a6
GH-111693: Propagate correct asyncio.CancelledError instance out of asyncio.Condition.wait() (#111694)
Also fix a race condition in `asyncio.Semaphore.acquire()` when cancelled.
2024-01-08 11:57:48 -08:00
Ronald Oussoren c6ca562138
gh-113791: Expose CLOCK_MONOTONIC_RAW_APPROX and CLOCK_UPTIME_RAW_APROX on macOS in the time module (#113792) 2024-01-08 20:44:00 +01:00
Zackery Spytz 73c9326563
gh-80109: Fix io.TextIOWrapper dropping the internal buffer during write() (GH-22535)
io.TextIOWrapper was dropping the internal decoding buffer
during read() and write() calls.
2024-01-08 12:33:34 +02:00
Zackery Spytz f19b93fce0
gh-73965: New environment variable PYTHON_HISTORY (#13208)
It can be used to set the location of a .python_history file

---------

Co-authored-by: Levi Sabah <0xl3vi@gmail.com>
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2024-01-06 22:30:12 -08:00
AN Long 541c5dbb81
gh-112795: Allow `/` folder in a zipfile (#112932)
Allow extraction (no-op) of a "/" folder in a zipfile, they are commonly added by some archive creation tools.

Co-authored-by: Erlend E. Aasland <erlend@python.org>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2024-01-07 01:14:18 +00:00
AN Long bbf214df23
gh-113537: support loads str in plistlib.loads (#113582)
Add support for loading XML plists from a string value instead of a only bytes value.
2024-01-06 10:26:59 +01:00
Barney Gale 3375dfed40
GH-113568: Stop raising deprecation warnings from pathlib ABCs (#113757) 2024-01-05 22:56:04 +00:00
Serhiy Storchaka bd754b93ca
gh-85567: Fix resouce warnings in pickle and pickletools CLIs (GH-113618)
Explicitly open and close files instead of using FileType.
2024-01-06 00:12:34 +02:00
Barney Gale 3c4e972d6d
GH-113568: Stop raising auditing events from pathlib ABCs (#113571)
Raise auditing events in `pathlib.Path.glob()`, `rglob()` and `walk()`,
but not in `pathlib._abc.PathBase` methods. Also move generation of a
deprecation warning into `pathlib.Path` so it gets the right stack level.
2024-01-05 21:41:19 +00:00
Alex Waygood ed6ea3ea79
gh-113320: Reduce the number of dangerous `getattr()` calls when constructing protocol classes (#113401)
- Only attempt to figure out whether protocol members are "method members" or not if the class is marked as a runtime protocol. This information is irrelevant for non-runtime protocols; we can safely skip the risky introspection for them.
- Only do the risky getattr() calls in one place (the runtime_checkable class decorator), rather than in three places (_ProtocolMeta.__init__, _ProtocolMeta.__instancecheck__ and _ProtocolMeta.__subclasscheck__). This reduces the number of locations in typing.py where the risky introspection could go wrong.
- For runtime protocols, if determining whether a protocol member is callable or not fails, give a better error message. I think it's reasonable for us to reject runtime protocols that have members which raise strange exceptions when you try to access them. PEP-544 clearly states that all protocol member must be callable for issubclass() calls against the protocol to be valid -- and if a member raises when we try to access it, there's no way for us to figure out whether it's a callable member or not!
2024-01-05 01:01:48 +00:00
Barney Gale c2e8298eba
GH-113225: Speed up `pathlib.Path.glob()` (#113226)
Use `os.DirEntry.path` as the string representation of child paths, unless
the parent path is empty, in which case we use the entry `name`.
2024-01-04 20:48:26 +00:00
Guido van Rossum 4681a5271a
gh-113538: Don't error in stream reader protocol callback when task is cancelled (#113690) 2024-01-04 12:20:21 -08:00
wookie184 1600d78e2d
gh-113569: Display calls in Mock.assert_has_calls failure when empty (GH-113573) 2024-01-04 21:11:34 +02:00
Filip Łapkiewicz 4c4b08dd2b
gh-52161: Enhance Cmd support for docstrings (#110987)
In `cmd.Cmd.do_help` call `inspect.cleandoc()`,
to clean indentation and remove leading/trailing empty
lines from a dosctring before printing.
2024-01-03 19:37:34 +00:00
AN Long b4b2cc1012
gh-53502: add a new option aware_datetime in plistlib to loads or dumps aware datetime. (#113363)
* add options to loads and dumps aware datetime in plistlib
2024-01-01 19:51:24 +01:00
Jeffrey Kintscher 5f3cc90a12
gh-62260: Fix ctypes.Structure subclassing with multiple layers (GH-13374)
The length field of StgDictObject for Structure class contains now
the total number of items in ffi_type_pointer.elements (excluding
the trailing null).

The old behavior of using the number of elements in the parent class can
cause the array to be truncated when it is copied, especially when there
are multiple layers of subclassing.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-01-01 18:24:24 +02:00
Ankit Kumar Pandey f46987b828
gh-103708: Make directory layout in sysconfig implementation configurable (#103709) 2023-12-29 17:55:17 +00:00
Nikita Sobolev fba324154e
gh-113543: Make sure that `MacOSXOSAScript` sends `webbrowser.open` audit event (#113544) 2023-12-28 19:58:06 +01:00
Jeffrey Kintscher c66b577d9f
bpo-26791: Update shutil.move() to provide the same symlink move behavior as the mv shell when moving a symlink into a directory that is the target of the symlink (GH-21759) 2023-12-27 16:23:42 +00:00
Zackery Spytz 1ddd773293
gh-64020: Deprecate pydoc.ispackage() (GH-20908)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-12-27 14:04:31 +00:00
Vinay Sajip 67655d8ad5
gh-111615: Fix regression in QueueHandler configuration. (GH-111638) 2023-12-27 09:35:15 +00:00
Gordon P. Hemsley 4b2c3e8e43
bpo-36959: Fix error messages for invalid ISO format string in _strptime() (GH-13408)
Previously some error messages complained about incompatible
combinations of directives that are not contained in the format string.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-12-26 19:26:17 +00:00
Serhiy Storchaka e87cadc1ce
gh-66515: mailbox.MH now supports folders withou the ".mh_sequences" file (GH-804)
(for example Claws Mail IMAP-cache folders).
2023-12-26 11:15:14 +02:00
Zackery Spytz 3f5eb3e6c7
bpo-21360: mailbox.Maildir now ignores files with a leading dot (GH-11833)
The maildir format specification states that files with a leading dot
should be ignored.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-12-25 17:07:51 +02:00
Serhiy Storchaka 0c574540e0
gh-113407: Fix import of unittest.mock when CPython is built without docstrings (GH-113408) 2023-12-24 13:38:56 +02:00
Serhiy Storchaka 1f06baeabd
gh-113191: Add support of os.fchmod() on Windows (GH-113192)
Also support a file descriptor in os.chmod().
2023-12-24 10:57:11 +00:00
Xu Song ce77ee5035
gh-113421: Fix multiprocessing logger for "%(filename)s" (GH-113423) 2023-12-24 12:04:12 +02:00
Jeff Allen 08398631a0
gh-113028: Correctly memoize str in pickle when escapes added (GH-113436)
This fixes a divergence between the Python and C implementations of pickle
for protocol 0, such that it pickle.py fails to re-use the first pickled
representation of strings involving characters that have to be escaped.
2023-12-24 11:43:44 +02:00
Kirill Podoprigora 894f0e573d
gh-111784: Fix two segfaults in the elementtree module (GH-113405)
First fix resolve situation when pyexpat module (which contains expat_CAPI
capsule) deallocates before _elementtree, so we need to hold a strong
reference to pyexpat module to.

Second fix resolve situation when module state is deallocated before
deallocation of XMLParser instances, which uses module state to clear
some stuff.
2023-12-24 10:57:41 +02:00
Yilei Yang 050783cb37
gh-112559: Avoid unnecessary conversion attempts to enum_klass in signal.py (#113040) 2023-12-23 17:07:52 -08:00
Allison Karlitskaya 0187a7e4ec
gh-112800: Ignore PermissionError on SubprocessTransport.close() in asyncio (#112803)
In case the spawned process is setuid, we may not be able to send
signals to it, in which case our .kill() call will raise
PermissionError.

Ignore that in order to avoid .close() raising an exception.  Hopefully
the process will exit as a result of receiving EOF on its stdin.
2023-12-23 16:43:39 -08:00
Serhiy Storchaka 6e02d79f96
gh-113188: Fix shutil.copymode() on Windows (GH-113189)
Previously it worked differently if dst is a symbolic link:
it modified the permission bits of dst itself rather than the file
it points to if follow_symlinks is true or src is not a symbolic link,
and did nothing if follow_symlinks is false and src is a symbolic link.

Also document similar changes in shutil.copystat().
2023-12-23 11:07:54 +00:00
Jason R. Coombs 2d91409c69
gh-113174: Sync with importlib_metadata 7.0 (#113175)
* Sync with importlib_metadata 7.0.0

* Add blurb

* Update docs to reflect changes.

* Link datamodel docs for object.__getitem__

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>

* Add what's new for removed __getattr__

* Link datamodel docs for object.__getitem__

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>

* Add exclamation point, as that seems to be used for other classes.

---------

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-12-21 15:04:05 -05:00
Martijn Pieters 1ff0238594
GH-113214: Fix SSLProto exception handling in SSL-over-SSL scenarios (#113334)
When wrapped, `_SSLProtocolTransport._force_close(exc)` is called just like in the unwrapped scenario `_SelectorTransport._force_close(exc)` or `_ProactorBasePipeTransport._force_close(exc)` would be called, except here the exception needs to be passed through the `SSLProtocol._abort()` method, which didn't accept an exception object.

This commit ensures that this path works, in the same way that the uvloop implementation of SSLProto passes on the exception (on which the current implementation of SSLProto is based).
2023-12-20 15:09:01 -08:00
Marat Idrisov e1117cb886
gh-87264: Convert tarinfo type to stat type (GH-113230)
Co-authored-by: val-shkolnikov <val@nvsoft.net>
2023-12-19 11:04:43 -08:00
Illia Volochii 41336a72b9
gh-113199: Make read1() and readline() of HTTPResponse close IO after reading all data (GH-113200) 2023-12-18 22:17:16 +02:00
Stéphane Bidoul 4a24bf9a13
gh-113246: Updated bundled pip to 23.3.2 (gh-113249)
Updated bundled pip to 23.3.2
2023-12-18 10:21:46 +00:00