Repository navigation
merging into my modded python. thank you for helping me - #1
Open
sidlovescoding wants to merge 338 commits into
Open
sidlovescoding wants to merge 338 commits into
sidlovescoding wants to merge 338 commits into
Conversation
… urllib.request.ProxyHandler (#161729) gh-52330 Document how a proxy auto-config (PAC) file can be used with urllib.request.ProxyHandler We will point to the pypi package pypac which supports PAC discovery and can be extended as a custom ProxyHandler to be used with urllib.request. The documentation will point to the pypi package and share high-level example of using this.
* Don't try to close mmap in SharedMemory.__del__ * Add a test for SharedMemory finalization with a live buffer, expand NEWS --------- Co-authored-by: Gregory P. Smith <greg@krypto.org>
* gh-154643: Only use _Py_STDC_VERSION when defined This fixes: $ g++ -I/usr/include/python3.15 -c -Werror=undef test.cpp In file included from /usr/include/python3.15/Python.h:68, from test.cpp:1: /usr/include/python3.15/pyport.h:494:9: error: ‘_Py_STDC_VERSION’ is not defined, evaluates to ‘0’ [-Werror=undef] 494 | # elif _Py_STDC_VERSION >= 201112L && !defined(__STDC_NO_THREADS__) | ^~~~~~~~~~~~~~~~ cc1plus: some warnings being treated as errors For any test.cpp that has #include <Python.h>. For locating the place for the added test, I used LLM. The main issue I could reproduce was in Include/pyport.h. Include/cpython/pyatomic.h was updated for completeness. Include/internal/mimalloc/mimalloc/atomic.h also has this for __STDC_VERSION__ but was left untouched as it is code from a bundled project and is likely not exposed publicly. Assisted-By: Claude Opus 4.6 * Also add test for C * Add -Werror=undef to PUBLIC_CFLAGS & PEDANTIC_CXXFLAGS in setup.py * Drop tests, we use PUBLIC_CFLAGS & PEDANTIC_CXXFLAGS instead
…161774) Co-authored-by: Stan Ulbrych <stan@python.org>
…#161790) Co-authored-by: Stan Ulbrych <stan@python.org>
Co-authored-by: Stan Ulbrych <stan@python.org>
gh-161827: Mark _PyEval_EvalFrameDefault as Py_NO_INLINE Signed-off-by: Iason Krommydas <iason.krom@gmail.com>
…RLs (#161596) urllib.request could not authenticate with a proxy for an https URL using ProxyBasicAuthHandler or ProxyDigestAuthHandler: http.client raised a plain OSError when the proxy answered the CONNECT request with 407, so the http_error_407 handlers never ran. * http.client: add ProxyTunnelError, an OSError subclass carrying the code, reason and headers of the proxy's response. It holds no socket and can be pickled. * urllib.request: do_open() passes a 407 to CONNECT on to the error handlers, so the request is retried with Proxy-Authorization on the CONNECT. Other CONNECT failures still raise URLError. * Request.set_proxy() keeps the tunnel when a request is re-opened, so the retried request still sends the path, not the absolute URL. * ProxyDigestAuthHandler computes the digest over the CONNECT request (CONNECT host:port) when tunnelling. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* gh-160303: Fix bytearray state after a failed del b[:n] When shrinking the storage of a bytearray which has a logical offset, allocate the new buffer before modifying the object, so that bytearray_setslice_linear() can restore ob_start if the allocation fails. * gh-160303: Keep ob_start instead of allocating in del b[:n] Move ob_start and the size before the shrinking resize, so a failed shrink leaves the bytes removed and the larger block in place, as the non-front path already does. Split the checks out of bytearray_resize_lock_held() so the slice code can resize directly. Move the tests into test_resize_error. * gh-160303: Test failed shrinks not at the front; narrow the unchecked resize Only the front path of bytearray_setslice_linear() calls bytearray_resize_unchecked(): it has already advanced ob_start and reduced the size, so bytearray_resize_lock_held() would return early without releasing memory. Other slices go through bytearray_resize_lock_held() again and keep the failure fixup to themselves. test_resize_error now also covers slices in the middle and at the end, and checks the null byte after the data with float().
…1061) Expat calls the default handler once per 1024-byte piece of a token that needs encoding conversion. Install a no-op instead of NULL when the handler is cleared after an error or unset from within a callback, as is already done for the character data handler. ANT-2026-0SJB3WWC
* Add 'Expect: 100-Continue' support to httplib Previously, http.client would always send content body immediately and ignore any 100 responses. This change makes HTTPClient.request() wait for a `Continue` response if the `Expect: 100-Continue` header is set, and adds a parameter to HTTPClient.getresponse() that will cause it to return 100 responses instead of eating them. --------- Co-authored-by: Peter Bierma <zintensitydev@gmail.com> Co-authored-by: Senthil Kumaran <senthil@python.org>
…n scripts (GH-154850) venv wrote the activation scripts with a fixed mode copied from the packaged templates, so they ignored the process umask and any default ACL, unlike every other file venv creates. Copy only the data and let the new files inherit the umask and ACL.
Doc: Correct FAQ explanations and extension debugging instructions
…th lazy imports (#161618)
…8987) Node.cloneNode() and Document.importNode() raised NamespaceErr for nodes without a namespace whose name contains a colon, for example created with createElement("svg:rect"). Such nodes are now cloned with the DOM Level 1 factory methods, which keeps also their prefix.
Co-authored-by: Victor Stinner <vstinner@python.org>
…1862) move the continue timeout assignment after the connection state check so a rejected putrequest call cannot modify the active request.
…0255) SPARC V9 has no frame record. The caller's %fp (biased by 2047) and return address are in slots 14 and 15 of the register window save area at fp, and are only there after the windows have been flushed to the stack.
…161105) IDNA normalization maps U+00A0 and similar characters to an ASCII space, so check the encoded host that is put into the CONNECT request line. ANT-2026-PIZPMECM
…156973) Co-authored-by: Sam Gross <colesbury@gmail.com>
* gh-162606: Fix port races in asyncio connection-refused tests test_create_connection_local_addr_skip_different_family and test_sock_client_fail expected a connect to an "unused" port to be refused, but the port was not reserved, so a parallel test could start listening on it and the connect would succeed. Keep a bound, non-listening socket open for the duration of each test instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * gh-162606: Avoid find_unused_port() races in more asyncio tests Bind servers to port 0 instead of picking a port first and binding it later, retry test_create_connection_local_addr on EADDRINUSE, and keep the port of test_open_connection_happy_eyeball_refcycles reserved on both loopback addresses so the connection is reliably refused. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * gh-162606: Remove unused import in test_proactor_events Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * gh-162606: Accept TimeoutError for non-listening ports on macOS macOS and iOS fail a connect to a bound but non-listening port with ETIMEDOUT immediately instead of ECONNREFUSED. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…ests (#162617) * gh-162616: Clear asyncio's `iscoroutine_typecache`s between refleak tests Creating a task checks if the argument is a coroutine. For non-native coroutines, this adds the type (the test's `Wrapper`) to `_asyncio`'s `iscoroutine_typecache`. Another check adds it to `asyncio.coroutines._iscoroutine_typecache`. Both caches are capped at 100 entries, so refleak tests report a reference leak unless you run 100+ warmup runs. Clear both caches in `libregrtest.utils.clear_caches`. * Apply suggestions from code review --------- Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
…rompt (GH-162557) On Unix with threaded Tcl, wait for events or input instead of polling. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…H-156342) In the free-threaded build, two threads creating Tcl interpreters at the same time could both free the Tcl lock. Interpreter creation is now serialized.
IncrementalNewlineDecoder AC vectorcall
`@vectorcall` with `**kwargs` always delegated to the keyword helper, which only reads a kwargs dict, so it couldn't be generated. The vectorcall now parses positionals with the shared positional emitter and builds the dict from kwnames only when there are keywords, otherwise passing NULL, as the tuple parser does. The `*args` and `**kwargs` parsers take the calling convention explicitly rather than reading `self.fastcall`, which describes the Python-visible entry point having stack style args, not the vectorcall. Fix `as` in AC **kwargs parameters: `*args as name` already set the C name; `**kwargs as name` failed to parse because the 'as' regex only allowed a single leading star. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Replace hand-written `picklebuf_new` with Argument Clinic + vectorcall.
Extra positional arguments now raise `TypeError: PickleBuffer expected 1 argument, got N` instead of `TypeError: PickleBuffer() takes at most 1 argument (N given)`. Keyword arguments now raise `TypeError: PickleBuffer() takes no keyword arguments` instead of `TypeError: PickleBuffer() takes exactly 1 positional argument (0 given)`.
Benchmark:
```
+--------------------------------+--------+------------------------+
| Benchmark | main | patch |
+================================+========+========================+
| PickleBuffer(b) | 187 ns | 112 ns: 1.67x faster |
| pickle.PickleBuffer(b) | 205 ns | 124 ns: 1.66x faster |
+--------------------------------+--------+------------------------+
| Geometric mean | (ref) | 1.66x faster |
+--------------------------------+--------+------------------------+
```
```python
import pyperf
SETUP = """
import pickle
b = b'abc'
PickleBuffer = pickle.PickleBuffer
"""
CASES = [
('PickleBuffer(b)', 'PickleBuffer(b)'),
('pickle.PickleBuffer(b)', 'pickle.PickleBuffer(b)')
]
runner = pyperf.Runner()
for name, stmt in CASES:
runner.timeit(name, stmt=stmt, setup=SETUP)
```
…5249) The key of the extensions cache was built with _PyUnicode_AsUTF8NoNUL(), so importing an extension module failed with UnicodeEncodeError if its path contained characters unencodable in UTF-8, e.g. surrogate escapes of an undecodable file name. The raw content of the strings is now used. The rejection of embedded null characters, which was a side effect of the UTF-8 encoding, is now explicit in the extension module loader. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Name the Argument Clinic parameter `buffer` to match the documented `PickleBuffer(buffer)` and move the type docstring into the clinic block, so `inspect.signature(pickle.PickleBuffer)` gives `(buffer, /)`. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* gh-92810: Lock-free cache implementation for ABCMeta Replace the sets of weak references used for the ABC registry and the positive/negative isinstance caches with hash tables keyed by class identity. Cached isinstance() and issubclass() checks are served without locking or reference count updates on the free-threaded build, and a negative result is no longer propagated into the cache of every subclass of the ABC, which made such checks quadratic for large hierarchies.
Registered classes are now also added to the positive cache, so `register()` after `_abc_registry_clear()` did nothing for them and the registration was lost once the caches were cleared. This broke the registry restoring of regrtest in refleak mode.
Add `@vectorcall` to existing AC.
Benchmark:
```
+-------------------------------------+--------+----------------------+
| Benchmark | main | patch |
+=====================================+========+======================+
| batched(x, 2) | 171 ns | 143 ns: 1.20x faster |
+-------------------------------------+--------+----------------------+
| pairwise(x) | 174 ns | 145 ns: 1.20x faster |
+-------------------------------------+--------+----------------------+
| groupby(x) | 173 ns | 131 ns: 1.32x faster |
+-------------------------------------+--------+----------------------+
| cycle(x) | 171 ns | 143 ns: 1.20x faster |
+-------------------------------------+--------+----------------------+
| dropwhile(pred, x) | 162 ns | 127 ns: 1.28x faster |
+-------------------------------------+--------+----------------------+
| takewhile(pred, x) | 162 ns | 128 ns: 1.27x faster |
+-------------------------------------+--------+----------------------+
| starmap(pow, pairs) | 173 ns | 136 ns: 1.28x faster |
+-------------------------------------+--------+----------------------+
| combinations(x, 2) | 208 ns | 157 ns: 1.32x faster |
+-------------------------------------+--------+----------------------+
| combinations_with_replacement(x, 2) | 201 ns | 160 ns: 1.26x faster |
+-------------------------------------+--------+----------------------+
| permutations(x) | 199 ns | 156 ns: 1.27x faster |
+-------------------------------------+--------+----------------------+
| accumulate(x) | 169 ns | 134 ns: 1.26x faster |
+-------------------------------------+--------+----------------------+
| compress(x, selectors) | 172 ns | 143 ns: 1.20x faster |
+-------------------------------------+--------+----------------------+
| filterfalse(pred, x) | 159 ns | 125 ns: 1.27x faster |
+-------------------------------------+--------+----------------------+
| count() | 133 ns | 116 ns: 1.15x faster |
+-------------------------------------+--------+----------------------+
```
```python
import pyperf
SETUP = """
import itertools
x = [1, 2, 3]
pred = lambda v: False
pairs = [(2, 3)]
selectors = [1, 0, 1]
"""
CASES = [
('batched(x, 2)', 'itertools.batched(x, 2)'),
('pairwise(x)', 'itertools.pairwise(x)'),
# _grouper is internal; exercised through groupby()
('groupby(x)', 'itertools.groupby(x)'),
# teedataobject is internal; exercised through tee()
('tee(x, 2)', 'itertools.tee(x, 2)'),
('cycle(x)', 'itertools.cycle(x)'),
('dropwhile(pred, x)', 'itertools.dropwhile(pred, x)'),
('takewhile(pred, x)', 'itertools.takewhile(pred, x)'),
('starmap(pow, pairs)', 'itertools.starmap(pow, pairs)'),
('combinations(x, 2)', 'itertools.combinations(x, 2)'),
('combinations_with_replacement(x, 2)', 'itertools.combinations_with_replacement(x, 2)'),
('permutations(x)', 'itertools.permutations(x)'),
('accumulate(x)', 'itertools.accumulate(x)'),
('compress(x, selectors)', 'itertools.compress(x, selectors)'),
('filterfalse(pred, x)', 'itertools.filterfalse(pred, x)'),
('count()', 'itertools.count()'),
]
runner = pyperf.Runner()
for name, stmt in CASES:
runner.timeit(name, stmt=stmt, setup=SETUP)
```
…rameter (GH-162179) Records created by the logging methods can hold `(None, None, None)` (`exc_info=True` outside an `except` block) or a tuple whose traceback is `None` (an exception instance that was never raised). Widen the documented type to cover both. Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
…op() (GH-162651) A nested mainloop() now restores the dispatching flag instead of resetting it, so the outer mainloop() still accepts calls from other threads. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…threads (GH-162649) quit() now stops only the mainloop() of its interpreter, and wakes it up if it is called from other thread. An exception raised in a callback is now only raised by an event loop in the same thread. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Remove the Tcl lock and the code for non-threaded Tcl. Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Add relaxed _Py_atomic_add_*
Add _Py_atomic_add_*_relaxed() for all arithmetic types supported by
_Py_atomic_add_*(). The existing add operations are sequentially
consistent, which is stronger (and on ARM, measurably more
expensive) than necessary for uses like statistics counters and unique
ID allocation, where the add must be atomic but does not need to order
surrounding memory accesses.
The GCC/Clang backend uses __atomic_fetch_add() with __ATOMIC_RELAXED,
and the standard C11/C++11 backend uses atomic_fetch_add_explicit()
with memory_order_relaxed. The MSVC backend uses the
_InterlockedExchangeAdd*_nf ("no fence") intrinsics on ARM64; on x86
and x64 those intrinsics do not exist, so it falls back to the plain
interlocked intrinsics, whose stronger ordering is a conforming
implementation of relaxed (x86 has no cheaper atomic
read-modify-write). As with the sequentially consistent version, 64-bit
adds on 32-bit x86 fall back to a compare-exchange loop.
* Use a relaxed add for the module index allocator
* Use relaxed adds for the GC allocation counter
* Use relaxed adds for the lru_cache hit/miss counters
* Use a relaxed add for the asyncio task name counter
* Add relaxed _Py_atomic_compare_exchange
* Use relaxed compare_exchange for gc young count
Use vsnprintf() on all platforms in PyOS_vsnprintf(). Since Visual Studio 2015, the MSVC runtime provides a C11-conforming vsnprintf(), so the _vsnprintf() special case is no longer needed. Add a test for the truncation case and update the outdated comment. Co-authored-by: Victor Stinner <vstinner@python.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.