repo
stringclasses
1 value
instance_id
stringlengths
20
22
problem_statement
stringlengths
126
60.8k
merge_commit
stringlengths
40
40
base_commit
stringlengths
40
40
python/cpython
python__cpython-116151
# Update installers to Tcl/Tk 8.6.14 Tcl/Tk 8.6.14 is out today: https://sourceforge.net/p/tcl/mailman/tcl-core/thread/SA1PR09MB887585E09B30AE57F0E7F2E3865F2%40SA1PR09MB8875.namprd09.prod.outlook.com/#msg58743251 I will open a few PRs for these shortly: one here for the macOS installer, and others at cpython-source-deps for Windows: https://github.com/python/cpython-source-deps/pull/33 https://github.com/python/cpython-source-deps/pull/34 There is still a known test failure with Tk 8.6.14 which I have neglected: gh-107262 <!-- gh-linked-prs --> ### Linked PRs * gh-116151 * gh-117030 * gh-119847 * gh-119922 * gh-120396 <!-- /gh-linked-prs -->
4fa95c6ec392b9fc80ad720cc4a8bd2786fc2835
3cc5ae5c2c6e729ca2750ed490dad56faa7c342d
python/cpython
python__cpython-116144
# Race condition in pydoc._start_server # Bug report ### Bug description: There's a race condition in `pydoc._start_server` - when `_start_server()` returns, we should get an object with a valid `docserver` attribute (set [here](https://github.com/python/cpython/blob/0656509033948780e6703391daca773c779041f7/Lib/pydoc.py#L2507)). However, the function only checks that the `serving` attribute is truthy before returning ([here](https://github.com/python/cpython/blob/0656509033948780e6703391daca773c779041f7/Lib/pydoc.py#L2532)). The race is triggered if setting `serving` to `True` [here](https://github.com/python/cpython/blob/0656509033948780e6703391daca773c779041f7/Lib/pydoc.py#L2513) happens before setting the `docserver` attribute [here](https://github.com/python/cpython/blob/0656509033948780e6703391daca773c779041f7/Lib/pydoc.py#L2507) -- we observed this happening frequently in the Cinder ASAN test suite (originally observed and fixed by @jbower). The race can be forced to happen by forcing a context switch after setting `self.serving = True`: ```diff diff --git a/Lib/pydoc.py b/Lib/pydoc.py index b0193b4a851..117a1dc8369 100755 --- a/Lib/pydoc.py +++ b/Lib/pydoc.py @@ -2511,6 +2511,7 @@ def run(self): def ready(self, server): self.serving = True + time.sleep(0.1) self.host = server.host self.port = server.server_port self.url = 'http://%s:%d/' % (self.host, self.port) ``` and running the `test_pydoc.PydocServerTest.test_server` test, which would fail and hang: ``` $ ./python.exe -m test test_pydoc -v -m 'test.test_pydoc.test_pydoc.PydocServerTest.test_server' == CPython 3.13.0a4+ (heads/main-dirty:06565090339, Feb 29 2024, 11:49:21) [Clang 15.0.0 (clang-1500.1.0.2.5)] == macOS-14.3.1-arm64-arm-64bit-Mach-O little-endian == Python build: debug == cwd: /Users/itamaro/work/pyexe/main-dbg/build/test_python_worker_66701æ == CPU count: 12 == encodings: locale=UTF-8 FS=utf-8 == resources: all test resources are disabled, use -u option to unskip tests Using random seed: 792156149 0:00:00 load avg: 5.34 Run 1 test sequentially 0:00:00 load avg: 5.34 [1/1] test_pydoc.test_pydoc test_server (test.test_pydoc.test_pydoc.PydocServerTest.test_server) ... ERROR test_server (test.test_pydoc.test_pydoc.PydocServerTest.test_server) ... ERROR Warning -- threading_cleanup() failed to clean up threads in 1.0 seconds Warning -- before: thread count=0, dangling=1 Warning -- after: thread count=1, dangling=2 Warning -- Dangling thread: <_MainThread(MainThread, started 7977835584)> Warning -- Dangling thread: <ServerThread(Thread-1, started 6150828032)> ====================================================================== ERROR: test_server (test.test_pydoc.test_pydoc.PydocServerTest.test_server) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/itamaro/work/cpython/Lib/test/test_pydoc/test_pydoc.py", line 1823, in test_server self.assertIn('localhost', serverthread.url) ^^^^^^^^^^^^^^^^ AttributeError: 'ServerThread' object has no attribute 'url' ====================================================================== ERROR: test_server (test.test_pydoc.test_pydoc.PydocServerTest.test_server) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/itamaro/work/cpython/Lib/test/test_pydoc/test_pydoc.py", line 1821, in <lambda> lambda: serverthread.stop() if serverthread.serving else None ~~~~~~~~~~~~~~~~~^^ File "/Users/itamaro/work/cpython/Lib/pydoc.py", line 2521, in stop self.docserver.quit = True ^^^^^^^^^^^^^^ AttributeError: 'ServerThread' object has no attribute 'docserver' ---------------------------------------------------------------------- Ran 1 test in 1.321s FAILED (errors=2) Warning -- threading._dangling was modified by test_pydoc.test_pydoc Warning -- Before: {<weakref at 0x10499c280; to '_MainThread' at 0x102eb0a10>} Warning -- After: {<weakref at 0x10550f3f0; to '_MainThread' at 0x102eb0a10>, <weakref at 0x10550f380; to 'ServerThread' at 0x1049b81f0>} test test_pydoc.test_pydoc failed test_pydoc.test_pydoc failed (2 errors) == Tests result: FAILURE == 1 test failed: test_pydoc.test_pydoc Total duration: 1.4 sec Total tests: run=1 (filtered) Total test files: run=1/1 (filtered) failed=1 Result: FAILURE ``` The race can be fixed by making sure the `docserver` attribute is also set before returning (PR incoming). ### CPython versions tested on: 3.8, 3.10, 3.12, CPython main branch ### Operating systems tested on: Linux, macOS <!-- gh-linked-prs --> ### Linked PRs * gh-116144 * gh-116415 * gh-116416 <!-- /gh-linked-prs -->
02ee475ee3ce9468d44758df2cd79df9f0926303
e800265aa1f3451855a2fc14fbafc4d89392e35c
python/cpython
python__cpython-116130
# JIT support for `aarch64-pc-windows-msvc` # Feature or enhancement I don't have hardware to test on yet, but the linked PR at least gets things building for WoA. <!-- gh-linked-prs --> ### Linked PRs * gh-116130 <!-- /gh-linked-prs -->
ffed8d985b57a97def2ec40c61b71a22a2af1b48
981f27dcc4be8bc4824464c9d75f2ea6c868863f
python/cpython
python__cpython-116350
# Implement PEP 705 (TypedDict: Read-only items) # Feature or enhancement PEP-705 was just accepted. For the runtime implementation, we'll need: - [ ] Add the new `ReadOnly` special form - [ ] Adjust the implementation of `TypedDict` - [ ] Update docs The [typing-extensions implementation](https://github.com/python/typing_extensions/blob/main/src/typing_extensions.py) should provide a good baseline. cc @alicederyn <!-- gh-linked-prs --> ### Linked PRs * gh-116350 <!-- /gh-linked-prs -->
df4784b3b7519d137ca6a1aeb500ef59e24a7f9b
3265087c07c261d1b5f526953682def334a52d56
python/cpython
python__cpython-116129
# Implement PEP 696 (Type parameter defaults) # Feature or enhancement Implement PEP-696, which was just accepted. Off the top of my head, we'll need the following: - [ ] Grammar changes - [ ] Changes in typing.py to type parameter application logic - [ ] Documentation I'll work on the first one but contributions on the other two are appreciated. The [implementation in typing-extensions](https://github.com/python/typing_extensions/blob/main/src/typing_extensions.py) can serve as an inspiration. cc @Gobot1234 <!-- gh-linked-prs --> ### Linked PRs * gh-116129 <!-- /gh-linked-prs -->
ca269e58c290be8ca11bb728004ea842d9f85e3a
852263e1086748492602a90347ecc0a3925e1dda
python/cpython
python__cpython-116138
# Add SBOM regeneration to PCBuild/build.bat Allows for Windows contributors to regenerate the SBOM file, common with the `cpython-source-deps` SBOM. <!-- gh-linked-prs --> ### Linked PRs * gh-116138 * gh-118435 <!-- /gh-linked-prs -->
72dae53e09a5344bf4922d934a34a2fa48a11c86
9a75d56d5d9fdffb6ce9d83ede98486df238102d
python/cpython
python__cpython-116117
# Fix building CPython in windows-i686 with clang-cl # Bug report ### Bug description: ``` In file included from $(SOURCE_ROOT)/python3/src/Modules/_blake2/blake2b_impl.c:30: $(SOURCE_ROOT)/python3/src/Modules/_blake2/impl/blake2b.c(31,23): error: conflicting types for '_mm_set_epi64x' static inline __m128i _mm_set_epi64x( const uint64_t u1, const uint64_t u0 ) ^ $(TOOL_ROOT)/clang/14.0.6/include/emmintrin.h(3613,1): note: previous definition is here _mm_set_epi64x(long long __q1, long long __q0) ^ 1 error generated. ``` ### CPython versions tested on: 3.12, CPython main branch ### Operating systems tested on: Windows <!-- gh-linked-prs --> ### Linked PRs * gh-116117 * gh-116315 <!-- /gh-linked-prs -->
9b9e819b5116302cb4e471763feb2764eb17dde8
0adfa8482d369899e9963206a3307f423309e10c
python/cpython
python__cpython-116371
# ``test_asyncio.test_streams`` raises a ``ResourceWarning`` # Bug report ### Bug description: ```python ./python.exe -m test test_asyncio.test_streams Using random seed: 4151462817 0:00:00 load avg: 28.75 Run 1 test sequentially 0:00:00 load avg: 28.75 [1/1] test_asyncio.test_streams /Users/admin/Projects/cpython/Lib/asyncio/streams.py:410: ResourceWarning: unclosed <StreamWriter transport=<_SelectorSocketTransport closing fd=12 read=idle write=<idle, bufsize=0>> reader=<StreamReader transport=<_SelectorSocketTransport closing fd=12 read=idle write=<idle, bufsize=0>>>> warnings.warn(f"unclosed {self!r}", ResourceWarning) == Tests result: SUCCESS == 1 test OK. Total duration: 1.5 sec Total tests: run=69 Total test files: run=1/1 Result: SUCCESS ``` ### CPython versions tested on: CPython main branch ### Operating systems tested on: macOS <!-- gh-linked-prs --> ### Linked PRs * gh-116371 <!-- /gh-linked-prs -->
990a5f17d05214abe8aafedf8e6418a0fb5ffd50
e205c5cd8f1a49d0ef126123312ee8a40d1416b6
python/cpython
python__cpython-116234
# Revert __signature__ to being a cache, remove string and callable support # Feature or enhancement ### Proposal: #100039 modified the behavior of `__signature__` as used by the inspect.signature function : - if the fields contains a Signature object, it is returned by the function (that doesn't change) - if it contains None, it is ignored (that doesn't change) - if it contains a string, it is converted to a signature (new) - if it contains a callable, it is called with no parameters and expected to return either a signature object or a string which will be treated as the above (new) - if it contains any other value, a TypeError is raised (this used to include strings and callables, it doesn't anymore) **As for strings :** The `__text_signature__` attribute's purpose is to pass a string to inform the signature. It's also only used for C-written functions, and iirc there's no way to use it in pure python : I understand that, but if the ability to specify a text override of inspect.signature must happen, then it should go through `__text_signature__` and not `__signature__`. **As for callables :** The Signature object qualifies, and the signature function inspects, callables. So, if when asked for the signature of a given callable you return another callable, it would make more sense to consider the second callable's signature as the signature of the first callable, than considering the second callable to _return_ the signature of the first. And why no parameters ? Why not pass the first callable as parameter ? Or the actual signature of the first callable ? That implementation raises a lot of questions of arbitrariness, which makes it a bad design in my opinion. **As for the purpose :** The use case, which was adding signature overrides to Enums, does not require any change to the inspect module, in fact a perfectly good alternative implementation can be found in #115937. It should also make for a considerably faster execution. I suggest reverting these changes. ### Links to previous discussion of this feature: This was discussed in #115937 and #116086 in which it was advised to separate the question of the implementation from that of the documentation. <!-- gh-linked-prs --> ### Linked PRs * gh-116234 <!-- /gh-linked-prs -->
eafd14fbe0fd464b9d700f6d00137415193aa143
b2a7272408593355c4c8e1d2ce9018cf96691bea
python/cpython
python__cpython-116105
# WindowsLoadTracker.__del__ fails if __init__ failed In the `WindowsLoadTracker` test helper, when the user doesn't have access to performance data, `__init__` will raise an exception before setting an attribute that `__del__` currently relies on: ``` Warning -- Failed to create WindowsLoadTracker: [WinError 5] Access is denied Warning -- Unraisable exception Exception ignored in: <function WindowsLoadTracker.__del__ at 0x00000182B08DB950> Traceback (most recent call last): File "C:\Users\cpydev\cpython\Lib\test\libregrtest\win_utils.py", line 113, in __del__ if self._running is not None: AttributeError: 'WindowsLoadTracker' object has no attribute '_running' ``` <!-- gh-linked-prs --> ### Linked PRs * gh-116105 * gh-116120 * gh-116121 <!-- /gh-linked-prs -->
186fa9387669bcba6d3974a99c012c2b2c6fb4ce
fb2e17b642fc3089e4f98e4bf6b09dd362e6b27d
python/cpython
python__cpython-116230
# New warning: ``‘fmt’ may be used uninitialized in this function [-Wmaybe-uninitialized]`` # Bug report ### Bug description: Popped up in https://github.com/python/cpython/pull/116101/files and https://github.com/python/cpython/pull/116096/files ### CPython versions tested on: CPython main branch ### Operating systems tested on: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-116230 <!-- /gh-linked-prs -->
cad3745b87ae85285a08ad8abd60cf10a59985b5
fb5e0344e41788988171f31c6b8d4fd1a13b9041
python/cpython
python__cpython-116101
# ``test_compile`` raises a ``DeprecationWarning`` # Bug report ### Bug description: ```python ./python.exe -m test test_compile Using random seed: 123325304 0:00:00 load avg: 1.63 Run 1 test sequentially 0:00:00 load avg: 1.63 [1/1] test_compile /Users/admin/Projects/cpython/Lib/test/test_compile.py:530: DeprecationWarning: If.__init__ missing 1 required positional argument: 'test'. This will become an error in Python 3.15. self.assertRaises(TypeError, compile, _ast.If(), '<ast>', 'exec') /Users/admin/Projects/cpython/Lib/test/test_compile.py:534: DeprecationWarning: BoolOp.__init__ missing 1 required positional argument: 'op'. This will become an error in Python 3.15. ast.body = [_ast.BoolOp()] == Tests result: SUCCESS == 1 test OK. Total duration: 1.7 sec Total tests: run=158 skipped=1 Total test files: run=1/1 Result: SUCCES ``` ### CPython versions tested on: CPython main branch ### Operating systems tested on: macOS <!-- gh-linked-prs --> ### Linked PRs * gh-116101 <!-- /gh-linked-prs -->
6a86030bc2519b4a6b055e0b47b9870c86db8588
bea2795be2c08dde3830f987830414f3f12bc1eb
python/cpython
python__cpython-116164
# ``test_interpreters`` fails when running with ``-R 3:3`` argument # Bug report ### Bug description: ```python ./python.exe -m test -R 3:3 test_interpreters Using random seed: 922541786 0:00:00 load avg: 2.79 Run 1 test sequentially 0:00:00 load avg: 2.79 [1/1] test_interpreters beginning 6 repetitions. Showing number of leaks (. for 0 or less, X for 10 or more) 123:456 XX. .../Include/object.h:1030: _Py_NegativeRefcount: Assertion failed: object has negative ref count <object at 0x104847bc0 is freed> Fatal Python error: _PyObject_AssertFailed: _PyObject_AssertFailed Python runtime state: initialized Current thread 0x00000001e11dd000 (most recent call first): <no Python frame> Extension modules: _xxsubinterpreters, _xxinterpqueues (total: 2) zsh: abort ./python.exe -m test -R 3:3 test_interpreters ``` ### CPython versions tested on: CPython main branch ### Operating systems tested on: macOS <!-- gh-linked-prs --> ### Linked PRs * gh-116164 <!-- /gh-linked-prs -->
2e94a6687c1a9750e9d2408a8dff0a422aeaf0e4
d7ddd90308324340855ddb9cc8dda2c1ee3a5944
python/cpython
python__cpython-116178
# ``test_frame`` fails when running with `-R 3:3` argument # Bug report ### Bug description: ```python ./python.exe -m test -R 3:3 test_frame Using random seed: 617081239 0:00:00 load avg: 38.69 Run 1 test sequentially 0:00:00 load avg: 38.69 [1/1] test_frame beginning 6 repetitions. Showing number of leaks (. for 0 or less, X for 10 or more) 123:456 Xtest test_frame failed -- Traceback (most recent call last): File "/Users/admin/Projects/cpython/Lib/test/test_frame.py", line 353, in test_sneaky_frame_object self.assertIs(g.gi_frame, sneaky_frame_object) ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AssertionError: <frame at 0x1063d5020, file '/Users/admin/Projects/cpython/Lib/test/test_frame.py', line 318, code f> is not <frame at 0x10637b9b0, file '/Users/admin/Projects/cpython/Lib/test/test_frame.py', line 353, code test_sneaky_frame_object> test_frame failed (1 failure) == Tests result: FAILURE == 1 test failed: test_frame Total duration: 146 ms Total tests: run=21 failures=1 Total test files: run=1/1 failed=1 Result: FAILURE ``` ### CPython versions tested on: CPython main branch ### Operating systems tested on: macOS <!-- gh-linked-prs --> ### Linked PRs * gh-116178 * gh-116687 <!-- /gh-linked-prs -->
7895a61168aad4565a1d953104c9ec620e7c588f
339c8e1c13adc299a0e2e49c93067e7817692380
python/cpython
python__cpython-116089
# (Auto-?) generate bottom checks in optimizer_cases.c.h If the abstract interpreter ever pushes `bottom` (i.e., a contradition) to the stack, it might as well stop -- this indicates we're looking at unreachable code (e.g., after a deopt that always deopts, or a branch that always branches). My original idea was to tweak the code generator to auto-generate such checks for the output stack effects (hand-waving a bit around array outputs, which are special anyways). But when I implemented that, I quickly found that most such pushes are freshly created symbols (e.g. `sym_new_const()` or `sym_new_undefined()`) that we already know cannot be `bottom`. Also, there's a category of stack writes that evades easy detection, e.g. when `_GUARD_BOTH_INT` calls `sym_set_type(left, &PyLong_Type)` (and ditto for `right`), this is part of an opcode whose input and output stack effects are identical, and for such opcodes, the push operation is actually a write (without changing the stack pointer) that is generated on a different code path in the generator. So no I'm considering to just hand-write bottom checks where they seem relevant. Perhaps we can change the `sym_set_...()` functions to return a `bool` result indicating whether they produced a `bottom` value, and change the (hand-written) code that calls these to emit something like ```c if (sym_set_null(sym)) { goto hit_bottom; } ``` where `hit_bottom` is a new error label that prints a different debug message. I'm still weighing my options though... <!-- gh-linked-prs --> ### Linked PRs * gh-116089 <!-- /gh-linked-prs -->
0656509033948780e6703391daca773c779041f7
3b6f4cadf19e6a4edd2cbbbc96a0a4024b395648
python/cpython
python__cpython-116076
# test_external_inspection.py fails on QEMU builds See https://github.com/python/cpython/pull/116062#issuecomment-1969922416 for details. Basically `get_stack_trace()` raises "OSError: Function not implemented" on some JIT builds (those with aarch64-unknown-linux in their name). On Discord, @erlend-aasland suggests: > The best fix would be to have some kind of feature detection when we build the _testexternalinspection extension module, so the build will fail if the target platform cannot support this kind of introspection. That will make test_external_inspection.py skip correctly. IMO. This test was introduced by @pablogsal in gh-115774 (brand new), in response to issue gh-115773. <!-- gh-linked-prs --> ### Linked PRs * gh-116076 <!-- /gh-linked-prs -->
4d1d35b906010c6db15f54443a9701c20af1db2d
f484a2a7486d0b4c7c11901f6c668eb23b74e81f
python/cpython
python__cpython-116058
# `test_walk_above_recursion_limit` uses absolute limits # Bug report ### Bug description: `os.walk` and `Path.walk` both have a test verifying that they're not implemented recursively. However, their recursion limits are absolute rather than relative to the current frame. Since the test framework itself already consumes about 30 frames, it only takes a few extra frames to cause a spurious failure. This can easily happen when running the tests within another script, which happens in the Android testbed. For example, if the limit in test_pathlib is reduced from 40 to 35: ``` ====================================================================== ERROR: test_walk_above_recursion_limit (test.test_pathlib.test_pathlib.PosixPathTest.test_walk_above_recursion_limit) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/msmith/git/python/cpython/Lib/pathlib/__init__.py", line 241, in __str__ return self._str ^^^^^^^^^ AttributeError: 'PosixPath' object has no attribute '_str' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/Users/msmith/git/python/cpython/Lib/pathlib/__init__.py", line 300, in drive return self._drv ^^^^^^^^^ AttributeError: 'PosixPath' object has no attribute '_drv' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/Users/msmith/git/python/cpython/Lib/test/test_pathlib/test_pathlib.py", line 1203, in test_walk_above_recursion_limit list(base.walk()) ~~~~^^^^^^^^^^^^^ File "/Users/msmith/git/python/cpython/Lib/pathlib/_abc.py", line 875, in walk scandir_obj = path._scandir() ~~~~~~~~~~~~~^^ File "/Users/msmith/git/python/cpython/Lib/pathlib/__init__.py", line 588, in _scandir return os.scandir(self) ~~~~~~~~~~^^^^^^ File "/Users/msmith/git/python/cpython/Lib/pathlib/__init__.py", line 177, in __fspath__ return str(self) ~~~^^^^^^ File "/Users/msmith/git/python/cpython/Lib/pathlib/__init__.py", line 243, in __str__ self._str = self._format_parsed_parts(self.drive, self.root, ^^^^^^^^^^ File "/Users/msmith/git/python/cpython/Lib/pathlib/__init__.py", line 302, in drive self._drv, self._root, self._tail_cached = self._parse_path(self._raw_path) ^^^^^^^^^^^^^^ File "/Users/msmith/git/python/cpython/Lib/pathlib/__init__.py", line 293, in _raw_path path = self.pathmod.join(*paths) ~~~~~~~~~~~~~~~~~^^^^^^^^ File "<frozen posixpath>", line 77, in join RecursionError: maximum recursion depth exceeded ``` ### CPython versions tested on: CPython main branch ### Operating systems tested on: * macOS * Android <!-- gh-linked-prs --> ### Linked PRs * gh-116058 <!-- /gh-linked-prs -->
2339e7cff745271f0e4a919573a347ab2bc1c2e9
c5fa796619a8cae5a1a8a4a043d05a99adec713d
python/cpython
python__cpython-116049
# Span for invalid escape sequence in multiline strings is wrong # Bug report ### Bug description: ```python a = """ Invalid\ Escape """ ``` When running with `PYTHONWARNINGS=error python3.13 example.py`, i get the correct error that there is an invalid escape sequence, but the error span is located at the beginning of the string, not at the location of the actual error: ```pytb File "/home/konsti/example.py", line 1 a = """ ^ SyntaxError: invalid escape sequence '\ ' ``` Similarly, for docstrings, the opening quotes are marked, not the actual location: ```python def f(): """This function computes f. Invalid\ Escape """ ``` ```pytb $ PYTHONWARNINGS=error python3.13 example.py File "/home/konsti/example.py", line 2 """This function computes f. ^^^ SyntaxError: invalid escape sequence '\ ' ``` This makes it look like the file is somehow corrupted or there is an encoding error rather than checking the actual docstring (https://github.com/astral-sh/uv/issues/1928). `Python 3.13.0a1+`, installed with pyenv. I'd expected this to have been reported before, but searching for "invalid escape sequence strings", "escape sequence span" and "SyntaxWarning location" i didn't find anything matching. ### CPython versions tested on: 3.13 ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-116049 * gh-130065 * gh-130066 <!-- /gh-linked-prs -->
56eda256336310a08d4beb75b998488cb359444b
49b11033bd87fb26eb4b74ba2451ed30b1af9780
python/cpython
python__cpython-116072
# Enum creation from values fails for certain values. # Bug report ### Bug description: Hello, I tried to define an enum with custom initializer and tuple values, akin to the [Planet example](https://docs.python.org/3/howto/enum.html#planet). When instantiating this enum from values it works for some values (0, 1) but fails for others (1, 0). ```python from enum import Enum class Cardinal(Enum): RIGHT = (1, 0) UP = (0, 1) LEFT = (-1, 0) DOWN = (0, -1) def __init__(self, x: int, y: int, /) -> None: self.x = x self.y = y up = Cardinal(0, 1) # works right = Cardinal(1, 0) # ValueError: 1 is not a valid Cardinal right_ = Cardinal((1, 0)) # works ``` I'm not quite sure if I'm allowed to construct this enum from separate x and y parameters or if I need to pass a tuple. Either way, it should either work for both (up and right) cases or fail for both cases. ### CPython versions tested on: 3.12 ### Operating systems tested on: Windows <!-- gh-linked-prs --> ### Linked PRs * gh-116072 * gh-116476 * gh-116508 * gh-116619 <!-- /gh-linked-prs -->
13ffd4bd9f529b6a5fe33741fbd57f14b4b80137
b2d74cdbcd0b47bc938200969bb31e5b37dc11e1
python/cpython
python__cpython-116031
# ``test_unparse`` raises a DeprecationWarning # Bug report ### Bug description: ```python ./python.exe -m test test_unparse Using random seed: 1839524422 0:00:00 load avg: 8.33 Run 1 test sequentially 0:00:00 load avg: 8.33 [1/1] test_unparse /Users/admin/Projects/cpython/Lib/test/test_unparse.py:721: DeprecationWarning: Name.__init__ missing 1 required positional argument: 'ctx'. This will become an error in Python 3.15. type_params=[ast.TypeVar("T", bound=ast.Name("int"))], /Users/admin/Projects/cpython/Lib/test/test_unparse.py:379: DeprecationWarning: Name.__init__ missing 1 required positional argument: 'ctx'. This will become an error in Python 3.15. ast.Name(id="test"), /Users/admin/Projects/cpython/Lib/test/test_unparse.py:373: DeprecationWarning: Name.__init__ missing 1 required positional argument: 'ctx'. This will become an error in Python 3.15. self.check_invalid(ast.Raise(exc=None, cause=ast.Name(id="X"))) == Tests result: SUCCESS == 1 test OK. Total duration: 1.9 sec Total tests: run=69 Total test files: run=1/1 Result: SUCCESS ``` ### CPython versions tested on: CPython main branch ### Operating systems tested on: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-116031 <!-- /gh-linked-prs -->
3b63d0769f49171f53e9cecc686fa01a383bd4b1
1752b51012269eaa35f7a28f162d18479a4f72aa
python/cpython
python__cpython-116340
# New warnings: ` warning: unused function 'ensure_shared_on_read' [-Wunused-function]` # Bug report ### Bug description: Popped up during the build (`./configure --with-pydebug && make -j`): ```bash Objects/dictobject.c:1233:1: warning: unused function 'ensure_shared_on_read' [-Wunused-function] ensure_shared_on_read(PyDictObject *mp) ^ In file included from Objects/obmalloc.c:16: In file included from Objects/mimalloc/static.c:23: Objects/mimalloc/alloc.c:77:5: warning: static function 'mi_debug_fill' is used in an inline function with external linkage [-Wstatic-in-inline] mi_debug_fill(page, block, MI_DEBUG_UNINIT, mi_page_usable_block_size(page)); ^ Objects/mimalloc/alloc.c:30:13: note: 'mi_debug_fill' declared here static void mi_debug_fill(mi_page_t* page, mi_block_t* block, int c, size_t size) { ... Objects/dictobject.c:5032:9: warning: logical not is only applied to the left hand side of this comparison [-Wlogical-not-parentheses] if (!dictiter_iternext_threadsafe(d, self, &value, NULL) == 0) { ^ ~~ Objects/dictobject.c:5032:9: note: add parentheses after the '!' to evaluate the comparison first if (!dictiter_iternext_threadsafe(d, self, &value, NULL) == 0) { ^ ( ) Objects/dictobject.c:5032:9: note: add parentheses around left hand side expression to silence this warning if (!dictiter_iternext_threadsafe(d, self, &value, NULL) == 0) { ^ ( ) Objects/dictobject.c:5155:9: warning: logical not is only applied to the left hand side of this comparison [-Wlogical-not-parentheses] if (!dictiter_iternext_threadsafe(d, self, NULL, &value) == 0) { ^ ~~ Objects/dictobject.c:5155:9: note: add parentheses after the '!' to evaluate the comparison first if (!dictiter_iternext_threadsafe(d, self, NULL, &value) == 0) { ^ ( ) Objects/dictobject.c:5155:9: note: add parentheses around left hand side expression to silence this warning if (!dictiter_iternext_threadsafe(d, self, NULL, &value) == 0) { ^ ``` ### CPython versions tested on: CPython main branch ### Operating systems tested on: macOS <!-- gh-linked-prs --> ### Linked PRs * gh-116340 <!-- /gh-linked-prs -->
58c7919d05a360f3437a204960cddbeb78a71dce
88b5c665ee1624af1bc5097d3eb2af090b9cabed
python/cpython
python__cpython-116027
# macos-13 builds are failing # Bug report In both #105511 and #116025, the macos-13 builds fail with: ``` Error: The `brew link` step did not complete successfully The formula built, but is not symlinked into /usr/local Could not symlink bin/2to3 Target /usr/local/bin/2to3 already exists. You may want to remove it: rm '/usr/local/bin/2to3' To force the link and overwrite all conflicting files: brew link --overwrite python@3.12 To list all files that would be deleted: brew link --overwrite python@3.12 --dry-run ``` The failure first appears on the main branch after #115661 was merged, but that looks unlikely to be related, especially since the failure happens before we even start building CPython. I suspect something changed in the runner. <!-- gh-linked-prs --> ### Linked PRs * gh-116027 * gh-116157 * gh-116158 <!-- /gh-linked-prs -->
02beb9f0208d22fd8bd893e6e6ec813f7e51b235
ed4dfd8825b49e16a0fcb9e67baf1b58bb8d438f
python/cpython
python__cpython-116037
# Omit optional fields from `ast.dump()` # Feature or enhancement ### Proposal: ```python >>> ast.dump(ast.arguments()) 'arguments(posonlyargs=[], args=[], kwonlyargs=[], kw_defaults=[], defaults=[])' ``` After #105858, it would be nice if `ast.dump()` also didn't output optional fields that are set to None or an empty string, so that its output is more concise. This should make it easier to understand the structure of large ASTs where most fields are missing. ### Has this already been discussed elsewhere? This is a minor feature, which does not need previous discussion elsewhere ### Links to previous discussion of this feature: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-116037 <!-- /gh-linked-prs -->
692e902c742f577f9fc8ed81e60ed9dd6c994e1e
7e87d30f1f30d39c3005e03195f3d7648b38a1e2
python/cpython
python__cpython-117046
# Improve `repr()` of AST nodes # Feature or enhancement ### Proposal: I often use `ast.parse` in the terminal to explore what the AST looks like: ``` >>> ast.parse("x = 3") <ast.Module object at 0x105450b50> ``` But I have to remember to use `ast.dump()` to get useful output: ``` >>> ast.dump(ast.parse("x = 3")) "Module(body=[Assign(targets=[Name(id='x', ctx=Store())], value=Constant(value=3))], type_ignores=[])" ``` It would be nice if the default repr() of AST nodes was more like the output of `ast.dump()`, so it's easier to see at a glance how it works. One concern would be around the size of the output: ``` >>> from pathlib import Path >>> import typing >>> typing_py = Path(typing.__file__).read_text() >>> len(ast.dump(ast.parse(typing_py))) 304244 ``` As a middle ground, we could limit the depth of the AST provided in the repr(), e.g. to 2 levels, and also the number of list elements provided. The repr() of a module's AST might then look something like: ``` Module(body=[Expr(value=Constant(...)), ..., Assign(targets=[Name(...)], value=Constant(...))], type_ignores=[]) ``` ### Has this already been discussed elsewhere? This is a minor feature, which does not need previous discussion elsewhere ### Links to previous discussion of this feature: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-117046 <!-- /gh-linked-prs -->
21d2a9ab2f4dcbf1be462d3b7f7a231a46bc1cb7
f9fa6ba4f8d90ae12bc1f6a792d66903bb169ba8
python/cpython
python__cpython-116014
# GetLastError() not preserved across GIL operations on Windows # Bug report Changes to TLS usage in 3.13 may cause the last error code to be reset when ensuring, checking or releasing the GIL. We need to preserve the value. `PyGILState_Check` was already updated, but the other public APIs need the same update. Potentially some of our internal/public ones too. It might just be best to add it to the `PyThread_tss_*` functions. <!-- gh-linked-prs --> ### Linked PRs * gh-116014 <!-- /gh-linked-prs -->
9578288a3e5a7f42d1f3bec139c0c85b87775c90
647053fed182066d3b8c934fb0bf52ee48ff3911
python/cpython
python__cpython-116246
# FAQ: Replace PEP 6 link with devguide # Documentation This FAQ entry: https://docs.python.org/3/faq/general.html#how-does-the-python-version-numbering-scheme-work Says: > See PEP 6 for more information about bugfix releases. But PEP 6 says: > This PEP is obsolete. The current release policy is documented in the devguide. See also PEP 101 for mechanics of the release process. Let's update the link to point to the devguide instead. PEP 387 (Backwards Compatibility Policy) would be worth linking as well. Are there any other PEP 6 references in the docs to update? <!-- gh-linked-prs --> ### Linked PRs * gh-116246 * gh-116286 * gh-116287 <!-- /gh-linked-prs -->
3383d6afa3e4454b237bca2ef856e0f79b5b30c1
4859ecb8609b51e2f6b8fb1b295e9ee0f83e1be6
python/cpython
python__cpython-116470
# ``Tools/cases_generator/optimizer_generator`` CLI does not work without explicit arguments # Bug report ### Bug description: ```python python3.11 optimizer_generator.py usage: optimizer_generator.py [-h] [-o OUTPUT] [-d] input ... optimizer_generator.py: error: the following arguments are required: input, base ``` I think it should work as the other generators. However, these lines suggests that it should work: https://github.com/python/cpython/blob/686ec17f506cddd0b14a8aad5849c15ffc20ed46/Tools/cases_generator/optimizer_generator.py#L231-L233 cc @Fidget-Spinner ### CPython versions tested on: CPython main branch ### Operating systems tested on: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-116470 <!-- /gh-linked-prs -->
b2d74cdbcd0b47bc938200969bb31e5b37dc11e1
834bf57eb79e9bf383a7173fccda032f4c53f69b
python/cpython
python__cpython-116013
# Make the specializing interpreter thread-safe in `--disable-gil` builds # Feature or enhancement ### Proposal: In free-threaded builds, the specializing adaptive interpreter needs to be made thread-safe. We should start with a small PR to simply disable it in free-threaded builds, which will be correct but will incur a performance penalty. Then we can work out how to properly support specialization in a free-threaded build. These two commits from Sam's nogil-3.12 branch can serve as inspiration: 1. [specialize: make specialization thread-safe ](https://github.com/colesbury/nogil-3.12/commit/7e7568672d) 2. [specialize: optimize for single-threaded programs](https://github.com/colesbury/nogil-3.12/commit/90d34f0d18) There are two primary concerns to balance while implementing this functionality on `main`: 1. **Runtime overhead**: There should be no performance impact on normal builds, and minimal performance impact on single-threaded code running in free-threaded builds. 2. **Reducing code duplication/divergence**: We should come up with a design that is minimally disruptive to ongoing work on the specializing interpreter. It should be easy for other devs to keep the free-threaded build working without having to know too much about it. ### Has this already been discussed elsewhere? I have already discussed this feature proposal on Discourse ### Links to previous discussion of this feature: - https://peps.python.org/pep-0703/ - https://github.com/python/cpython/issues/108219 ### Specialization Families ```[tasklist] - [x] BINARY_OP - [x] BINARY_SUBSCR - @corona10 - [x] CALL - @mpage - [x] CALL_KW - @mpage - [x] COMPARE_OP - @Yhg1s - [x] CONTAINS_OP - @corona10 - [x] FOR_ITER - @Yhg1s - [x] LOAD_ATTR - @mpage - [x] LOAD_CONST - [x] LOAD_GLOBAL - @mpage - [x] LOAD_SUPER_ATTR - @nascheme - [x] RESUME - [x] SEND - @nascheme - [x] STORE_ATTR - -@nascheme - [x] STORE_SUBSCR - @colesbury - [x] TO_BOOL - @corona10 - [x] UNPACK_SEQUENCE - @Eclips4 ``` <!-- gh-linked-prs --> ### Linked PRs * gh-116013 * gh-123926 * gh-124953 * gh-124997 * gh-126410 * gh-126414 * gh-126440 * gh-126450 * gh-126498 * gh-126515 * gh-126600 * gh-126607 * gh-126616 * gh-127030 * gh-127123 * gh-127128 * gh-127167 * gh-127169 * gh-127227 * gh-127426 * gh-127514 * gh-127711 * gh-127713 * gh-127737 * gh-127838 * gh-128164 * gh-128166 * gh-128637 * gh-128798 * gh-129365 * gh-131285 * gh-133824 * gh-134286 * gh-134348 * gh-136249 <!-- /gh-linked-prs -->
339c8e1c13adc299a0e2e49c93067e7817692380
2e94a6687c1a9750e9d2408a8dff0a422aeaf0e4
python/cpython
python__cpython-116019
# Improve documentation for `pprint` module # Documentation The documentation for the `pprint` module could be improved in many respects: - Most users will probably only ever need to use `pprint.pp()` or `pprint.pprint()`, but these are buried halfway down the module. It would be nice if these were the first things on the page. - All examples in the documentation use `pprint.pprint()`, which has some unexpected behaviour. For example, it sorts dictionaries by default, which is somewhat unintuitive now that dictionaries maintain insertion order. I suggest we change the examples to use `pprint.pp()` instead, which has the more intuitive default of `sort_dicts=False`. - Similarly, the docs for `pprint.pprint()` could explicitly call out that it has unintuitive defaults for things such as `sort_dicts` and link to `pprint.pp()` - Some links in the module's documentation incorrectly point to the module itself (`pprint`) instead of the function `pprint.pprint()`. These don't all necessarily need to be tackled in the same PR <!-- gh-linked-prs --> ### Linked PRs * gh-116019 * gh-116061 * gh-116064 * gh-116085 * gh-116104 * gh-116382 * gh-116383 * gh-116614 * gh-117196 * gh-117197 * gh-117401 * gh-117403 * gh-118146 * gh-121098 * gh-121099 <!-- /gh-linked-prs -->
e205c5cd8f1a49d0ef126123312ee8a40d1416b6
72714c0266ce6d39c7c7fb63f617573b8f5a3cb2
python/cpython
python__cpython-116528
# Disable building test modules that require `dlopen()` under WASI SDK 21 `_testimportmultiple`, `_testmultiphase`, `_testsinglephase`, `xxlimited`, `xxlimited_35` all get built under WASI SDK 21 thanks to `dlopen()`, but since that function doesn't work normally under WASI we should skip building them. https://github.com/python/cpython/blob/6087315926fb185847a52559af063cc7d337d978/configure.ac#L7582-L7593 We could either update `Tools/wasm/wasi.py` to disable test modules, update `configure.ac` so they don't get compiled under WASI, or see if we can get them compiled in statically. <!-- gh-linked-prs --> ### Linked PRs * gh-116528 * gh-120316 <!-- /gh-linked-prs -->
8c094c3095feb4de2efebd00f67fb6cc3b2bc240
e39795f2cbad5375536f4be6b3c3906f457992bf
python/cpython
python__cpython-116754
# Fix `test_importlib` under WASI SDK 21 # Bug report ### Bug description: This very likely stems from `dlopen()` being available in WASI SDK 21 but not being usable dynamically as-is. <details> <summary>Test failure output</summary> ``` ====================================================================== ERROR: test_is_package (test.test_importlib.extension.test_loader.Frozen_LoaderTests.test_is_package) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Lib/test/test_importlib/extension/test_loader.py", line 86, in test_is_package self.assertFalse(self.loader.is_package(util.EXTENSIONS.name)) ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^ File "<frozen importlib._bootstrap_external>", line 1322, in is_package File "<frozen importlib._bootstrap_external>", line 134, in _path_split File "<frozen importlib._bootstrap_external>", line 134, in <genexpr> AttributeError: 'NoneType' object has no attribute 'rfind' ====================================================================== ERROR: test_load_module_API (test.test_importlib.extension.test_loader.Frozen_LoaderTests.test_load_module_API) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Lib/test/test_importlib/extension/test_loader.py", line 48, in test_load_module_API self.loader.load_module() ~~~~~~~~~~~~~~~~~~~~~~~^^ File "<frozen importlib._bootstrap_external>", line 668, in _check_name_wrapper File "<frozen importlib._bootstrap_external>", line 1195, in load_module File "<frozen importlib._bootstrap_external>", line 1019, in load_module File "<frozen importlib._bootstrap>", line 531, in _load_module_shim File "<frozen importlib._bootstrap>", line 673, in spec_from_loader File "<frozen importlib._bootstrap_external>", line 875, in spec_from_file_location File "<frozen importlib._bootstrap_external>", line 1322, in is_package File "<frozen importlib._bootstrap_external>", line 134, in _path_split File "<frozen importlib._bootstrap_external>", line 134, in <genexpr> AttributeError: 'NoneType' object has no attribute 'rfind' ====================================================================== ERROR: test_module (test.test_importlib.extension.test_loader.Frozen_LoaderTests.test_module) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Lib/test/test_importlib/extension/test_loader.py", line 55, in test_module module = self.load_module(util.EXTENSIONS.name) ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^ File "/Lib/test/test_importlib/extension/test_loader.py", line 32, in load_module return self.loader.load_module(fullname) ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^ File "<frozen importlib._bootstrap_external>", line 668, in _check_name_wrapper File "<frozen importlib._bootstrap_external>", line 1195, in load_module File "<frozen importlib._bootstrap_external>", line 1019, in load_module File "<frozen importlib._bootstrap>", line 531, in _load_module_shim File "<frozen importlib._bootstrap>", line 673, in spec_from_loader File "<frozen importlib._bootstrap_external>", line 875, in spec_from_file_location File "<frozen importlib._bootstrap_external>", line 1322, in is_package File "<frozen importlib._bootstrap_external>", line 134, in _path_split File "<frozen importlib._bootstrap_external>", line 134, in <genexpr> AttributeError: 'NoneType' object has no attribute 'rfind' ====================================================================== ERROR: test_module_reuse (test.test_importlib.extension.test_loader.Frozen_LoaderTests.test_module_reuse) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Lib/test/test_importlib/extension/test_loader.py", line 81, in test_module_reuse module1 = self.load_module(util.EXTENSIONS.name) ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^ File "/Lib/test/test_importlib/extension/test_loader.py", line 32, in load_module return self.loader.load_module(fullname) ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^ File "<frozen importlib._bootstrap_external>", line 668, in _check_name_wrapper File "<frozen importlib._bootstrap_external>", line 1195, in load_module File "<frozen importlib._bootstrap_external>", line 1019, in load_module File "<frozen importlib._bootstrap>", line 531, in _load_module_shim File "<frozen importlib._bootstrap>", line 673, in spec_from_loader File "<frozen importlib._bootstrap_external>", line 875, in spec_from_file_location File "<frozen importlib._bootstrap_external>", line 1322, in is_package File "<frozen importlib._bootstrap_external>", line 134, in _path_split File "<frozen importlib._bootstrap_external>", line 134, in <genexpr> AttributeError: 'NoneType' object has no attribute 'rfind' ====================================================================== ERROR: test_is_package (test.test_importlib.extension.test_loader.Source_LoaderTests.test_is_package) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Lib/test/test_importlib/extension/test_loader.py", line 86, in test_is_package self.assertFalse(self.loader.is_package(util.EXTENSIONS.name)) ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^ File "/Lib/importlib/_bootstrap_external.py", line 1322, in is_package file_name = _path_split(self.path)[1] ~~~~~~~~~~~^^^^^^^^^^^ File "/Lib/importlib/_bootstrap_external.py", line 134, in _path_split i = max(path.rfind(p) for p in path_separators) ~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Lib/importlib/_bootstrap_external.py", line 134, in <genexpr> i = max(path.rfind(p) for p in path_separators) ^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'rfind' ====================================================================== ERROR: test_load_module_API (test.test_importlib.extension.test_loader.Source_LoaderTests.test_load_module_API) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Lib/test/test_importlib/extension/test_loader.py", line 48, in test_load_module_API self.loader.load_module() ~~~~~~~~~~~~~~~~~~~~~~~^^ File "/Lib/importlib/_bootstrap_external.py", line 668, in _check_name_wrapper return method(self, name, *args, **kwargs) ~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Lib/importlib/_bootstrap_external.py", line 1195, in load_module return super(FileLoader, self).load_module(fullname) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^ File "/Lib/importlib/_bootstrap_external.py", line 1019, in load_module return _bootstrap._load_module_shim(self, fullname) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^ File "/Lib/importlib/_bootstrap.py", line 531, in _load_module_shim spec = spec_from_loader(fullname, self) ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^ File "/Lib/importlib/_bootstrap.py", line 673, in spec_from_loader return spec_from_file_location(name, loader=loader) ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^ File "/Lib/importlib/_bootstrap_external.py", line 875, in spec_from_file_location is_package = loader.is_package(name) ~~~~~~~~~~~~~~~~~^^^^^^ File "/Lib/importlib/_bootstrap_external.py", line 1322, in is_package file_name = _path_split(self.path)[1] ~~~~~~~~~~~^^^^^^^^^^^ File "/Lib/importlib/_bootstrap_external.py", line 134, in _path_split i = max(path.rfind(p) for p in path_separators) ~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Lib/importlib/_bootstrap_external.py", line 134, in <genexpr> i = max(path.rfind(p) for p in path_separators) ^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'rfind' ====================================================================== ERROR: test_module (test.test_importlib.extension.test_loader.Source_LoaderTests.test_module) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Lib/test/test_importlib/extension/test_loader.py", line 55, in test_module module = self.load_module(util.EXTENSIONS.name) ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^ File "/Lib/test/test_importlib/extension/test_loader.py", line 32, in load_module return self.loader.load_module(fullname) ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^ File "/Lib/importlib/_bootstrap_external.py", line 668, in _check_name_wrapper return method(self, name, *args, **kwargs) ~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Lib/importlib/_bootstrap_external.py", line 1195, in load_module return super(FileLoader, self).load_module(fullname) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^ File "/Lib/importlib/_bootstrap_external.py", line 1019, in load_module return _bootstrap._load_module_shim(self, fullname) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^ File "/Lib/importlib/_bootstrap.py", line 531, in _load_module_shim spec = spec_from_loader(fullname, self) ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^ File "/Lib/importlib/_bootstrap.py", line 673, in spec_from_loader return spec_from_file_location(name, loader=loader) ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^ File "/Lib/importlib/_bootstrap_external.py", line 875, in spec_from_file_location is_package = loader.is_package(name) ~~~~~~~~~~~~~~~~~^^^^^^ File "/Lib/importlib/_bootstrap_external.py", line 1322, in is_package file_name = _path_split(self.path)[1] ~~~~~~~~~~~^^^^^^^^^^^ File "/Lib/importlib/_bootstrap_external.py", line 134, in _path_split i = max(path.rfind(p) for p in path_separators) ~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Lib/importlib/_bootstrap_external.py", line 134, in <genexpr> i = max(path.rfind(p) for p in path_separators) ^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'rfind' ====================================================================== ERROR: test_module_reuse (test.test_importlib.extension.test_loader.Source_LoaderTests.test_module_reuse) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Lib/test/test_importlib/extension/test_loader.py", line 81, in test_module_reuse module1 = self.load_module(util.EXTENSIONS.name) ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^ File "/Lib/test/test_importlib/extension/test_loader.py", line 32, in load_module return self.loader.load_module(fullname) ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^ File "/Lib/importlib/_bootstrap_external.py", line 668, in _check_name_wrapper return method(self, name, *args, **kwargs) ~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Lib/importlib/_bootstrap_external.py", line 1195, in load_module return super(FileLoader, self).load_module(fullname) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^ File "/Lib/importlib/_bootstrap_external.py", line 1019, in load_module return _bootstrap._load_module_shim(self, fullname) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^ File "/Lib/importlib/_bootstrap.py", line 531, in _load_module_shim spec = spec_from_loader(fullname, self) ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^ File "/Lib/importlib/_bootstrap.py", line 673, in spec_from_loader return spec_from_file_location(name, loader=loader) ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^ File "/Lib/importlib/_bootstrap_external.py", line 875, in spec_from_file_location is_package = loader.is_package(name) ~~~~~~~~~~~~~~~~~^^^^^^ File "/Lib/importlib/_bootstrap_external.py", line 1322, in is_package file_name = _path_split(self.path)[1] ~~~~~~~~~~~^^^^^^^^^^^ File "/Lib/importlib/_bootstrap_external.py", line 134, in _path_split i = max(path.rfind(p) for p in path_separators) ~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Lib/importlib/_bootstrap_external.py", line 134, in <genexpr> i = max(path.rfind(p) for p in path_separators) ^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'rfind' ====================================================================== FAIL: test_module (test.test_importlib.extension.test_finder.Frozen_FinderTests.test_module) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Lib/test/test_importlib/extension/test_finder.py", line 29, in test_module self.assertTrue(self.find_spec(util.EXTENSIONS.name)) ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AssertionError: None is not true ====================================================================== FAIL: test_module (test.test_importlib.extension.test_finder.Source_FinderTests.test_module) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Lib/test/test_importlib/extension/test_finder.py", line 29, in test_module self.assertTrue(self.find_spec(util.EXTENSIONS.name)) ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AssertionError: None is not true ====================================================================== FAIL: test_bad_modules (test.test_importlib.extension.test_loader.Frozen_MultiPhaseExtensionModuleTests.test_bad_modules) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Lib/test/test_importlib/extension/test_loader.py", line 192, in setUp assert self.spec ^^^^^^^^^ AssertionError ====================================================================== FAIL: test_functionality (test.test_importlib.extension.test_loader.Frozen_MultiPhaseExtensionModuleTests.test_functionality) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Lib/test/test_importlib/extension/test_loader.py", line 192, in setUp assert self.spec ^^^^^^^^^ AssertionError ====================================================================== FAIL: test_load_short_name (test.test_importlib.extension.test_loader.Frozen_MultiPhaseExtensionModuleTests.test_load_short_name) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Lib/test/test_importlib/extension/test_loader.py", line 192, in setUp assert self.spec ^^^^^^^^^ AssertionError ====================================================================== FAIL: test_load_submodule (test.test_importlib.extension.test_loader.Frozen_MultiPhaseExtensionModuleTests.test_load_submodule) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Lib/test/test_importlib/extension/test_loader.py", line 192, in setUp assert self.spec ^^^^^^^^^ AssertionError ====================================================================== FAIL: test_load_twice (test.test_importlib.extension.test_loader.Frozen_MultiPhaseExtensionModuleTests.test_load_twice) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Lib/test/test_importlib/extension/test_loader.py", line 192, in setUp assert self.spec ^^^^^^^^^ AssertionError ====================================================================== FAIL: test_module (test.test_importlib.extension.test_loader.Frozen_MultiPhaseExtensionModuleTests.test_module) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Lib/test/test_importlib/extension/test_loader.py", line 192, in setUp assert self.spec ^^^^^^^^^ AssertionError ====================================================================== FAIL: test_nonascii (test.test_importlib.extension.test_loader.Frozen_MultiPhaseExtensionModuleTests.test_nonascii) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Lib/test/test_importlib/extension/test_loader.py", line 192, in setUp assert self.spec ^^^^^^^^^ AssertionError ====================================================================== FAIL: test_nonmodule (test.test_importlib.extension.test_loader.Frozen_MultiPhaseExtensionModuleTests.test_nonmodule) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Lib/test/test_importlib/extension/test_loader.py", line 192, in setUp assert self.spec ^^^^^^^^^ AssertionError ====================================================================== FAIL: test_nonmodule_with_methods (test.test_importlib.extension.test_loader.Frozen_MultiPhaseExtensionModuleTests.test_nonmodule_with_methods) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Lib/test/test_importlib/extension/test_loader.py", line 192, in setUp assert self.spec ^^^^^^^^^ AssertionError ====================================================================== FAIL: test_null_slots (test.test_importlib.extension.test_loader.Frozen_MultiPhaseExtensionModuleTests.test_null_slots) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Lib/test/test_importlib/extension/test_loader.py", line 192, in setUp assert self.spec ^^^^^^^^^ AssertionError ====================================================================== FAIL: test_reload (test.test_importlib.extension.test_loader.Frozen_MultiPhaseExtensionModuleTests.test_reload) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Lib/test/test_importlib/extension/test_loader.py", line 192, in setUp assert self.spec ^^^^^^^^^ AssertionError ====================================================================== FAIL: test_try_registration (test.test_importlib.extension.test_loader.Frozen_MultiPhaseExtensionModuleTests.test_try_registration) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Lib/test/test_importlib/extension/test_loader.py", line 192, in setUp assert self.spec ^^^^^^^^^ AssertionError ====================================================================== FAIL: test_unloadable (test.test_importlib.extension.test_loader.Frozen_MultiPhaseExtensionModuleTests.test_unloadable) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Lib/test/test_importlib/extension/test_loader.py", line 192, in setUp assert self.spec ^^^^^^^^^ AssertionError ====================================================================== FAIL: test_unloadable_nonascii (test.test_importlib.extension.test_loader.Frozen_MultiPhaseExtensionModuleTests.test_unloadable_nonascii) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Lib/test/test_importlib/extension/test_loader.py", line 192, in setUp assert self.spec ^^^^^^^^^ AssertionError ====================================================================== FAIL: test_module (test.test_importlib.extension.test_loader.Frozen_SinglePhaseExtensionModuleTests.test_module) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Lib/test/test_importlib/extension/test_loader.py", line 111, in setUp assert self.spec ^^^^^^^^^ AssertionError ====================================================================== FAIL: test_unloadable (test.test_importlib.extension.test_loader.Frozen_SinglePhaseExtensionModuleTests.test_unloadable) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Lib/test/test_importlib/extension/test_loader.py", line 111, in setUp assert self.spec ^^^^^^^^^ AssertionError ====================================================================== FAIL: test_unloadable_nonascii (test.test_importlib.extension.test_loader.Frozen_SinglePhaseExtensionModuleTests.test_unloadable_nonascii) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Lib/test/test_importlib/extension/test_loader.py", line 111, in setUp assert self.spec ^^^^^^^^^ AssertionError ====================================================================== FAIL: test_bad_modules (test.test_importlib.extension.test_loader.Source_MultiPhaseExtensionModuleTests.test_bad_modules) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Lib/test/test_importlib/extension/test_loader.py", line 192, in setUp assert self.spec ^^^^^^^^^ AssertionError ====================================================================== FAIL: test_functionality (test.test_importlib.extension.test_loader.Source_MultiPhaseExtensionModuleTests.test_functionality) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Lib/test/test_importlib/extension/test_loader.py", line 192, in setUp assert self.spec ^^^^^^^^^ AssertionError ====================================================================== FAIL: test_load_short_name (test.test_importlib.extension.test_loader.Source_MultiPhaseExtensionModuleTests.test_load_short_name) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Lib/test/test_importlib/extension/test_loader.py", line 192, in setUp assert self.spec ^^^^^^^^^ AssertionError ====================================================================== FAIL: test_load_submodule (test.test_importlib.extension.test_loader.Source_MultiPhaseExtensionModuleTests.test_load_submodule) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Lib/test/test_importlib/extension/test_loader.py", line 192, in setUp assert self.spec ^^^^^^^^^ AssertionError ====================================================================== FAIL: test_load_twice (test.test_importlib.extension.test_loader.Source_MultiPhaseExtensionModuleTests.test_load_twice) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Lib/test/test_importlib/extension/test_loader.py", line 192, in setUp assert self.spec ^^^^^^^^^ AssertionError ====================================================================== FAIL: test_module (test.test_importlib.extension.test_loader.Source_MultiPhaseExtensionModuleTests.test_module) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Lib/test/test_importlib/extension/test_loader.py", line 192, in setUp assert self.spec ^^^^^^^^^ AssertionError ====================================================================== FAIL: test_nonascii (test.test_importlib.extension.test_loader.Source_MultiPhaseExtensionModuleTests.test_nonascii) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Lib/test/test_importlib/extension/test_loader.py", line 192, in setUp assert self.spec ^^^^^^^^^ AssertionError ====================================================================== FAIL: test_nonmodule (test.test_importlib.extension.test_loader.Source_MultiPhaseExtensionModuleTests.test_nonmodule) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Lib/test/test_importlib/extension/test_loader.py", line 192, in setUp assert self.spec ^^^^^^^^^ AssertionError ====================================================================== FAIL: test_nonmodule_with_methods (test.test_importlib.extension.test_loader.Source_MultiPhaseExtensionModuleTests.test_nonmodule_with_methods) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Lib/test/test_importlib/extension/test_loader.py", line 192, in setUp assert self.spec ^^^^^^^^^ AssertionError ====================================================================== FAIL: test_null_slots (test.test_importlib.extension.test_loader.Source_MultiPhaseExtensionModuleTests.test_null_slots) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Lib/test/test_importlib/extension/test_loader.py", line 192, in setUp assert self.spec ^^^^^^^^^ AssertionError ====================================================================== FAIL: test_reload (test.test_importlib.extension.test_loader.Source_MultiPhaseExtensionModuleTests.test_reload) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Lib/test/test_importlib/extension/test_loader.py", line 192, in setUp assert self.spec ^^^^^^^^^ AssertionError ====================================================================== FAIL: test_try_registration (test.test_importlib.extension.test_loader.Source_MultiPhaseExtensionModuleTests.test_try_registration) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Lib/test/test_importlib/extension/test_loader.py", line 192, in setUp assert self.spec ^^^^^^^^^ AssertionError ====================================================================== FAIL: test_unloadable (test.test_importlib.extension.test_loader.Source_MultiPhaseExtensionModuleTests.test_unloadable) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Lib/test/test_importlib/extension/test_loader.py", line 192, in setUp assert self.spec ^^^^^^^^^ AssertionError ====================================================================== FAIL: test_unloadable_nonascii (test.test_importlib.extension.test_loader.Source_MultiPhaseExtensionModuleTests.test_unloadable_nonascii) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Lib/test/test_importlib/extension/test_loader.py", line 192, in setUp assert self.spec ^^^^^^^^^ AssertionError ====================================================================== FAIL: test_module (test.test_importlib.extension.test_loader.Source_SinglePhaseExtensionModuleTests.test_module) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Lib/test/test_importlib/extension/test_loader.py", line 111, in setUp assert self.spec ^^^^^^^^^ AssertionError ====================================================================== FAIL: test_unloadable (test.test_importlib.extension.test_loader.Source_SinglePhaseExtensionModuleTests.test_unloadable) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Lib/test/test_importlib/extension/test_loader.py", line 111, in setUp assert self.spec ^^^^^^^^^ AssertionError ====================================================================== FAIL: test_unloadable_nonascii (test.test_importlib.extension.test_loader.Source_SinglePhaseExtensionModuleTests.test_unloadable_nonascii) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Lib/test/test_importlib/extension/test_loader.py", line 111, in setUp assert self.spec ^^^^^^^^^ AssertionError ====================================================================== FAIL: test_spec_from_file_location_smsl_default (test.test_importlib.test_spec.Frozen_FactoryTests.test_spec_from_file_location_smsl_default) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Lib/test/test_importlib/test_spec.py", line 629, in test_spec_from_file_location_smsl_default self.assertEqual(spec.submodule_search_locations, [os.getcwd()]) ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AssertionError: Lists differ: [''] != ['/'] First differing element 0: '' '/' - [''] + ['/'] ? + ====================================================================== FAIL: test_spec_from_file_location_smsl_empty (test.test_importlib.test_spec.Frozen_FactoryTests.test_spec_from_file_location_smsl_empty) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Lib/test/test_importlib/test_spec.py", line 604, in test_spec_from_file_location_smsl_empty self.assertEqual(spec.submodule_search_locations, [os.getcwd()]) ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AssertionError: Lists differ: [''] != ['/'] First differing element 0: '' '/' - [''] + ['/'] ? + ====================================================================== FAIL: test_spec_from_loader_is_package_true_with_fileloader (test.test_importlib.test_spec.Frozen_FactoryTests.test_spec_from_loader_is_package_true_with_fileloader) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Lib/test/test_importlib/test_spec.py", line 505, in test_spec_from_loader_is_package_true_with_fileloader self.assertEqual(spec.submodule_search_locations, [os.getcwd()]) ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AssertionError: Lists differ: [''] != ['/'] First differing element 0: '' '/' - [''] + ['/'] ? + ====================================================================== FAIL: test_spec_from_file_location_smsl_default (test.test_importlib.test_spec.Source_FactoryTests.test_spec_from_file_location_smsl_default) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Lib/test/test_importlib/test_spec.py", line 629, in test_spec_from_file_location_smsl_default self.assertEqual(spec.submodule_search_locations, [os.getcwd()]) ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AssertionError: Lists differ: [''] != ['/'] First differing element 0: '' '/' - [''] + ['/'] ? + ====================================================================== FAIL: test_spec_from_file_location_smsl_empty (test.test_importlib.test_spec.Source_FactoryTests.test_spec_from_file_location_smsl_empty) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Lib/test/test_importlib/test_spec.py", line 604, in test_spec_from_file_location_smsl_empty self.assertEqual(spec.submodule_search_locations, [os.getcwd()]) ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AssertionError: Lists differ: [''] != ['/'] First differing element 0: '' '/' - [''] + ['/'] ? + ====================================================================== FAIL: test_spec_from_loader_is_package_true_with_fileloader (test.test_importlib.test_spec.Source_FactoryTests.test_spec_from_loader_is_package_true_with_fileloader) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Lib/test/test_importlib/test_spec.py", line 505, in test_spec_from_loader_is_package_true_with_fileloader self.assertEqual(spec.submodule_search_locations, [os.getcwd()]) ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AssertionError: Lists differ: [''] != ['/'] First differing element 0: '' '/' - [''] + ['/'] ? + ====================================================================== FAIL: test_cache_from_source_respects_pycache_prefix_relative (test.test_importlib.test_util.Frozen_PEP3147Tests.test_cache_from_source_respects_pycache_prefix_relative) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Lib/test/test_importlib/test_util.py", line 578, in test_cache_from_source_respects_pycache_prefix_relative self.assertEqual( ~~~~~~~~~~~~~~~~^ self.util.cache_from_source(path, optimization=''), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expect) ^^^^^^^ AssertionError: '/tmp/bytecode/foo/bar/baz/qux.cpython-313.pyc' != '/tmp/bytecode/./foo/bar/baz/qux.cpython-313.pyc' - /tmp/bytecode/foo/bar/baz/qux.cpython-313.pyc + /tmp/bytecode/./foo/bar/baz/qux.cpython-313.pyc ? ++ ====================================================================== FAIL: test_cache_from_source_respects_pycache_prefix_relative (test.test_importlib.test_util.Source_PEP3147Tests.test_cache_from_source_respects_pycache_prefix_relative) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Lib/test/test_importlib/test_util.py", line 578, in test_cache_from_source_respects_pycache_prefix_relative self.assertEqual( ~~~~~~~~~~~~~~~~^ self.util.cache_from_source(path, optimization=''), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expect) ^^^^^^^ AssertionError: '/tmp/bytecode/foo/bar/baz/qux.cpython-313.pyc' != '/tmp/bytecode/./foo/bar/baz/qux.cpython-313.pyc' - /tmp/bytecode/foo/bar/baz/qux.cpython-313.pyc + /tmp/bytecode/./foo/bar/baz/qux.cpython-313.pyc ? ++ ``` </details> ### CPython versions tested on: CPython main branch ### Operating systems tested on: Other <!-- gh-linked-prs --> ### Linked PRs * gh-116754 * gh-116759 * gh-116762 <!-- /gh-linked-prs -->
61733a2fb9dc36d2246d922146a3462a2248832d
5ff012a4495060fe9f53ed034c90033e7eafb780
python/cpython
python__cpython-116228
# Turn off `preadv()`, `readv()`, `pwritev()`, and `writev()` under WASI # Bug report ### Bug description: The POSIX functions `preadv()`, `readv()`, `pwritev()`, and `writev()` don't work as expected under [WASI 0.2 on wasmtime](https://github.com/bytecodealliance/wasmtime/issues/7830). Since there are no plans to change that as their semantics are still POSIX-compliant, we should turn them off for WASI via https://github.com/python/cpython/blob/main/Tools/wasm/config.site-wasm32-wasi . ### CPython versions tested on: CPython main branch ### Operating systems tested on: Other <!-- gh-linked-prs --> ### Linked PRs * gh-116228 * gh-116231 * gh-116232 <!-- /gh-linked-prs -->
5dc8c84d397110f9edfa56793ad8887b1f176d79
cad3745b87ae85285a08ad8abd60cf10a59985b5
python/cpython
python__cpython-116516
# Add WASI to CI I asked if anyone had objections at https://discuss.python.org/t/adding-wasi-to-ci/46481 and no one had any. The biggest question will be how to install/cache WASI SDK for faster runs. This will also only be on `main` as it's the only branch to reach tier 2. <!-- gh-linked-prs --> ### Linked PRs * gh-116516 <!-- /gh-linked-prs -->
05070f40bbc3384c36c8b3dab76345ba92098d42
113053a070ba753101f73553ef6435c5c6c9f3f7
python/cpython
python__cpython-115963
# Add name and mode attributes to compressed file-like objects # Feature or enhancement Regular file objects returned by the `open()` building have `name` and `name` and `mode` attributes. Some code may use these optional attributes for different purposes, for example to distinguish readable files from writable files, binary files from text files, or just for formatting the repr or error messages. For example: * https://github.com/python/cpython/blob/5a832922130908994d313b56a3345ff410a0e11a/Lib/tarfile.py#L1666 * https://github.com/python/cpython/blob/5a832922130908994d313b56a3345ff410a0e11a/Lib/tarfile.py#L1669 * https://github.com/python/cpython/blob/5a832922130908994d313b56a3345ff410a0e11a/Lib/socket.py#L455 * https://github.com/python/cpython/blob/5a832922130908994d313b56a3345ff410a0e11a/Lib/gzip.py#L201 * https://github.com/python/cpython/blob/5a832922130908994d313b56a3345ff410a0e11a/Lib/asyncio/base_events.py#L982 * https://github.com/python/cpython/blob/5a832922130908994d313b56a3345ff410a0e11a/Lib/wave.py#L654 There are several file-like objects in compressing modules `gzip`, `bz2` and `lama` and archiving modules `zipfile` and `tarfile`. They usually implement the raw or buffered file protocols from `io`, but not always have `name` and `mode` attributes, and when they have, they not always have common semantic. `GzipFile`, unlike to `BZ2File` and `LZMAFile`, has `name` and `mode` attributes, but `mode` is an integer, that confuses `tarfile` (see #62775). `ZipExtFile` has the `mode` attribute which is always `'r'`. It is a legacy from Python 2, when it could also be `'U'` or `'rU'` for files with universal newlines. But this mode was removed long time ago, and since it is a binary file, its mode should be `'rb'`. See also #68446, #91373, #91374. I opened this issue because consider it all the parts of larger image. <!-- gh-linked-prs --> ### Linked PRs * gh-115963 * gh-116032 * gh-116036 * gh-116039 <!-- /gh-linked-prs -->
e72576c48b8be1e4f22c2f387f9769efa073c5be
02beb9f0208d22fd8bd893e6e6ec813f7e51b235
python/cpython
python__cpython-116009
# asyncio.TaskGroup does not close unawaited coroutines # Bug report ### Bug description: Consider the following code: ```python import asyncio async def wait_and_raise(): await asyncio.sleep(0.5) raise RuntimeError(1) async def wait_and_start(tg): try: await asyncio.sleep(1) finally: try: tg.create_task(asyncio.sleep(1)) except RuntimeError as e: print(f"wait_and_start() caught {e!r}") async def main(): try: async with asyncio.TaskGroup() as tg: tg.create_task(wait_and_start(tg)) tg.create_task(wait_and_raise()) except Exception as e: print(f"main() caught {e!r}") try: tg.create_task(asyncio.sleep(1)) except RuntimeError as e: print(f"main() caught {e!r}") asyncio.run(main()) ``` This gives the following output ``` wait_and_start() caught RuntimeError('TaskGroup <TaskGroup tasks=1 errors=1 cancelling> is shutting down') C:\code\taskgrouptest.py:16: RuntimeWarning: coroutine 'sleep' was never awaited print(f"wait_and_start() caught {e!r}") RuntimeWarning: Enable tracemalloc to get the object allocation traceback main() caught ExceptionGroup('unhandled errors in a TaskGroup', [RuntimeError(1)]) main() caught RuntimeError('TaskGroup <TaskGroup cancelling> is finished') C:\code\taskgrouptest.py:29: RuntimeWarning: coroutine 'sleep' was never awaited print(f"main() caught {e!r}") RuntimeWarning: Enable tracemalloc to get the object allocation traceback ``` Arguably, when you call `tg.create_task()` on a task group that is shutting down or has finished, the calling code "knows" about the error because it gets a `RuntimeError` exception (as you can see above), so there is no need to get a warning about a coroutine that was not awaited. So, when a `TaskGroup` encounters this situation, it should close the coroutine before raising the error. The other argument would be that this still represents a design mistake so should still get the warning. I can see both points of view but I'm raising this issue so a conscious decision can be made. For comparison, when you do this on a [Trio Nursery](https://trio.readthedocs.io/en/stable/reference-core.html#nurseries-and-spawning) or [AnyIO TaskGroup](https://anyio.readthedocs.io/en/stable/tasks.html#differences-with-asyncio-taskgroup) that has already closed, a coroutine never even gets created in the first place, because you use a different syntax (`nursery.start_soon(foo, 1, 2)` rather than `tg.create_task(foo(1, 2))`), so it's a lot like if asyncio were to close the coroutine. The situation is a bit different for a nursery that is shutting down: then it runs till the first (unshielded) `await` and is cancelled at that point, which is possible because they use level-based cancellation rather than edge-based cancellation. ### CPython versions tested on: 3.12 ### Operating systems tested on: Windows <!-- gh-linked-prs --> ### Linked PRs * gh-116009 <!-- /gh-linked-prs -->
ce0ae1d784871085059a415aa589d9bd16ea8301
7114cf20c015b99123b32c1ba4f5475b7a6c3a13
python/cpython
python__cpython-115944
# `AcquirerProxy` object has no attribute `locked` # Bug report ### Bug description: According to the documentation, both [multiprocessing.Manager.Lock](https://docs.python.org/3.12/library/multiprocessing.html#multiprocessing.managers.SyncManager.Lock) and [RLock](https://docs.python.org/3.12/library/multiprocessing.html#multiprocessing.managers.SyncManager.RLock) should be the equivalent of an [threading.Lock](https://docs.python.org/3.12/library/threading.html#threading.Lock) and [RLock](https://docs.python.org/3.12/library/threading.html#threading.RLock), but the underlying [AcquirerProxy](https://github.com/python/cpython/blob/79061af448ada100a8c038beae927fb1debb2a64/Lib/multiprocessing/managers.py#L1047) is missing the implementation of the `.locked()` method to query the state of the lock. E.g. ```python from multiprocessing import Manager from threading import Lock if __name__ == "__main__": lock_th = Lock() lock_th.locked() # this one works with Manager() as manager: lock_man = manager.Lock() lock_man.locked() # this throws an "AttributeError: 'AcquirerProxy' object has no attribute 'locked'" ``` ### CPython versions tested on: 3.11, 3.12 ### Operating systems tested on: Linux, macOS <!-- gh-linked-prs --> ### Linked PRs * gh-115944 <!-- /gh-linked-prs -->
f7305a06c7a322d23b39ad9d16af814d467624c6
6cd1d6c6b142697fb72f422b7b448c27ebc30534
python/cpython
python__cpython-116196
# Documentation: PyDictKeysObjects layout diagram in the comments section of Objects/dictobjects.c file # Documentation The `PyDictKeysObjects` layout diagram in the file `Objects/dictobjects.c` comments section, shown below: ``` layout: +---------------------+ | dk_refcnt | | dk_log2_size | | dk_log2_index_bytes | | dk_kind | | dk_usable | | dk_nentries | +---------------------+ | dk_indices[] | | | +---------------------+ | dk_entries[] | | | +---------------------+ ``` seems not to correspond with the actual definition of `PyDictKeysObjects` which is a typedef of `_dictkeysobject`, where `_dictkeysobject` is located in the file ```Include/internal/pycore_dict.h```, and its structure is reproduced below: ```c /* See dictobject.c for actual layout of DictKeysObject */ struct _dictkeysobject { Py_ssize_t dk_refcnt; /* Size of the hash table (dk_indices). It must be a power of 2. */ uint8_t dk_log2_size; /* Size of the hash table (dk_indices) by bytes. */ uint8_t dk_log2_index_bytes; /* Kind of keys */ uint8_t dk_kind; /* Version number -- Reset to 0 by any modification to keys */ uint32_t dk_version; /* Number of usable entries in dk_entries. */ Py_ssize_t dk_usable; /* Number of used entries in dk_entries. */ Py_ssize_t dk_nentries; /* Actual hash table of dk_size entries. It holds indices in dk_entries, or DKIX_EMPTY(-1) or DKIX_DUMMY(-2). Indices must be: 0 <= indice < USABLE_FRACTION(dk_size). The size in bytes of an indice depends on dk_size: - 1 byte if dk_size <= 0xff (char*) - 2 bytes if dk_size <= 0xffff (int16_t*) - 4 bytes if dk_size <= 0xffffffff (int32_t*) - 8 bytes otherwise (int64_t*) Dynamically sized, SIZEOF_VOID_P is minimum. */ char dk_indices[]; /* char is required to avoid strict aliasing. */ /* "PyDictKeyEntry or PyDictUnicodeEntry dk_entries[USABLE_FRACTION(DK_SIZE(dk))];" array follows: see the DK_ENTRIES() macro */ }; ``` The struct ```_dictkeysobject``` has a ```dk_version``` field and it doesn't contain a ```dk_entries``` field, whereas the layout diagram in the code comments' section shows such fields. End. <!-- gh-linked-prs --> ### Linked PRs * gh-116196 <!-- /gh-linked-prs -->
5e0c7bc1d311048e8252bae6fc91cb51c556f807
ff96b81d78c4a52fb1eb8384300af3dd0dd2db0d
python/cpython
python__cpython-115935
# ``test_unparse`` raises a ``SyntaxWarning`` # Bug report ### Bug description: ```python ./python.exe -m test test_unparse Using random seed: 1838242075 0:00:00 load avg: 3.28 Run 1 test sequentially 0:00:00 load avg: 3.28 [1/1] test_unparse <unknown>:1: SyntaxWarning: invalid escape sequence '\ ' <unknown>:1: SyntaxWarning: invalid escape sequence '\ ' == Tests result: SUCCESS == 1 test OK. Total duration: 2.9 sec Total tests: run=69 Total test files: run=1/1 Result: SUCCESS ``` ### CPython versions tested on: CPython main branch ### Operating systems tested on: macOS <!-- gh-linked-prs --> ### Linked PRs * gh-115935 * gh-115948 <!-- /gh-linked-prs -->
b7383b8b71d49c761480ae9a8b2111644310e61d
37f5d06b1bf830048c09ed967bb2cda945d56541
python/cpython
python__cpython-115927
# Non-equation in random.uniform # Documentation The [`random.uniform`](https://docs.python.org/3/library/random.html#random.uniform) doc says: > the equation `a + (b-a) * random()` That's not an equation. Just an expression. The page mentions "equation" twice more right above, but I think those refer to actual equations like the `pdf(x) = ...` for [`random.gammavariate`](https://docs.python.org/3/library/random.html#random.gammavariate) and are thus correct. <!-- gh-linked-prs --> ### Linked PRs * gh-115927 * gh-115928 * gh-115929 <!-- /gh-linked-prs -->
de0b4f95cbfe1f868514029289597204074c05c8
bee7bb3310b356e99e3a0f75f23efbc97f1b0a24
python/cpython
python__cpython-115916
# double init filename_obj value in pythonrun.c function PyRun_AnyFileExFlags # Bug report ### Bug description: ```c /* Parse input from a file and execute it */ int PyRun_AnyFileExFlags(FILE *fp, const char *filename, int closeit, PyCompilerFlags *flags) { PyObject *filename_obj; if (filename != NULL) { filename_obj = PyUnicode_DecodeFSDefault(filename); if (filename_obj == NULL) { PyErr_Print(); return -1; } } else { filename_obj = NULL; } int res = _PyRun_AnyFileObject(fp, filename_obj, closeit, flags); Py_XDECREF(filename_obj); return res; } ``` ===================== more better ============= ```c /* Parse input from a file and execute it */ int PyRun_AnyFileExFlags(FILE *fp, const char *filename, int closeit, PyCompilerFlags *flags) { PyObject *filename_obj = NULL; if (filename != NULL) { filename_obj = PyUnicode_DecodeFSDefault(filename); if (filename_obj == NULL) { PyErr_Print(); return -1; } } int res = _PyRun_AnyFileObject(fp, filename_obj, closeit, flags); Py_XDECREF(filename_obj); return res; } ``` ### CPython versions tested on: 3.8, 3.9, 3.10, 3.11, 3.12, 3.13, CPython main branch ### Operating systems tested on: Linux, macOS, Windows, Other <!-- gh-linked-prs --> ### Linked PRs * gh-115916 <!-- /gh-linked-prs -->
f082a05c67cc949ccd1a940ecf6721953bbdc34f
84a275c4a2c8a22d198c6f227d538e6b27bbb029
python/cpython
python__cpython-116131
# importlib: PermissionError during startup if working directory isn't readable # Bug report ### Bug description: On macOS `importlib._bootstrap_external.PathFinder._path_importer_cache()` raises `PermissionError` during interpreter startup if `''` is included in `sys.path` and the current working directory is not readable. # Reproduction Given a CWD that is not readable by fred, the user fred cannot run Python ``` ➜ private su fred -c "whoami; python3.13 -c 'pass'" Password: fred Traceback (most recent call last): File "<frozen importlib._bootstrap>", line 1360, in _find_and_load File "<frozen importlib._bootstrap>", line 1322, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 1262, in _find_spec File "<frozen importlib._bootstrap_external>", line 1544, in find_spec File "<frozen importlib._bootstrap_external>", line 1516, in _get_spec File "<frozen importlib._bootstrap_external>", line 1495, in _path_importer_cache PermissionError: [Errno 13] Permission denied ➜ private uname -mv; whoami; pwd; ls -ld Darwin Kernel Version 23.3.0: Wed Dec 20 21:30:44 PST 2023; root:xnu-10002.81.5~7/RELEASE_ARM64_T6000 arm64 alex /Users/alex/private drwx------ 2 alex staff 64 25 Feb 10:44 . ➜ private python3.13 -c "import sys;print(sys.version)" 3.13.0a4+ (heads/main:6550b54813, Feb 25 2024, 10:56:11) [Clang 15.0.0 (clang-1500.1.0.2.5)] ``` # Workaround Adding `-P`, prevents `''` being added to `sys.path`, so avoids the exception ``` ➜ private su fred -c "whoami; python3.13 -P -c 'pass'" Password: fred ``` # Discussion On macOS the libc function `getcwd()` can return `EACCES`. From the manpage > [EACCES] Read or search permission was denied for a component of the pathname. This is only checked in limited cases, depending on implementation details. When searching for importable modules `PathFinder._path_importer_cache()` attempts to determine the cwd by calling `os.getcwd()`, it handles a `FileNotFoundError` exception, but not `PermissionError`. Because `PathFinder` is used during interpreter startup user code has no opportunity to catch the exception. # Proposed fix Ignore `PermissionError` in `PathFinder._path_importer_cache()`, the same way `FileNotFoundError` is currently. This would result in imports succeeding, but without getting cached. E.g. applying the below change & rebuilding/reinstalling ``` ➜ private su fred -c "whoami; python3.13 -c 'import sys;print(sys.version)'" Password: fred 3.13.0a4+ (heads/main:6550b54813, Feb 25 2024, 10:56:11) [Clang 15.0.0 (clang-1500.1.0.2.5)] ``` I'm happy to submit a PR with this, and unit tests as deemed suitable ```diff ➜ cpython git:(main) ✗ git diff diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py index 2a9aef0317..5d1f4f1de0 100644 --- a/Lib/importlib/_bootstrap_external.py +++ b/Lib/importlib/_bootstrap_external.py @@ -1493,7 +1493,7 @@ def _path_importer_cache(cls, path): if path == '': try: path = _os.getcwd() - except FileNotFoundError: + except (FileNotFoundError, PermissionError): # Don't cache the failure as the cwd can easily change to # a valid directory later on. return None ``` # Other Python Versions In Python 3.10, 3.11 & 3.12 the same exception can occur when user code imports a non-builtin module (e.g. `base64`, zlib), but it does not occur during interpreter startup. I presume this is due to a change in which modules are required during interpreter initialisation. ``` ➜ private su fred -c "whoami; python3.10 -c 'import sys;print(sys.version);import zlib'" Password: fred 3.10.13 (main, Aug 24 2023, 12:59:26) [Clang 15.0.0 (clang-1500.1.0.2.5)] Traceback (most recent call last): File "<string>", line 1, in <module> File "<frozen importlib._bootstrap>", line 1027, in _find_and_load File "<frozen importlib._bootstrap>", line 1002, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 945, in _find_spec File "<frozen importlib._bootstrap_external>", line 1439, in find_spec File "<frozen importlib._bootstrap_external>", line 1408, in _get_spec File "<frozen importlib._bootstrap_external>", line 1366, in _path_importer_cache PermissionError: [Errno 13] Permission denied ➜ private su fred -c "whoami; python3.11 -c 'import sys;print(sys.version);import zlib'" Password: fred 3.11.7 (main, Dec 4 2023, 18:10:11) [Clang 15.0.0 (clang-1500.1.0.2.5)] Traceback (most recent call last): File "<string>", line 1, in <module> File "<frozen importlib._bootstrap>", line 1176, in _find_and_load File "<frozen importlib._bootstrap>", line 1138, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 1078, in _find_spec File "<frozen importlib._bootstrap_external>", line 1504, in find_spec File "<frozen importlib._bootstrap_external>", line 1473, in _get_spec File "<frozen importlib._bootstrap_external>", line 1431, in _path_importer_cache PermissionError: [Errno 13] Permission denied ➜ private su fred -c "whoami; python3.12 -c 'import sys;print(sys.version);import zlib'" Password: fred 3.12.1 (main, Dec 7 2023, 20:45:44) [Clang 15.0.0 (clang-1500.1.0.2.5)] Traceback (most recent call last): File "<string>", line 1, in <module> File "<frozen importlib._bootstrap>", line 1360, in _find_and_load File "<frozen importlib._bootstrap>", line 1322, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 1262, in _find_spec File "<frozen importlib._bootstrap_external>", line 1524, in find_spec File "<frozen importlib._bootstrap_external>", line 1496, in _get_spec File "<frozen importlib._bootstrap_external>", line 1475, in _path_importer_cache PermissionError: [Errno 13] Permission denied ``` ### CPython versions tested on: 3.10, 3.11, 3.12, CPython main branch ### Operating systems tested on: macOS <!-- gh-linked-prs --> ### Linked PRs * gh-116131 <!-- /gh-linked-prs -->
a8dc6d6d44a141a8f839deb248a02148dcfb509e
914c232e9391e8e5014b089ba12c75d4a3b0cc7f
python/cpython
python__cpython-116018
# test_capi failure when GIL disabled # Bug report ### Bug description: `test_capi` is failing reliably for me on Ubuntu 22.04 (Intel) and MacOS Sonoma (M1 Pro). Repeat with: ```bash git clean -fdx ./configure make ./python -E -m test --fast-ci --timeout= test_capi # test_capi succeeds git clean -fdx ./configure --disable-gil make ./python -E -m test --fast-ci --timeout= test_capi # test_capi fails ``` Output: ``` FAIL: test_pyobject_freed_is_freed (test.test_capi.test_mem.PyMemDebugTests.test_pyobject_freed_is_freed) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/skip/src/python/cpython/Lib/test/test_capi/test_mem.py", line 113, in test_pyobject_freed_is_freed self.check_pyobject_is_freed('check_pyobject_freed_is_freed') ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/skip/src/python/cpython/Lib/test/test_capi/test_mem.py", line 97, in check_pyobject_is_freed assert_python_ok( ~~~~~~~~~~~~~~~~^ '-c', code, ^^^^^^^^^^^ PYTHONMALLOC=self.PYTHONMALLOC, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ MALLOC_CONF="junk:false", ^^^^^^^^^^^^^^^^^^^^^^^^^ ) ^ File "/Users/skip/src/python/cpython/Lib/test/support/script_helper.py", line 180, in assert_python_ok return _assert_python(True, *args, **env_vars) ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/skip/src/python/cpython/Lib/test/support/script_helper.py", line 165, in _assert_python res.fail(cmd_line) ~~~~~~~~^^^^^^^^^^ File "/Users/skip/src/python/cpython/Lib/test/support/script_helper.py", line 75, in fail raise AssertionError("Process return code is %d\n" ...<13 lines>... err)) AssertionError: Process return code is 1 command line: ['/Users/skip/src/python/cpython/python.exe', '-X', 'faulthandler', '-c', '\nimport gc, os, sys, _testinternalcapi\n# Disable the GC to avoid crash on GC collection\ngc.disable()\n_testinternalcapi.check_pyobject_freed_is_freed()\n# Exit immediately to avoid a crash while deallocating\n# the invalid object\nos._exit(0)\n'] stdout: --- --- stderr: --- Traceback (most recent call last): File "<string>", line 5, in <module> _testinternalcapi.check_pyobject_freed_is_freed() ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^ AssertionError: object is not seen as freed --- ``` I tried this on both MacOS Sonoma (14.3) and Dell (Intel) Ubuntu 22.04. Results were the same. ### CPython versions tested on: CPython main branch ### Operating systems tested on: Linux, macOS <!-- gh-linked-prs --> ### Linked PRs * gh-116018 <!-- /gh-linked-prs -->
75c6c05fea212330f4b0259602ffae1b2cb91be3
df5212df6c6f08308c68de4b3ed8a1b51ac6334b
python/cpython
python__cpython-115887
# shm_open() and shm_unlink() truncate names with embedded null characters # Bug report Posix functions `shm_open()` and `shm_unlink()` take a null terminated C strings using `PyUnicode_AsUTF8AndSize(path, NULL)` which returns a pointer to char buffer which can include embedded null characters. When interpreted as C strings they are terminated at embedded null characters. <!-- gh-linked-prs --> ### Linked PRs * gh-115887 * gh-115906 * gh-115907 <!-- /gh-linked-prs -->
79811ededd160b6e8bcfbe4b0f9d5b4589280f19
5770006ffac2abd4f1c9fd33bf5015c9ef023576
python/cpython
python__cpython-115350
# Fix building CPython with -DWIN32_LEAN_AND_MEAN on Windows # Feature or enhancement ### Proposal: We use customized build of CPython which compiles all the sources with `-WIN32_LEAN_AND_MEAN`, thus limiting the amount of transitive `#include` from `Windows.h` header. I would like to propose a series of enhancements to make CPython buildable in this configuration. ### Has this already been discussed elsewhere? No response given ### Links to previous discussion of this feature: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-115350 <!-- /gh-linked-prs -->
96c10c648565c7406d5606099dbbb937310c26dc
c0fdfba7ff981c55ac13325e4dddaf382601b246
python/cpython
python__cpython-115920
# `ast.parse()` believes valid context manager py38 syntax to be invalid when `feature_version=(3, 8)` is passed # Bug report ### Bug description: The following code is completely valid on Python 3.8: ```python from contextlib import nullcontext with ( nullcontext() if bool() else nullcontext() ): pass ``` However, following https://github.com/python/cpython/commit/0daba822212cd5d6c63384a27f390f0945330c2b (which was backported to Python 3.11 and Python 3.10), `ast.parse()` incorrectly throws an error if you try to parse this code with `feature_version=(3, 8)`: ```pycon % python Python 3.10.6 (main, Feb 24 2024, 10:35:05) [Clang 15.0.0 (clang-1500.1.0.2.5)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import ast >>> source = """ ... with ( ... nullcontext() if bool() else nullcontext() ... ): ... pass ... """ >>> ast.parse(source, feature_version=(3, 8)) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/alexw/.pyenv/versions/3.10.6/lib/python3.10/ast.py", line 50, in parse return compile(source, filename, mode, flags, File "<unknown>", line 5 pass ^ SyntaxError: Parenthesized context managers are only supported in Python 3.9 and greater ``` Cc. @hauntsaninja / @pablogsal ### CPython versions tested on: 3.8, 3.9, 3.10, 3.11, 3.12 ### Operating systems tested on: macOS <!-- gh-linked-prs --> ### Linked PRs * gh-115920 * gh-115959 * gh-115960 * gh-115980 * gh-116173 * gh-116174 <!-- /gh-linked-prs -->
7a3518e43aa50ea57fd35863da831052749b6115
8e8ab75d97f51c2850eb8cd711010662d5f1d360
python/cpython
python__cpython-116204
# Segfaults when accessing module state in `tp_dealloc` (itertools teedataobject clear) # Crash report ### What happened? ```python from dataclasses import dataclass from itertools import tee from typing import Optional # if we remove @dataclass, then no segfault @dataclass class SomeDataClass: pass class SomeClass: # if we remove Optional, then no segfault _value: Optional[SomeDataClass] def __init__(self, it): self._it = it def prepare_segfault(self): (lhs, _) = tee(self._it) # if we don't assign lhs to self._it, then no segfault self._it = lhs # if some_object isn't bound at the top-level scope, then no segfault some_object = SomeClass(iter("testing")) some_object.prepare_segfault() ``` Running the file from the terminal with `python3.12 minimal.py` is sufficient. When the interpreter exits, it segfaults. Crash does not occur in python 3.8-3.11, but does occur in 3.12 and 3.13. Crash not observed on Windows with 3.12. Backtrace: ``` #0 0x00007fc2c1a72e01 in teedataobject_clear (tdo=tdo@entry=0x7fc2b3ed2040) at /usr/src/debug/python3.12-3.12.1-2.fc39.x86_64/Modules/itertoolsmodule.c:836 #1 0x00007fc2c1a72d49 in teedataobject_dealloc (tdo=0x7fc2b3ed2040) at /usr/src/debug/python3.12-3.12.1-2.fc39.x86_64/Modules/itertoolsmodule.c:845 #2 0x00007fc2c1b06a0e in Py_DECREF (op=<optimized out>) at /usr/src/debug/python3.12-3.12.1-2.fc39.x86_64/Include/object.h:706 #3 tee_clear (to=to@entry=0x7fc2b3c13b00) at /usr/src/debug/python3.12-3.12.1-2.fc39.x86_64/Modules/itertoolsmodule.c:1050 #4 0x00007fc2c1b069ac in tee_dealloc (to=0x7fc2b3c13b00) at /usr/src/debug/python3.12-3.12.1-2.fc39.x86_64/Modules/itertoolsmodule.c:1059 #5 0x00007fc2c1a390d8 in _Py_Dealloc (op=<optimized out>) at /usr/src/debug/python3.12-3.12.1-2.fc39.x86_64/Objects/object.c:2608 #6 Py_DECREF (op=<optimized out>) at /usr/src/debug/python3.12-3.12.1-2.fc39.x86_64/Include/object.h:706 #7 Py_XDECREF (op=<optimized out>) at /usr/src/debug/python3.12-3.12.1-2.fc39.x86_64/Include/object.h:799 #8 _PyObject_FreeInstanceAttributes (self=0x7fc2b3daf1d0) at /usr/src/debug/python3.12-3.12.1-2.fc39.x86_64/Objects/dictobject.c:5571 #9 subtype_dealloc (self=0x7fc2b3daf1d0) at /usr/src/debug/python3.12-3.12.1-2.fc39.x86_64/Objects/typeobject.c:2017 #10 0x00007fc2c19f5440 in _Py_Dealloc (op=<optimized out>) at /usr/src/debug/python3.12-3.12.1-2.fc39.x86_64/Objects/object.c:2625 #11 Py_DECREF (op=<optimized out>) at /usr/src/debug/python3.12-3.12.1-2.fc39.x86_64/Include/object.h:706 #12 Py_XDECREF (op=<optimized out>) at /usr/src/debug/python3.12-3.12.1-2.fc39.x86_64/Include/object.h:799 #13 free_keys_object (interp=0x7fc2c1df0d48 <_PyRuntime+76392>, keys=0x7fc2b3d7a100) at /usr/src/debug/python3.12-3.12.1-2.fc39.x86_64/Objects/dictobject.c:673 #14 0x00007fc2c1aa72bd in dict_tp_clear (op=<optimized out>) at /usr/src/debug/python3.12-3.12.1-2.fc39.x86_64/Objects/dictobject.c:3564 #15 0x00007fc2c1a02cfa in delete_garbage (old=0x7fc2c1df0e00 <_PyRuntime+76576>, collectable=0x7ffcdfc26270, gcstate=0x7fc2c1df0db8 <_PyRuntime+76504>, tstate=0x7fc2c1e4e668 <_PyRuntime+459656>) at /usr/src/debug/python3.12-3.12.1-2.fc39.x86_64/Modules/gcmodule.c:1029 #16 gc_collect_main (tstate=0x7fc2c1e4e668 <_PyRuntime+459656>, generation=generation@entry=2, n_collected=n_collected@entry=0x0, n_uncollectable=n_uncollectable@entry=0x0, nofail=nofail@entry=1) at /usr/src/debug/python3.12-3.12.1-2.fc39.x86_64/Modules/gcmodule.c:1303 #17 0x00007fc2c1abe201 in _PyGC_CollectNoFail (tstate=<optimized out>) at /usr/src/debug/python3.12-3.12.1-2.fc39.x86_64/Modules/gcmodule.c:2135 #18 0x00007fc2c1aaacda in Py_FinalizeEx () at /usr/src/debug/python3.12-3.12.1-2.fc39.x86_64/Python/pylifecycle.c:1889 #19 0x00007fc2c1ab96c9 in Py_RunMain () at /usr/src/debug/python3.12-3.12.1-2.fc39.x86_64/Modules/main.c:711 #20 0x00007fc2c1a74f5c in Py_BytesMain (argc=<optimized out>, argv=<optimized out>) at /usr/src/debug/python3.12-3.12.1-2.fc39.x86_64/Modules/main.c:763 #21 0x00007fc2c164614a in __libc_start_call_main (main=main@entry=0x56033de41160 <main>, argc=argc@entry=2, argv=argv@entry=0x7ffcdfc26698) at ../sysdeps/nptl/libc_start_call_main.h:58 #22 0x00007fc2c164620b in __libc_start_main_impl (main=0x56033de41160 <main>, argc=2, argv=0x7ffcdfc26698, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7ffcdfc26688) at ../csu/libc-start.c:360 #23 0x000056033de41095 in _start () ``` ### CPython versions tested on: 3.12 ### Operating systems tested on: Linux ### Output from running 'python -VV' on the command line: Python 3.12.1 (main, Dec 18 2023, 00:00:00) [GCC 13.2.1 20231205 (Red Hat 13.2.1-6)] <!-- gh-linked-prs --> ### Linked PRs * gh-116204 * gh-116955 * gh-117741 * gh-118114 <!-- /gh-linked-prs -->
e2fcaf19d302b05d3466807bad0a61f39db2a51b
cd2ed917801b93fb46d1dcf19dd480e5146932d8
python/cpython
python__cpython-115873
# Doc: obsolete reference to MSI packages https://docs.python.org/3.13/using/windows.html page refers to "MSI packages" in the following sentence: To make Python available, the CPython team has compiled Windows installers (**MSI packages**) with every release for many years. However, MSI packages have been replaced regular Windows installer since python-3.5; for example see here: https://docs.python.org/3.13/whatsnew/3.5.html Windows improvements: * A new installer for Windows has replaced the old MSI. because of this the reference for MSI packages should be removed from documentation here: https://docs.python.org/3.13/using/windows.html <!-- gh-linked-prs --> ### Linked PRs * gh-115873 * gh-115876 * gh-115877 <!-- /gh-linked-prs -->
52517118685dd3cc35068af6bba80b650775a89b
200271c61db44d90759f8a8934949aefd72d5724
python/cpython
python__cpython-115860
# Type propagation: just because something is const doesn't mean it automatically matches the type # Bug report ### Bug description: See log files for failure: https://github.com/python/cpython/actions/runs/8021737661/job/21914497578 An example failure from my Windows machine: ``` Assertion failed: PyFloat_CheckExact(sym_get_const(left)), file C:\Users\Ken\Documents\GitHub\cpython\Python\tier2_redundancy_eliminator_cases.c.h, line 279 Fatal Python error: Aborted ``` Just because a constant is present, doesn't mean it's the right type. In such a case, I think we should bail from the abstract interpreter, because it's a guaranteed deopt. E.g. ```C op(_GUARD_BOTH_FLOAT, (left, right -- left, right)) { if (sym_matches_type(left, &PyFloat_Type) && sym_matches_type(right, &PyFloat_Type)) { REPLACE_OP(this_instr, _NOP, 0 ,0); } sym_set_type(left, &PyFloat_Type); sym_set_type(right, &PyFloat_Type); } ``` should become ```C op(_GUARD_BOTH_FLOAT, (left, right -- left, right)) { if (sym_matches_type(left, &PyFloat_Type) && sym_matches_type(right, &PyFloat_Type)) { REPLACE_OP(this_instr, _NOP, 0 ,0); } if (sym_is_const(left)) { if (!sym_const_is_type(left, &PyFloat_Type) goto guaranteed_deopt; } if (sym_is_const(right)) { if (!sym_const_is_type(right, &PyFloat_Type) goto guaranteed_deopt; } sym_set_type(left, &PyFloat_Type); sym_set_type(right, &PyFloat_Type); } ``` While ```C op(_BINARY_OP_ADD_FLOAT, (left, right -- res)) { if (sym_is_const(left) && sym_is_const(right)) { assert(PyFloat_CheckExact(sym_get_const(left))); assert(PyFloat_CheckExact(sym_get_const(right))); PyObject *temp = PyFloat_FromDouble( PyFloat_AS_DOUBLE(sym_get_const(left)) + PyFloat_AS_DOUBLE(sym_get_const(right))); ERROR_IF(temp == NULL, error); OUT_OF_SPACE_IF_NULL(res = sym_new_const(ctx, temp)); // TODO gh-115506: // replace opcode with constant propagated one and update tests! } else { OUT_OF_SPACE_IF_NULL(res = sym_new_known_type(ctx, &PyFloat_Type)); } } ``` should become ```C op(_BINARY_OP_ADD_FLOAT, (left, right -- res)) { if (sym_is_const(left) && sym_is_const(right)) { if(!PyFloat_CheckExact(sym_get_const(left))) { goto guaranteed_deopt; } if(!PyFloat_CheckExact(sym_get_const(right))) { goto guaranteed_deopt; } PyObject *temp = PyFloat_FromDouble( PyFloat_AS_DOUBLE(sym_get_const(left)) + PyFloat_AS_DOUBLE(sym_get_const(right))); ERROR_IF(temp == NULL, error); OUT_OF_SPACE_IF_NULL(res = sym_new_const(ctx, temp)); // TODO gh-115506: // replace opcode with constant propagated one and update tests! } else { OUT_OF_SPACE_IF_NULL(res = sym_new_known_type(ctx, &PyFloat_Type)); } } ``` ### CPython versions tested on: CPython main branch ### Operating systems tested on: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-115860 * gh-116062 * gh-116079 <!-- /gh-linked-prs -->
3409bc29c9f06051c28ae0791155e3aebd76ff2d
75c6c05fea212330f4b0259602ffae1b2cb91be3
python/cpython
python__cpython-115837
# test_monitoring contains hardcoded line numbers # Bug report ### Bug description: `test_lines_single`, `test_lines_loop`, and `test_lines_two` in [`test_monitoring.LinesMonitoringTest`](https://github.com/python/cpython/blob/main/Lib/test/test_monitoring.py#L520) all contain some hardcoded line numbers in their expected values. They should consistently use offsets from `co_firstlineno` on the relevant code objects instead. I ran into this while adding a test for gh-115832, and already have a fix ready to put up as a PR. ### CPython versions tested on: CPython main branch ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-115837 <!-- /gh-linked-prs -->
a494a3dd8e0e74861972698c37b14a4087a4688c
b48101864c724a7eab41a6878a836f38e54e04fb
python/cpython
python__cpython-115856
# Coverage.py test suite failure since commit 0749244d134 # Bug report ### Bug description: Coverage.py runs its test suite against nightly builds of Python. The tests stalled last night. Running them locally, there's one test that freezes the suite. The GitHub action is eventually cancelled by timing out after six hours: https://github.com/nedbat/coveragepy/actions/runs/8000886484 Bisecting CPython, the first bad commit is 0749244d13412d7cb5b53d834f586f2198f5b9a6 ``` commit 0749244d13412d7cb5b53d834f586f2198f5b9a6 Author: Brett Simmers <swtaarrs@users.noreply.github.com> Date: Tue Feb 20 06:57:48 2024 -0800 gh-112175: Add `eval_breaker` to `PyThreadState` (#115194) This change adds an `eval_breaker` field to `PyThreadState`. The primary motivation is for performance in free-threaded builds: with thread-local eval breakers, we can stop a specific thread (e.g., for an async exception) without interrupting other threads. The source of truth for the global instrumentation version is stored in the `instrumentation_version` field in PyInterpreterState. Threads usually read the version from their local `eval_breaker`, where it continues to be colocated with the eval breaker bits. ``` I'm still investigating, but I'm hoping that someone familiar with the change (@swtaarrs?) will be able to help. To reproduce: ``` % git clone https://github.com/nedbat/coveragepy % cd coveragepy % export COVERAGE_ANYPY=/path/to/your/python3 % pip install tox % tox -qre anypy -- -n 0 -vvv -k test_multiprocessing_simple === CPython 3.13.0a4+ (rev 0749244d13) with C tracer (.tox/anypy/bin/python) === ===================================================================== test session starts ====================================================================== platform darwin -- Python 3.13.0a4+, pytest-8.0.1, pluggy-1.4.0 -- /Users/ned/coverage/trunk/.tox/anypy/bin/python cachedir: .tox/anypy/.pytest_cache hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase(PosixPath('/Users/ned/coverage/trunk/.hypothesis/examples')) rootdir: /Users/ned/coverage/trunk configfile: pyproject.toml plugins: flaky-3.7.0, xdist-3.5.0, hypothesis-6.98.9 collected 1386 items / 1384 deselected / 2 selected run-last-failure: no previously failed tests, not deselecting items. tests/test_concurrency.py::MultiprocessingTest::test_multiprocessing_simple[fork] PASSED [ 50%] tests/test_concurrency.py::MultiprocessingTest::test_multiprocessing_simple[spawn] PASSED [100%] ============================================================== 2 passed, 1384 deselected in 3.37s ============================================================== === CPython 3.13.0a4+ (rev 0749244d13) with sys.monitoring (.tox/anypy/bin/python) === ===================================================================== test session starts ====================================================================== platform darwin -- Python 3.13.0a4+, pytest-8.0.1, pluggy-1.4.0 -- /Users/ned/coverage/trunk/.tox/anypy/bin/python cachedir: .tox/anypy/.pytest_cache hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase(PosixPath('/Users/ned/coverage/trunk/.hypothesis/examples')) rootdir: /Users/ned/coverage/trunk configfile: pyproject.toml plugins: flaky-3.7.0, xdist-3.5.0, hypothesis-6.98.9 collected 1386 items / 1384 deselected / 2 selected run-last-failure: no previously failed tests, not deselecting items. tests/test_concurrency.py::MultiprocessingTest::test_multiprocessing_simple[fork] PASSED [ 50%] tests/test_concurrency.py::MultiprocessingTest::test_multiprocessing_simple[spawn] ``` and there it is stuck. ### CPython versions tested on: CPython main branch ### Operating systems tested on: Linux, macOS <!-- gh-linked-prs --> ### Linked PRs * gh-115856 <!-- /gh-linked-prs -->
0adfa8482d369899e9963206a3307f423309e10c
15dc2979bc1b24269177f0e150495abb7f3eb546
python/cpython
python__cpython-115828
# Warning "Objects/longobject.c:1186:42: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]" # Bug report It happens here: https://github.com/python/cpython/blob/b348313e7a48811acacc293ac4b2c8b20b4c631b/Objects/longobject.c#L1166-L1193 Line `1186`. The problem is: - (no warning) https://github.com/python/cpython/blob/b348313e7a48811acacc293ac4b2c8b20b4c631b/Objects/longobject.c#L1173 - (warning) https://github.com/python/cpython/blob/b348313e7a48811acacc293ac4b2c8b20b4c631b/Objects/longobject.c#L1186 Buildbot link: https://buildbot.python.org/all/#/builders/332/builds/1372 I have a PR ready. <!-- gh-linked-prs --> ### Linked PRs * gh-115828 <!-- /gh-linked-prs -->
465df8855e9fff771e119ea525344de48869ef1a
b348313e7a48811acacc293ac4b2c8b20b4c631b
python/cpython
python__cpython-115824
# Invalid error range when the tokeniser finds invalid bytes When the tokeniser raises errors due to invalid byte sequences **only when the parser encoding is implicit** (such when parsing a file), the error locations are not properly transformed to character offsets <!-- gh-linked-prs --> ### Linked PRs * gh-115824 * gh-115949 * gh-115950 <!-- /gh-linked-prs -->
015b97d19a24a169cc3c0939119e1228791e4253
b7383b8b71d49c761480ae9a8b2111644310e61d
python/cpython
python__cpython-116063
# Document in the main Enum page that super().__new__ should not be called The HowTo page says [here](https://docs.python.org/3/howto/enum.html#when-to-use-new-vs-init) that `super().__new__` should not be called in user-defined `__new__` methods of an Enum (subclass), along with a short explanation for why it is the case. But this is a hard limitation, not a bonus explanation. When I tried using the super, I ended up with an exception I didn't understand and the doc entry for `Enum.__new__` didn't help me at all as per why that was failing. The explanation should probably remain in the howto page, but a similar red warning should be added to [`Enum.__new__`](https://docs.python.org/3/library/enum.html#enum.Enum.__new__), saying that calling `super().__new__` inside user-defined `__new__` functions is forbidden. <!-- gh-linked-prs --> ### Linked PRs * gh-116063 * gh-116065 <!-- /gh-linked-prs -->
3ea78fd5bc93fc339ef743e6a5dfde35f04d972e
4d1d35b906010c6db15f54443a9701c20af1db2d
python/cpython
python__cpython-116355
# Eliminate boolean and `None` guards for constants Eliminate the following guard ops if the input is constant: * `_GUARD_IS_TRUE_POP` * `_GUARD_IS_FALSE_POP` * `_GUARD_IS_NONE_POP` * `_GUARD_IS_NOT_NONE_POP` <!-- gh-linked-prs --> ### Linked PRs * gh-116355 <!-- /gh-linked-prs -->
0c81ce13602b88fd59f23f701ed8dc377d74e76e
c91bdf86ef1cf9365b61a46aa2e51e5d1932b00a
python/cpython
python__cpython-116109
# Undocumented attributes of logging.Logger # Documentation The `logging.Logger` class has a few undocumented, useful, relatively well-known attributes, namely - `name` - `level` - `parent` - `handlers` - `disabled` It would be useful to add them to the documentation or, if that is undesired, perhaps to add a caveat that these should not be accessed even though there naming without an underscore suggests public visibility. <!-- gh-linked-prs --> ### Linked PRs * gh-116109 * gh-116185 * gh-116186 <!-- /gh-linked-prs -->
3b6f4cadf19e6a4edd2cbbbc96a0a4024b395648
04d1000071b5eefd4b1dd69051aacad343da4b21
python/cpython
python__cpython-115812
# TimedRotatingFileHandler: reliable algorithm to determine the files to delete # Bug report There were many issues related to removing old files in TimedRotatingFileHandler: * bpo-44753/#88916 * bpo-45628/#89791 * bpo-46063/#90221 * #93205 It is complicated because the namer attribute allows arbitrary transformation of the file name. 1. #93205 almost nailed the case without namer. But when there are two handlers with the same basename, and one has no namer, while other has a simple namer that adds an extension, the former handler will delete logs of the latter one. This is because the regular expression `extMatch` includes an optional extension. It is a remnant from former attempts to handle rotation, and is not needed now. The issue can be fixed by removing it. 2. It is even more complicated when we have more complex namer. It can add more complex suffix, it can modify the prefix. We can only expect that it leaves the datetime part unchanged. I think that the most reliable way to find candidates for deletion is to find the datetime part in the file, then generate a new filename for this datetime and compare it with the original filename. It should work for arbitrary deterministic namer that does not modify the datetime part, and should not produce false positives. <!-- gh-linked-prs --> ### Linked PRs * gh-115812 * gh-116261 * gh-116262 <!-- /gh-linked-prs -->
87faec28c78f6fa8eaaebbd1ababf687c7508e71
002a5948fc9139abec2ecf92df8b543e093c43fb
python/cpython
python__cpython-115814
# Add operator.is_none() # Feature or enhancement ### Proposal: With floating point data, the `float('NaN')` special value is commonly used as a placeholder for missing values. We provide `math.isnan` to support stripping out those values prior to sorting or summation: ```python >>> from math import isnan >>> from itertools import filterfalse >>> data = [3.3, float('nan'), 1.1, 2.2] >>> sorted(filterfalse(isnan, data)) [1.1, 2.2, 3.3] ``` For non-float data, the `None` special value is commonly used as a placeholder for missing values. I propose a new function in the operator module analogous to `math.isnan()`: ```pycon >>> data = ['c', None, 'a', 'b'] >>> sorted(filterfalse(is_none, data)) ['a', 'b', 'c'] ``` This helps fulfill a primary use case for the operator module which is to support functional programming with `map()`, `filter()`, etc. ### Has this already been discussed elsewhere? No response given ### Links to previous discussion of this feature: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-115814 <!-- /gh-linked-prs -->
5580f31c56e6f90909bdceddda077504cc2d18b0
0fd97e46c75bb3060485b796ca597b13af7e6bec
python/cpython
python__cpython-115807
# Configure UX # Feature or enhancement The LDLIBRARY and HOSTRUNNER checks overlap; this results in garbled output: ```console $ ./configure [...] checking LDLIBRARY... checking HOSTRUNNER... libpython$(VERSION)$(ABIFLAGS).a ``` The IPv6 library check is very subtle: ```console $ ./configure [...] configure: using libc ``` Suggesting to clean this up, for improved `configure` user experience: ```console $ ./configure [...] checking LDLIBRARY... libpython$(VERSION)$(ABIFLAGS).a checking HOSTRUNNER... [...] checking ipv6 stack type... kame checking ipv6 library... libc ``` <!-- gh-linked-prs --> ### Linked PRs * gh-115807 * gh-116165 * gh-129390 <!-- /gh-linked-prs -->
e74cd0f9101d06045464ac3173ab73e0b78d175e
2e92ffd7fa89e3bd33ee2f31541d3dc53aaa2d12
python/cpython
python__cpython-118333
# difflib._check_types allows string inputs instead of sequences of strings as documented # Bug report ### Bug description: Both `difflib.unified_diff` and `difflib.context_diff` document that `a` and `b` input arguments are to be lists of strings. These functions perform argument type checking by way of `difflib._check_types`, however this function allows `a` and `b` to be direct `str` arguments. Technically this does not cause a failure in `difflib.unified_diff` (and I assume the same is true for `context_diff` but I have not tested it), however, for very large strings `a` and/or `b`, `difflib.unified_diff` is exponentially slower to calculate the diff, because the underlying `SequenceMatcher` is optimized to compare two lists of string, not two sequences of chars. We can obviously see that the implementation of `_check_types` uses a seemingly naive type check of the first element in `a` and `b` which will pass for both the documented input of a list of strings, but also for a positive length string itself. ```python def _check_types(a, b, *args): # Checking types is weird, but the alternative is garbled output when # someone passes mixed bytes and str to {unified,context}_diff(). E.g. # without this check, passing filenames as bytes results in output like # --- b'oldfile.txt' # +++ b'newfile.txt' # because of how str.format() incorporates bytes objects. if a and not isinstance(a[0], str): raise TypeError('lines to compare must be str, not %s (%r)' % (type(a[0]).__name__, a[0])) if b and not isinstance(b[0], str): raise TypeError('lines to compare must be str, not %s (%r)' % (type(b[0]).__name__, b[0])) for arg in args: if not isinstance(arg, str): raise TypeError('all arguments must be str, not: %r' % (arg,)) ``` This would be rather trivial to fix in `_check_types` but I want to first make sure that the documentation of a list of string is to be considered correct behavior? ### CPython versions tested on: 3.8, 3.9, 3.10, 3.11, 3.12, 3.13, CPython main branch ### Operating systems tested on: Linux, macOS <!-- gh-linked-prs --> ### Linked PRs * gh-118333 <!-- /gh-linked-prs -->
c3b6dbff2c8886de1edade737febe85dd47ff4d0
b90bd3e5bbc136f53b24ee791824acd6b17e0d42
python/cpython
python__cpython-115884
# An error in python Exception Handling doc. [link](https://docs.python.org/3.13/c-api/exceptions.html#c.PyErr_FormatUnraisable) void PyErr_FormatUnraisable(const char *format, ...) Similar to PyErr_WriteUnraisable(), but the format and subsequent parameters help format the warning message; they have the same meaning and values as in [PyUnicode_FromFormat()](https://docs.python.org/3.13/c-api/unicode.html#c.PyUnicode_FromFormat). PyErr_WriteUnraisable(obj) is roughtly equivalent to PyErr_FormatUnraisable("Exception ignored in: %R, obj). If format is NULL, only the traceback is printed. I think the PyErr_FormatUnraisable("Exception ignored in: %R, obj) should be PyErr_FormatUnraisable("Exception ignored in: %R", obj). <!-- gh-linked-prs --> ### Linked PRs * gh-115884 <!-- /gh-linked-prs -->
6a3236fe2e61673cf9f819534afbf14a18678408
8f5be78bce95deb338e2e1cf13a0a579b3b42dd2
python/cpython
python__cpython-115797
# _testinternalcapi.assemble_code_object doesn't construct the exception table The code object returned from `_testinternalcapi.assemble_code_object.` doesn't have a code object: ``` from _testinternalcapi import compiler_codegen, optimize_cfg, assemble_code_object metadata = { 'filename' : 'exc.py', 'name' : 'exc', 'consts' : {2 : 0}, } # code for "try: pass\n except: pass" insts = [ ('RESUME', 0), ('SETUP_FINALLY', 3), ('RETURN_CONST', 0), ('SETUP_CLEANUP', 8), ('PUSH_EXC_INFO', 0), ('POP_TOP', 0), ('POP_EXCEPT', 0), ('RETURN_CONST', 0), ('COPY', 3), ('POP_EXCEPT', 0), ('RERAISE', 1), ] from test.test_compiler_assemble import IsolatedAssembleTests metadata = IsolatedAssembleTests().complete_metadata(metadata) insts = IsolatedAssembleTests().complete_insts_info(insts) co = assemble_code_object(metadata['filename'], insts, metadata) print(co.co_exceptiontable) ``` Output: `b''` <!-- gh-linked-prs --> ### Linked PRs * gh-115797 <!-- /gh-linked-prs -->
96c1737591b45bc1c528df1103eb0e500751fefe
8aa372edcd857d2fbec8da0cb993de15b4179308
python/cpython
python__cpython-115749
# Doc: Windows set up documentation refers to obsolete URL # Documentation Using python on Windows documentation refers to an old URL for windows releases here: https://docs.python.org/3.13/using/windows.html In the sentence: "To make Python available, the CPython team has compiled Windows installers (MSI packages) with every [release](https://www.python.org/download/releases/) for many years." https://www.python.org/download/releases/ should be replaced with https://www.python.org/downloads/ <!-- gh-linked-prs --> ### Linked PRs * gh-115749 * gh-115803 * gh-115804 <!-- /gh-linked-prs -->
7bc79371a62e8f45542cf5679ed35d0d29e94226
fac99b8b0df209ca6546545193b1873672d536ca
python/cpython
python__cpython-115815
# Bytecodes cleanup: promote TIER_{ONE,TWO}_ONLY to properties Instead of ``` op(FOO, (left, right -- res)) { TIER_TWO_ONLY <actual code> } ``` I'd like to be able to write ``` tier2 op(FOO, (left, right -- res)) { <actual code> } ``` <!-- gh-linked-prs --> ### Linked PRs * gh-115815 <!-- /gh-linked-prs -->
e4561e050148f6dc347e8c7ba30c8125b5fc0e45
59057ce55a443f35bfd685c688071aebad7b3671
python/cpython
python__cpython-116269
# Double ``versionadded`` labels in ``typing.NoReturn`` doc I think it was added by mistake: https://github.com/python/cpython/blob/5f7df88821347c5f44fc4e2c691e83a60a6c6cd5/Doc/library/typing.rst#L957-L958 cc @JelleZijlstra @AlexWaygood <!-- gh-linked-prs --> ### Linked PRs * gh-116269 * gh-116361 * gh-116362 <!-- /gh-linked-prs -->
0064dfa0919cc93257c351a609f99461f6e4e3ac
23db9c62272f7470aadf8f52fe3ebb42b5e5d380
python/cpython
python__cpython-115774
# Exercise the debug structs placed in PyRuntime To avoid breaking external inspection, profilers and debuggers too often or to make supporting them too difficult, we added a [special offset struct](https://github.com/python/cpython/blob/5f7df88821347c5f44fc4e2c691e83a60a6c6cd5/Include/internal/pycore_runtime.h#L53) in the `PyRuntime` structure. Unfortunately there is nothing testing that this offsets are correct or that they are enough to analyse or profile a Python application on their own. To fix this, we should add some testing that exercises the offsets and ensure they are enough to serve the purpose they were added. <!-- gh-linked-prs --> ### Linked PRs * gh-115774 * gh-116212 * gh-118591 * gh-120112 * gh-121283 <!-- /gh-linked-prs -->
1752b51012269eaa35f7a28f162d18479a4f72aa
d53560deb2c9ae12147201003fe63b266654ee21
python/cpython
python__cpython-137326
# IP Interface is_unspecified broken # Bug report ### Bug description: ```python from ipaddress import ip_interface ip_interface('0.0.0.0/32').is_unspecified == False ip_interface('0.0.0.0/32').network.is_unspecified == True ip_interface('0.0.0.0/32').ip.is_unspecified == True ``` Per the [documentation](https://docs.python.org/3/library/ipaddress.html#ipaddress.IPv4Interface), the IP interface classes inherit all properties from the associated address classes. As such, `is_unspecified` is available as a property, although as implemented now, it will always return `False` for an interface. Given that an interface is just a network and host combined, it might be reasonable for the implementation of `is_unspecified` to be something along the lines of `self.network.is_unspecified and self.ip.is_unspecifed`, possibly implemented more efficiently (for example `self._ip == 0 and self._prefixlen == 32` for IPv4) The current implementation isn't specified for an interface, so it falls back to the [address implementation](https://github.com/python/cpython/blob/main/Lib/ipaddress.py#L1362) which checks if the address equals '0.0.0.0', although this subtly always fails because the [interface equality function](https://github.com/python/cpython/blob/main/Lib/ipaddress.py#L1421) is used which will never return `True` comparing an interface and address object. ### CPython versions tested on: CPython main branch ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-137326 <!-- /gh-linked-prs -->
deb0020e3d478fa72104b82e2ba1a1c0c6eb4eae
bc4996c125b3cd5c73d41c6bf4e71571a2b832c2
python/cpython
python__cpython-128411
# Upgrade to GNU Autoconf 2.72 # Feature or enhancement Autoconf 2.72 was [released 2023-12-22](https://lists.gnu.org/archive/html/info-gnu/2023-12/msg00002.html). Relevant highlights (some C&P verbatim) from the release announcement: - Pre-C89 compilers are no longer supported. This should not be a problem for us, as [we're using C11](https://peps.python.org/pep-0007/#c-dialect). - `AC_USE_SYSTEM_EXTENSIONS` now enables C23 Annex F extensions by defining `__STDC_WANT_IEC_60559_EXT__` (is this a problem?) - ~~Autoconf now quotes ```'like this'``` instead of ``` `like this'```; perhaps we should clean up our quoting in a separate first, so the 2.72 change is easier to review.~~ <= not worth the churn - Improved compatibility with a wide variety of systems and tools including CheriBSD, Darwin (macOS), GNU Guix, OS/2, z/OS, Bash 5.2, the BusyBox shell and utilities, Clang/LLVM version 16, the upcoming GCC version 14, etc. The other version requirements (Perl, M4, etc.) should not affect us. Preliminary actions: - [x] #116016 - [x] #115792 <!-- gh-linked-prs --> ### Linked PRs * gh-128411 * gh-128502 <!-- /gh-linked-prs -->
8abd6cef68a0582a4d912be76caddd9da5d55ccd
4ed36d6efb3e3bc613045016dee594d671997709
python/cpython
python__cpython-115781
# Make PyCode_GetFirstFree a PEP-689 unstable API > It was and it wasn't. We don't really want to expose it, but if we don't then Cython and other C extensions will access the internal fields directly, which is worse. > > Now that we have an unstable API, it should probably be part of that. I'd like all code object C APIs to be unstable, but it's probably too late for that. > > Maybe rename it to `PyUnstableCode_GetFirstFree`? _Originally posted by @markshannon in https://github.com/python/cpython/pull/115654#discussion_r1497192136_ <!-- gh-linked-prs --> ### Linked PRs * gh-115781 <!-- /gh-linked-prs -->
a8e93d3dca086896e668b88b6c5450eaf644c0e7
a3cf0fada09b74b1a6981cc06c4dd0bb1091b092
python/cpython
python__cpython-115750
# "dyld: Library not loaded: /lib/libpython3.13.dylib" in 3.13.0a4 MacOS non-framework build with custom prefix # Bug report ### Bug description: The above error was discovered in [Pyenv CI check](https://github.com/pyenv/pyenv/actions/runs/7927748950/job/21644695424?pr=2903) (logs are on the link). See https://github.com/pyenv/pyenv/pull/2903#issuecomment-1954681384 for diagnostics and probable cause. ### CPython versions tested on: 3.13 ### Operating systems tested on: macOS <!-- gh-linked-prs --> ### Linked PRs * gh-115750 <!-- /gh-linked-prs -->
074bbec9c4911da1d1155e56bd1693665800b814
10fc4675fdb14e19f2fdd15102c6533b9f71e992
python/cpython
python__cpython-115736
# segfault with PYTHON_LLTRACE=3 and PYTHON_UOPS=1 on debug build # Crash report ### What happened? On main, run ``` PYTHON_UOPS=1 PYTHON_LLTRACE=3 ./python ``` ### CPython versions tested on: CPython main branch ### Operating systems tested on: _No response_ ### Output from running 'python -VV' on the command line: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-115736 <!-- /gh-linked-prs -->
7a8c3ed43abb4b7a18e7a271aaee3ca69c0d83bc
e3ad6ca56f9b49db0694f432a870f907a8039f79
python/cpython
python__cpython-115740
# 3.13.0a4 SIGSEGV when calling next on a list-iterator in for that loops the same iterator # Bug report ### Bug description: --- EDIT smaller reproducer: ```python parts = iter([...] * 3) # odd number of elements for part in parts: next(parts, ...) ``` --- Hello, when we try to build Flask in Fedora with Python 3.13.0a4, we see a SIGSEGV. With @befeleme we've been able to isolate the failure to the following: ```python # reporducer.py import flask app = flask.Flask("flask_test") app.config.update(TESTING=True) @app.route("/") def index(): return "x" with app.app_context(): app.test_client().get("/") ``` ``` $ sudo dnf --enablerepo=updates-testing install python3.13-debug $ sudo dnf --enablerepo=updates-testing debuginfo-install python3.13 $ python3.13d --version Python 3.13.0a4 $ python3.13d -m venv venv3.13d $ . venv3.13d/bin/activate (venv3.13d)$ pip install flask ... (venv3.13d)$ pip list Package Version ------------ ------- blinker 1.7.0 click 8.1.7 Flask 3.0.2 itsdangerous 2.1.2 Jinja2 3.1.3 MarkupSafe 2.1.5 pip 23.2.1 Werkzeug 3.0.1 (venv3.13d)$ rm venv3.13d/lib64/python3.13/site-packages/markupsafe/_speedups.cpython-313-x86_64-linux-gnu.so # to eliminate possibility of SIGSEGV in markupsafe (venv3.13d)$ python -X dev reproducer.py Fatal Python error: Segmentation fault Current thread 0x00007f9445ba8740 (most recent call first): File "/tmp/venv3.13d/lib64/python3.13/site-packages/werkzeug/urls.py", line 40 in _unquote_partial File "/tmp/venv3.13d/lib64/python3.13/site-packages/werkzeug/urls.py", line 85 in uri_to_iri File "/tmp/venv3.13d/lib64/python3.13/site-packages/werkzeug/sansio/utils.py", line 137 in get_current_url File "/tmp/venv3.13d/lib64/python3.13/site-packages/werkzeug/wsgi.py", line 66 in get_current_url File "/tmp/venv3.13d/lib64/python3.13/site-packages/werkzeug/test.py", line 944 in _add_cookies_to_wsgi File "/tmp/venv3.13d/lib64/python3.13/site-packages/werkzeug/test.py", line 985 in run_wsgi_app File "/tmp/venv3.13d/lib64/python3.13/site-packages/werkzeug/test.py", line 1114 in open File "/tmp/venv3.13d/lib64/python3.13/site-packages/flask/testing.py", line 235 in open File "/tmp/venv3.13d/lib64/python3.13/site-packages/werkzeug/test.py", line 1160 in get File "/tmp/reproducer.py", line 10 in <module> Segmentation fault (core dumped) ``` Here's a bt from gdb: ``` (gdb) bt #0 0x00007ffff7af344f in Py_TYPE (ob=0x0) at /usr/src/debug/python3.13-3.13.0~a4-1.fc39.x86_64/Include/object.h:333 #1 0x00007ffff7af3f7c in PyList_GET_SIZE (op=0x0) at /usr/src/debug/python3.13-3.13.0~a4-1.fc39.x86_64/Include/cpython/listobject.h:31 #2 0x00007ffff7b04e26 in _PyEval_EvalFrameDefault (tstate=0x7ffff7f2a8b8 <_PyRuntime+247704>, frame=0x7ffff7fb8620, throwflag=0) at /usr/src/debug/python3.13-3.13.0~a4-1.fc39.x86_64/Python/generated_cases.c.h:2544 #3 0x00007ffff7af53d3 in _PyEval_EvalFrame (tstate=0x7ffff7f2a8b8 <_PyRuntime+247704>, frame=0x7ffff7fb8120, throwflag=0) at /usr/src/debug/python3.13-3.13.0~a4-1.fc39.x86_64/Include/internal/pycore_ceval.h:115 #4 0x00007ffff7b25677 in _PyEval_Vector (tstate=0x7ffff7f2a8b8 <_PyRuntime+247704>, func=0x7fffe8570b90, locals=0x0, args=0x7fffe88d8fd0, argcount=2, kwnames=('method',)) at /usr/src/debug/python3.13-3.13.0~a4-1.fc39.x86_64/Python/ceval.c:1788 #5 0x00007ffff796cfe2 in _PyFunction_Vectorcall (func=<function at remote 0x7fffe8570b90>, stack=0x7fffe88d8fd0, nargsf=2, kwnames=('method',)) at /usr/src/debug/python3.13-3.13.0~a4-1.fc39.x86_64/Objects/call.c:413 #6 0x00007ffff7970daa in _PyObject_VectorcallTstate (tstate=0x7ffff7f2a8b8 <_PyRuntime+247704>, callable=<function at remote 0x7fffe8570b90>, args=0x7fffe88d8fd0, nargsf=2, kwnames=('method',)) at /usr/src/debug/python3.13-3.13.0~a4-1.fc39.x86_64/Include/internal/pycore_call.h:168 #7 0x00007ffff79714d6 in method_vectorcall (method=<method at remote 0x7fffe8dc0c50>, args=0x7fffe88d8fd8, nargsf=9223372036854775809, kwnames=('method',)) at /usr/src/debug/python3.13-3.13.0~a4-1.fc39.x86_64/Objects/classobject.c:62 #8 0x00007ffff796ca02 in _PyVectorcall_Call (tstate=0x7ffff7f2a8b8 <_PyRuntime+247704>, func=0x7ffff7971329 <method_vectorcall>, callable=<method at remote 0x7fffe8dc0c50>, tuple=('/',), kwargs={'method': 'GET'}) at /usr/src/debug/python3.13-3.13.0~a4-1.fc39.x86_64/Objects/call.c:285 #9 0x00007ffff796cd00 in _PyObject_Call (tstate=0x7ffff7f2a8b8 <_PyRuntime+247704>, callable=<method at remote 0x7fffe8dc0c50>, args=('/',), kwargs={'method': 'GET'}) at /usr/src/debug/python3.13-3.13.0~a4-1.fc39.x86_64/Objects/call.c:348 #10 0x00007ffff796cddb in PyObject_Call (callable=<method at remote 0x7fffe8dc0c50>, args=('/',), kwargs={'method': 'GET'}) at /usr/src/debug/python3.13-3.13.0~a4-1.fc39.x86_64/Objects/call.c:373 #11 0x00007ffff7afdbbf in _PyEval_EvalFrameDefault (tstate=0x7ffff7f2a8b8 <_PyRuntime+247704>, frame=0x7ffff7fb8098, throwflag=0) at /usr/src/debug/python3.13-3.13.0~a4-1.fc39.x86_64/Python/generated_cases.c.h:1250 #12 0x00007ffff7af53d3 in _PyEval_EvalFrame (tstate=0x7ffff7f2a8b8 <_PyRuntime+247704>, frame=0x7ffff7fb8020, throwflag=0) at /usr/src/debug/python3.13-3.13.0~a4-1.fc39.x86_64/Include/internal/pycore_ceval.h:115 #13 0x00007ffff7b25677 in _PyEval_Vector (tstate=0x7ffff7f2a8b8 <_PyRuntime+247704>, func=0x7fffe9d4dcd0, locals={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/tmp/reproducer.py') at remote 0x7fffe9d60e20>, '__spec__': None, '__annotations__': {}, '__builtins__': <module at remote 0x7ffff74e3830>, '__file__': '/tmp/reproducer.py', '__cached__': None, 'flask': <module at remote 0x7fffe9dcc290>, 'app': <Flask(import_name='flask_test', _static_folder='static', _static_url_path=None, template_folder='templates', root_path='/tmp', cli=<AppGroup(name='flask_test', context_settings={}, callback=None, params=[], help=None, epilog=None, options_metavar='[OPTIONS]', short_help=None, add_help_option=True, no_args_is_help=True, hidden=False, deprecated=False, invoke_without_command=False, subcommand_metavar='COMMAND [ARGS]...', chain=False, _result_callback=None, commands={}) at remote 0x7fffe8709eb0>, view_functions={'static': <function at remote 0x7fffe8adb1d0>, 'index': <function at remote 0x7fffe87559d0>}, err...(truncated), args=0x0, argcount=0, kwnames=0x0) at /usr/src/debug/python3.13-3.13.0~a4-1.fc39.x86_64/Python/ceval.c:1788 #14 0x00007ffff7af6edd in PyEval_EvalCode (co=<code at remote 0x5555555ece50>, globals={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/tmp/reproducer.py') at remote 0x7fffe9d60e20>, '__spec__': None, '__annotations__': {}, '__builtins__': <module at remote 0x7ffff74e3830>, '__file__': '/tmp/reproducer.py', '__cached__': None, 'flask': <module at remote 0x7fffe9dcc290>, 'app': <Flask(import_name='flask_test', _static_folder='static', _static_url_path=None, template_folder='templates', root_path='/tmp', cli=<AppGroup(name='flask_test', context_settings={}, callback=None, params=[], help=None, epilog=None, options_metavar='[OPTIONS]', short_help=None, add_help_option=True, no_args_is_help=True, hidden=False, deprecated=False, invoke_without_command=False, subcommand_metavar='COMMAND [ARGS]...', chain=False, _result_callback=None, commands={}) at remote 0x7fffe8709eb0>, view_functions={'static': <function at remote 0x7fffe8adb1d0>, 'index': <function at remote 0x7fffe87559d0>}, err...(truncated), locals={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/tmp/reproducer.py') at remote 0x7fffe9d60e20>, '__spec__': None, '__annotations__': {}, '__builtins__': <module at remote 0x7ffff74e3830>, '__file__': '/tmp/reproducer.py', '__cached__': None, 'flask': <module at remote 0x7fffe9dcc290>, 'app': <Flask(import_name='flask_test', _static_folder='static', _static_url_path=None, template_folder='templates', root_path='/tmp', cli=<AppGroup(name='flask_test', context_settings={}, callback=None, params=[], help=None, epilog=None, options_metavar='[OPTIONS]', short_help=None, add_help_option=True, no_args_is_help=True, hidden=False, deprecated=False, invoke_without_command=False, subcommand_metavar='COMMAND [ARGS]...', chain=False, _result_callback=None, commands={}) at remote 0x7fffe8709eb0>, view_functions={'static': <function at remote 0x7fffe8adb1d0>, 'index': <function at remote 0x7fffe87559d0>}, err...(truncated)) at /usr/src/debug/python3.13-3.13.0~a4-1.fc39.x86_64/Python/ceval.c:592 #15 0x00007ffff7bcd505 in run_eval_code_obj (tstate=0x7ffff7f2a8b8 <_PyRuntime+247704>, co=0x5555555ece50, globals={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/tmp/reproducer.py') at remote 0x7fffe9d60e20>, '__spec__': None, '__annotations__': {}, '__builtins__': <module at remote 0x7ffff74e3830>, '__file__': '/tmp/reproducer.py', '__cached__': None, 'flask': <module at remote 0x7fffe9dcc290>, 'app': <Flask(import_name='flask_test', _static_folder='static', _static_url_path=None, template_folder='templates', root_path='/tmp', cli=<AppGroup(name='flask_test', context_settings={}, callback=None, params=[], help=None, epilog=None, options_metavar='[OPTIONS]', short_help=None, add_help_option=True, no_args_is_help=True, hidden=False, deprecated=False, invoke_without_command=False, subcommand_metavar='COMMAND [ARGS]...', chain=False, _result_callback=None, commands={}) at remote 0x7fffe8709eb0>, view_functions={'static': <function at remote 0x7fffe8adb1d0>, 'index': <function at remote 0x7fffe87559d0>}, err...(truncated), locals={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/tmp/reproducer.py') at remote 0x7fffe9d60e20>, '__spec__': None, '__annotations__': {}, '__builtins__': <module at remote 0x7ffff74e3830>, '__file__': '/tmp/reproducer.py', '__cached__': None, 'flask': <module at remote 0x7fffe9dcc290>, 'app': <Flask(import_name='flask_test', _static_folder='static', _static_url_path=None, template_folder='templates', root_path='/tmp', cli=<AppGroup(name='flask_test', context_settings={}, callback=None, params=[], help=None, epilog=None, options_metavar='[OPTIONS]', short_help=None, add_help_option=True, no_args_is_help=True, hidden=False, deprecated=False, invoke_without_command=False, subcommand_metavar='COMMAND [ARGS]...', chain=False, _result_callback=None, commands={}) at remote 0x7fffe8709eb0>, view_functions={'static': <function at remote 0x7fffe8adb1d0>, 'index': <function at remote 0x7fffe87559d0>}, err...(truncated)) at /usr/src/debug/python3.13-3.13.0~a4-1.fc39.x86_64/Python/pythonrun.c:1294 #16 0x00007ffff7bcd8d5 in run_mod (mod=0x55555561ffd0, filename='/tmp/reproducer.py', globals={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/tmp/reproducer.py') at remote 0x7fffe9d60e20>, '__spec__': None, '__annotations__': {}, '__builtins__': <module at remote 0x7ffff74e3830>, '__file__': '/tmp/reproducer.py', '__cached__': None, 'flask': <module at remote 0x7fffe9dcc290>, 'app': <Flask(import_name='flask_test', _static_folder='static', _static_url_path=None, template_folder='templates', root_path='/tmp', cli=<AppGroup(name='flask_test', context_settings={}, callback=None, params=[], help=None, epilog=None, options_metavar='[OPTIONS]', short_help=None, add_help_option=True, no_args_is_help=True, hidden=False, deprecated=False, invoke_without_command=False, subcommand_metavar='COMMAND [ARGS]...', chain=False, _result_callback=None, commands={}) at remote 0x7fffe8709eb0>, view_functions={'static': <function at remote 0x7fffe8adb1d0>, 'index': <function at remote 0x7fffe87559d0>}, err...(truncated), locals={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/tmp/reproducer.py') at remote 0x7fffe9d60e20>, '__spec__': None, '__annotations__': {}, '__builtins__': <module at remote 0x7ffff74e3830>, '__file__': '/tmp/reproducer.py', '__cached__': None, 'flask': <module at remote 0x7fffe9dcc290>, 'app': <Flask(import_name='flask_test', _static_folder='static', _static_url_path=None, template_folder='templates', root_path='/tmp', cli=<AppGroup(name='flask_test', context_settings={}, callback=None, params=[], help=None, epilog=None, options_metavar='[OPTIONS]', short_help=None, add_help_option=True, no_args_is_help=True, hidden=False, deprecated=False, invoke_without_command=False, subcommand_metavar='COMMAND [ARGS]...', chain=False, _result_callback=None, commands={}) at remote 0x7fffe8709eb0>, view_functions={'static': <function at remote 0x7fffe8adb1d0>, 'index': <function at remote 0x7fffe87559d0>}, err...(truncated), flags=0x7fffffffd318, arena=0x7fffe9daf700, interactive_src=0x0, generate_new_source=0) at /usr/src/debug/python3.13-3.13.0~a4-1.fc39.x86_64/Python/pythonrun.c:1379 #17 0x00007ffff7bcd2e2 in pyrun_file (fp=0x5555555851b0, filename='/tmp/reproducer.py', start=257, globals={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/tmp/reproducer.py') at remote 0x7fffe9d60e20>, '__spec__': None, '__annotations__': {}, '__builtins__': <module at remote 0x7ffff74e3830>, '__file__': '/tmp/reproducer.py', '__cached__': None, 'flask': <module at remote 0x7fffe9dcc290>, 'app': <Flask(import_name='flask_test', _static_folder='static', _static_url_path=None, template_folder='templates', root_path='/tmp', cli=<AppGroup(name='flask_test', context_settings={}, callback=None, params=[], help=None, epilog=None, options_metavar='[OPTIONS]', short_help=None, add_help_option=True, no_args_is_help=True, hidden=False, deprecated=False, invoke_without_command=False, subcommand_metavar='COMMAND [ARGS]...', chain=False, _result_callback=None, commands={}) at remote 0x7fffe8709eb0>, view_functions={'static': <function at remote 0x7fffe8adb1d0>, 'index': <function at remote 0x7fffe87559d0>}, err...(truncated), locals={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/tmp/reproducer.py') at remote 0x7fffe9d60e20>, '__spec__': None, '__annotations__': {}, '__builtins__': <module at remote 0x7ffff74e3830>, '__file__': '/tmp/reproducer.py', '__cached__': None, 'flask': <module at remote 0x7fffe9dcc290>, 'app': <Flask(import_name='flask_test', _static_folder='static', _static_url_path=None, template_folder='templates', root_path='/tmp', cli=<AppGroup(name='flask_test', context_settings={}, callback=None, params=[], help=None, epilog=None, options_metavar='[OPTIONS]', short_help=None, add_help_option=True, no_args_is_help=True, hidden=False, deprecated=False, invoke_without_command=False, subcommand_metavar='COMMAND [ARGS]...', chain=False, _result_callback=None, commands={}) at remote 0x7fffe8709eb0>, view_functions={'static': <function at remote 0x7fffe8adb1d0>, 'index': <function at remote 0x7fffe87559d0>}, err...(truncated), closeit=1, flags=0x7fffffffd318) at /usr/src/debug/python3.13-3.13.0~a4-1.fc39.x86_64/Python/pythonrun.c:1215 #18 0x00007ffff7bcb69d in _PyRun_SimpleFileObject (fp=0x5555555851b0, filename='/tmp/reproducer.py', closeit=1, flags=0x7fffffffd318) at /usr/src/debug/python3.13-3.13.0~a4-1.fc39.x86_64/Python/pythonrun.c:464 #19 0x00007ffff7bcaa1c in _PyRun_AnyFileObject (fp=0x5555555851b0, filename='/tmp/reproducer.py', closeit=1, flags=0x7fffffffd318) at /usr/src/debug/python3.13-3.13.0~a4-1.fc39.x86_64/Python/pythonrun.c:77 #20 0x00007ffff7c033cb in pymain_run_file_obj (program_name='/tmp/venv3.13d/bin/python', filename='/tmp/reproducer.py', skip_source_first_line=0) at /usr/src/debug/python3.13-3.13.0~a4-1.fc39.x86_64/Modules/main.c:357 #21 0x00007ffff7c034a5 in pymain_run_file (config=0x7ffff7f05838 <_PyRuntime+96024>) at /usr/src/debug/python3.13-3.13.0~a4-1.fc39.x86_64/Modules/main.c:376 #22 0x00007ffff7c03d17 in pymain_run_python (exitcode=0x7fffffffd4b4) at /usr/src/debug/python3.13-3.13.0~a4-1.fc39.x86_64/Modules/main.c:628 #23 0x00007ffff7c03e5c in Py_RunMain () at /usr/src/debug/python3.13-3.13.0~a4-1.fc39.x86_64/Modules/main.c:707 #24 0x00007ffff7c03f32 in pymain_main (args=0x7fffffffd530) at /usr/src/debug/python3.13-3.13.0~a4-1.fc39.x86_64/Modules/main.c:737 #25 0x00007ffff7c03ffa in Py_BytesMain (argc=4, argv=0x7fffffffd6a8) at /usr/src/debug/python3.13-3.13.0~a4-1.fc39.x86_64/Modules/main.c:761 #26 0x000055555555517d in main (argc=4, argv=0x7fffffffd6a8) at /usr/src/debug/python3.13-3.13.0~a4-1.fc39.x86_64/Programs/python.c:15 ``` ### CPython versions tested on: 3.13 ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-115740 <!-- /gh-linked-prs -->
520403ed4cdf4890d63403c9cf01ac63233f5ef4
494739e1f71f8e290a2c869d4f40f4ea36a045c2
python/cpython
python__cpython-115726
# Show number of leaks in --huntrleaks # Feature or enhancement Currently, `-R` (`--huntrleaks`) only displays the reference counts when the test fails. It also uses a [generous heuristic](https://github.com/python/cpython/issues/74959), which avoid false positives, but might hide issues. To get more insight into what's going on, I propose to show the number of leaks instead of the *dot*, with - `.` instead of `0`, so leaks stand out - `X` instead of 10 or more, to keep the display as a single digit Additionally, I'd like to separate warmup runs, so you know when to start worrying. The output would look like this: ``` beginning 9 repetitions. Showing number of leaks (. for zero, X for 10 or more) 12345:6789 XX.1. .... ``` meaning the first 2 warmups “leaked” a lot, then one more had a single “leak”, and there were no more leaks. <!-- gh-linked-prs --> ### Linked PRs * gh-115726 <!-- /gh-linked-prs -->
af5f9d682c20c951b90e3c020eeccac386c9bbb0
6087315926fb185847a52559af063cc7d337d978
python/cpython
python__cpython-115757
# On WASI, time.process_time is not in seconds In a fresh WASI build, `time.process_time`, which should be in seconds, counts 10⁶ times faster than `time.time`: ``` >>> import time >>> time.time(); time.process_time() 1708435312.596558 4775079350.12 >>> time.time(); time.process_time() 1708435313.0949461 4780063256.54 >>> time.get_clock_info('process_time') namespace(implementation='clock_gettime(CLOCK_PROCESS_CPUTIME_ID)', monotonic=True, adjustable=False, resolution=1e-09) ``` It looks like [WASI might remove `CLOCK_PROCESS_CPUTIME_ID`](https://github.com/WebAssembly/wasi-libc/issues/266). Should we wait for that? Remove it from Python sooner? Work around the issue? (Codespaces has an “unexpected error” for me right now, so I built the container from `.devcontainer/Dockerfile` directly. Hope that doesn't affect the result.) <!-- gh-linked-prs --> ### Linked PRs * gh-115757 <!-- /gh-linked-prs -->
8aa372edcd857d2fbec8da0cb993de15b4179308
baae73d7307214ee97abbe80aaa8c1c773a6f682
python/cpython
python__cpython-115721
# CSV dialect with delimiter=' ' and skipinitialspace=True # Bug report Combination of `delimiter=' '` and `skipinitialspace=True` was considered illegal in #113796, because it is ambiguous in case of empty fields. But there may be a use case for this, when the input is a preformatted table with a series of spaces considered as a delimiter: ``` apples red 100 bananas yellow 3 ``` Empty fields are not compatible with such format, so the writer should either quote them, or fail if quoting is not possible. <!-- gh-linked-prs --> ### Linked PRs * gh-115721 * gh-115729 * gh-115738 <!-- /gh-linked-prs -->
937d2821501de7adaa5ed8491eef4b7f3dc0940a
cc82e33af978df793b83cefe4e25e07223a3a09e
python/cpython
python__cpython-118639
# Type propagation does not account for the setting local variables via `frame.f_locals` in a debugger or similar. # Bug report ### Bug description: Consider ```Py def testfunc(loops): for _ in range(loops): a = 1 a + a a + a change_a() a + a ``` and suppose that `change_a` manages to change the value of the local `a` to `"a"`. Specialization will have converted the subsequent `a + a` to integer addition, and type propagation will have stripped the guard, resulting in a crash. This is incredibly unlikely, and very hard to come up with a test for but it is theoretically possible. It may be become more likely (and easier to test for) if PEP 667 is accepted. <!-- gh-linked-prs --> ### Linked PRs * gh-118639 <!-- /gh-linked-prs -->
616b745b89a52a1d27123107718f85e65918afdc
00d913c6718aa365027c6dcf850e8f40731e54fc
python/cpython
python__cpython-115708
# `PCbuild\build.bat` script cannot generate `Python\generated_cases.c.h` files and so on # Bug report ### Bug description: When I ran the script `PCbuild/build.bat` with and without the `--regen` argument, it could not regenerate `Python\generated_cases.c.h` file. I found the files in `Tools\cases_generateor` changed. Is it the reason why the script fail? ### CPython versions tested on: CPython main branch ### Operating systems tested on: Windows <!-- gh-linked-prs --> ### Linked PRs * gh-115708 <!-- /gh-linked-prs -->
a2bb8ad14409c7ecb8dea437b0e281eb1f65b5d8
626c414995bad1dab51c7222a6f7bf388255eb9e
python/cpython
python__cpython-115693
# Increase coverage of `json` module I'll open a PR to increase some test coverage, following https://devguide.python.org/testing/coverage/ For my own reference, here's a one-liner to run tests and generate HTML coverage report: `python -m coverage run --pylib --branch --source=json Lib/test/regrtest.py test_json -v && python -m coverage html -i --include="Lib/*" --omit="Lib/test/*,Lib/*/tests/*"` <!-- gh-linked-prs --> ### Linked PRs * gh-115693 * gh-117867 <!-- /gh-linked-prs -->
8fc953f606cae5545a4d766dc3031316646b014a
9c93b7402ba11d1d68e856516e56ca72989a7db9
python/cpython
python__cpython-115688
# Type/value propagate through COMPARE_OP - [x] Split up into uops - [x] Propagate bool value and constants too. <!-- gh-linked-prs --> ### Linked PRs * gh-115688 * gh-116360 <!-- /gh-linked-prs -->
dcba21f905ef170b2cd0a6433b6fe6bcb4316a67
a2bb8ad14409c7ecb8dea437b0e281eb1f65b5d8
python/cpython
python__cpython-115686
# Type/value propagation for `TO_BOOL` * [x] Normal _TO_BOOL specializations and friends. * [x] TO_BOOL_ALWAYS_TRUE (only if it's worth it?) <!-- gh-linked-prs --> ### Linked PRs * gh-115686 * gh-116311 * gh-116352 <!-- /gh-linked-prs -->
d01886c5c9e3a62921b304ba7e5145daaa56d3cf
c04a981ff414b101736688773dbe24f824ca32ce
python/cpython
python__cpython-116519
# datetime.date.replace() description not clear enough # Documentation In documentation explanation to command date.replace() is not clear enough. I'm not that experienced, so it's maybe look from junior perspective, but since documentation quite needed for beginers i think my opinion might be valuable. In documentation description to this function says "Return a date with the same value, except for those parameters given new values by whichever keyword arguments are specified." and gives an examle: ```python --- from datetime import date --- d = date(2002, 12, 31) --- d.replace(day=26) datetime.date(2002, 12, 26) ``` But it confused me, since it looks like you can change datetime object and as documentation says - datetime objects are immutable, so i had to check and of course you can't change variable like that, the only way that works if you create a new variable (for example: d2 = d.replace(day=26)) So i propose to make this part that there won't be any confusion for anyone by rephrasing it. For example: Return a new date object with the same value as initial, except for those parameters given new values by whichever keyword arguments are specified. ```python --- from datetime import date --- d = date(2002, 12, 31) --- d2 = d.replace(day=26) --- d2 datetime.date(2002, 12, 26) ``` I haven't seen any tickets issued about this one, but i apologise if there is and i've missed it, or if i miss something in documentation itself. <!-- gh-linked-prs --> ### Linked PRs * gh-116519 * gh-131676 * gh-131683 * gh-131694 <!-- /gh-linked-prs -->
d2d886215cf694d5f3e7f0cbd76507a96bac322b
d716ea34cb8a105e8e39a1ddfd610c3c0f11a0e7
python/cpython
python__cpython-115665
# Fix the use of versionadded and versionchanged directives While reviewing the PR for #115652 I noticed other errors in multiprocessing.rst: incorrect order of `versionchanged` directives, using `versionadded` instead of `versionchanged`, misusing the term "argument" instead of "parameter". Then I tried to search similar errors in other files, and found tens possible candidates. So I opened an issue to fix all these errors. `versionadded` indicates when the entity (module, class, function, method, attribute, etc) was added. It should be aligned with the description of the entity. `versionchanged` indicates when the behavior of the entity was changed, including adding or removal of parameters or support of protocols. When a new parameter is added to the function or when the class starts supporting the context manager protocol, `versionchanged` should be used. If a new attribute or method was added, but they do not have their own entry, `versionchanged` can be used, applied to the parent class. <!-- gh-linked-prs --> ### Linked PRs * gh-115665 * gh-115676 * gh-115677 * gh-115678 * gh-115681 * gh-115682 * gh-116298 * gh-116304 * gh-116450 * gh-116452 * gh-116456 * gh-117900 <!-- /gh-linked-prs -->
8f602981ba95273f036968cfc5ac28fdcd1808fa
b02ab65e8083185b76a7dd06f470b779580a3b03
python/cpython
python__cpython-115790
# Tools/build/generate_sbom.py fails if `expat` and `_decimal/libmpdec/**` are configured to come from the system # Bug report ### Bug description: I try to build Python 3.13.0a4 for Fedora Linux, but unsuccessfully. `expat` and `_decimal/libmpdec` are removed from our version of Python. We configure it with the options `--with-system-expat` and `--with-system-libmpdec`. The traceback: ```pytb $ python3.13 /builddir/build/BUILD/Python-3.13.0a4/Tools/build/generate_sbom.py fatal: no path specified Traceback (most recent call last): File "/builddir/build/BUILD/Python-3.13.0a4/Tools/build/generate_sbom.py", line 228, in <module> main() ~~~~^^ File "/builddir/build/BUILD/Python-3.13.0a4/Tools/build/generate_sbom.py", line 190, in main paths = filter_gitignored_paths(paths) ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^ File "/builddir/build/BUILD/Python-3.13.0a4/Tools/build/generate_sbom.py", line 121, in filter_gitignored_paths assert git_check_ignore_proc.returncode in (0, 1) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AssertionError make: *** [Makefile:2885: regen-sbom] Error 1 ``` `paths` for the removed Modules resolves to an empty list, this is passed to the subprocess invoking git which ends with return code 128, hence assertion error visible above. generate_sbom, if really has to be a part of `regen all`, should not require the presence of those libraries if Python is configured without them. ### CPython versions tested on: 3.13 ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-115790 * gh-115820 <!-- /gh-linked-prs -->
c6a47de70966e6899871245e800a0a9271e25b12
96c1737591b45bc1c528df1103eb0e500751fefe
python/cpython
python__cpython-115654
# Missing documentation for public C-API function # Documentation There are no documentation for the ```PyCode_GetFirstFree``` and incorrect return type for ```PyCode_GetNumFree``` <!-- gh-linked-prs --> ### Linked PRs * gh-115654 * gh-115752 <!-- /gh-linked-prs -->
10fc4675fdb14e19f2fdd15102c6533b9f71e992
77430b6a329bb04ca884d08afefda25112372afa
python/cpython
python__cpython-115658
# Indentation in the documentation of multiprocessing.get_start_method # Documentation There is a problem with the indentation in the documentation of [`multiprocessing.get_start_method`](https://docs.python.org/3/library/multiprocessing.html#multiprocessing.get_start_method). "Changed in version 3.8: [...]" and "New in version 3.4." should be indented. <!-- gh-linked-prs --> ### Linked PRs * gh-115658 * gh-115659 * gh-115660 <!-- /gh-linked-prs -->
d504968983c5cd5ddbdf73ccd3693ffb89e7952f
aa8c1a0d1626b5965c2f3a1d5af15acbb110eac1
python/cpython
python__cpython-115711
# Convert `LOAD_ATTR_MODULE` to a constant where the module is already a constant Expressions like `mod.attr`, where `mod` is a module, are in almost all cases effectively constants. We should optimize them as such. We already treat the `mod` as a constant, so it is a relatively simple step to treat `mod.attr` as a constant. <!-- gh-linked-prs --> ### Linked PRs * gh-115711 <!-- /gh-linked-prs -->
b348313e7a48811acacc293ac4b2c8b20b4c631b
c6a47de70966e6899871245e800a0a9271e25b12
python/cpython
python__cpython-115628
# `PySSL_SetError` needs to be updated # Bug report ### Bug description: It was dealt with other issues before, but the contents are not intuitive, so I rearrange them. The `SSL_write()` and `SSL_read()` used in python 3.9 were modified from python 3.10 to `SSL_write_ex()` and `SSL_read_ex()`, and the return value was fixed to 0 on error. However, in `PySSL_SetError`, there is no update accordingly, so this part needs to be modified. Related issue can be referred to the following link. [OpenSSL 1.1.1: use SSL_write_ex() and SSL_read_ex()](https://github.com/python/cpython/issues/87020) The difference between `SSL_write()` and `SSL_write_ex()` is as follows. ```c int SSL_write(SSL *s, const void *buf, int num) { int ret; size_t written; if (num < 0) { ERR_raise(ERR_LIB_SSL, SSL_R_BAD_LENGTH); return -1; } ret = ssl_write_internal(s, buf, (size_t)num, 0, &written); /* * The cast is safe here because ret should be <= INT_MAX because num is * <= INT_MAX */ if (ret > 0) ret = (int)written; return ret; } ``` `SSL_write()` has a return value of 0 or less when an error occurs. ```c int SSL_write_ex(SSL *s, const void *buf, size_t num, size_t *written) { return SSL_write_ex2(s, buf, num, 0, written); } int SSL_write_ex2(SSL *s, const void *buf, size_t num, uint64_t flags, size_t *written) { int ret = ssl_write_internal(s, buf, num, flags, written); if (ret < 0) ret = 0; return ret; } ``` `SSL_write_ex()` is fixed to 0 when an error occurs. As the return value changes, the behavior of the `PySSL_SetError` function changes. https://github.com/python/cpython/blob/f9154f8f237e31e7c30f8698f980bee5e494f1e0/Modules/_ssl.c#L648 ```c case SSL_ERROR_SYSCALL: { if (e == 0) { PySocketSockObject *s = GET_SOCKET(sslsock); if (ret == 0 || (((PyObject *)s) == Py_None)) { p = PY_SSL_ERROR_EOF; type = state->PySSLEOFErrorObject; errstr = "EOF occurred in violation of protocol"; } else if (s && ret == -1) { /* underlying BIO reported an I/O error */ ERR_clear_error(); #ifdef MS_WINDOWS if (err.ws) { return PyErr_SetFromWindowsErr(err.ws); } #endif if (err.c) { errno = err.c; return PyErr_SetFromErrno(PyExc_OSError); } else { p = PY_SSL_ERROR_EOF; type = state->PySSLEOFErrorObject; errstr = "EOF occurred in violation of protocol"; } } else { /* possible? */ p = PY_SSL_ERROR_SYSCALL; type = state->PySSLSyscallErrorObject; errstr = "Some I/O error occurred"; } } else { if (ERR_GET_LIB(e) == ERR_LIB_SSL && ERR_GET_REASON(e) == SSL_R_CERTIFICATE_VERIFY_FAILED) { type = state->PySSLCertVerificationErrorObject; } p = PY_SSL_ERROR_SYSCALL; } break; } ``` According to the part `if (ret == 0 || ((PyObject *) == Py_None))`, the retrun of the function `SSL_write_ex()` is fixed to 0, resulting in `SSLEOFError` instead of `OSError`. I determined that the change to this error was not intended. If the connection is terminated by the other peer, it is better for the user to respond to it by returning it as an error such as BrokenPIPE rather than an error that is a protocol rule violation. The modifications affected by the change have been identified as follows. https://github.com/python/cpython/pull/25553 - The behavior of the SSL test server for OSError has changed. ConnectionError did not previously shut down the server, but now it does. - I think this is because the change has not been tested as OSError does not occur at write or read. https://github.com/python/cpython/pull/25574 - It is believed that an intermittent EOF error occurred instead of an OSError. https://github.com/python/cpython/pull/26520 - OSError has disappeared, only EOF errors have been handled. Related issues are as follows. https://github.com/python/cpython/issues/110467 https://github.com/urllib3/urllib3/issues/2733 ### CPython versions tested on: 3.10, 3.11, 3.12, 3.13, CPython main branch ### Operating systems tested on: Linux, macOS <!-- gh-linked-prs --> ### Linked PRs * gh-115628 * gh-117821 <!-- /gh-linked-prs -->
ea9a296fce2f786b4cf43c7924e5de01061f27ca
d52bdfb19fadd7614a0e5abaf68525fc7300e841
python/cpython
python__cpython-115619
# Incorrect Py_XDECREFs in property # Crash report When `property` methods `getter()`, `setter()` or `deleter()` are called with None as argument, they call `Py_XDECREF()` on it. Now, when None is immortal, it perhaps have no effect, but in earlier Python versions it could have bad consequences. It was not reported earlier only because nobody normally calls them with None. <!-- gh-linked-prs --> ### Linked PRs * gh-115619 * gh-115620 * gh-115621 <!-- /gh-linked-prs -->
090dd21ab9379d6a2a6923d6cbab697355fb7165
aba37d451fabb44a7f478958ba117ae5b6ea54c0
python/cpython
python__cpython-115610
# test_os permanently change the process priority # Bug report ProgramPriorityTests in test_os changes the process priority (makes it less prioritized in the scheduler) and then tries to restore the old value, why is fail unless the test is ran as root. It affects all further tests if run in sequential mode and all further tests in test_os if run in parallel mode. It can makes the testing process less responsible and make some tests (especially relying on timeouts or interruption) unstable. This test should be run in a separate subprocess. <!-- gh-linked-prs --> ### Linked PRs * gh-115610 * gh-115616 * gh-115617 <!-- /gh-linked-prs -->
90dd653a6122a6c5b4b1fe5abe773c4751e5ca25
437924465de5cb81988d1e580797b07090c26a28
python/cpython
python__cpython-115850
# Python 3.13a4 ships with wrong pyconfig.h? # Bug report ### Bug description: Hello, I tried to build a C-extension locally with python 3.13a4 and got the error `LINK : fatal error LNK1104: cannot open file 'python313t.lib'`. (I got Python 3.13a4 from the python.org installer, tested Windows 32 and 64 bit). After trying to install the free threaded builds using the new installer option, trying to build using those, and then installing everything fresh, I found that in `include/pyconfig.h`, there is a line `#define Py_GIL_DISABLED 1`. This line causes the compiler to look for python313t.lib instead of python313.lib, and commenting it out fixed the build. It seems to me that the non-freethreaded build is shipping out with the wrong pyconfig.h setup. This was reported by Pillow here: https://github.com/python-pillow/Pillow/pull/7805 They linked it to https://github.com/python/cpython/issues/115545, but I think that may be a different issue? The interpreters launch fine from the python.org install, they just don't seem to work for building C-extensions with. Thank you. ### CPython versions tested on: 3.13 ### Operating systems tested on: Windows <!-- gh-linked-prs --> ### Linked PRs * gh-115850 <!-- /gh-linked-prs -->
37a13b941394a1337576c67bff35d4a44a1157e2
72cff8d8e5a476d3406efb0491452bf9d6b02feb
python/cpython
python__cpython-117632
# URI Netloc deprecated; replaced by Authority # Documentation cpython has several references to "netloc" (primarily in the [Lib](https://github.com/python/cpython/tree/3.12/Lib) and [urllib](https://github.com/python/cpython/tree/3.12/Lib/urllib) libraries). This term describes the network location and login information in a URI (Uniform Resource Indicator) as seen in [RFC 1808](https://www.rfc-editor.org/rfc/rfc1808), but has been outdated since 1998 and 2005 with the publishing of [RFC 2396](https://www.rfc-editor.org/rfc/rfc2396) and [RFC 3986](https://www.rfc-editor.org/rfc/rfc3986) which is the Internet Standard. The correct term for this URI component is "authority." This excerpt from RFC 3986 shows the components of the URI: ``` The following are two example URIs and their component parts: foo://example.com:8042/over/there?name=ferret#nose \_/ \______________/\_________/ \_________/ \__/ | | | | | scheme authority path query fragment | _____________________|__ / \ / \ urn:example:animal:ferret:nose ``` This update would require renaming all references of "netloc" and "net_loc" to "authority" or some abbreviation (E.g. "auth"). Because this would be a breaking change, it perhaps is not a documentation update. However, the other issue types didn't seem to fit. Thanks. <!-- gh-linked-prs --> ### Linked PRs * gh-117632 * gh-118656 <!-- /gh-linked-prs -->
3ed3bc379a0c4ce7a107dd4bc276554fbb477998
7528b84e947f727734bd802356e380673553387d
python/cpython
python__cpython-115631
# ``codeobject.replace`` function is undocumented ### Bug description: ``codeobject.replace`` function was introduced in a9f05d69ccbf3c75cdd604c25094282697789a62, but there's only a note in ``Doc/whatsnew``. My folk @daler-sz would like to work on a fix :) ### CPython versions tested on: 3.11, 3.12, 3.13 ### Operating systems tested on: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-115631 * gh-115632 * gh-115633 <!-- /gh-linked-prs -->
0c80da4c14d904a367968955544dd6ae58c8101c
371c9708863c23ddc716085198ab07fa49968166
python/cpython
python__cpython-115568
# ``test_ctypes`` on Windows prints unnecessary information # Bug report ### Bug description: ```python ./python -m test -R 3:3 test_ctypes Running Debug|x64 interpreter... Using random seed: 212491410 0:00:00 Run 1 test sequentially 0:00:00 [1/1] test_ctypes beginning 6 repetitions 123456 a=5, b=10, c=15 a=5, b=10, c=15 .a=5, b=10, c=15 a=5, b=10, c=15 .a=5, b=10, c=15 a=5, b=10, c=15 .a=5, b=10, c=15 a=5, b=10, c=15 .a=5, b=10, c=15 a=5, b=10, c=15 .a=5, b=10, c=15 a=5, b=10, c=15 . == Tests result: SUCCESS == 1 test OK. Total duration: 24.7 sec Total tests: run=541 skipped=19 Total test files: run=1/1 Result: SUCCESS ``` ### CPython versions tested on: 3.12, CPython main branch ### Operating systems tested on: Windows <!-- gh-linked-prs --> ### Linked PRs * gh-115568 * gh-115609 <!-- /gh-linked-prs -->
265548a4eaaebc3fb379f85f2a919848927f09e5
04005f5021a17b191dae319faaadf1c942af3fe9
python/cpython
python__cpython-115557
# Windows test scripts don't escape commas properly In Windows batch file execution, a comma is one of the magic parameter delimiters. To pass a comma as parameter data, you have to use string quotes around that parameter, like: ``` .\Tools\buildbot\test.bat -M33g "-uall,extralargefile" test_zipfile64 ``` However, now the quotes become part of the parameter. Inside `test.bat` we employ some command-line parsing and shifting, which requires us to *remove* the quotes from parameters, if any, for the code to continue working. This is doubly complicated by the fact that `test.bat` passes execution to `rt.bat`, which does similar parsing there. The fix is needed there, too. <!-- gh-linked-prs --> ### Linked PRs * gh-115557 <!-- /gh-linked-prs -->
711f42de2e3749208cfa7effa0d45b04e4e1fdd4
74e6f4b32fceea8e8ffb0424d9bdc6589faf7ee4
python/cpython
python__cpython-115793
# Python Install Fails Due To Newer Launcher # Bug report ### Bug description: ```python # Add a code block here, if required ``` If you have a Windows machine with multiple versions of python installed the presence of a newer version of the installer can prevent updating the older python version installations. For example installing in the following sequence, (all with `install py launcher` checked _(global or otherwise)_, tested with both 64 & 32 bit versions: 1. Python 3.11.7 _OK_ 2. Python 3.12.1 _OK (Updates Launcher)_ 3. Python 3.11.8 _Select Update or Customise with the py launcher ticked_ Part way through the install a pop-up is shown. ![image](https://github.com/python/cpython/assets/5593690/22856aac-77e0-4f27-86d6-ff8be2973feb) Select `OK` & Installation is wound back. Followed by: ![image](https://github.com/python/cpython/assets/5593690/fedacd03-5200-438b-91bd-065b0d90fc62) The relevant section of the log reads: ```log [D824:8A50][2024-02-16T07:58:01]i325: Registering dependency: {02717f5c-724f-48a7-86c0-ee11d4de681c} on package provider: {8EEE1658-8844-4DAD-8A3B-7AF321C9A4FD}, package: tcltk_JustForMe [D824:8A50][2024-02-16T07:58:01]i301: Applying execute package: launcher_JustForMe, action: Install, path: C:\Users\Gadge\AppData\Local\Package Cache\{8DFCF17F-8C82-4E21-96F1-B1777F61A757}v3.11.8150.0\launcher.msi, arguments: ' MSIFASTINSTALL="7" ADDLOCAL="DefaultFeature,AssociateFiles"' [D824:8A50][2024-02-16T07:59:54]e000: Error 0x80070643: Failed to install MSI package. [D824:8A50][2024-02-16T07:59:54]e000: Error 0x80070643: Failed to configure per-user MSI package. [D824:8A50][2024-02-16T07:59:54]i319: Applied execute package: launcher_JustForMe, result: 0x80070643, restart: None [D824:8A50][2024-02-16T07:59:54]e000: Error 0x80070643: Failed to execute MSI package. [D824:8A50][2024-02-16T07:59:54]i351: Removing cached package: launcher_JustForMe, from path: C:\Users\Gadge\AppData\Local\Package Cache\{8DFCF17F-8C82-4E21-96F1-B1777F61A757}v3.11.8150.0\ [D824:8A50][2024-02-16T07:59:54]i329: Removed package dependency provider: {9E9F28A9-A7A6-4483-842C-07579F9D7FDD}, package: tcltk_JustForMe_d ``` 4. Running `py -0` results in: ``` $ py -0 -V:3.12 Python 3.12 (64-bit) -V:3.10 Python 3.10 (64-bit) -V:3.10-32 Python 3.10 (32-bit) -V:3.9 Python 3.9 (64-bit) ``` So I have now lost my Python 3.11 installation! ***Not very happy at this point!*** 5. Re-running the installer, selecting `Customize Installation` and unticking `py launcher` will allow a successful installation **but**: - Many users may not realise this option will resolve the issue! - In controlled environments *such as at my work* an `unattend.xml` file or install script may prevent the user changing this option. # Possible Resolutions There is more than one way that this issue could be handled. If a newer py launcher is present: - Skip installing py launcher silently or with a message but not an error. Unlikely to actually cause a problem but may invalidate some test environments. - Offer to downgrade py launcher or leave the newer one. - Offer the option to skip py launcher or cancel install _(with warning that old installation may be lost)_. ### CPython versions tested on: 3.9, 3.10, 3.11, 3.12 ### Operating systems tested on: Windows <!-- gh-linked-prs --> ### Linked PRs * gh-115793 * gh-116200 * gh-116201 <!-- /gh-linked-prs -->
9b7f253b55f10df03d43c8a7c2da40ea523ac7a1
59167c962efcae72e8d88aa4b33062ed3de4f120
python/cpython
python__cpython-115544
# py.exe launcher does not detect Windows Store 3.13 package Need to update a few references - quite straightforward, but should be backported. <!-- gh-linked-prs --> ### Linked PRs * gh-115544 * gh-115689 * gh-115690 <!-- /gh-linked-prs -->
6cd18c75a41a74cab69ebef0b7def3e48421bdd1
57d31ec3598429789492e0b3544efaaffca5799f
python/cpython
python__cpython-115636
# enum.Flag with a flag set to None raises an exception # Bug report ### Bug description: The following code snippet defines a `Flag` class denoting an unsupported flag with `None`. ```python from enum import Flag class TestFlag(Flag): O_NONE = 0 O_ONE = 1 O_TWO = 2 O_FOUR = 4 O_NOT_SUPPORTED = None ``` While working fine on earlier Python versions, this code raises an exception on Python 3.11 and 3.12 without even instantiating the class. The snippet above on Python 3.9: ```python Python 3.9.13 (tags/v3.9.13:6de2ca5, May 17 2022, 16:36:42) [MSC v.1929 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> from enum import Flag >>> class TestFlag(Flag): ... O_NONE = 0 ... O_ONE = 1 ... O_TWO = 2 ... O_FOUR = 4 ... O_NOT_SUPPORTED = None ... >>> ``` Same snippet on Python 3.12: ```python Python 3.12.2 (tags/v3.12.2:6abddd9, Feb 6 2024, 21:26:36) [MSC v.1937 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> from enum import Flag >>> class TestFlag(Flag): ... O_NONE = 0 ... O_ONE = 1 ... O_TWO = 2 ... O_FOUR = 4 ... O_NOT_SUPPORTED = None ... Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.752.0_x64__qbz5n2kfra8p0\Lib\enum.py", line 593, in __new__ raise exc.with_traceback(tb) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.752.0_x64__qbz5n2kfra8p0\Lib\enum.py", line 583, in __new__ enum_class = super().__new__(metacls, cls, bases, classdict, **kwds) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.752.0_x64__qbz5n2kfra8p0\Lib\enum.py", line 286, in __set_name__ enum_class._flag_mask_ |= value TypeError: unsupported operand type(s) for |=: 'int' and 'NoneType' >>> ``` Works on: - Python 3.8 (Windows and Linux) - Python 3.9 (Windows and Linux) Fails on: - Python 3.11 (Windows, Linux not tested) - Python 3.12 (Windows and Linux) ### CPython versions tested on: 3.8, 3.9, 3.11, 3.12 ### Operating systems tested on: Linux, Windows <!-- gh-linked-prs --> ### Linked PRs * gh-115636 * gh-115694 * gh-115695 <!-- /gh-linked-prs -->
c2cb31bbe1262213085c425bc853d6587c66cae9
6cd18c75a41a74cab69ebef0b7def3e48421bdd1
python/cpython
python__cpython-116925
# Windows debug main test_os, test_venv failures `python -m test -uall test_os` ``` test test_os failed -- Traceback (most recent call last): File "f:\dev\3x\Lib\test\test_os.py", line 2229, in test_fdopen self.check_bool(os.fdopen, encoding="utf-8") ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "f:\dev\3x\Lib\test\test_os.py", line 2224, in check_bool with self.assertRaises(RuntimeWarning): f(fd, *args, **kwargs) AssertionError: RuntimeWarning not raised ``` `python -m test.test_os` crash box EDIT: this is with direct unittest run ``` minkernal\crts\ucrt\src\appcrt\lowio\isatty.cpp Assertion failed (fh>=0 && (unsigned)fh < (unsigned)_nhandle ``` `python -m test test_venv` ``` Traceback (most recent call last): File "f:\dev\3x\Lib\multiprocessing\process.py", line 314, in _bootstrap self.run() ~~~~~~~~^^ File "f:\dev\3x\Lib\multiprocessing\process.py", line 108, in run self._target(*self._args, **self._kwargs) ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "f:\dev\3x\Lib\test\_test_venv_multiprocessing.py", line 10, in drain_queue if code != queue.get(): ~~~~~~~~~^^ File "f:\dev\3x\Lib\multiprocessing\queues.py", line 102, in get with self._rlock: res = self._recv_bytes() File "f:\dev\3x\Lib\multiprocessing\synchronize.py", line 98, in __exit__ return self._semlock.__exit__(*args) ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^ OSError: [WinError 6] The handle is invalid ``` ``` test test_venv failed -- Traceback (most recent call last): File "f:\dev\3x\Lib\test\test_venv.py", line 277, in test_prefixes self.assertEqual(out.strip(), expected.encode(), prefix) ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AssertionError: b'f:\\dev\\3x' != b'f:\\dev\\3x\\' : base_prefix ``` `python -m test -uall -v test_venv` hangs with test_with_pip (test.test_venv.EnsurePipTest.test_with_pip) `python -m test.test_venv -vv` shows traceback and then hangs <!-- gh-linked-prs --> ### Linked PRs * gh-116925 * gh-117065 * gh-117076 * gh-117116 * gh-117263 * gh-117264 * gh-117265 * gh-117461 * gh-117462 <!-- /gh-linked-prs -->
cd2ed917801b93fb46d1dcf19dd480e5146932d8
43c9d6196a8593ebd1fda221a277dccb984e84b6
python/cpython
python__cpython-115863
# Add kernel density estimation to the statistics module # Feature ### Proposal: I propose promoting the KDE statistics recipe to be an actual part of the statistics module. See: https://docs.python.org/3.13/library/statistics.html#kernel-density-estimation My thought Is that it is an essential part of statistical reasoning about sample data See: https://www.itm-conferences.org/articles/itmconf/pdf/2018/08/itmconf_sam2018_00037.pdf ### Discussion of this feature: This was discussed and reviewed with the module author who gave it his full support: > This looks really great, both as a concept and the code itself. It's a > good showcase for match, and an important statistics function. > > Thank you for working on this. ### Working Draft: ```python from typing import Sequence, Callable from bisect import bisect_left, bisect_right from math import sqrt, exp, cos, pi, cosh def kde(sample: Sequence[float], h: float, kernel_function: str='gauss', ) -> Callable[[float], float]: """Kernel Density Estimation. Creates a continuous probability density function from discrete samples. The basic idea is to smooth the data using a kernel function to help draw inferences about a population from a sample. The degree of smoothing is controlled by the scaling parameter h which is called the bandwidth. Smaller values emphasize local features while larger values give smoother results. Kernel functions that give some weight to every sample point: gauss or normal logistic sigmoid Kernel functions that only give weight to sample points within the bandwidth: rectangular or uniform triangular epanechnikov or parabolic biweight or quartic triweight cosine Example ------- Given a sample of six data points, estimate the probablity density at evenly spaced points from -6 to 10: >>> sample = [-2.1, -1.3, -0.4, 1.9, 5.1, 6.2] >>> f_hat = kde(sample, h=1.5) >>> total = 0.0 >>> for x in range(-6, 11): ... density = f_hat(x) ... total += density ... plot = ' ' * int(density * 400) + 'x' ... print(f'{x:2}: {density:.3f} {plot}') ... -6: 0.002 x -5: 0.009 x -4: 0.031 x -3: 0.070 x -2: 0.111 x -1: 0.125 x 0: 0.110 x 1: 0.086 x 2: 0.068 x 3: 0.059 x 4: 0.066 x 5: 0.082 x 6: 0.082 x 7: 0.058 x 8: 0.028 x 9: 0.009 x 10: 0.002 x >>> round(total, 3) 0.999 References ---------- Kernel density estimation and its application: https://www.itm-conferences.org/articles/itmconf/pdf/2018/08/itmconf_sam2018_00037.pdf Kernel functions in common use: https://en.wikipedia.org/wiki/Kernel_(statistics)#Kernel_functions_in_common_use Interactive graphical demonstration and exploration: https://demonstrations.wolfram.com/KernelDensityEstimation/ """ kernel: Callable[[float], float] support: float | None match kernel_function: case 'gauss' | 'normal': c = 1 / sqrt(2 * pi) kernel = lambda t: c * exp(-1/2 * t * t) support = None case 'logistic': # 1.0 / (exp(t) + 2.0 + exp(-t)) kernel = lambda t: 1/2 / (1.0 + cosh(t)) support = None case 'sigmoid': # (2/pi) / (exp(t) + exp(-t)) c = 1 / pi kernel = lambda t: c / cosh(t) support = None case 'rectangular' | 'uniform': kernel = lambda t: 1/2 support = 1.0 case 'triangular': kernel = lambda t: 1.0 - abs(t) support = 1.0 case 'epanechnikov' | 'parabolic': kernel = lambda t: 3/4 * (1.0 - t * t) support = 1.0 case 'biweight' | 'quartic': kernel = lambda t: 15/16 * (1.0 - t * t) ** 2 support = 1.0 case 'triweight': kernel = lambda t: 35/32 * (1.0 - t * t) ** 3 support = 1.0 case 'cosine': c1 = pi / 4 c2 = pi / 2 kernel = lambda t: c1 * cos(c2 * t) support = 1.0 case _: raise ValueError(f'Unknown kernel function: {kernel_function!r}') n = len(sample) if support is None: def pdf(x: float) -> float: return sum(kernel((x - x_i) / h) for x_i in sample) / (n * h) else: sample = sorted(sample) bandwidth = h * support def pdf(x: float) -> float: i = bisect_left(sample, x - bandwidth) j = bisect_right(sample, x + bandwidth) supported = sample[i : j] return sum(kernel((x - x_i) / h) for x_i in supported) / (n * h) return pdf def _test() -> None: from statistics import NormalDist def kde_normal(sample: Sequence[float], h: float) -> Callable[[float], float]: "Create a continuous probability density function from a sample." # Smooth the sample with a normal distribution kernel scaled by h. kernel_h = NormalDist(0.0, h).pdf n = len(sample) def pdf(x: float) -> float: return sum(kernel_h(x - x_i) for x_i in sample) / n return pdf D = NormalDist(250, 50) data = D.samples(100) h = 30 pd = D.pdf fg = kde(data, h, 'gauss') fg2 = kde_normal(data, h) fr = kde(data, h, 'rectangular') ft = kde(data, h, 'triangular') fb = kde(data, h, 'biweight') fe = kde(data, h, 'epanechnikov') fc = kde(data, h, 'cosine') fl = kde(data, h, 'logistic') fs = kde(data, h, 'sigmoid') def show(x: float) -> None: for func in (pd, fg, fg2, fr, ft, fb, fe, fc, fl, fs): print(func(x)) print() show(197) show(255) show(320) def integrate(func: Callable[[float], float], low: float, high: float, steps: int=1000) -> float: width = (high - low) / steps xarr = (low + width * i for i in range(steps)) return sum(map(func, xarr)) * width print('\nIntegrals:') for func in (pd, fg, fg2, fr, ft, fb, fe, fc, fl, fs): print(integrate(func, 0, 500, steps=10_000)) if __name__ == '__main__': import doctest _test() print(doctest.testmod()) ``` <!-- gh-linked-prs --> ### Linked PRs * gh-115863 * gh-117897 * gh-118210 <!-- /gh-linked-prs -->
6d34eb0e36d3a7edd9e7629f21da39b6a74b8f68
6a3236fe2e61673cf9f819534afbf14a18678408
python/cpython
python__cpython-128037
# Spurious "Exception in callback None()" after upgrading to 3.12 # Bug report ### Bug description: Hello, after upgrading our application to 3.12.1 that uses aiohttp to download stuff via HTTPS as well as connects to some RabbitMQ servers via ssl, we get this spurious exception to stderr, dozens-hundres of them in close succession. They happen after several minutes of running (so after dozens of ssl connections are used). Unfortunately, I can't tell what is the culprit, the trace contains nothing other than the runtime :( I can provide more info if you give me some pointers on where to look. It looks like write-after-close, but the "writing" is done by internal asyncio mechanisms. ``` Exception in callback None() handle: <Handle created at /usr/local/lib/python3.12/asyncio/selector_events.py:313> source_traceback: Object created at (most recent call last): File "/usr/local/lib/python3.12/asyncio/base_events.py", line 671, in run_until_complete self.run_forever() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 638, in run_forever self._run_once() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1963, in _run_once handle._run() File "/usr/local/lib/python3.12/asyncio/events.py", line 84, in _run self._context.run(self._callback, *self._args) File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 1111, in _write_sendmsg self._maybe_resume_protocol() # May append to buffer. File "/usr/local/lib/python3.12/asyncio/transports.py", line 300, in _maybe_resume_protocol self._protocol.resume_writing() File "/usr/local/lib/python3.12/asyncio/sslproto.py", line 907, in resume_writing self._process_outgoing() File "/usr/local/lib/python3.12/asyncio/sslproto.py", line 715, in _process_outgoing self._transport.write(data) File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 1084, in write self._loop._add_writer(self._sock_fd, self._write_ready) File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 313, in _add_writer handle = events.Handle(callback, args, self, None) ``` ### CPython versions tested on: 3.12 ### Operating systems tested on: Linux <!-- gh-linked-prs --> ### Linked PRs * gh-128037 * gh-129581 * gh-129582 <!-- /gh-linked-prs -->
4e38eeafe2ff3bfc686514731d6281fed34a435e
853a6b7de222964d8cd0e9478cb5c78d490032e6
python/cpython
python__cpython-115504
# `run_presite`'s error handling is wrong # Bug report https://github.com/python/cpython/blob/474204765bdbdd4bc84a8ba49d3a6558e9e4e3fd/Python/pylifecycle.c#L1106-L1113 I think that `Py_DECREF(presite_modname);` is not needed, because `presite_modname` is `NULL` in this branch. This will, likely, lead to a crash. I have a PR ready. <!-- gh-linked-prs --> ### Linked PRs * gh-115504 <!-- /gh-linked-prs -->
20eaf4d5dff7fa20f8a745450fef760f0923eb52
321d13fd2b858d76cd4cbd03e6d8c4cba307449e