124556 Commits

Author SHA1 Message Date
Marc Mueller
4fd9eb2aca
Fix typo: Use AsyncFor element access in codegen (#127278)
Use AsyncFor element access in codegen
2024-11-26 01:00:46 +00:00
mpage
193890c1cc
gh-126612: Include stack effects of uops when computing maximum stack depth (#126894) 2024-11-26 00:53:49 +00:00
funkyrailroad
26ff32b305
gh-127265: Remove single quotes from 'arrow's in tutorial/errors.rst (GH-127267) 2024-11-25 15:34:01 -06:00
Barney Gale
5bb059fe60
GH-127236: pathname2url(): generate RFC 1738 URL for absolute POSIX path (#127194)
When handed an absolute Windows path such as `C:\foo` or `//server/share`,
the `urllib.request.pathname2url()` function returns a URL with an
authority section, such as `///C:/foo` or `//server/share` (or before
GH-126205, `////server/share`). Only the `file:` prefix is omitted.

But when handed an absolute POSIX path such as `/etc/hosts`, or a Windows
path of the same form (rooted but lacking a drive), the function returns a
URL without an authority section, such as `/etc/hosts`.

This patch corrects the discrepancy by adding a `//` prefix before
drive-less, rooted paths when generating URLs.
2024-11-25 19:59:20 +00:00
sobolevn
a2ee899682
gh-127182: Fix io.StringIO.__setstate__ crash when None is the first value (#127219)
Co-authored-by: Victor Stinner <vstinner@python.org>
2024-11-25 20:32:02 +03:00
Sam Gross
d3da04bfc9
gh-127022: Remove _PyEvalFramePushAndInit_UnTagged (gh-127168)
The interpreter now handles `_PyStackRef`s pointing to immortal objects
without the deferred bit set, so `_PyEvalFramePushAndInit_UnTagged` is
no longer necessary.
2024-11-25 12:24:37 -05:00
Sergey Muraviov
3e7ce6e9ae
gh-127248: Fix several removed or misnamed files in pythoncore.vcxproj (GH-127249) 2024-11-25 14:56:46 +00:00
Victor Stinner
d9331f1b16
gh-107954: Document PEP 741 in What's New 3.14 (#127056) 2024-11-25 15:24:33 +01:00
Jun Komoda
c7f1e3e150
gh-127183: Add _ctypes.CopyComPointer tests (GH-127184)
* Make `create_shelllink_persist` top level function.

* Add `CopyComPointerTests`.

* Add more tests.

* Update tests.

* Add assertions for `Release`'s return value.
2024-11-25 14:55:07 +01:00
Jun Komoda
f4f075b3d5
Replace :platform: with .. availability:: in socket.ioctl doc. (GH-127122)
In `socket.ioctl`, `:platform:` -> `.. availability::`
2024-11-25 13:53:17 +01:00
Sergey B Kirpichev
c595eae84c
gh-127238: adjust error message for sys.set_int_max_str_digits() (#127241)
Now it's correct and closer to Python/initconfig.c
2024-11-25 00:29:55 -05:00
Brandt Bucher
17c16aea66
GH-115869: Make jit_stencils.h reproducible (GH-127166) 2024-11-24 14:42:50 -08:00
Barney Gale
307c633586
Improve pathname2url() and url2pathname() docs (#127125)
These functions have long sown confusion among Python developers. The
existing documentation says they deal with URL path components, but that
doesn't fit the evidence on Windows:

    >>> pathname2url(r'C:\foo')
    '///C:/foo'
    >>> pathname2url(r'\\server\share')
    '////server/share'  # or '//server/share' as of quite recently

If these were URL path components, they would imply complete URLs like
`file://///C:/foo` and `file://////server/share`. Clearly this isn't right.
Yet the implementation in `nturl2path` is deliberate, and the 
`url2pathname()` function correctly inverts it.

On non-Windows platforms, the behaviour until quite recently is to simply
quote/unquote the path without adding or removing any leading slashes. This
behaviour is compatible with *both* interpretations -- 1) the value is a
URL path component (existing docs), and 2) the value is everything
following `file:` (this commit)

The conclusion I draw is that these functions operate on everything after
the `file:` prefix, which may include an authority section. This is the
only explanation that fits both the  Windows and non-Windows behaviour.
It's also a better match for the function names.
2024-11-24 17:33:46 +00:00
Serhiy Storchaka
97b2ceaaaf
gh-127217: Fix pathname2url() for paths starting with multiple slashes on Posix (GH-127218) 2024-11-24 19:30:29 +02:00
da-woods
2bb7846cac
Fix macro expansions in critical section docs (#127226) 2024-11-24 12:21:02 -05:00
Bénédikt Tran
e0ef08f5b4
gh-122356: restore the position of a file-like object after zipfile.is_zipfile (#122397) 2024-11-24 11:36:15 -05:00
Yuki Kobayashi
3d8ac48aed
gh-101100: Fix sphinx warnings of removed opcodes (#127222) 2024-11-24 17:43:25 +02:00
Savannah Ostrowski
2104bde572
GH-127133: Remove ability to nest argument groups & mutually exclusive groups (#127186) 2024-11-24 15:20:37 +00:00
Sergey B Kirpichev
f7bb658124
gh-113841: fix possible undefined division by 0 in _Py_c_pow() (GH-127211)
`x**y == 1/x**-y ` thus changing `/=` to `*=` by negating the exponent.
2024-11-23 23:37:37 -08:00
Stephen Morton
a4d4c1ede2
gh-126662: harmonize naming for three namedtuple base classes in urllib.parse (GH-126663)
harmonize naming for three namedtuple base classes in urllib.parse
2024-11-23 18:36:48 -08:00
Barney Gale
4ea71278ca
pathlib tests: move walk() tests into their own classes (GH-126651)
Move tests for Path.walk() into a new PathWalkTest class, and apply a similar change in tests for the ABCs. This allows us to properly tear down the walk test hierarchy in tearDown(), rather than leaving it to os_helper.rmtree().
2024-11-23 18:31:00 -08:00
Stan U.
dbd23790db
Fix "useable" typo in docs (#127200)
Fix typo in docs
2024-11-23 16:41:01 -05:00
Richard Hansen
e3038e976b
Doc: C API: Fix Py_NewInterpreterFromConfig example code (#126667) 2024-11-23 21:47:08 +02:00
Barney Gale
cc813e10ff
GH-125866: Preserve Windows drive letter case in file URIs (#127138)
Stop converting Windows drive letters to uppercase in
`urllib.request.pathname2url()` and `url2pathname()`. This behaviour is
unnecessary and inconsistent with pathlib's file URI implementation.
2024-11-23 10:41:39 +00:00
Savannah Ostrowski
a13e94d84b
GH-127134: Add note about forward compatibility for suggest_on_error (#127137) 2024-11-22 19:18:18 -08:00
Rafael Fontenelle
39e60aeb38
Fix a few typos found in the docs (GH-127126) 2024-11-22 16:02:51 -08:00
mpage
d24a22e9b6
gh-115999: Record success in specialize (#127167)
Record success in `specialize`

This matches the existing behavior where we increment the success
stat for the generic opcode each time we successfully specialize
an instruction.
2024-11-22 12:07:05 -08:00
Irit Katriel
4b12a6ff4a
gh-119786: add code object doc, inline locations.md into it (#126832) 2024-11-22 19:27:41 +00:00
Radislav Chugunov
ca3ea9ad05
gh-109746: Make _thread.start_new_thread delete state of new thread on its startup failure (GH-109761)
If Python fails to start newly created thread
due to failure of underlying PyThread_start_new_thread() call,
its state should be removed from interpreter' thread states list
to avoid its double cleanup.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-11-22 21:20:07 +02:00
Filipe Laíns 🇵🇸
a264637654
GH-89435: os.path should not be a frozen module (#126924) 2024-11-22 18:50:30 +00:00
Sam Gross
4759ba6eec
gh-127022: Simplify PyStackRef_FromPyObjectSteal (#127024)
This gets rid of the immortal check in `PyStackRef_FromPyObjectSteal()`.
Overall, this improves performance about 2% in the free threading
build.

This also renames `PyStackRef_Is()` to `PyStackRef_IsExactly()` because
the macro requires that the tag bits of the arguments match, which is
only true in certain special cases.
2024-11-22 12:55:33 -05:00
Łukasz Langa
8214e0f709
Enable aarch64 Ubuntu CI jobs (#125786)
This change enables custom GHA runners for Ubuntu-24.04 that run on Arm hardware. It also prepares for Windows runners on Arm hardware, but doesn't enable that just yet, because the Arm GHA runner images for Windows need to be updated.
2024-11-22 18:29:18 +01:00
Kirill Podoprigora
27486c3365
gh-115999: Add free-threaded specialization for UNPACK_SEQUENCE (#126600)
Add free-threaded specialization for `UNPACK_SEQUENCE` opcode.
`UNPACK_SEQUENCE_TUPLE/UNPACK_SEQUENCE_TWO_TUPLE` are already thread safe since tuples are immutable.
`UNPACK_SEQUENCE_LIST` is not thread safe because of nature of lists (there is nothing preventing another thread from adding items to or removing them the list while the instruction is executing). To achieve thread safety we add a critical section to the implementation of `UNPACK_SEQUENCE_LIST`, especially around the parts where we check the size of the list and push items onto the stack.


---------

Co-authored-by: Matt Page <mpage@meta.com>
Co-authored-by: mpage <mpage@cs.stanford.edu>
2024-11-22 19:00:35 +02:00
Eric Snow
5ba67af006
gh-127117: Ensure the Correct Last Fields of PyInterpreterState and of _PyRuntimeState (gh-127118)
We add some comments so contributors can be aware and we move one out-of-place field up.
2024-11-22 09:37:02 -07:00
Serhiy Storchaka
a5440d4a38
gh-86463: Fix a trailing space in argparse.rst (#127162) 2024-11-22 16:34:05 +00:00
Andrei Bodrov
1848ce61f3
gh-88110: Clear concurrent.futures.thread._threads_queues after fork to avoid joining parent process' threads (GH-126098)
Threads are gone after fork, so clear the queues too. Otherwise the
child process (here created via multiprocessing.Process) crashes on
interpreter exit.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-11-22 18:20:34 +02:00
Jun Komoda
7725c0371a
gh-126384: Add tests to verify the behavior of basic COM methods. (GH-126610) 2024-11-22 16:57:31 +01:00
Victor Stinner
0cb20177d6
gh-109413: Fix libregrtest get_running() (#127153)
Skip threads which are not running.
2024-11-22 16:56:03 +01:00
Serhiy Storchaka
8899e85de1
gh-127001: Fix PATHEXT issues in shutil.which() on Windows (GH-127035)
* Name without a PATHEXT extension is only searched if the mode does not
  include X_OK.
* Support multi-component PATHEXT extensions (e.g. ".foo.bar").
* Support files without extensions in PATHEXT contains dot-only extension
  (".", "..", etc).
* Support PATHEXT extensions that end with a dot (e.g. ".foo.").
2024-11-22 17:52:15 +02:00
Sergey Muraviov
615abb99a4
Fix broken XML in Visual Studio project file (GH-127142) 2024-11-22 15:30:01 +00:00
Serhiy Storchaka
0cb4d6c654
gh-86463: Fix default prog in subparsers if usage is used in the main parser (GH-125891)
The usage parameter of argparse.ArgumentParser no longer
affects the default value of the prog parameter in subparsers.

Previously the full custom usage of the main parser was used as
the prog prefix in subparsers.
2024-11-22 17:29:33 +02:00
Cody Maloney
46f8a7bbdb
gh-127076: Ignore memory mmap in FileIO testing (#127088)
`mmap`, `munmap`, and `mprotect` are used by CPython for memory
management, which may occur in the middle of the FileIO tests. The
system calls can also be used with files, so `strace` includes them
in its `%file` and `%desc` filters.

Filter out the `mmap` system calls related to memory allocation for the
file tests. Currently FileIO doesn't do `mmap` at all, so didn't add
code to track from `mmap` through `munmap` since it wouldn't be used.
For now if an `mmap` on a fd happens, the call will be included (which
may cause test to fail), and at that time support for tracking the
address throug `munmap` could be added.
2024-11-22 15:55:32 +01:00
Tomas R.
0a1944cda8
gh-126700: pygettext: Support more gettext functions (GH-126912)
Support multi-argument gettext functions: ngettext(), pgettext(), dgettext(), etc.
2024-11-22 16:52:16 +02:00
Sam Gross
f83ca6962a
gh-127065: Make methodcaller thread-safe in free threading build (#127109)
The `methodcaller` C vectorcall implementation uses an arguments array
that is shared across calls. The first argument is modified on every
invocation. This isn't thread-safe in the free threading build. I think
it's also not safe in general, but for now just disable it in the free
threading build.
2024-11-22 09:21:59 -05:00
Jun Komoda
3c770e3f09
gh-127082: Replace "Windows only" with the availability: Windows in ctypes doc (#127099) 2024-11-22 08:56:34 +01:00
Peter Bierma
89125e9f9f
Allow local use of static PyMutex in the C analyzer (#127102) 2024-11-22 08:48:39 +01:00
Barney Gale
8c98ed846a
GH-127078: url2pathname(): handle extra slash before UNC drive in URL path (#127132)
Decode a file URI like `file://///server/share` as a UNC path like
`\\server\share`. This form of file URI is created by software the simply
prepends `file:///` to any absolute Windows path.
2024-11-22 04:12:50 +00:00
Barney Gale
ebf564a1d3
GH-126766: url2pathname(): handle 'localhost' authority (#127129)
Discard any 'localhost' authority from the beginning of a `file:` URI. As a
result, file URIs like `//localhost/etc/hosts` are correctly decoded as
`/etc/hosts`.
2024-11-22 03:17:06 +00:00
Savannah Ostrowski
fcfdb55465
GH-122679: Add register() to argparse docs (#126939)
* Add register() to argparse docs

* Add newline

* Formatting

* Fix codeblock

* Move section

* Add signature

* Add newline

* Fix indent

* Fix indent take 2

* Rephrase

* Simplify language

* Address PR comments

* Add references to register in type and action

* Remove unnecessary reference

* Rephrase and add success case
2024-11-21 16:36:11 -08:00
Barney Gale
fd133d4f21
GH-126601: pathname2url(): handle NTFS alternate data streams (#126760)
Adjust `pathname2url()` to encode embedded colon characters in Windows
paths, rather than bailing out with an `OSError`.

Co-authored-by: Steve Dower <steve.dower@microsoft.com>
2024-11-22 00:29:05 +00:00