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-123778 | # PyObject_GetBuffer(PyBUF_FORMAT) breaks on a memoryview
# Bug report
### Bug description:
Calling `PyObject_GetBuffer()` with the `PyBUF_FORMAT` flag on a memoryview object that wraps a bytes object fails with the exception:
`BufferError: memoryview: cannot cast to unsigned bytes if the format flag is present`
Calling it directly on the same bytes object does not fail.
The test is in `memory_getbuf()` in memoryobject.c. The test is failing because `format` is not `NULL`. `format` is actually `"B"` which is the equivalent of `NULL`. I think the test should be changed to allow a `format` value of `"B"`.
An alternative might be to change `PyBuffer_FillInfo()` to always set `format` to `NULL`.
### CPython versions tested on:
3.12, 3.13
### Operating systems tested on:
Linux, macOS
<!-- gh-linked-prs -->
### Linked PRs
* gh-123778
* gh-123903
* gh-123904
<!-- /gh-linked-prs -->
| 962304a54ca79da0838cf46dd4fb744045167cdd | fb1b51a58df4315f7ef3171a5abeb74f132b0971 |
python/cpython | python__cpython-123582 | # Match statement's `signed_number` token is not properly defined
# Documentation
It seems that the last line in the following production list intended to define the token `signed_number` but mistakenly put it inside the definition of `literal_pattern`.
https://github.com/python/cpython/blob/91b7f2e7f6593acefda4fa860250dd87d6f849bf/Doc/reference/compound_stmts.rst?plain=1#L836-L844
The intended meaning might be:
```
signed_number: NUMBER | "-" NUMBER
```
<!-- gh-linked-prs -->
### Linked PRs
* gh-123582
* gh-123623
* gh-123624
<!-- /gh-linked-prs -->
| 9e079c220b7f64d78a1aa36a23b513d7f377a694 | 9684f40b9f51816fd326f1b4957ea5fb5b5922c8 |
python/cpython | python__cpython-123612 | # Document "!" token in lexical analysis document
# Documentation
I think after [PEP701](https://peps.python.org/pep-0701/) The `!` character became a token.
But this is not listed like other tokens:
- https://docs.python.org/3/reference/lexical_analysis.html#delimiters
- https://docs.python.org/3/reference/lexical_analysis.html#operators
It is mentioned in the grammar though: https://docs.python.org/3/reference/lexical_analysis.html#formatted-string-literals
I think it would be helpful to list it in https://docs.python.org/3/reference/lexical_analysis.html or remove the rest of tokens and refer to Grammar/Tokens file so the list is always up to date.
<!-- gh-linked-prs -->
### Linked PRs
* gh-123612
* gh-123637
* gh-123638
<!-- /gh-linked-prs -->
| 68fe5758bf1900ffdcdf7cd9e40f5018555a39d4 | 782217f28f0d67916fc3ff82b03b88573686c0e7 |
python/cpython | python__cpython-123571 | # Improve `weakref_slot` docs in `dataclasses.rst`
While merging https://github.com/python/cpython/pull/123342 I've noticed that we can improve `weakref_slot` docs. Here's how it looks now:
<img width="759" alt="Снимок экрана 2024-09-01 в 13 53 28" src="https://github.com/user-attachments/assets/318b56f5-46b5-4994-b4dd-6f30d4fafebc">
I think that we can add a link to `weakref.ref` under "weakref-able" term. Like this:
<img width="762" alt="Снимок экрана 2024-09-01 в 13 55 34" src="https://github.com/user-attachments/assets/547d6db5-27ff-43b3-afea-9e9944fbc26c">
Right now `dataclass.rst` does not have a single link to `weakref.rst`. This change will make it easier for users to navigate to this term, which not all people are familiar with.
<!-- gh-linked-prs -->
### Linked PRs
* gh-123571
* gh-123594
* gh-123595
<!-- /gh-linked-prs -->
| c3ed775899eedd47d37f8f1840345b108920e400 | 88210c295d51364c9f779989bc528084b8fe8765 |
python/cpython | python__cpython-123563 | # Improve `SyntaxError` message for `case ... as a.b`
# Feature or enhancement
There's already a similar rule: https://github.com/python/cpython/blob/084e0f35d1492495b01e7cf24c3106849e854188/Grammar/python.gram#L1378
But, it has two problems:
1. It does not work for cases like `as a.b`, because `a` matches `NAME`
2. It does not show rich error message, only a static one: `invalid pattern target`
My proposed change:
```
| or_pattern 'as' a=expression {
RAISE_SYNTAX_ERROR_KNOWN_LOCATION(
a, "cannot use pattern target as %s", _PyPegen_get_expr_name(a)) }
```
Why is it safe?
Here's how the parent rule is defined:
```
as_pattern[pattern_ty]:
| pattern=or_pattern 'as' target=pattern_capture_target {
_PyAST_MatchAs(pattern, target->v.Name.id, EXTRA) }
| invalid_as_pattern
```
So, if `pattern=or_pattern 'as' target=pattern_capture_target` with a valid `'as' NAME` is matched, we won't fall to the next `invalid_` rule.
Proposed result:
```python
>>> match 1:
... case x as a.b: ...
...
File "<python-input-0>", line 2
case x as a.b: ...
^^^
SyntaxError: cannot use pattern target as attribute
```
Refs https://github.com/python/cpython/issues/123440
<!-- gh-linked-prs -->
### Linked PRs
* gh-123563
<!-- /gh-linked-prs -->
| 23f159ae711d84177e8ce34cd9a6c8a762de64ac | c3ed775899eedd47d37f8f1840345b108920e400 |
python/cpython | python__cpython-123561 | # Invalid description for '' (None) formatting type for floats
Docs [says](https://docs.python.org/3.12/library/string.html#format-specification-mini-language), that if format type is not specified:
"For [float](https://docs.python.org/3.12/library/functions.html#float) this is the same as 'g', except that when fixed-point notation is used to format the result, it always includes at least one digit past the decimal point. The precision used is as large as needed to represent the given value faithfully.
[...]
The overall effect is to match the output of [str()](https://docs.python.org/3.12/library/stdtypes.html#str) as altered by the other format modifiers."
On another hand, for 'g' presentation type it says:
"General format. For a given precision p >= 1, this rounds the number to p significant digits and then formats the result in either fixed-point format or in scientific notation, depending on its magnitude. A precision of 0 is treated as equivalent to a precision of 1.
The precise rules are as follows: suppose that the result formatted with presentation type 'e' and precision p-1 would have exponent exp. Then, if ``-4 <= exp < p`` [...], the number is formatted with presentation type 'f' and precision ``p-1-exp``. Otherwise, the number is formatted with presentation type 'e' and precision ``p-1``. In both cases insignificant trailing zeros are removed from the significand, and the decimal point is also removed if there are no remaining digits following it, unless the '#' option is used.
With no precision given, uses a precision of 6 significant digits for [float](https://docs.python.org/3.12/library/functions.html#float)."
Lets consider case, when precision is specified. Obviously, it's not "same as 'g':
```pycon
Python 3.14.0a0 (heads/main:58ce131037, Aug 29 2024, 16:19:25) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> format(1.0, '.1')
'1e+00'
>>> format(1.0, '.1g')
'1'
>>> format(12.34, '.2')
'1.2e+01'
>>> format(12.34, '.2g')
'12'
```
Here exponential format is used instead of fixed-point, as for 'g' type. IIUC, this coming from https://github.com/python/cpython/issues/50114. It seems, that 'g' type comparison should be changed here (for '' presentation type) to ``-4 <= exp < p-1`` instead. I'll work on a patch.
<!-- gh-linked-prs -->
### Linked PRs
* gh-123561
* gh-124596
* gh-124597
<!-- /gh-linked-prs -->
| 274d9ab619b8150a613275835234ea9ef935f21f | 19fed6cf6eb51044fd0c02c6338259e2dd7fd462 |
python/cpython | python__cpython-123554 | # New warning: `‘compiler_is_top_level_await’ defined but not used [-Wunused-function]`
# Bug report
### Bug description:
Popped up in https://github.com/python/cpython/pull/123546/files
I have a PR ready.
### CPython versions tested on:
CPython main branch
### Operating systems tested on:
Linux
<!-- gh-linked-prs -->
### Linked PRs
* gh-123554
* gh-123578
<!-- /gh-linked-prs -->
| 084e0f35d1492495b01e7cf24c3106849e854188 | bac0e115b8c439def509053c71a6c20651348313 |
python/cpython | python__cpython-123551 | # Incorrect code snippet for `BUILD_TUPLE` in `dis` docs
# Documentation
The code snippet in the docs removes the last *count* items from the stack before creating the tuple instead of first creating the tuple from the last *count* items and then removing them from the stack.
https://github.com/python/cpython/blob/917283ada6fb01a3221b708d64f0a5195e1672dc/Doc/library/dis.rst?plain=1#L1113-L1124
<!-- gh-linked-prs -->
### Linked PRs
* gh-123551
* gh-123555
* gh-123556
<!-- /gh-linked-prs -->
| bac0e115b8c439def509053c71a6c20651348313 | 0ff59d707ce33c2fd7390d473a5779a3d16a5764 |
python/cpython | python__cpython-123546 | # Remove duplicative `Py_DECREF` when handling `_PyOptimizer_Optimize` errors
There are two places in the code where we call `Py_DECREF` twice when `_PyOptimizer_Optimize` returns `-1`. In both cases, we do so in the conditional block and then as part of the `GOTO_UNWIND` macro. This never really happens in practice, but it would be problematic if this error'd.
https://github.com/python/cpython/blob/34ddb64d088dd7ccc321f6103d23153256caa5d4/Python/bytecodes.c#L4741
https://github.com/python/cpython/blob/34ddb64d088dd7ccc321f6103d23153256caa5d4/Python/bytecodes.c#L4824
<!-- gh-linked-prs -->
### Linked PRs
* gh-123546
* gh-123759
<!-- /gh-linked-prs -->
| 1fbc118c5d3916e920a57cda3cb6d9a0292de26e | aa1339aaaa6363c38186defaa079d069b4cb08b2 |
python/cpython | python__cpython-123629 | # Improve `SyntaxError` message for `import a as b.c`
# Feature or enhancement
Right now it shows:
```python
>>> import a as b.c
File "<unknown>", line 1
import a as b.c
^
SyntaxError: invalid syntax
```
Proposed message:
```python
>>> import a as b.c
File "<unknown>", line 1
import a as b.c
^^^
SyntaxError: cannot use import statement with attribute
```
Refs https://github.com/python/cpython/issues/123440
I have a PR ready.
<!-- gh-linked-prs -->
### Linked PRs
* gh-123629
* gh-133344
<!-- /gh-linked-prs -->
| a6ddd078d050bc501817d8afe27fab2777a482aa | 39afd290ae2b086bc1e7c560229164ead22cd9c4 |
python/cpython | python__cpython-123544 | # Move typing-related usage of PEP585 generics from `typing` docs to `collections.abc`
# Documentation
As pointed out in #123521, currently we have typing-related usage of PEP585 generics (`Generator`, `Callable`, `Coroutine`, etc.) explained on [`typing`](https://docs.python.org/3/library/typing.html#typing.Generator) page. However, those aliases are deprecated, and there's no backlink from their `collections.abc` [counterparts](https://docs.python.org/3/library/collections.abc.html#collections.abc.Generator).
So, currently all users of the recommended modern option (`collections.abc` generics) have no documentation regarding their use in typing context at hand. Worse, classes there don't even have their generic arguments listed - only the name:
> `class collections.abc.Generator`
This clearly should be fixed. At minimum the following needs to hold:
* `collections.abc` aliases have their generic arguments listed in the docs
* All typing-related info from corresponding `typing` docs entries should be reachable from `collections.abc` docs.
Upon some thinking I agree with @ZeroIntensity that moving all information to `collections.abc` and only retaining deprecation warning with a link in `typing` docs could be the most ergonomic option.
<!-- gh-linked-prs -->
### Linked PRs
* gh-123544
* gh-123790
* gh-123792
<!-- /gh-linked-prs -->
| 56e4a417ce170e5c538ce9aafccf3333e7bf7492 | d343f977ba89c415aa4dcaf75122e0b4235d4fb1 |
python/cpython | python__cpython-123518 | # Remove unnecessary `:meth:` parentheses
# Documentation
Follow up with #123492 and sphinx-lint's [issue](https://github.com/sphinx-contrib/sphinx-lint/issues/114).
It's suggested that the unnecessary parentheses with meth role should also be fixed ([ref](https://github.com/sphinx-doc/sphinx/issues/12847#issuecomment-2321749168)).
<!-- gh-linked-prs -->
### Linked PRs
* gh-123518
* gh-123576
* gh-123577
<!-- /gh-linked-prs -->
| cf472577e24911cb70b619304c0108c7fba97cac | 34ddb64d088dd7ccc321f6103d23153256caa5d4 |
python/cpython | python__cpython-123505 | # `_tkinter` leaks type references on initialization
# Bug report
### Bug description:
Reproducer:
```
$ ./python -Xshowrefcount -c "import tkinter"
```
Seems to be caused by the use of `AddObjectRef` on a strong reference in the `_tkinter` initialization function, causing a double `Py_INCREF`.
### CPython versions tested on:
CPython main branch
### Operating systems tested on:
Linux
<!-- gh-linked-prs -->
### Linked PRs
* gh-123505
* gh-123662
<!-- /gh-linked-prs -->
| a8bc03696c7c2c03e1d580633151ec7b850366f3 | cfbc841ef3c27b3e65d1223bf8fedf1f652137bc |
python/cpython | python__cpython-123495 | # The return types for `webbrowser`'s API aren't documented
# Documentation
Related to https://stackoverflow.com/a/78930912/51685, it isn't clear that `webbrowser.open()` and friends return booleans.
(I have a PR fired up for this.)
<!-- gh-linked-prs -->
### Linked PRs
* gh-123495
* gh-123548
* gh-123549
<!-- /gh-linked-prs -->
| 0b6acfee04b30e7993314723c614625ddd90ae6e | 917283ada6fb01a3221b708d64f0a5195e1672dc |
python/cpython | python__cpython-123493 | # Remove unnecessary `:func:` parentheses
# Documentation
The func role's parentheses are unnecessary as Sphinx will add them to the rendered output.
```rst
.. bad
:func:`!locale.resetlocale()`
.. good
:func:`!locale.resetlocale`
```
We're introducing a new rule to the sphinx-lint ([issue](https://github.com/sphinx-contrib/sphinx-lint/issues/114) & [PR](https://github.com/sphinx-contrib/sphinx-lint/pull/115)) and, since sphinx-lint utilizes CPython Docs in the CI, we'd like to also fix the issue.
### TODO:
- [x] fix on main branch
- [x] backport to 3.12
- [x] backport to 3.13
<!-- gh-linked-prs -->
### Linked PRs
* gh-123493
* gh-123512
* gh-123513
<!-- /gh-linked-prs -->
| 103a0470e31d80d56097f57a27d97d7d2d3c9fbb | 8aaf7525ab839c32966ee862363ad2543a721306 |
python/cpython | python__cpython-123485 | # _Py_DebugOffsets for PyLongObject are incorrect
# Bug report
### Bug description:
All other debug offsets are relative to the start of the object, but the offsets for PyLongObject's fields are relative to the start of an inner object, and so each field's value is too small by `sizeof(PyObject)`.
### CPython versions tested on:
3.13, CPython main branch
### Operating systems tested on:
Linux
<!-- gh-linked-prs -->
### Linked PRs
* gh-123485
* gh-123499
<!-- /gh-linked-prs -->
| 7fca268beee8ed13a8f161f0a0d5e21ff52d1ac1 | 103a0470e31d80d56097f57a27d97d7d2d3c9fbb |
python/cpython | python__cpython-123478 | # TCP_QUICKACK is available on Windows, but is only implemented by the python runtime for Linux
# Bug report
### Bug description:
```python
import socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_QUICKACK, 1)
sock.getsockopt(socket.IPPROTO_TCP, socket.TCP_QUICKACK)
```
On windows this throws `AttributeError: module 'socket' has no attribute 'TCP_QUICKACK'`
Support is for this setting is available on windows, it just isn't implemented in the python runtime. It's implemented for Linux and I believe for Mac as well, though I didn't check the latter.
I'm opening this mostly to track my PR as I already have the fix implemented.
### CPython versions tested on:
3.12, CPython main branch
### Operating systems tested on:
Linux, Windows
<!-- gh-linked-prs -->
### Linked PRs
* gh-123478
<!-- /gh-linked-prs -->
| b5aa271f86229f126c21805ff2bd3b95526818a4 | 6e43928831a6f62b40f5e43ad4c12eff0a5f8639 |
python/cpython | python__cpython-123474 | # C API: `PyType_FromSpec()`: `__vectorcalloffset__` (and other special offset members) does not support `Py_RELATIVE_OFFSET`
# Bug report
### Bug description:
When declaring members of custom types via `PyType_FromSpec()`, it is advisable to rely on `Py_RELATIVE_OFFSET` to declare their position using a *relative* byte offset.
This is needed to create portable stable API / limited ABI extensions since we don't need to make assumptions about the layout of the base type, and how Python concatenates the two (e.g. is there intermediate padding/alignment?)
In addition, one can specify a special member called `__vectorcalloffset__` to declare the byte offset of a pointer that implements a vector call handler.
Unfortunately, these two features don't work together. That is bad news for anyone who wants to extend an opaque type (e.g. `PyTypeObject`) and add the ability to dispatch vector calls. I ran into this issue while looking for temporary workarounds for #100554.
I created a minified reproducer here: https://github.com/wjakob/vectorcall_issue (installable via `pip install https://github.com/wjakob/vectorcall_issue`)
This extension creates a metaclass `Meta` that declares `tp_call` and vector call, along with a type `Class` created using this metaclass. It specifies the `__vectorcalloffset__` using one of two different ways:
```c
PyMemberDef meta_members [] = {
#if TRIGGER_BUG
{ "__vectorcalloffset__", Py_T_PYSSIZET, 0, Py_READONLY | Py_RELATIVE_OFFSET },
#else
{ "__vectorcalloffset__", Py_T_PYSSIZET, sizeof(PyHeapTypeObject), Py_READONLY },
#endif
{ NULL }
};
```
Compiling this extension with `#define TRIGGER_BUG 1` and instantiating `Class` shows that the `tp_call` path is used.
```pycon
Python 3.12.5 (main, Aug 6 2024, 19:08:49) [Clang 15.0.0 (clang-1500.1.0.2.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from vectorcall_issue import Class
>>> Class()
Constructing using tp_call
<vectorcall_issue.Class object at 0x102faca10>
>>>
```
If I switch over from a relative to an absolute byte offset (change `#define TRIGGER_BUG 1` to `#define TRIGGER_BUG 0` at the top), the vector call is used. But that is not portable.
```
Python 3.12.5 (main, Aug 6 2024, 19:08:49) [Clang 15.0.0 (clang-1500.1.0.2.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from vectorcall_issue import Class
>>> Class()
Constructing using vector call
<vectorcall_issue.Class object at 0x102fb8a10>
```
### CPython versions tested on:
3.12
### Operating systems tested on:
macOS
<!-- gh-linked-prs -->
### Linked PRs
* gh-123474
* gh-125460
<!-- /gh-linked-prs -->
| 16be8db6bec7bf8b58df80601cab58a26eee4afa | ce9f84a47bfbafedd09a25d0f6f0c8209550fb6c |
python/cpython | python__cpython-123464 | # Logging flow chart missing from PDF
# Documentation
gh-121035 changed the format of the logging HOWTO flow chart from PNG to SVG. This broke the inclusion of the flow chart in the PDF doc build.
<!-- gh-linked-prs -->
### Linked PRs
* gh-123464
* gh-123666
* gh-123667
<!-- /gh-linked-prs -->
| 7d2c2f24daf7a2abd166bb51652ba55c6f55695f | c08ede27140121a919e884c7e8dfdce7b1a2e906 |
python/cpython | python__cpython-123507 | # python 3.12.5 new added build target _RegenSbom fails to build on windows
# Bug report
### Bug description:
```xml
<Target Name="Regen"
Condition="$(Configuration) != 'PGUpdate'"
DependsOnTargets="_TouchRegenSources;_RegenPegen;_RegenAST_H;_RegenOpcodes;_RegenTokens;_RegenKeywords;_RegenGlobalObjects;_RegenSbom">
<Message Text="Generated sources are up to date" Importance="high" />
</Target>
```
```pytb
FAILURE -
_RegenGlobalObjects:
Regenerate Global Objects
"C:\Temp\3499797612\python\src\Python-3.12.5\PCbuild\\..\externals\pythonx86\tools\python.exe" Tools\build\generate_global_objects.py
# not changed: C:\Temp\3499797612\python\src\Python-3.12.5\Include\internal\pycore_global_strings.h
# not changed: C:\Temp\3499797612\python\src\Python-3.12.5\Include\internal\pycore_runtime_init_generated.h
# not changed: C:\Temp\3499797612\python\src\Python-3.12.5\Include\internal\pycore_unicodeobject_generated.h
# not changed: C:\Temp\3499797612\python\src\Python-3.12.5\Include\internal\pycore_global_objects_fini_generated.h
_RegenSbom:
"C:\Temp\3499797612\python\src\Python-3.12.5\PCbuild\\..\externals\pythonx86\tools\python.exe" "C:\Temp\3499797612\python\src\Python-3.12.5\Tools\build\generate_sbom.py"
fatal: not a git repository (or any of the parent directories): .git
Traceback (most recent call last):
File "C:\Temp\3499797612\python\src\Python-3.12.5\Tools\build\generate_sbom.py", line 349, in <module>
main()
File "C:\Temp\3499797612\python\src\Python-3.12.5\Tools\build\generate_sbom.py", line 344, in main
create_source_sbom()
File "C:\Temp\3499797612\python\src\Python-3.12.5\Tools\build\generate_sbom.py", line 245, in create_source_sbom
paths = filter_gitignored_paths(paths)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Temp\3499797612\python\src\Python-3.12.5\Tools\build\generate_sbom.py", line 124, in filter_gitignored_paths
assert git_check_ignore_proc.returncode in (0, 1)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError
```
How I am building -
[Python-3.12.5\PCbuild]call build.bat -e -v -p x64 --no-tkinter
I was able to build 3.12.3 successfully using this but 3.12.5 if failing with git error . I am not using git here though it is installed on my windows host. could someone Please suggest a way out here.
### CPython versions tested on:
3.12
### Operating systems tested on:
Windows
<!-- gh-linked-prs -->
### Linked PRs
* gh-123507
* gh-123615
* gh-123616
<!-- /gh-linked-prs -->
| db42934270c5c23be9f6804cad98dfd8234caf6f | fbb26f067a7a3cd6dc6eed31cce12892cc0fedbb |
python/cpython | python__cpython-123449 | # Memory leak of `NoDefaultType` in `_typing`
# Bug report
### Bug description:
Quick reproducer:
```
$ ./python -X showrefcount -c "import _typing"
[8 refs, 0 blocks]
```
The underlying leaked object is `NoDefaultType`. I think this was caused by gh-118897 (cc @JelleZijlstra).
### CPython versions tested on:
CPython main branch
### Operating systems tested on:
Linux
<!-- gh-linked-prs -->
### Linked PRs
* gh-123449
* gh-123450
<!-- /gh-linked-prs -->
| c9930f5022f5e7a290896522280e47a1fecba38a | b379f1b26c1e89c8e9160b4dede61b980cc77be6 |
python/cpython | python__cpython-123461 | # `PyArg_UnpackTuple` is used with `name=""`
# Bug report
### Bug description:
`PyArg_UnpackTuple(args, "",` causes empty name to be used in error messages:
```py
>>> str.join.__get__()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: expected at least 1 argument, got 0
# ^^
>>> try: str.join.__get__()
... except Exception as e: exc = e
...
>>> str(exc)
' expected at least 1 argument, got 0'
#^
```
According to my quick search, `PyArg_UnpackTuple(args, "",` is used 10 times in `Objects/typeobject.c` and 3 times in `Modules/_csv.c`.
### CPython versions tested on:
3.12, CPython main branch
### Operating systems tested on:
_No response_
<!-- gh-linked-prs -->
### Linked PRs
* gh-123461
* gh-123462
* gh-123466
* gh-123470
<!-- /gh-linked-prs -->
| 303f92a9ce0de3667fb6b3ed22fa3bea5f835066 | 0c3ea3023878f5ad5ca4680d5510da1fe208cbfa |
python/cpython | python__cpython-123483 | # calendar.day_name returns a class object and not array
# Documentation
In the https://docs.python.org/3/library/calendar.html#calendar.day_name, its mentioned day_name returns "An array that represents the days of the week in the current locale." but it returns a class object. Also, it would be helpful to provide documentation with regards to how to use the object returned to obtain the day names.
<!-- gh-linked-prs -->
### Linked PRs
* gh-123483
* gh-124500
* gh-124501
<!-- /gh-linked-prs -->
| 8447c933da308939b06e33544ca9abc9fc46aa8b | 0d38409f422b7be158a45e59766d8f4605dfa5df |
python/cpython | python__cpython-123442 | # Improve error message for `except a as b.c:` case
# Feature or enhancement
Right now the syntax error is not very clear:
<img width="788" alt="Снимок экрана 2024-08-28 в 21 00 51" src="https://github.com/user-attachments/assets/5d8a6a90-2151-4969-831b-f7af39692f70">
I propose to instead use something like:
<img width="788" alt="Снимок экрана 2024-08-28 в 20 59 42" src="https://github.com/user-attachments/assets/047ac672-e82d-4d13-9b66-16caa1daede2">
@JelleZijlstra suggested to use similar error messages to `:=` case, where we also only expect a name:
```python
>>> (a.b := 3)
File "<unknown>", line 1
(a.b := 3)
^^^
SyntaxError: cannot use assignment expressions with attribute
>>> (a[0] := 3)
File "<unknown>", line 1
(a[0] := 3)
^^^^
SyntaxError: cannot use assignment expressions with subscript
>>> ((a, b) := 3)
File "<unknown>", line 1
((a, b) := 3)
^^^^^^
SyntaxError: cannot use assignment expressions with tuple
```
I am working on this right now :)
<!-- gh-linked-prs -->
### Linked PRs
* gh-123442
<!-- /gh-linked-prs -->
| e451a8937df95b2757b6def26b39aec1bd0f157f | d8e69b2c1b3388c31a6083cfdd9dc9afff5b9860 |
python/cpython | python__cpython-123434 | # Harmonize extension code checks in pickle
The C implementation of `pickle` checks (partially explicitly, partially implicitly) the type and the range of the value returned by the extension registry. These checks are redundant in normal circumstances, because it is already checked in `copyreg.add_extension()` which is the only public interface for registering an extension. It is still worth to have some checks in the C code to prevent crash, undefined behavior or producing incorrect output in improbable situation (realistically, this can happen only if you broke the extension registry).
The Python implementation does not have explicit check. Broken extension registry will cause errors (with different type and message, but this is not important), except one case -- the code with the false boolean value (`0`, `None`, `()`, etc) -- in that case it produces output. Although, there is a difference when the code has `__index__` method but is not `int`.
The following PR makes both implementations raising exception in the same circumstances (although the type of the exception may be different). The C checks are simplified. The Python check made more reliable.
<!-- gh-linked-prs -->
### Linked PRs
* gh-123434
* gh-123459
* gh-123460
<!-- /gh-linked-prs -->
| 0c3ea3023878f5ad5ca4680d5510da1fe208cbfa | c9930f5022f5e7a290896522280e47a1fecba38a |
python/cpython | python__cpython-123475 | # Add `:root { color-scheme: light dark; }` to http.server directory list and error pages
# Feature or enhancement
### Proposal:
Allow browsers to apply light or dark themes to the http.server directory list according to the users prefered color scheme.
This can be done by adding the CSS [`color-scheme` property](https://developer.mozilla.org/en-US/docs/Web/CSS/color-scheme) to `:root` with the value `light dark`.
```css
:root {
color-scheme: light dark;
}
```
### 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:
Something similar was discussed previously in #95812. There it was [rejected](https://github.com/python/cpython/issues/95812#issuecomment-1209057716), as "[t]he listing [should] not contain any hardcoded colors".
I agree with this statement, but I think the page should allow browsers to select their own color scheme and don't see it as a "a problem either with [the] configuration or with the browser", as long as the `color-scheme` property is not set properly.
<!-- gh-linked-prs -->
### Linked PRs
* gh-123475
<!-- /gh-linked-prs -->
| 9684f40b9f51816fd326f1b4957ea5fb5b5922c8 | 13f61bf7f1fb9b9b109b089610e845d98e6dc937 |
python/cpython | python__cpython-123429 | # Extract ZipInfo for archive functionality
In https://github.com/python/cpython/pull/123354, I found the need to copy code from zipfile into the test:
https://github.com/python/cpython/blob/9e108b8719752a0a2e390eeeaa8f52391f75120d/Lib/test/test_zipfile/_path/test_path.py#L662-L676
Let's instead extract that functionality in the zipfile module for re-use in the test (before it starts diverging).
<!-- gh-linked-prs -->
### Linked PRs
* gh-123429
<!-- /gh-linked-prs -->
| 7e819ce0f32068de7914cd1ba3b4b95e91ea9873 | ffece5590e95e89d3b5b6847e3beb443ff65c3db |
python/cpython | python__cpython-123673 | # OpenSSL vulnerability CVE-2024-2511
# Bug report
### Bug description:
### Description
Defender on Windows is detecting openssl vulnerabilities when python is installed.
Tested for Windows Python 3.11.9 and 3.12.15.
Defender is flagging vulnerabilities in the following files in Version 3.0.13:
C:\Python\DLLs\libcrypto-3.dll
C:\Python\DLLs\libssl-3.dll
[CVE-2024-2511](https://nvd.nist.gov/vuln/detail/CVE-2024-2511)
[OpenSSL Changelog](https://openssl-library.org/news/openssl-3.0-notes/)
Latest OPENSSL Version with fix:
3.0.14 [4 Jun 2024]
### Impact
Issue summary: Some non-default TLS server configurations can cause unbounded memory growth when processing TLSv1.3 sessions Impact summary: An attacker may exploit certain server configurations to trigger unbounded memory growth that would lead to a Denial of Service This problem can occur in TLSv1.3 if the non-default SSL_OP_NO_TICKET option is being used (but not if early_data support is also configured and the default anti-replay protection is in use). In this case, under certain conditions, the session cache can get into an incorrect state and it will fail to flush properly as it fills. The session cache will continue to grow in an unbounded manner. A malicious client could deliberately create the scenario for this failure to force a Denial of Service. It may also happen by accident in normal operation. This issue only affects TLS servers supporting TLSv1.3. It does not affect TLS clients. The FIPS modules in 3.2, 3.1 and 3.0 are not affected by this issue. OpenSSL 1.0.2 is also not affected by this issue.
### Python versions tested
3.11.9 Windows
3.12.15 WIndows
### CPython versions tested on:
3.11, 3.12
### Operating systems tested on:
Windows
<!-- gh-linked-prs -->
### Linked PRs
* gh-123673
* gh-123675
* gh-123684
* gh-123685
* gh-123686
* gh-123691
* gh-123692
* gh-123696
* gh-123698
* gh-123699
* gh-123715
* gh-123729
* gh-123730
<!-- /gh-linked-prs -->
| d2eafe2f48aac31aa8a152620bdfd0f2a274ee1d | a4562fedadb73fe1e978dece65c3bcefb4606678 |
python/cpython | python__cpython-123419 | # Incorrect ipaddress.ip_address.reverse_pointer with improved textual representation of IPv4-mapped IPv6 addresses
# Bug report
### Bug description:
I'm seeing strange results with python 3.13 with the `ipaddress.ip_address.reverse_pointer` attribute with the new improved textual representation of IPv4-mapped IPv6 addresses:
IP Address: `::FFFF:192.168.1.35`
Results in a `reverse_pointer` of:
`5.3...1...8.6.1...2.9.1.f.f.f.f.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa`
instead of the old:
`3.2.1.0.8.a.0.c.f.f.f.f.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa`
Python 3.13:
```python
>>> import ipaddress
>>> ip = '::FFFF:192.168.1.35'
>>> ipaddress.ip_address(ip).reverse_pointer
'5.3...1...8.6.1...2.9.1.f.f.f.f.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa'
```
Python 3.12:
```python
>>> import ipaddress
>>> ip = '::FFFF:192.168.1.35'
>>> ipaddress.ip_address(ip).reverse_pointer
'3.2.1.0.8.a.0.c.f.f.f.f.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa'
```
I'm not sure which one is more valid or if a pointer record is even relevant in the context of mapped addresses. The original way *seems* more correct to me if nothing for the fact that there are strange extra dots in the new output.
This is related to:
Issue: https://github.com/python/cpython/issues/87799
PR: https://github.com/python/cpython/pull/29345
_Originally posted by @kellyjonbrazil in https://github.com/python/cpython/issues/87799#issuecomment-2264098846_
### CPython versions tested on:
3.13
### Operating systems tested on:
Linux
@opavlyuk
<!-- gh-linked-prs -->
### Linked PRs
* gh-123419
* gh-123606
* gh-135085
* gh-135086
* gh-135087
* gh-135088
<!-- /gh-linked-prs -->
| 77a2fb4bf1a1b160d6ce105508288fc77f636943 | f95fc4de115ae03d7aa6dece678240df085cb4f6 |
python/cpython | python__cpython-123408 | # Docs: enable translations of code blocks
# Documentation
Code blocks, e.g. in the tutorial, include comments that are complement to the regular content of tutorial articles. An example in tutorial's introduction in [section “Numbers”](https://docs.python.org/3/tutorial/introduction.html#numbers):
```python
>>> 17 / 3 # classic division returns a float
5.666666666666667
>>>
>>> 17 // 3 # floor division discards the fractional part
5
>>> 17 % 3 # the % operator returns the remainder of the division
2
>>> 5 * 3 + 2 # floored quotient * divisor + remainder
17
```
I'd like to propose changing gettext builder configuration by allowing `'literal-block'` [element types translation](https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-gettext_additional_targets).
The topic previously was brought up on [doc-sig mailing list](https://mail.python.org/pipermail/doc-sig/2020-January/004190.html) without a conclusion.
<!-- gh-linked-prs -->
### Linked PRs
* gh-123408
* gh-123530
* gh-123531
* gh-123852
<!-- /gh-linked-prs -->
| 5332d989af45378e6ae99aeda72bfa82042b8659 | 10bf615bab9f832971a098f0a42b0d617aea6993 |
python/cpython | python__cpython-123405 | # `http.cookies` module does not parse obsolete RFC 850 date format
# Bug report
### Bug description:
**Description**: According to [RFC 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-date-time-formats), a recipient that parses a timestamp value in an HTTP field MUST accept all three HTTP-date formats. This includes the obsolete RFC 850 format, e.g., `Sunday, 06-Nov-94 08:49:37 GMT`. However, the Python standard library module `http.cookies` currently fails to parse this format, which leads to the cookie being discarded entirely.
**Steps to Reproduce**:
1. Attempt to parse a cookie with a date in the obsolete RFC 850 format using the `http.cookies` module.
2. Observe that the module fails to parse the date, resulting in the cookie being discarded.
**Code Example**:
```python
import http.cookies
cookie_string = 'example=value; expires=Sunday, 06-Nov-94 08:49:37 GMT'
cookie = http.cookies.SimpleCookie()
cookie.load(cookie_string)
# The expected behavior is that the cookie's expiration date is correctly parsed.
# However, the module fails to parse the date in the obsolete RFC 850 format,
# resulting in the cookie being discarded.
print(cookie['example'].get('expires'))
```
**Expected Behavior**:
The `http.cookies` module should correctly parse the obsolete RFC 850 date format and retain the cookie.
**Actual Behavior**:
The module fails to parse the date, resulting in a `KeyError` and the cookie being discarded.
### CPython versions tested on:
CPython main branch
### Operating systems tested on:
Linux
<!-- gh-linked-prs -->
### Linked PRs
* gh-123405
* gh-127828
* gh-127829
<!-- /gh-linked-prs -->
| 359389ed51aecc107681e600b71852c0a97304e1 | b2ad7e0a2c1518539d9b0ef83c9f7a09d10fd303 |
python/cpython | python__cpython-123394 | # Document callables more explicitly
# Documentation
Currently, some options that expect callables [read like this in the documentation](https://docs.python.org/3/library/json.html#json.load):
> ```
> json.load(...)
> ```
>
> parse_constant, if specified, will be called with one of the following strings: '-Infinity', 'Infinity', 'NaN'. This can be used to raise an exception if invalid JSON numbers are encountered.
One potentially confusing interpretation of the above is "_if `parse_constant` is specific, then `json.load` will be called with..._". It would be clearer if these were documented like the `object_hook` parameter right above it:
> object_hook is an optional function that will be called with the result...
This issue is being opened to tag a PR to that updates the documentation in this module like this:
```
<param>, if specified, will be called ----> <param> is an [optional] function that will be called
```
The goal is for the documentation to be more consistent and less likely for a user to misinterpret what will be called.
<!-- gh-linked-prs -->
### Linked PRs
* gh-123394
* gh-123664
* gh-123665
<!-- /gh-linked-prs -->
| c08ede27140121a919e884c7e8dfdce7b1a2e906 | b423ae6b0879ab1b53c6f517274c0d9e0f235d78 |
python/cpython | python__cpython-124935 | # Incorrect handling of negative `start` values on `PyUnicodeErrorObject`
# Bug report
### Bug description:
Found when implementing #123343. We have:
```C
int
PyUnicodeEncodeError_GetStart(PyObject *exc, Py_ssize_t *start)
{
Py_ssize_t size;
PyObject *obj = get_unicode(((PyUnicodeErrorObject *)exc)->object,
"object");
if (!obj)
return -1;
*start = ((PyUnicodeErrorObject *)exc)->start;
size = PyUnicode_GET_LENGTH(obj);
if (*start<0)
*start = 0; /*XXX check for values <0*/
if (*start>=size)
*start = size-1;
Py_DECREF(obj);
return 0;
}
```
The line `*start = size-1` might set `start` to `-1` when `start = 0`, in which case this leads to assertion failures when the index is used normally.
### CPython versions tested on:
CPython main branch
### Operating systems tested on:
Linux
<!-- gh-linked-prs -->
### Linked PRs
* gh-124935
* gh-125098
* gh-125099
* gh-123380
* gh-127739
<!-- /gh-linked-prs -->
| ba14dfafd97d1fd03938ac8ddec4ca5b2f12985d | 19984fe024bfd90649f1c36b78c9abf3ed72b27d |
python/cpython | python__cpython-123457 | # The canvas cannot be cleared after running turtledemo clock
# Bug report
### Bug description:
**First, run turtledemo clock. Then stop**
<img width="710" alt="2024-08-27 095034" src="https://github.com/user-attachments/assets/4dbe25e9-cbda-4d3d-be9e-ede39ed2af03">
When the clock stops running, the date appears, and the clear button becomes unusable. After switching to other files, the date still remains visible. Even after other files finish, pressing the clear button still cannot clear the date, but it can clear the drawings of the current file.
<img width="710" alt="2024-08-27 095211" src="https://github.com/user-attachments/assets/95df1a10-8124-4816-b4b7-fdce3a58b722">
<!-- gh-linked-prs -->
### Linked PRs
* gh-123457
* gh-125653
* gh-125656
<!-- /gh-linked-prs -->
| c124577ebe915a00de4033c0f7fa7c47621d79e0 | 528bbab96feadbfabb798547e5bb2ad52070fb73 |
python/cpython | python__cpython-123387 | # CONTAINS_OP can provide the operation name
# Feature or enhancement
### Proposal:
When referring to the ```in``` and ```not in``` operator, the dis module does not display in ```COMPARE_OP``` which operator is being used
```python
>>> dis.dis('a in b')
0 0 RESUME 0
1 2 LOAD_NAME 0 (a)
4 LOAD_NAME 1 (b)
6 CONTAINS_OP 0
8 RETURN_VALUE
>>> dis.dis('a not in b')
0 0 RESUME 0
1 2 LOAD_NAME 0 (a)
4 LOAD_NAME 1 (b)
6 CONTAINS_OP 1
8 RETURN_VALUE
```
But if we look at the output of many other operators, we see explicit notation there:
```
>>> dis.dis('a + b')
0 0 RESUME 0
1 2 LOAD_NAME 0 (a)
4 LOAD_NAME 1 (b)
6 BINARY_OP 0 (+)
10 RETURN_VALUE
>>> dis.dis('a==b')
0 0 RESUME 0
1 2 LOAD_NAME 0 (a)
4 LOAD_NAME 1 (b)
6 COMPARE_OP 40 (==)
10 RETURN_VALUE
```
### Has this already been discussed elsewhere?
No response given
### Links to previous discussion of this feature:
_No response_
<!-- gh-linked-prs -->
### Linked PRs
* gh-123387
<!-- /gh-linked-prs -->
| 6a7765b9fad8bf67e2c118b637a516c5e6c42349 | 2231286d78d328c2f575e0b05b16fe447d1656d6 |
python/cpython | python__cpython-123346 | # Improve the documentation of `fnmatch`
The implementation of `fnmatch.fnmatch` calls `os.path.normcase` on both the filename and the pattern, also allowing path-like objects. On the other hand, `fnmatch.filter` call `os.path.normcase` to normalize the pattern as well as `os.path.normcase` on the filenames being iterated over, but only on non-POSIX platforms.
Following the discussion on #123215, we decided not to change the runtime behaviour (i.e. do not call `os.fspath`) but simply clarify the documentation. Inconsistencies remain between platforms where non-POSIX platforms will not get a TypeError if they use path-like objects in `fnmatch.filter`. We will also not document `fnmatch.fnmatch` as accepting path-like objects.
Related:
- #123135
- https://github.com/python/cpython/issues/123215#issuecomment-2308763569
- https://github.com/python/typeshed/pull/12522
<!-- gh-linked-prs -->
### Linked PRs
* gh-123346
* gh-128775
* gh-128776
<!-- /gh-linked-prs -->
| 29fe8072cf404b891dde9c1d415095edddbe19de | b00e1254fc00941bf91e41138940e73fd22e1cbf |
python/cpython | python__cpython-123377 | # AST optimizer skips PEP 696 type parameter defaults
# Bug report
### Bug description:
```
>>> dis.dis("def f[T = 1 + 2](): pass")
... snip ...
L1: LOAD_CONST 0 (1)
LOAD_CONST 1 (2)
BINARY_OP 0 (+)
... snip ...
```
cc @Eclips4. This is easy to fix but it might be better to wait for #122667 so we can test the fix better.
### CPython versions tested on:
CPython main branch
### Operating systems tested on:
_No response_
<!-- gh-linked-prs -->
### Linked PRs
* gh-123377
* gh-123427
<!-- /gh-linked-prs -->
| be083cee34d62ae860acac70dfa078fc5c96ade3 | 9e108b8719752a0a2e390eeeaa8f52391f75120d |
python/cpython | python__cpython-123353 | # `tkinter.Event` is not subscriptable at runtime but generic in stub file
# Bug report
### Bug description:
```python
import tkinter
tkinter.Event[tkinter.Canvas] # TypeError: 'type' object is not subscriptable
```
This has been briefly discussed at https://github.com/python/typeshed/issues/12591
It would be great if this problem (a little more detailed version [here](https://mypy.readthedocs.io/en/stable/runtime_troubles.html#using-classes-that-are-generic-in-stubs-but-not-at-runtime)) could be fixed in the entire standard library. As of right now, the inconsistency of class subscription support is just way too confusing for developers.
### CPython versions tested on:
3.8, 3.9, 3.10, 3.11, 3.12, 3.13, CPython main branch
### Operating systems tested on:
Linux, Windows
<!-- gh-linked-prs -->
### Linked PRs
* gh-123353
<!-- /gh-linked-prs -->
| 42a818912bdb367c4ec2b7d58c18db35f55ebe3b | 64af2b29d2fcc4c4a305f970b6e81e7e79643b33 |
python/cpython | python__cpython-123348 | # dis: IS_OP should provide the name of the op
# Feature or enhancement
### Proposal:
`dis` output does not show which `IS_OP` is being used (0 = `is`, 1 = `is not`):
```
>>> dis.dis("a is b")
0 RESUME 0
1 LOAD_NAME 0 (a)
LOAD_NAME 1 (b)
IS_OP 0
RETURN_VALUE
>>> dis.dis("a is not b")
0 RESUME 0
1 LOAD_NAME 0 (a)
LOAD_NAME 1 (b)
IS_OP 1
RETURN_VALUE
```
For comparison:
```
>>> dis.dis("a > b")
0 RESUME 0
1 LOAD_NAME 0 (a)
LOAD_NAME 1 (b)
COMPARE_OP 132 (>)
RETURN_VALUE
```
(Not planning to work on this myself.)
### 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-123348
<!-- /gh-linked-prs -->
| 1eed0f968f5f44d6a13403c1676298a322cbfbad | 7bd6ebf696efcd5cf8e4e7946f9d8d8aee05664c |
python/cpython | python__cpython-123323 | # `PyOS_Readline` crashes in a multi-threaded race
# Crash report
### What happened?
The second breakpoint segfaults on Windows (==access violation).
```python
import asyncio
async def main():
def inner():
breakpoint()
pass
asyncio.create_task(asyncio.to_thread(inner))
asyncio.create_task(asyncio.to_thread(inner))
asyncio.ensure_future(main())
asyncio.get_event_loop().run_forever()
```
Core of the problem is in the myreadline.c module.
Implementing a fix...
### CPython versions tested on:
3.12, CPython main branch
### Operating systems tested on:
Windows
### Output from running 'python -VV' on the command line:
_No response_
<!-- gh-linked-prs -->
### Linked PRs
* gh-123323
* gh-123676
* gh-123677
* gh-123690
* gh-123798
<!-- /gh-linked-prs -->
| a4562fedadb73fe1e978dece65c3bcefb4606678 | c530ce1e9d336b81c053a5985444b4553fdd7050 |
python/cpython | python__cpython-123355 | # pickletools.dis() doesn't allow redefinition of memo items while pickle itself doesn't mind
# Bug report
### Bug description:
pickletools' disassembler has a [check here](https://github.com/python/cpython/blob/main/Lib/pickletools.py#L2497) that doesn't allow memo indices to be redefined, while the pickle.Unpickler doesn't care about it, [an existing item is handled without complaint here](https://github.com/python/cpython/blob/main/Modules/_pickle.c#L1538). FWIW, [the opcode doc](https://github.com/python/cpython/blob/main/Lib/pickletools.py#L1827) doesn't mention a restriction either.
Such pickles aren't produced by the Pickler, but it is strange for a debug tool to be more restrictive than the thing it is supposed to help debug. (I found this while fuzzing a non-Python unpickling library.) I think the check in pickletools L2497 can just be removed. A warning could also be emitted, but that would be the first such warning in pickletools.
### CPython versions tested on:
3.12
### Operating systems tested on:
Linux
<!-- gh-linked-prs -->
### Linked PRs
* gh-123355
* gh-123374
* gh-123533
* gh-123534
<!-- /gh-linked-prs -->
| e5a567b0a721c26c79530249d9aa159afbd11955 | 5332d989af45378e6ae99aeda72bfa82042b8659 |
python/cpython | python__cpython-123298 | # CPython does not record and propagate linker flags to LDCXXSHARED in sysconfig
CPython records and propagates several compilation-related flags from the time CPython is built, which in turn are used by `distutils` and `setuptools` to pass them to extension modules.
Unfortunately after https://github.com/pypa/distutils/pull/228, `distutils` now introduced a new `LDCXXSHARED`, and are using that in preference to `LDSHARED` when linking C++ code. We do set `LDCXXSHARED` but we don't propagate `LDFLAGS` to that variable if the user has set in the environment.
This is a problem because many distributions use the old variable `LDFLAGS` to propagate linker flags to extension modules (such as hardening and configuration flags) and now these are silently failing for C++ extension modules.
<!-- gh-linked-prs -->
### Linked PRs
* gh-123298
* gh-123319
* gh-123320
<!-- /gh-linked-prs -->
| c535a49e9260ad0fac022474f6381836051c9758 | 249b083ed8b3cfdff30bf578d7f9d3c5e982a4eb |
python/cpython | python__cpython-123276 | # PYTHON_GIL=1 and -Xgil=1 should work in non-free-threading builds
# Bug report
### Bug description:
In a non-free-threading build of Python 3.13, using environment variables or CLI arguments to ensure the GIL is used results in an error:
```console
$ PYTHON_GIL=1 python3.13
Fatal Python error: config_read_gil: PYTHON_GIL / -X gil are not supported by this build
Python runtime state: preinitialized
$ python3.13 -Xgil=1
Fatal Python error: config_read_gil: PYTHON_GIL / -X gil are not supported by this build
Python runtime state: preinitialized
```
This is user-hostile behavior that makes it more difficult to write tests and set up test environments. It makes sense that `PYTHON_GIL=0` or `-Xgil=0` must fail for non-free-threading builds, but there's no reason why a user requesting that the GIL be enabled in a build where the GIL is always enabled should be an error rather than a no-op.
I bumped into this while working on the test suite for [PyStack](https://pypi.org/project/pystack/), where it has forced me into this nasty hack:
```py
@pytest.fixture(autouse=True)
def enable_gil_if_free_threading(python, monkeypatch):
_, python_executable = python
proc = subprocess.run([python_executable, "-Xgil=1", "-cpass"], capture_output=True)
free_threading = proc.returncode == 0
if free_threading:
monkeypatch.setenv("PYTHON_GIL", "1")
```
instead of what I had originally wanted to do:
```py
@pytest.fixture(autouse=True)
def enable_gil_if_free_threading(monkeypatch):
monkeypatch.setenv("PYTHON_GIL", "1")
```
### CPython versions tested on:
3.13
### Operating systems tested on:
Linux
<!-- gh-linked-prs -->
### Linked PRs
* gh-123276
* gh-123753
* gh-123754
* gh-123755
<!-- /gh-linked-prs -->
| 84ad264ce602fb263a46a4536377bdc830eea81e | 42f52431e9961d5236b33a68af16cca07b74d02c |
python/cpython | python__cpython-123272 | # Builtin zip method is not safe under free-threading
# Bug report
### Bug description:
A common optimization technique (used in `zip_next`) for methods generating tuples is to keep an internal reference to the returned tuple and when the method is called again check whether the internal tuple has reference count 1. If the refcount is one, the tuple can be re-used. Under the free-threading build this is not safe: after the check on the reference count another thread can perform the same check and also re-use the tuple. This can lead to a double decref on the items of the tuple replaced and a double incref (memory leak) on the items of the tuple being set.
Some options to address this:
- Stop the internal tracking of the tuple. This affects performance of zip when the tuple can be re-used
- Lock the entire zip object during a call to zip_next. This is expensive, also for the single-threaded case.
- Use an atomic "check refcount equals one and conditionally increment" method. This could be less expensive than locking the entire object, but maybe this method is not available or almost as expensive as locking the object.
A minimal example reproducing the issue is added as a test in #123272. It shows the issue when executed with a free-threading debug build.
### CPython versions tested on:
CPython main branch
### Operating systems tested on:
Windows
<!-- gh-linked-prs -->
### Linked PRs
* gh-123272
<!-- /gh-linked-prs -->
| 7e38e6745d2f9ee235d934ab7f3c6b3085be2b70 | d24d1c986d2c55933f89c6b73b2e618448115f54 |
python/cpython | python__cpython-123354 | # zipfile.Path regression
# Bug report
### Bug description:
#122906 introduced a regression with directories that look like Windows drive letters (on Linux):
```python
>>> import io, zipfile
>>> zf = zipfile.ZipFile(io.BytesIO(), "w")
>>> zf.writestr("d:/foo", "bar")
>>> zf.extractall("a")
>>> open("a/d:/foo").read()
'bar'
>>> p = zipfile.Path(zf)
>>> x = p / "d" / "foo"
>>> y = p / "d:" / "foo"
>>> list(p.iterdir()) # before: [Path(None, 'd:/')]
[Path(None, 'd/')]
>>> p.root.namelist() # before: ['d:/foo', 'd:/']
['d/foo', 'd/']
>>> x.exists() # before: False
True
>>> y.exists() # before: True
False
>>> zf.extractall("b") # before: worked like above
KeyError: "There is no item named 'd/foo' in the archive"
>>> x.read_text() # before: FileNotFoundError
KeyError: "There is no item named 'd/foo' in the archive"
>>> y.read_text() # before: worked
FileNotFoundError: ...
```
This is the result of `_sanitize()` unconditionally treating a directory that looks like a drive letter as such and removing the colon, regardless of operating system:
https://github.com/python/cpython/blob/58fdb169c8a93925541fecc74ba73c566147f2ca/Lib/zipfile/_path/__init__.py#L141
Whereas `_extract_member()` uses `os.path.splitdrive()` (which is a no-op on Linux):
https://github.com/python/cpython/blob/58fdb169c8a93925541fecc74ba73c566147f2ca/Lib/zipfile/__init__.py#L1807
### CPython versions tested on:
3.12
### Operating systems tested on:
Linux
<!-- gh-linked-prs -->
### Linked PRs
* gh-123354
* gh-123410
* gh-123411
* gh-123425
* gh-123426
* gh-123432
* gh-123433
<!-- /gh-linked-prs -->
| 2231286d78d328c2f575e0b05b16fe447d1656d6 | 7e38e6745d2f9ee235d934ab7f3c6b3085be2b70 |
python/cpython | python__cpython-123255 | # Improve `tuple` C-API docs with better error info
There are multiple functions which do not declare:
- That they can return `NULL`
- That they also set an exception on error
I will send a PR.
<!-- gh-linked-prs -->
### Linked PRs
* gh-123255
* gh-123415
* gh-123416
<!-- /gh-linked-prs -->
| 6f563e364d1a7902417573f842019746a79cdc1b | 6a7765b9fad8bf67e2c118b637a516c5e6c42349 |
python/cpython | python__cpython-123244 | # `_decimal` leaks references
# Bug report
### Bug description:
The following leaks can be seen since a43cc3fa1ffebfd15eff2c6d8e5433a17969e348, fb0d9b9ac1ec3ea13fae8b8ef6a4f0a5a80482b3:
```py
>python -X showrefcount -c "import _decimal"
[7117 refs, 4232 blocks]
```
### CPython versions tested on:
3.13, CPython main branch
### Operating systems tested on:
Windows
<!-- gh-linked-prs -->
### Linked PRs
* gh-123244
* gh-123280
<!-- /gh-linked-prs -->
| 5ff638f1b53587b9f912a18fc776a2a141fd7bed | 556e8556849cb9df0666629b0f564b5dd203344c |
python/cpython | python__cpython-124557 | # ModuleType.__annotations__ and type.__annotations__ result in AttributeError
# Bug report
### Bug description:
If you call dir() on ModuleType or type, it shows `__annotations__` as one of the attributes. However, when you attempt to access that attribute, for ModuleType you get `AttributeError: type object 'module' has no attribute '__annotations__'` and for type you get `AttributeError: type object 'type' has no attribute '__annotations__'`.
```python
>>> from types import ModuleType
>>> dir(ModuleType)
['__annotations__', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__']
>>> ModuleType.__annotations__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: type object 'module' has no attribute '__annotations__'
>>>
>>> dir(type)
['__abstractmethods__', '__annotations__', '__base__', '__bases__', '__basicsize__', '__call__', '__class__', '__delattr__', '__dict__', '__dictoffset__', '__dir__', '__doc__', '__eq__', '__flags__', '__format__', '__ge__', '__getattribute__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__instancecheck__', '__itemsize__', '__le__', '__lt__', '__module__', '__mro__', '__name__', '__ne__', '__new__', '__or__', '__prepare__', '__qualname__', '__reduce__', '__reduce_ex__', '__repr__', '__ror__', '__setattr__', '__sizeof__', '__str__', '__subclasscheck__', '__subclasses__', '__subclasshook__', '__text_signature__', '__weakrefoffset__', 'mro']
>>> type.__annotations__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: type object 'type' has no attribute '__annotations__'
```
I found this bug because I have a method that iterates over the attributes returned from dir and gets each attribute. After upgrading from Python 3.8 to 3.11, this caused an interesting failure. I would expect that attributes returned by dir() would be accessible and not result in an AttributeError.
### CPython versions tested on:
3.11, 3.13
### Operating systems tested on:
Linux
<!-- gh-linked-prs -->
### Linked PRs
* gh-124557
* gh-124562
* gh-124569
<!-- /gh-linked-prs -->
| 99b23c64de301c9e77add6b0d8e60118ef807840 | bc543936ab4ca3625bd7cbeac97faa47f5fd93dc |
python/cpython | python__cpython-123274 | # input audit hook is not called from new repl
# Bug report
### Bug description:
sorry, another pretty strange corner case that probably doesn't matter, but I still wanted to report it.
In the new repl, calling `input` does not trigger the audit-hook for `input` any more, because the builtin is replaced with a pyrepl-specific function:
```pycon
cfbolz@triacontahedron:~/projects/cpython$ ./python
Python 3.14.0a0 (heads/main-dirty:3d7b1a526d8, Aug 22 2024, 14:55:23) [GCC 13.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> def audithook(name, *args):
... if "input" in name: print(name, args)
...
>>> import sys
>>> sys.addaudithook(audithook)
>>> input()
abcdef
'abcdef'
>>>
```
Here's the old behaviour:
``` pycon
cfbolz@triacontahedron:~/projects/cpython$ python3
Python 3.11.6 (main, Apr 10 2024, 17:26:07) [GCC 13.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> def audithook(name, *args):
... if "input" in name: print(name, args)
...
>>> sys.addaudithook(audithook)
>>> input()
builtins.input ((None,),)
abc
builtins.input/result (('abc',),)
'abc'
```
### CPython versions tested on:
3.13, CPython main branch
### Operating systems tested on:
Linux
<!-- gh-linked-prs -->
### Linked PRs
* gh-123274
* gh-123737
<!-- /gh-linked-prs -->
| aa1339aaaa6363c38186defaa079d069b4cb08b2 | 327463aef173a1cb9659bccbecfff4530bbe6bbf |
python/cpython | python__cpython-123236 | # "Deferred by Instruction" stats don't add up.
# Bug report
### Bug description:
The "Deferred by instruction" [stats](https://github.com/faster-cpython/benchmarking-public/blob/main/results/bm-20240819-3.14.0a0-e077b20-PYTHON_UOPS/bm-20240819-azure-x86_64-python-e077b201f49a6007ddad-3.14.0a0-e077b20-pystats.md#deferred-by-instruction) should add up to the total "Not specialized" total in [Specialization effectiveness](https://github.com/faster-cpython/benchmarking-public/blob/main/results/bm-20240819-3.14.0a0-e077b20-PYTHON_UOPS/bm-20240819-azure-x86_64-python-e077b201f49a6007ddad-3.14.0a0-e077b20-pystats.md#specialization-effectiveness) but they don't come close.
In the current latest stats "Not specialized" total is ~8.8 billion, but the "deferred by instruction" adds up to only ~4 billion.
### CPython versions tested on:
CPython main branch
### Operating systems tested on:
_No response_
<!-- gh-linked-prs -->
### Linked PRs
* gh-123236
* gh-123381
<!-- /gh-linked-prs -->
| 0b0f7befaddb2b5eff2811398a0f0d4604a82a90 | 5fce482c9a9d18d36c8177bdd0028cd2fef9f09f |
python/cpython | python__cpython-123263 | # New valgrind warning in Python 3.12.5
# Bug report
### Bug description:
I’ve just started seeing a Valgrind (1:3.18.1-1ubuntu2) warning in a Linux (ubuntu-22.04) Github test that started happening today when the Python version changed from 3.12.4 to 3.12.5.
The test is the pytest test suite in PyMuPDF - see https://github.com/pymupdf/PyMuPDF/actions/workflows/test-valgrind.yml.
There were no changes to PyMuPDF or MuPDF when the Valgrind warning appeared and Valgrind itself and pytest versions have also not changed. So it looks like the only change is Python itself.
```
Conditional jump or move depends on uninitialised value(s)
at 0x4A66154: tok_get_fstring_mode (/home/runner/work/_temp/SourceCode/Parser/tokenizer.c:2705)
by 0x4A63925: tok_get (/home/runner/work/_temp/SourceCode/Parser/tokenizer.c:2857)
by 0x4A63925: _PyTokenizer_Get (/home/runner/work/_temp/SourceCode/Parser/tokenizer.c:2862)
by 0x4A5282D: _PyPegen_fill_token (/home/runner/work/_temp/SourceCode/Parser/pegen.c:298)
by 0x4A62BAF: fstring_replacement_field_rule (/home/runner/work/_temp/SourceCode/Parser/parser.c:15914)
by 0x4A58F7A: fstring_middle_rule (/home/runner/work/_temp/SourceCode/Parser/parser.c:15858)
by 0x4A58F7A: _loop0_114_rule (/home/runner/work/_temp/SourceCode/Parser/parser.c:32096)
by 0x4A58F7A: fstring_rule (/home/runner/work/_temp/SourceCode/Parser/parser.c:16193)
by 0x4A58F7A: _tmp_259_rule (/home/runner/work/_temp/SourceCode/Parser/parser.c:40681)
by 0x4A58F7A: _loop1_115_rule (/home/runner/work/_temp/SourceCode/Parser/parser.c:32163)
by 0x4A58F7A: strings_rule (/home/runner/work/_temp/SourceCode/Parser/parser.c:16294)
by 0x4A580A7: atom_rule (/home/runner/work/_temp/SourceCode/Parser/parser.c:14690)
by 0x4A60048: primary_raw (/home/runner/work/_temp/SourceCode/Parser/parser.c:14328)
by 0x4A5FCE8: primary_rule (/home/runner/work/_temp/SourceCode/Parser/parser.c:14126)
by 0x4A5F731: await_primary_rule (/home/runner/work/_temp/SourceCode/Parser/parser.c:14080)
by 0x4A5F731: power_rule (/home/runner/work/_temp/SourceCode/Parser/parser.c:13956)
by 0x4A5F731: factor_rule (/home/runner/work/_temp/SourceCode/Parser/parser.c:13906)
by 0x4A5ECDE: term_raw (/home/runner/work/_temp/SourceCode/Parser/parser.c:13747)
by 0x4A5E9C0: term_rule (/home/runner/work/_temp/SourceCode/Parser/parser.c:13509)
by 0x4A5E80A: sum_raw (/home/runner/work/_temp/SourceCode/Parser/parser.c:13391)
by 0x4A5E80A: sum_rule (/home/runner/work/_temp/SourceCode/Parser/parser.c:13342)
```
I can look at creating a cut-down reproducer if required.
Thanks,
\- Julian
### CPython versions tested on:
3.12
### Operating systems tested on:
Linux
<!-- gh-linked-prs -->
### Linked PRs
* gh-123263
* gh-123264
* gh-123265
<!-- /gh-linked-prs -->
| adc5190014efcf7b7a4c5dfc9998faa8345527ed | 0b0f7befaddb2b5eff2811398a0f0d4604a82a90 |
python/cpython | python__cpython-123281 | # _pyrepl.readline._ReadlineWrapper.get_line_buffer should return a `str`, not a `bytes` object
# Bug report
### Bug description:
`_pyrepl.readline._ReadlineWrapper.get_line_buffer` should return a `str`, not a `bytes` object, because `readline.get_line_buffer` also returns an `str`, not a `bytes`.
this has very little effect in CPython, but in PyPy it causes various problem, because we don't have a `readline` module at all, and use `_pyrepl.readline` instead.
I'm working on a PR.
### CPython versions tested on:
3.13, CPython main branch
### Operating systems tested on:
_No response_
<!-- gh-linked-prs -->
### Linked PRs
* gh-123281
* gh-123293
* gh-123302
* gh-123313
<!-- /gh-linked-prs -->
| ca18ff2a34435faa557f7f9d4d3a554dadb05e50 | c4ee4e756a311f03633723445299bde90eb7b79c |
python/cpython | python__cpython-123214 | # Element.extend hides exceptions from underlying generators.
# Bug report
### Bug description:
```python
>>> from xml.etree.ElementTree import Element
>>> Element("a").extend(Element("a") for i in range(10)) # works
>>> Element("a").extend(1/0 for i in range(10)) # throws unrelated TypeError
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: expected sequence, not "generator"
```
C-implementation only bug.
Submitting a patch...
### CPython versions tested on:
3.12, 3.13, CPython main branch
### Operating systems tested on:
macOS, Windows
<!-- gh-linked-prs -->
### Linked PRs
* gh-123214
* gh-123257
* gh-123258
<!-- /gh-linked-prs -->
| 90b6d0e0f8f07d7443695e14a18488cb499d3b4d | a64aa47302bad05c4cd2e98d54e39a33722bf54f |
python/cpython | python__cpython-123417 | # `super` builtin class
# Documentation
I found the leading sentence in this paragraph a little misleading:
https://github.com/python/cpython/blob/ec89620e5e147ba028a46dd695ef073a72000b84/Doc/library/functions.rst?plain=1#L1961
because if the `object_or_type` is an object, it won't have `__mro__` attribute. The attribute should be `object.__class__.__mro__`.
On the other hand, if `object_or_type` is a type (class), then `__mro__` attribute does exist.
<!-- gh-linked-prs -->
### Linked PRs
* gh-123417
* gh-123732
* gh-123733
<!-- /gh-linked-prs -->
| 327463aef173a1cb9659bccbecfff4530bbe6bbf | 092abc4060768f2ae8b7b9c133558bf05bfeff88 |
python/cpython | python__cpython-123206 | # New warnings: ` 'initializing': conversion from '__int64' to 'int', possible loss of data [D:\a\cpython\cpython\PCbuild\pythoncore.vcxproj]`
# Bug report
### Bug description:
Popped up in https://github.com/python/cpython/pull/123203/files
### CPython versions tested on:
CPython main branch
### Operating systems tested on:
Other
<!-- gh-linked-prs -->
### Linked PRs
* gh-123206
<!-- /gh-linked-prs -->
| 67f2c84bff06eb837fd5ca64466d79f038e22ef8 | d7ae4dc5c14bc014ca0c056dab54c86ba8f395cb |
python/cpython | python__cpython-123200 | # The stats for "deferred" instructions (tier 1 specialization) are incorrect.
From a recent stats run:
### Execution counts
LOAD_ATTR 577 million
### Specialization stats
#### LOAD_ATTR
deferred 837 million
The number of deferred `LOAD_ATTR`s cannot exceed the number of `LOAD_ATTR`s executed, but the stats say they do.
<!-- gh-linked-prs -->
### Linked PRs
* gh-123200
* gh-123222
<!-- /gh-linked-prs -->
| 7b26c4d1e3a856b9a377c57cffc3e7b3921d18bb | 1eba8bae9223600677dfa3a4ce8b7e4d2b8fd00d |
python/cpython | python__cpython-123190 | # New warnings: `./Modules/blake2module.c:314:18: warning: unused variable 'st' [-Wunused-variable]`
# Bug report
### Bug description:
```bash
admin@Admins-MacBook-Air ~/P/cpython (main)> make -j
gcc -I./Modules/_hacl/include -fno-strict-overflow -Wsign-compare -g -Og -Wall -fstack-protector-strong -std=c11 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -Werror=implicit-function-declaration -fvisibility=hidden -I./Include/internal -I./Include/internal/mimalloc -I. -I./Include -c ./Modules/blake2module.c -o Modules/blake2module.o
./Modules/blake2module.c:314:18: warning: unused variable 'st' [-Wunused-variable]
Blake2State* st = blake2_get_state_from_type(type);
^
./Modules/blake2module.c:107:20: warning: unused function 'has_simd128' [-Wunused-function]
static inline bool has_simd128(cpu_flags *flags) {
^
./Modules/blake2module.c:113:20: warning: unused function 'has_simd256' [-Wunused-function]
static inline bool has_simd256(cpu_flags *flags) {
^
3 warnings generated.
gcc -bundle -undefined dynamic_lookup Modules/blake2module.o Modules/_hacl/libHacl_Hash_Blake2.a -o Modules/_blake2.cpython-314d-darwin.so
The necessary bits to build these optional modules were not found:
_gdbm
To find the necessary bits, look in configure.ac and config.log.
Checked 112 modules (34 built-in, 77 shared, 0 n/a on macosx-14.5-arm64, 0 disabled, 1 missing, 0 failed on import)
```
I have a PR ready to fix that.
### CPython versions tested on:
CPython main branch
### Operating systems tested on:
macOS
<!-- gh-linked-prs -->
### Linked PRs
* gh-123190
<!-- /gh-linked-prs -->
| 8aaf7525ab839c32966ee862363ad2543a721306 | f8a736b8e14ab839e1193cb1d3955b61c316d048 |
python/cpython | python__cpython-123194 | # ``test_dataclasses`` fails with a segfault in hunt refleaks mode
# Bug report
### Bug description:
```python
eclips4@nixos ~/p/p/cpython (main)> ./python -m test -R 3:3 test_dataclasses
Using random seed: 315532800
0:00:00 load avg: 0.96 Run 1 test sequentially in a single process
0:00:00 load avg: 0.96 [1/1] test_dataclasses
beginning 6 repetitions. Showing number of leaks (. for 0 or less, X for 10 or more)
123:456
XFatal Python error: Segmentation fault
Current thread 0x00007f14a8f07b80 (most recent call first):
File "/home/eclips4/programming/programming-languages/cpython/Lib/test/test_dataclasses/__init__.py", line 2217 in test_dataclasses_qualnames
File "/home/eclips4/programming/programming-languages/cpython/Lib/unittest/case.py", line 606 in _callTestMethod
File "/home/eclips4/programming/programming-languages/cpython/Lib/unittest/case.py", line 660 in run
File "/home/eclips4/programming/programming-languages/cpython/Lib/unittest/case.py", line 716 in __call__
File "/home/eclips4/programming/programming-languages/cpython/Lib/unittest/suite.py", line 122 in run
File "/home/eclips4/programming/programming-languages/cpython/Lib/unittest/suite.py", line 84 in __call__
File "/home/eclips4/programming/programming-languages/cpython/Lib/unittest/suite.py", line 122 in run
File "/home/eclips4/programming/programming-languages/cpython/Lib/unittest/suite.py", line 84 in __call__
File "/home/eclips4/programming/programming-languages/cpython/Lib/test/libregrtest/testresult.py", line 148 in run
File "/home/eclips4/programming/programming-languages/cpython/Lib/test/libregrtest/single.py", line 57 in _run_suite
File "/home/eclips4/programming/programming-languages/cpython/Lib/test/libregrtest/single.py", line 37 in run_unittest
File "/home/eclips4/programming/programming-languages/cpython/Lib/test/libregrtest/single.py", line 135 in test_func
File "/home/eclips4/programming/programming-languages/cpython/Lib/test/libregrtest/refleak.py", line 132 in runtest_refleak
File "/home/eclips4/programming/programming-languages/cpython/Lib/test/libregrtest/single.py", line 87 in regrtest_runner
File "/home/eclips4/programming/programming-languages/cpython/Lib/test/libregrtest/single.py", line 138 in _load_run_test
File "/home/eclips4/programming/programming-languages/cpython/Lib/test/libregrtest/single.py", line 181 in _runtest_env_changed_exc
File "/home/eclips4/programming/programming-languages/cpython/Lib/test/libregrtest/single.py", line 281 in _runtest
File "/home/eclips4/programming/programming-languages/cpython/Lib/test/libregrtest/single.py", line 310 in run_single_test
File "/home/eclips4/programming/programming-languages/cpython/Lib/test/libregrtest/main.py", line 363 in run_test
File "/home/eclips4/programming/programming-languages/cpython/Lib/test/libregrtest/main.py", line 397 in run_tests_sequentially
File "/home/eclips4/programming/programming-languages/cpython/Lib/test/libregrtest/main.py", line 541 in _run_tests
File "/home/eclips4/programming/programming-languages/cpython/Lib/test/libregrtest/main.py", line 576 in run_tests
File "/home/eclips4/programming/programming-languages/cpython/Lib/test/libregrtest/main.py", line 739 in main
File "/home/eclips4/programming/programming-languages/cpython/Lib/test/libregrtest/main.py", line 747 in main
File "/home/eclips4/programming/programming-languages/cpython/Lib/test/__main__.py", line 2 in <module>
File "/home/eclips4/programming/programming-languages/cpython/Lib/runpy.py", line 88 in _run_code
File "/home/eclips4/programming/programming-languages/cpython/Lib/runpy.py", line 198 in _run_module_as_main
Extension modules: _testinternalcapi (total: 1)
fish: Job 1, './python -m test -R 3:3 test_da…' terminated by signal SIGSEGV (Address boundary error)
```
### CPython versions tested on:
CPython main branch
### Operating systems tested on:
Linux
<!-- gh-linked-prs -->
### Linked PRs
* gh-123194
<!-- /gh-linked-prs -->
| 1eba8bae9223600677dfa3a4ce8b7e4d2b8fd00d | 90c892efeaae28bd849a01b42842f19dcd67b9f4 |
python/cpython | python__cpython-123267 | # Pasting long line in new REPL causes text to appear after >>>
# Bug report
### Bug description:
When I paste code that is one line and my REPL window is small the text that would not be shown because it is offscreen is displayed after pressing enter.
For example I am pasting
```Python
thread = threading.Thread(target=lambda: threading.current_thread().name == 'MainThread')
```
After I paste and then press enter to create the object I see
```Python
>>> read')
```
I can't remove the text or use the arrow keys to navigate the letters since the >>> prompt is empty.
When the window is smaller more text is shown after `>>>`.
```
>>> thread = threading.Thread(target=lambda: threading.current_thread()\
>
>>> name == 'MainThread')
```
### CPython versions tested on:
3.13
### Operating systems tested on:
macOS
<!-- gh-linked-prs -->
### Linked PRs
* gh-123267
* gh-123322
* gh-123324
* gh-123327
<!-- /gh-linked-prs -->
| fdb3f9b588f58f3cf95fe1dbf6e5b61ef525a351 | c535a49e9260ad0fac022474f6381836051c9758 |
python/cpython | python__cpython-123168 | # Add `show_positions` keyword argument to `dis.dis` and related functions
# Feature or enhancement
### Proposal:
`dis.dis` is a useful debugging tool when trying to debug minor bytecode compiler errors.
However it lacks one important feature, the ability to see the exact positions attached to instructions. It can only show line numbers.
We should add a `show_positions` keyword argument to show positions.
For example, the function:
```Py
def foo(x):
if x == 2:
return 1
```
disassembles to:
```
2 RESUME 0
3 LOAD_FAST 0 (x)
LOAD_CONST 1 (2)
COMPARE_OP 88 (bool(==))
POP_JUMP_IF_FALSE 1 (to L1)
4 RETURN_CONST 2 (1)
3 L1: RETURN_CONST 0 (None)
```
with `show_positions` it would disassemble to something like:
```
2:0-2:0 RESUME 0
3:7-3:8 LOAD_FAST 0 (x)
3:12-3:13 LOAD_CONST 1 (2)
3:7-3:13 COMPARE_OP 88 (bool(==))
3:7-3:13 POP_JUMP_IF_FALSE 1 (to L1)
4:15-4:16 RETURN_CONST 2 (1)
3:7-3:13 L1: RETURN_CONST 0 (None)
```
### 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-123168
* gh-123220
* gh-123808
<!-- /gh-linked-prs -->
| b1d3bd2e09d8b9d9f49cb8db9d47880ce2ec8f70 | 94036e43a83e8993f6ff42408759091b7c60d17d |
python/cpython | python__cpython-125607 | # Free-threaded builds with PGO fail to build on Windows
# Bug report
### Bug description:
I don't consider this a high-priority bug, since free threading remains experimental, however it does prevent us from getting accurate benchmarking figures for free-threaded builds on Windows.
Building with
```
PCbuild\build.bat --pgo --disable-gil -c Release
```
currently fails with an internal compiler error:
```
C:\actions-runner\_work\benchmarking\benchmarking\cpython\Python\ceval.c(761): fatal error C1001: Internal compiler error. [C:\actions-runner\_work\benchmarking\benchmarking\cpython\PCbuild\pythoncore.vcxproj]
(compiler file 'D:\a\_work\1\s\src\vctools\Compiler\Utc\src\p2\main.c', line 224)
To work around this problem, try simplifying or changing the program near the locations listed above.
If possible please provide a repro here: https://developercommunity.visualstudio.com
Please choose the Technical Support command on the Visual C++
Help menu, or open the Technical Support help file for more information
link!InvokeCompilerPass()+0x10e636
link!InvokeCompilerPass()+0x10e636
link!InvokeCompilerPass()+0x10e373
link!InvokeCompilerPass()+0x10b310
link!InvokeCompilerPass()+0x10b215
link!InvokeCompilerPass()+0x102cea
```
[Full build log here](https://gist.github.com/mdboom/a87219640036780d3dafff796d67d1fa)
### CPython versions tested on:
CPython main branch
### Operating systems tested on:
Windows
<!-- gh-linked-prs -->
### Linked PRs
* gh-125607
<!-- /gh-linked-prs -->
| 37986e830ba25d2c382988b06bbe27410596346c | dbcc5ac4709dfd8dfaf323d51f135f2218d14068 |
python/cpython | python__cpython-123151 | # The repr() of the input function is absurdly long
# Bug report
### Bug description:
```python
>>> input
<bound method _ReadlineWrapper.input of _ReadlineWrapper(f_in=0, f_out=1, reader=ReadlineAlikeReader(console=WindowsConsole(screen=['\x1b[1;35m>>> \x1b[0minput'], height=35, width=140), buffer=['i', 'n', 'p', 'u', 't'], pos=5, ps1='>>> ', ps2='>>> ', ps3='... ', ps4='', kill_ring=[], msg='', arg=None, dirty=False, finished=True, paste_mode=False, in_bracketed_paste=False, commands={'digit_arg': <class '_pyrepl.commands.digit_arg'>, 'digit-arg': <class '_pyrepl.commands.digit_arg'>, 'clear_screen': <class '_pyrepl.commands.clear_screen'>, 'clear-screen': <class '_pyrepl.commands.clear_screen'>, 'refresh': <class '_pyrepl.commands.refresh'>, 'repaint': <class '_pyrepl.commands.repaint'>, 'kill_line': <class '_pyrepl.commands.kill_line'>, 'kill-line': <class '_pyrepl.commands.kill_line'>, 'unix_line_discard': <class '_pyrepl.commands.unix_line_discard'>, 'unix-line-discard': <class '_pyrepl.commands.unix_line_discard'>, 'unix_word_rubout': <class '_pyrepl.commands.unix_word_rubout'>, 'unix-word-rubout': <class '_pyrepl.commands.unix_word_rubout'>, 'kill_word': <class '_pyrepl.commands.kill_word'>, 'kill-word': <class '_pyrepl.commands.kill_word'>, 'backward_kill_word': <class '_pyrepl.commands.backward_kill_word'>, 'backward-kill-word': <class '_pyrepl.commands.backward_kill_word'>, 'yank': <class '_pyrepl.commands.yank'>, 'yank_pop': <class '_pyrepl.commands.yank_pop'>, 'yank-pop': <class '_pyrepl.commands.yank_pop'>, 'interrupt': <class '_pyrepl.commands.interrupt'>, 'ctrl_c': <class '_pyrepl.commands.ctrl_c'>, 'ctrl-c': <class '_pyrepl.commands.ctrl_c'>, 'suspend': <class '_pyrepl.commands.suspend'>, 'up': <class '_pyrepl.commands.up'>, 'down': <class '_pyrepl.commands.down'>, 'left': <class '_pyrepl.commands.left'>, 'right': <class '_pyrepl.commands.right'>, 'beginning_of_line': <class '_pyrepl.commands.beginning_of_line'>, 'beginning-of-line': <class '_pyrepl.commands.beginning_of_line'>, 'end_of_line': <class '_pyrepl.commands.end_of_line'>, 'end-of-line': <class '_pyrepl.commands.end_of_line'>, 'home': <class '_pyrepl.commands.home'>, 'end': <class '_pyrepl.commands.end'>, 'forward_word': <class '_pyrepl.commands.forward_word'>, 'forward-word': <class '_pyrepl.commands.forward_word'>, 'backward_word': <class '_pyrepl.commands.backward_word'>, 'backward-word': <class '_pyrepl.commands.backward_word'>, 'self_insert': <class '_pyrepl.completing_reader.self_insert'>, 'self-insert': <class '_pyrepl.completing_reader.self_insert'>, 'insert_nl': <class '_pyrepl.commands.insert_nl'>, 'insert-nl': <class '_pyrepl.commands.insert_nl'>, 'transpose_characters': <class '_pyrepl.commands.transpose_characters'>, 'transpose-characters': <class '_pyrepl.commands.transpose_characters'>, 'backspace': <class '_pyrepl.commands.backspace'>, 'delete': <class '_pyrepl.commands.delete'>, 'accept': <class '_pyrepl.commands.accept'>, 'help': <class '_pyrepl.commands.help'>, 'invalid_key': <class '_pyrepl.commands.invalid_key'>, 'invalid-key': <class '_pyrepl.commands.invalid_key'>, 'invalid_command': <class '_pyrepl.commands.invalid_command'>, 'invalid-command': <class '_pyrepl.commands.invalid_command'>, 'show_history': <class '_pyrepl.commands.show_history'>, 'show-history': <class '_pyrepl.commands.show_history'>, 'paste_mode': <class '_pyrepl.commands.paste_mode'>, 'paste-mode': <class '_pyrepl.commands.paste_mode'>, 'enable_bracketed_paste': <class '_pyrepl.commands.enable_bracketed_paste'>, 'enable-bracketed-paste': <class '_pyrepl.commands.enable_bracketed_paste'>, 'disable_bracketed_paste': <class '_pyrepl.commands.disable_bracketed_paste'>, 'disable-bracketed-paste': <class '_pyrepl.commands.disable_bracketed_paste'>, 'complete': <class '_pyrepl.completing_reader.complete'>, 'next_history': <class '_pyrepl.historical_reader.next_history'>, 'next-history': <class '_pyrepl.historical_reader.next_history'>, 'previous_history': <class '_pyrepl.historical_reader.previous_history'>, 'previous-history': <class '_pyrepl.historical_reader.previous_history'>, 'restore_history': <class '_pyrepl.historical_reader.restore_history'>, 'restore-history': <class '_pyrepl.historical_reader.restore_history'>, 'first_history': <class '_pyrepl.historical_reader.first_history'>, 'first-history': <class '_pyrepl.historical_reader.first_history'>, 'last_history': <class '_pyrepl.historical_reader.last_history'>, 'last-history': <class '_pyrepl.historical_reader.last_history'>, 'yank_arg': <class '_pyrepl.historical_reader.yank_arg'>, 'yank-arg': <class '_pyrepl.historical_reader.yank_arg'>, 'forward_history_isearch': <class '_pyrepl.historical_reader.forward_history_isearch'>, 'forward-history-isearch': <class '_pyrepl.historical_reader.forward_history_isearch'>, 'reverse_history_isearch': <class '_pyrepl.historical_reader.reverse_history_isearch'>, 'reverse-history-isearch': <class '_pyrepl.historical_reader.reverse_history_isearch'>, 'isearch_end': <class '_pyrepl.historical_reader.isearch_end'>, 'isearch-end': <class '_pyrepl.historical_reader.isearch_end'>, 'isearch_add_character': <class '_pyrepl.historical_reader.isearch_add_character'>, 'isearch-add-character': <class '_pyrepl.historical_reader.isearch_add_character'>, 'isearch_cancel': <class '_pyrepl.historical_reader.isearch_cancel'>, 'isearch-cancel': <class '_pyrepl.historical_reader.isearch_cancel'>, 'isearch_backspace': <class '_pyrepl.historical_reader.isearch_backspace'>, 'isearch-backspace': <class '_pyrepl.historical_reader.isearch_backspace'>, 'isearch_forwards': <class '_pyrepl.historical_reader.isearch_forwards'>, 'isearch-forwards': <class '_pyrepl.historical_reader.isearch_forwards'>, 'isearch_backwards': <class '_pyrepl.historical_reader.isearch_backwards'>, 'isearch-backwards': <class '_pyrepl.historical_reader.isearch_backwards'>, 'operate_and_get_next': <class '_pyrepl.historical_reader.operate_and_get_next'>, 'operate-and-get-next': <class '_pyrepl.historical_reader.operate_and_get_next'>, 'maybe_accept': <class '_pyrepl.readline.maybe_accept'>, 'maybe-accept': <class '_pyrepl.readline.maybe_accept'>, 'backspace_dedent': <class '_pyrepl.readline.backspace_dedent'>, 'backspace-dedent': <class '_pyrepl.readline.backspace_dedent'>}, last_command=<class '_pyrepl.readline.maybe_accept'>, syntax_table={'\x00': 2, '\x01': 2, '\x02': 2, '\x03': 2, '\x04': 2, '\x05': 2, '\x06': 2, '\x07': 2, '\x08': 2, '\t': 2, '\n': 0, '\x0b': 2, '\x0c': 2, '\r': 2, '\x0e': 2, '\x0f': 2, '\x10': 2, '\x11': 2, '\x12': 2, '\x13': 2, '\x14': 2, '\x15': 2, '\x16': 2, '\x17': 2, '\x18': 2, '\x19': 2, '\x1a': 2, '\x1b': 2, '\x1c': 2, '\x1d': 2, '\x1e': 2, '\x1f': 2, ' ': 0, '!': 2, '"': 2, '#': 2, '$': 2, '%': 2, '&': 2, "'": 2, '(': 2, ')': 2, '*': 2, '+': 2, ',': 2, '-': 2, '.': 2, '/': 2, '0': 1, '1': 1, '2': 1, '3': 1, '4': 1, '5': 1, '6': 1, '7': 1, '8': 1, '9': 1, ':': 2, ';': 2, '<': 2, '=': 2, '>': 2, '?': 2, '@': 2, 'A': 1, 'B': 1, 'C': 1, 'D': 1, 'E': 1, 'F': 1, 'G': 1, 'H': 1, 'I': 1, 'J': 1, 'K': 1, 'L': 1, 'M': 1, 'N': 1, 'O': 1, 'P': 1, 'Q': 1, 'R': 1, 'S': 1, 'T': 1, 'U': 1, 'V': 1, 'W': 1, 'X': 1, 'Y': 1, 'Z': 1, '[': 2, '\\': 2, ']': 2, '^': 2, '_': 2, '`': 2, 'a': 1, 'b': 1, 'c': 1, 'd': 1, 'e': 1, 'f': 1, 'g': 1, 'h': 1, 'i': 1, 'j': 1, 'k': 1, 'l': 1, 'm': 1, 'n': 1, 'o': 1, 'p': 1, 'q': 1, 'r': 1, 's': 1, 't': 1, 'u': 1, 'v': 1, 'w': 1, 'x': 1, 'y': 1, 'z': 1, '{': 2, '|': 2, '}': 2, '~': 2, '\x7f': 2, '\x80': 2, '\x81': 2, '\x82': 2, '\x83': 2, '\x84': 2, '\x85': 2, '\x86': 2, '\x87': 2, '\x88': 2, '\x89': 2, '\x8a': 2, '\x8b': 2, '\x8c': 2, '\x8d': 2, '\x8e': 2, '\x8f': 2, '\x90': 2, '\x91': 2, '\x92': 2, '\x93': 2, '\x94': 2, '\x95': 2, '\x96': 2, '\x97': 2, '\x98': 2, '\x99': 2, '\x9a': 2, '\x9b': 2, '\x9c': 2, '\x9d': 2, '\x9e': 2, '\x9f': 2, '\xa0': 2, '¡': 2, '¢': 2, '£': 2, '¤': 2, '¥': 2, '¦': 2, '§': 2, '¨': 2, '©': 2, 'ª': 1, '«': 2, '¬': 2, '\xad': 2, '®': 2, '¯': 2, '°': 2, '±': 2, '²': 1, '³': 1, '´': 2, 'µ': 1, '¶': 2, '·': 2, '¸': 2, '¹': 1, 'º': 1, '»': 2, '¼': 1, '½': 1, '¾': 1, '¿': 2, 'À': 1, 'Á': 1, 'Â': 1, 'Ã': 1, 'Ä': 1, 'Å': 1, 'Æ': 1, 'Ç': 1, 'È': 1, 'É': 1, 'Ê': 1, 'Ë': 1, 'Ì': 1, 'Í': 1, 'Î': 1, 'Ï': 1, 'Ð': 1, 'Ñ': 1, 'Ò': 1, 'Ó': 1, 'Ô': 1, 'Õ': 1, 'Ö': 1, '×': 2, 'Ø': 1, 'Ù': 1, 'Ú': 1, 'Û': 1, 'Ü': 1, 'Ý': 1, 'Þ': 1, 'ß': 1, 'à': 1, 'á': 1, 'â': 1, 'ã': 1, 'ä': 1, 'å': 1, 'æ': 1, 'ç': 1, 'è': 1, 'é': 1, 'ê': 1, 'ë': 1, 'ì': 1, 'í': 1, 'î': 1, 'ï': 1, 'ð': 1, 'ñ': 1, 'ò': 1, 'ó': 1, 'ô': 1, 'õ': 1, 'ö': 1, '÷': 2, 'ø': 1, 'ù': 1, 'ú': 1, 'û': 1, 'ü': 1, 'ý': 1, 'þ': 1, 'ÿ': 1}, keymap=(('\\C-a', 'beginning-of-line'), ('\\C-b', 'left'), ('\\C-c', 'interrupt'), ('\\C-d', 'delete'), ('\\C-e', 'end-of-line'), ('\\C-f', 'right'), ('\\C-g', 'cancel'), ('\\C-h', 'backspace'), ('\\C-j', 'accept'), ('\\<return>', 'accept'), ('\\C-k', 'kill-line'), ('\\C-l', 'clear-screen'), ('\\C-m', 'accept'), ('\\C-t', 'transpose-characters'), ('\\C-u', 'unix-line-discard'), ('\\C-w', 'unix-word-rubout'), ('\\C-x\\C-u', 'upcase-region'), ('\\C-y', 'yank'), ('\\C-z', 'suspend'), ('\\M-b', 'backward-word'), ('\\M-c', 'capitalize-word'), ('\\M-d', 'kill-word'), ('\\M-f', 'forward-word'), ('\\M-l', 'downcase-word'), ('\\M-t', 'transpose-words'), ('\\M-u', 'upcase-word'), ('\\M-y', 'yank-pop'), ('\\M--', 'digit-arg'), ('\\M-0', 'digit-arg'), ('\\M-1', 'digit-arg'), ('\\M-2', 'digit-arg'), ('\\M-3', 'digit-arg'), ('\\M-4', 'digit-arg'), ('\\M-5', 'digit-arg'), ('\\M-6', 'digit-arg'), ('\\M-7', 'digit-arg'), ('\\M-8', 'digit-arg'), ('\\M-9', 'digit-arg'), ('\\M-\\n', 'accept'), ('\\\\', 'self-insert'), ('\\x1b[200~', 'enable_bracketed_paste'), ('\\x1b[201~', 'disable_bracketed_paste'), ('\\x03', 'ctrl-c'), (' ', 'self-insert'), ('!', 'self-insert'), ('"', 'self-insert'), ('#', 'self-insert'), ('$', 'self-insert'), ('%', 'self-insert'), ('&', 'self-insert'), ("'", 'self-insert'), ('(', 'self-insert'), (')', 'self-insert'), ('*', 'self-insert'), ('+', 'self-insert'), (',', 'self-insert'), ('-', 'self-insert'), ('.', 'self-insert'), ('/', 'self-insert'), ('0', 'self-insert'), ('1', 'self-insert'), ('2', 'self-insert'), ('3', 'self-insert'), ('4', 'self-insert'), ('5', 'self-insert'), ('6', 'self-insert'), ('7', 'self-insert'), ('8', 'self-insert'), ('9', 'self-insert'), (':', 'self-insert'), (';', 'self-insert'), ('<', 'self-insert'), ('=', 'self-insert'), ('>', 'self-insert'), ('?', 'self-insert'), ('@', 'self-insert'), ('A', 'self-insert'), ('B', 'self-insert'), ('C', 'self-insert'), ('D', 'self-insert'), ('E', 'self-insert'), ('F', 'self-insert'), ('G', 'self-insert'), ('H', 'self-insert'), ('I', 'self-insert'), ('J', 'self-insert'), ('K', 'self-insert'), ('L', 'self-insert'), ('M', 'self-insert'), ('N', 'self-insert'), ('O', 'self-insert'), ('P', 'self-insert'), ('Q', 'self-insert'), ('R', 'self-insert'), ('S', 'self-insert'), ('T', 'self-insert'), ('U', 'self-insert'), ('V', 'self-insert'), ('W', 'self-insert'), ('X', 'self-insert'), ('Y', 'self-insert'), ('Z', 'self-insert'), ('[', 'self-insert'), (']', 'self-insert'), ('^', 'self-insert'), ('_', 'self-insert'), ('`', 'self-insert'), ('a', 'self-insert'), ('b', 'self-insert'), ('c', 'self-insert'), ('d', 'self-insert'), ('e', 'self-insert'), ('f', 'self-insert'), ('g', 'self-insert'), ('h', 'self-insert'), ('i', 'self-insert'), ('j', 'self-insert'), ('k', 'self-insert'), ('l', 'self-insert'), ('m', 'self-insert'), ('n', 'self-insert'), ('o', 'self-insert'), ('p', 'self-insert'), ('q', 'self-insert'), ('r', 'self-insert'), ('s', 'self-insert'), ('t', 'self-insert'), ('u', 'self-insert'), ('v', 'self-insert'), ('w', 'self-insert'), ('x', 'self-insert'), ('y', 'self-insert'), ('z', 'self-insert'), ('{', 'self-insert'), ('|', 'self-insert'), ('}', 'self-insert'), ('~', 'self-insert'), ('ª', 'self-insert'), ('µ', 'self-insert'), ('º', 'self-insert'), ('À', 'self-insert'), ('Á', 'self-insert'), ('Â', 'self-insert'), ('Ã', 'self-insert'), ('Ä', 'self-insert'), ('Å', 'self-insert'), ('Æ', 'self-insert'), ('Ç', 'self-insert'), ('È', 'self-insert'), ('É', 'self-insert'), ('Ê', 'self-insert'), ('Ë', 'self-insert'), ('Ì', 'self-insert'), ('Í', 'self-insert'), ('Î', 'self-insert'), ('Ï', 'self-insert'), ('Ð', 'self-insert'), ('Ñ', 'self-insert'), ('Ò', 'self-insert'), ('Ó', 'self-insert'), ('Ô', 'self-insert'), ('Õ', 'self-insert'), ('Ö', 'self-insert'), ('Ø', 'self-insert'), ('Ù', 'self-insert'), ('Ú', 'self-insert'), ('Û', 'self-insert'), ('Ü', 'self-insert'), ('Ý', 'self-insert'), ('Þ', 'self-insert'), ('ß', 'self-insert'), ('à', 'self-insert'), ('á', 'self-insert'), ('â', 'self-insert'), ('ã', 'self-insert'), ('ä', 'self-insert'), ('å', 'self-insert'), ('æ', 'self-insert'), ('ç', 'self-insert'), ('è', 'self-insert'), ('é', 'self-insert'), ('ê', 'self-insert'), ('ë', 'self-insert'), ('ì', 'self-insert'), ('í', 'self-insert'), ('î', 'self-insert'), ('ï', 'self-insert'), ('ð', 'self-insert'), ('ñ', 'self-insert'), ('ò', 'self-insert'), ('ó', 'self-insert'), ('ô', 'self-insert'), ('õ', 'self-insert'), ('ö', 'self-insert'), ('ø', 'self-insert'), ('ù', 'self-insert'), ('ú', 'self-insert'), ('û', 'self-insert'), ('ü', 'self-insert'), ('ý', 'self-insert'), ('þ', 'self-insert'), ('ÿ', 'self-insert'), ('\\<up>', 'up'), ('\\<down>', 'down'), ('\\<left>', 'left'), ('\\C-\\<left>', 'backward-word'), ('\\<right>', 'right'), ('\\C-\\<right>', 'forward-word'), ('\\<delete>', 'delete'), ('\\<backspace>', 'backspace'), ('\\M-\\<backspace>', 'backward-kill-word'), ('\\<end>', 'end-of-line'), ('\\<home>', 'beginning-of-line'), ('\\<f1>', 'help'), ('\\<f2>', 'show-history'), ('\\<f3>', 'paste-mode'), ('\\EOF', 'end'), ('\\EOH', 'home'), ('\\t', 'complete'), ('\\C-n', 'next-history'), ('\\C-p', 'previous-history'), ('\\C-o', 'operate-and-get-next'), ('\\C-r', 'reverse-history-isearch'), ('\\C-s', 'forward-history-isearch'), ('\\M-r', 'restore-history'), ('\\M-.', 'yank-arg'), ('\\<page down>', 'last-history'), ('\\<page up>', 'first-history'), ('\\n', 'maybe-accept'), ('\\<backspace>', 'backspace-dedent')), input_trans=<_pyrepl.input.KeymapTranslator object at 0x0000015EC6269400s=[], can_colorize=True, last_refresh_cache=Reader.RefreshCache(in_bracketed_paste=False, screen=['\x1b[1;35m>>> \x1b[0minput'], screeninfo=le=False, cmpltn_message_visible=False, cmpltn_menu_end=0, cmpltn_menu_choices=[], history=['vars()', 'vars().foo = 1', 'globals()', 'locals()', 'locals() is globals() is vars()', 'foo = 1', 'def fun():\n bar = 2\n print(vars())\n ', 'fun()', 'def fun():\n bar = 2\n print(dict(globals()).update(locals()))', 'fun()', 'def fun():\n bar = 2\n print(dict(**globals(), **locals()))', 'fun()', 'def fun():\n bar = 2\n print(dict(**__builtins__, **globals(), **locals()))', 'fun()', 'def fun():\n bar = 2\n print(dict(**vars(__builtins__), **globals(), **locals()))', 'fun()', 'def fun():\n bar = 2\n print(vars(__builtins__) | globals() | locals())', 'fun()', 'bar = 1', 'fun()', 'def fun():\n bar = 2\n print(vars(__builtins__) | globals() | locals())', 'fun()', 'for k, v in (vars(__builtins__) | globals() | locals()).items():\n print(f"{k}\\n{v}\\n")\n ', 'input'], historyi=23, next_history=None, transient_history={}, isearch_term='', isearch_direction='', isearch_start=(0, 0), isearch_trans=<_pyrepl.input.KeymapTranslator object at 0x0000015EC4963ED0>, yank_arg_i=0, yank_arg_yanked='', config=ReadlineConfig(readline_completer=<bound method Completer.complete of <rlcompleter.Completer object at 0x0000015EC6269940>>, completer_delims=frozenset({'$', '{', '"', '#', ',', ')', '!', '|', '%', '+', '~', ':', '?', '@', "'", '*', '^', '-', '(', '\t', '[', '}', '=', ' ', '/', '>', '\n', ';', '\\', '&', '`', '<', ']'})), more_lines=None, last_used_indentation=' '), saved_history_length=-1, startup_hook=None, config=ReadlineConfig(readline_completer=<bound method Completer.complete of <rlcompleter.Completer object at 0x0000015EC6269940>>, completer_delims=frozenset({'$', '{', '"', '#', ',', ')', '!', '|', '%', '+', '~', ':', '?', '@', "'", '*', '^', '-', '(', '\t', '[', '}', '=', ' ', '/', '>', '\n', ';', '\\', '&', '`', '<', ']'})))>
>>>
```
Yes, this is one incredibly long line.
This is bound to trip up a new user, and provides little of value to an experienced user. Its worth pruning the repr.
### CPython versions tested on:
3.13
### Operating systems tested on:
Windows
<!-- gh-linked-prs -->
### Linked PRs
* gh-123151
* gh-123157
<!-- /gh-linked-prs -->
| 833c58b81ebec84dc24ef0507f8c75fe723d9f66 | 48856ead6ae023b2819ee63cb6ff97a0976a2cc3 |
python/cpython | python__cpython-123173 | # Source locations too broad for list comprehension iterable expression
# Bug report
Reported here: https://github.com/python/cpython/pull/120330#issuecomment-2295256627
```python
class Foo:
def __iter__(self):
assert False
a = [x for x in Foo()]
```
output (Python 3.12.5):
```python
Traceback (most recent call last):
File "/home/frank/projects/executing/codi.py", line 5, in <module>
a = [x for x in Foo()]
^^^^^^^^^^^^^^^^^^
File "/home/frank/projects/executing/codi.py", line 3, in __iter__
assert False
^^^^^
AssertionError
```
<!-- gh-linked-prs -->
### Linked PRs
* gh-123173
* gh-123209
* gh-123210
* gh-123420
* gh-123435
* gh-123436
<!-- /gh-linked-prs -->
| ec89620e5e147ba028a46dd695ef073a72000b84 | a4fd7aa4a6420cef1c22ec64eab54d8aea41cc57 |
python/cpython | python__cpython-125426 | # Make description of presentation types `f` and `e` in format spec more clear
Some time ago I was reading docs of [format specification mini-language](https://docs.python.org/3/library/string.html#format-specification-mini-language) and got a bit confused with the description for presentation type `f`. Because of my misunderstanding, I created #111125 thinking there is an error in docs. There I got an explanation what was actually meant.
Here is the current description of type `f`:
> `'f'` -- Fixed-point notation. For a given precision `p`, formats the number as a decimal number with exactly `p` digits following the decimal point. With no precision given, uses a precision of 6 digits after the decimal point for [float](https://docs.python.org/3/library/functions.html#float), and uses a precision large enough to show all coefficient digits for [Decimal](https://docs.python.org/3/library/decimal.html#decimal.Decimal). If no digits follow the decimal point, the decimal point is also removed unless the `#` option is used.
The source of my confusion had come from the last sentence. I assumed that it refers to the case with no precision given mentioned in the previous sentence, but it actually refers to the case when `p` is zero. For comparison, the description of type `g` at first lists the case when no digits follow the decimal point, and then in a different paragraph lists the case with no precision given (I do not quote the description here because it is too large).
I suggest to rearrange two last sentences in descriptions of types `f` and `e` and maybe rephrase some parts. Here are two examples for type `f`.
Just rearrangement:
> `'f'` -- Fixed-point notation. For a given precision `p`, formats the number as a decimal number with exactly `p` digits following the decimal point. If no digits follow the decimal point, the decimal point is also removed unless the `#` option is used. With no precision given, uses a precision of 6 digits after the decimal point for [float](https://docs.python.org/3/library/functions.html#float), and uses a precision large enough to show all coefficient digits for [Decimal](https://docs.python.org/3/library/decimal.html#decimal.Decimal).
Rearranged sentences with edited 2nd sentence.
> `'f'` -- Fixed-point notation. For a given precision `p`, formats the number as a decimal number with exactly `p` digits following the decimal point. With a precision of `0`, the decimal point is removed unless the `#` option is used. With no precision given, uses a precision of 6 digits after the decimal point for [float](https://docs.python.org/3/library/functions.html#float), and uses a precision large enough to show all coefficient digits for [Decimal](https://docs.python.org/3/library/decimal.html#decimal.Decimal).
<!-- gh-linked-prs -->
### Linked PRs
* gh-125426
* gh-125428
* gh-125429
<!-- /gh-linked-prs -->
| cfc27bc50fe165330f2295f9ac0ad56ca5b0f31c | f1d33dbddd3496b062e1fbe024fb6d7b023a35f5 |
python/cpython | python__cpython-123131 | # Ambiguous invalid syntax error for a missing comma
# Bug report
### Bug description:
Trying to run the following code:
```python
dummy_call(
"dummy value"
foo="bar",
)
```
results in a `SyntaxError` that looks like:
```
File "...", line 2
"dummy value"
^^^
SyntaxError: invalid syntax. Perhaps you forgot a comma?
```
On 3.13+, the first three characters are also highlighted in red. I would expect the end of the line (where the comma should be) to be marked, the `foo=bar` line, or possibly the entire line.
Interestingly, if you remove the indentation, then the error looks as expected:
```
File "...", line 1
dummy_call("dummy value" foo="bar",)
^^^^^^^^^^^^^^^^^
SyntaxError: invalid syntax. Perhaps you forgot a comma?
```
### CPython versions tested on:
3.12, 3.13, CPython main branch
### Operating systems tested on:
Linux
<!-- gh-linked-prs -->
### Linked PRs
* gh-123131
* gh-123147
<!-- /gh-linked-prs -->
| 48856ead6ae023b2819ee63cb6ff97a0976a2cc3 | b6d0a40a42fa17d087e502245b29cde46368ac07 |
python/cpython | python__cpython-123111 | # Incorrect note about _Bool type in the struct module docs
Note from table of [format characters](https://docs.python.org/3.14/library/struct.html#format-characters) says: "The '?' conversion code corresponds to the _Bool type defined by C99. If this type is not available, it is simulated using a char. In standard mode, it is always represented by one byte."
Since a9296e7f3b, C99 bool's are required. So, either this could be removed or reduced to the first sentence.
<!-- gh-linked-prs -->
### Linked PRs
* gh-123111
* gh-123126
* gh-123127
<!-- /gh-linked-prs -->
| b0f462d4c808d6fb1d381bba4932acd8309c1f3b | 63603bca35798c166e1b8e0be76aef69217f8b1b |
python/cpython | python__cpython-123511 | # Stable ABI: `Objects/bytesobject.c:122: PyBytes_FromStringAndSize: Assertion '_Py_IsImmortal(op)' failed.`
# Crash report
### What happened?
While testing `qiskit`, I've found another crash in the stable ABI with 3.13. I've confirmed it with CPython 3.13 as of 3ab8eafbd94b82fe73995e165bb0e6ff5d67cdab.
To reproduce:
```
pip install qiskit pytest ddt
git clone https://github.com/Qiskit/qiskit/
cd qiskit
mv qiskit{,~} # hide the non-compiled package
pytest -s test/python/circuit/library/test_blueprintcircuit.py::TestBlueprintCircuit::test_global_phase_copied
```
Python traceback:
```pytb
========================================================= test session starts =========================================================
platform linux -- Python 3.13.0rc1, pytest-8.3.2, pluggy-1.5.0
rootdir: /tmp/qiskit
configfile: pyproject.toml
collected 1 item
test/python/circuit/library/test_blueprintcircuit.py python: Objects/bytesobject.c:122: PyBytes_FromStringAndSize: Assertion `_Py_IsImmortal(op)' failed.
Fatal Python error: Aborted
Current thread 0x00007f1add1ff740 (most recent call first):
File "/tmp/venv/lib/python3.13/site-packages/qiskit/circuit/quantumcircuit.py", line 3714 in copy_empty_like
File "/tmp/venv/lib/python3.13/site-packages/qiskit/circuit/library/blueprintcircuit.py", line 204 in copy_empty_like
File "/tmp/qiskit/test/python/circuit/library/test_blueprintcircuit.py", line 204 in test_global_phase_copied
File "/home/mgorny/git/cpython/Lib/unittest/case.py", line 606 in _callTestMethod
File "/home/mgorny/git/cpython/Lib/unittest/case.py", line 651 in run
File "/home/mgorny/git/cpython/Lib/unittest/case.py", line 707 in __call__
File "/tmp/venv/lib/python3.13/site-packages/_pytest/unittest.py", line 351 in runtest
File "/tmp/venv/lib/python3.13/site-packages/_pytest/runner.py", line 174 in pytest_runtest_call
File "/tmp/venv/lib/python3.13/site-packages/pluggy/_callers.py", line 103 in _multicall
File "/tmp/venv/lib/python3.13/site-packages/pluggy/_manager.py", line 120 in _hookexec
File "/tmp/venv/lib/python3.13/site-packages/pluggy/_hooks.py", line 513 in __call__
File "/tmp/venv/lib/python3.13/site-packages/_pytest/runner.py", line 242 in <lambda>
File "/tmp/venv/lib/python3.13/site-packages/_pytest/runner.py", line 341 in from_call
File "/tmp/venv/lib/python3.13/site-packages/_pytest/runner.py", line 241 in call_and_report
File "/tmp/venv/lib/python3.13/site-packages/_pytest/runner.py", line 132 in runtestprotocol
File "/tmp/venv/lib/python3.13/site-packages/_pytest/runner.py", line 113 in pytest_runtest_protocol
File "/tmp/venv/lib/python3.13/site-packages/pluggy/_callers.py", line 103 in _multicall
File "/tmp/venv/lib/python3.13/site-packages/pluggy/_manager.py", line 120 in _hookexec
File "/tmp/venv/lib/python3.13/site-packages/pluggy/_hooks.py", line 513 in __call__
File "/tmp/venv/lib/python3.13/site-packages/_pytest/main.py", line 362 in pytest_runtestloop
File "/tmp/venv/lib/python3.13/site-packages/pluggy/_callers.py", line 103 in _multicall
File "/tmp/venv/lib/python3.13/site-packages/pluggy/_manager.py", line 120 in _hookexec
File "/tmp/venv/lib/python3.13/site-packages/pluggy/_hooks.py", line 513 in __call__
File "/tmp/venv/lib/python3.13/site-packages/_pytest/main.py", line 337 in _main
File "/tmp/venv/lib/python3.13/site-packages/_pytest/main.py", line 283 in wrap_session
File "/tmp/venv/lib/python3.13/site-packages/_pytest/main.py", line 330 in pytest_cmdline_main
File "/tmp/venv/lib/python3.13/site-packages/pluggy/_callers.py", line 103 in _multicall
File "/tmp/venv/lib/python3.13/site-packages/pluggy/_manager.py", line 120 in _hookexec
File "/tmp/venv/lib/python3.13/site-packages/pluggy/_hooks.py", line 513 in __call__
File "/tmp/venv/lib/python3.13/site-packages/_pytest/config/__init__.py", line 175 in main
File "/tmp/venv/lib/python3.13/site-packages/_pytest/config/__init__.py", line 201 in console_main
File "/tmp/venv/bin/pytest", line 8 in <module>
Extension modules: numpy._core._multiarray_umath, numpy._core._multiarray_tests, numpy.linalg._umath_linalg, symengine.lib.symengine_wrapper, numpy.random._common, numpy.random.bit_generator, numpy.random._bounded_integers, numpy.random._mt19937, numpy.random.mtrand, numpy.random._philox, numpy.random._pcg64, numpy.random._sfc64, numpy.random._generator, scipy._lib._ccallback_c (total: 14)
Aborted (core dumped)
```
C backtrace:
```
(gdb) bt
#0 0x00007f88c9c9639c in ?? () from /usr/lib64/libc.so.6
#1 0x00007f88c9c3ec96 in raise () from /usr/lib64/libc.so.6
#2 0x00007f88ca0b6806 in faulthandler_fatal_error (signum=6) at ./Modules/faulthandler.c:338
#3 <signal handler called>
#4 0x00007f88c9c9639c in ?? () from /usr/lib64/libc.so.6
#5 0x00007f88c9c3ec96 in raise () from /usr/lib64/libc.so.6
#6 0x00007f88c9c268fa in abort () from /usr/lib64/libc.so.6
#7 0x00007f88c9c2681e in ?? () from /usr/lib64/libc.so.6
#8 0x00007f88c9c36fd6 in __assert_fail () from /usr/lib64/libc.so.6
#9 0x00007f88c9ee1a06 in PyBytes_FromStringAndSize (str=0x7f88ca37cd60 <_PyRuntime+78432> "a", size=1) at Objects/bytesobject.c:122
#10 0x00007f88c9f8b15e in unicode_encode_utf8 (unicode=0x7f88ca37cd38 <_PyRuntime+78392>,
error_handler=error_handler@entry=_Py_ERROR_UNKNOWN, errors=errors@entry=0x0) at Objects/unicodeobject.c:5340
#11 0x00007f88c9f98a30 in _PyUnicode_AsUTF8String (unicode=<optimized out>, errors=errors@entry=0x0) at Objects/unicodeobject.c:5428
#12 0x00007f88c9f98a47 in PyUnicode_AsUTF8String (unicode=<optimized out>) at Objects/unicodeobject.c:5435
#13 0x00007f88c7ee711e in <pyo3::pybacked::PyBackedStr as pyo3::conversion::FromPyObject>::extract_bound ()
from /tmp/venv/lib/python3.13/site-packages/qiskit/_accelerate.abi3.so
#14 0x00007f88c80a2c47 in qiskit_circuit::parameter_table::ParameterTable::track ()
from /tmp/venv/lib/python3.13/site-packages/qiskit/_accelerate.abi3.so
#15 0x00007f88c7f878ce in qiskit_circuit::circuit_data::CircuitData::set_global_phase ()
from /tmp/venv/lib/python3.13/site-packages/qiskit/_accelerate.abi3.so
#16 0x00007f88c7f86f0d in qiskit_circuit::circuit_data::CircuitData::new ()
from /tmp/venv/lib/python3.13/site-packages/qiskit/_accelerate.abi3.so
#17 0x00007f88c80b5a70 in qiskit_circuit::circuit_data::CircuitData::__pymethod___new____ ()
from /tmp/venv/lib/python3.13/site-packages/qiskit/_accelerate.abi3.so
#18 0x00007f88c7f510d4 in pyo3::impl_::trampoline::trampoline ()
from /tmp/venv/lib/python3.13/site-packages/qiskit/_accelerate.abi3.so
#19 0x00007f88c80933c1 in qiskit_circuit::circuit_data::<impl pyo3::impl_::pyclass::PyMethods<qiskit_circuit::circuit_data::CircuitData> for pyo3::impl_::pyclass::PyClassImplCollector<qiskit_circuit::circuit_data::CircuitData>>::py_methods::ITEMS::trampoline ()
from /tmp/venv/lib/python3.13/site-packages/qiskit/_accelerate.abi3.so
#20 0x00007f88c9f6e758 in type_call (self=0x565319729bb0, args=0x7f88c2a3c840, kwds=0x7f88c2a3d680) at Objects/typeobject.c:1978
#21 0x00007f88c9eea976 in _PyObject_MakeTpCall (tstate=tstate@entry=0x7f88ca3aebc0 <_PyRuntime+282816>,
callable=callable@entry=0x565319729bb0, args=args@entry=0x7f88ca51d608, nargs=<optimized out>,
keywords=keywords@entry=0x7f88c5f8d540) at Objects/call.c:242
#22 0x00007f88c9eeabc6 in _PyObject_VectorcallTstate (tstate=0x7f88ca3aebc0 <_PyRuntime+282816>,
callable=callable@entry=0x565319729bb0, args=args@entry=0x7f88ca51d608, nargsf=<optimized out>, nargsf@entry=9223372036854775810,
kwnames=kwnames@entry=0x7f88c5f8d540) at ./Include/internal/pycore_call.h:166
#23 0x00007f88c9eeac3b in PyObject_Vectorcall (callable=callable@entry=0x565319729bb0, args=args@entry=0x7f88ca51d608,
nargsf=9223372036854775810, kwnames=kwnames@entry=0x7f88c5f8d540) at Objects/call.c:327
#24 0x00007f88ca01692e in _PyEval_EvalFrameDefault (tstate=0x7f88ca3aebc0 <_PyRuntime+282816>, frame=0x7f88ca51d588, throwflag=0)
at Python/generated_cases.c.h:1500
#25 0x00007f88ca022a66 in _PyEval_EvalFrame (tstate=tstate@entry=0x7f88ca3aebc0 <_PyRuntime+282816>, frame=<optimized out>,
throwflag=throwflag@entry=0) at ./Include/internal/pycore_ceval.h:119
#26 0x00007f88ca022ba9 in _PyEval_Vector (tstate=0x7f88ca3aebc0 <_PyRuntime+282816>, func=func@entry=0x7f88c87b23e0,
locals=locals@entry=0x0, args=args@entry=0x7f88c3181be0, argcount=argcount@entry=1, kwnames=kwnames@entry=0x7f88c8f335e0)
at Python/ceval.c:1806
#27 0x00007f88c9eea7bf in _PyFunction_Vectorcall (func=0x7f88c87b23e0, stack=0x7f88c3181be0, nargsf=<optimized out>,
kwnames=0x7f88c8f335e0) at Objects/call.c:413
#28 0x00007f88c9eeda11 in _PyObject_VectorcallTstate (tstate=tstate@entry=0x7f88ca3aebc0 <_PyRuntime+282816>,
callable=callable@entry=0x7f88c87b23e0, args=args@entry=0x7f88c3181be0, nargsf=nargsf@entry=1,
kwnames=kwnames@entry=0x7f88c8f335e0) at ./Include/internal/pycore_call.h:168
#29 0x00007f88c9eedc09 in method_vectorcall (method=<optimized out>, args=0x7f88c3181be8, nargsf=<optimized out>,
kwnames=0x7f88c8f335e0) at Objects/classobject.c:62
#30 0x00007f88c9eec5d2 in _PyVectorcall_Call (tstate=tstate@entry=0x7f88ca3aebc0 <_PyRuntime+282816>,
func=0x7f88c9eeda93 <method_vectorcall>, callable=callable@entry=0x7f88c2a3cdc0,
tuple=tuple@entry=0x7f88ca37f318 <_PyRuntime+88088>, kwargs=kwargs@entry=0x7f88c31954c0) at Objects/call.c:285
#31 0x00007f88c9eec839 in _PyObject_Call (tstate=0x7f88ca3aebc0 <_PyRuntime+282816>, callable=callable@entry=0x7f88c2a3cdc0,
args=args@entry=0x7f88ca37f318 <_PyRuntime+88088>, kwargs=kwargs@entry=0x7f88c31954c0) at Objects/call.c:348
#32 0x00007f88c9eec883 in PyObject_Call (callable=callable@entry=0x7f88c2a3cdc0, args=args@entry=0x7f88ca37f318 <_PyRuntime+88088>,
kwargs=kwargs@entry=0x7f88c31954c0) at Objects/call.c:373
#33 0x00007f88ca0161ec in _PyEval_EvalFrameDefault (tstate=0x7f88ca3aebc0 <_PyRuntime+282816>, frame=0x7f88ca51d278, throwflag=0)
at Python/generated_cases.c.h:1353
#34 0x00007f88ca022a66 in _PyEval_EvalFrame (tstate=tstate@entry=0x7f88ca3aebc0 <_PyRuntime+282816>, frame=<optimized out>,
throwflag=throwflag@entry=0) at ./Include/internal/pycore_ceval.h:119
#35 0x00007f88ca022ba9 in _PyEval_Vector (tstate=0x7f88ca3aebc0 <_PyRuntime+282816>, func=func@entry=0x7f88c87b25c0,
locals=locals@entry=0x0, args=args@entry=0x7f88c842c038, argcount=argcount@entry=1, kwnames=kwnames@entry=0x7f88c8baf010)
at Python/ceval.c:1806
#36 0x00007f88c9eea7bf in _PyFunction_Vectorcall (func=0x7f88c87b25c0, stack=0x7f88c842c038, nargsf=<optimized out>,
kwnames=0x7f88c8baf010) at Objects/call.c:413
#37 0x00007f88c9eec310 in _PyObject_VectorcallDictTstate (tstate=tstate@entry=0x7f88ca3aebc0 <_PyRuntime+282816>,
callable=callable@entry=0x7f88c87b25c0, args=args@entry=0x7ffdb7758be0, nargsf=<optimized out>, nargsf@entry=1,
kwargs=kwargs@entry=0x7f88c8397940) at Objects/call.c:146
--Type <RET> for more, q to quit, c to continue without paging--c
#38 0x00007f88c9eec41b in _PyObject_Call_Prepend (tstate=tstate@entry=0x7f88ca3aebc0 <_PyRuntime+282816>,
callable=callable@entry=0x7f88c87b25c0, obj=obj@entry=0x7f88c2b57750, args=args@entry=0x7f88ca37f318 <_PyRuntime+88088>,
kwargs=kwargs@entry=0x7f88c8397940) at Objects/call.c:504
#39 0x00007f88c9f74087 in slot_tp_call (self=0x7f88c2b57750, args=0x7f88ca37f318 <_PyRuntime+88088>, kwds=0x7f88c8397940)
at Objects/typeobject.c:9534
#40 0x00007f88c9eea976 in _PyObject_MakeTpCall (tstate=tstate@entry=0x7f88ca3aebc0 <_PyRuntime+282816>,
callable=callable@entry=0x7f88c2b57750, args=args@entry=0x7f88ca51d258, nargs=<optimized out>,
keywords=keywords@entry=0x7f88c84a23e0) at Objects/call.c:242
#41 0x00007f88c9eeabc6 in _PyObject_VectorcallTstate (tstate=0x7f88ca3aebc0 <_PyRuntime+282816>,
callable=callable@entry=0x7f88c2b57750, args=args@entry=0x7f88ca51d258, nargsf=<optimized out>, nargsf@entry=9223372036854775808,
kwnames=kwnames@entry=0x7f88c84a23e0) at ./Include/internal/pycore_call.h:166
#42 0x00007f88c9eeac3b in PyObject_Vectorcall (callable=callable@entry=0x7f88c2b57750, args=args@entry=0x7f88ca51d258,
nargsf=9223372036854775808, kwnames=kwnames@entry=0x7f88c84a23e0) at Objects/call.c:327
#43 0x00007f88ca01692e in _PyEval_EvalFrameDefault (tstate=0x7f88ca3aebc0 <_PyRuntime+282816>, frame=0x7f88ca51d1e0, throwflag=0)
at Python/generated_cases.c.h:1500
#44 0x00007f88ca022a66 in _PyEval_EvalFrame (tstate=tstate@entry=0x7f88ca3aebc0 <_PyRuntime+282816>, frame=<optimized out>,
throwflag=throwflag@entry=0) at ./Include/internal/pycore_ceval.h:119
#45 0x00007f88ca022ba9 in _PyEval_Vector (tstate=0x7f88ca3aebc0 <_PyRuntime+282816>, func=func@entry=0x7f88c8baa0c0,
locals=locals@entry=0x0, args=args@entry=0x7f88c842c098, argcount=argcount@entry=1, kwnames=kwnames@entry=0x7f88c83da3e0)
at Python/ceval.c:1806
#46 0x00007f88c9eea7bf in _PyFunction_Vectorcall (func=0x7f88c8baa0c0, stack=0x7f88c842c098, nargsf=<optimized out>,
kwnames=0x7f88c83da3e0) at Objects/call.c:413
#47 0x00007f88c9eec310 in _PyObject_VectorcallDictTstate (tstate=tstate@entry=0x7f88ca3aebc0 <_PyRuntime+282816>,
callable=callable@entry=0x7f88c8baa0c0, args=args@entry=0x7ffdb7758fb0, nargsf=<optimized out>, nargsf@entry=1,
kwargs=kwargs@entry=0x7f88c2a1c240) at Objects/call.c:146
#48 0x00007f88c9eec41b in _PyObject_Call_Prepend (tstate=tstate@entry=0x7f88ca3aebc0 <_PyRuntime+282816>,
callable=callable@entry=0x7f88c8baa0c0, obj=obj@entry=0x7f88c84b7510, args=args@entry=0x7f88ca37f318 <_PyRuntime+88088>,
kwargs=kwargs@entry=0x7f88c2a1c240) at Objects/call.c:504
#49 0x00007f88c9f74087 in slot_tp_call (self=self@entry=0x7f88c84b7510, args=args@entry=0x7f88ca37f318 <_PyRuntime+88088>,
kwds=kwds@entry=0x7f88c2a1c240) at Objects/typeobject.c:9534
#50 0x00007f88c9eec797 in _PyObject_Call (tstate=0x7f88ca3aebc0 <_PyRuntime+282816>, callable=callable@entry=0x7f88c84b7510,
args=args@entry=0x7f88ca37f318 <_PyRuntime+88088>, kwargs=kwargs@entry=0x7f88c2a1c240) at Objects/call.c:361
#51 0x00007f88c9eec883 in PyObject_Call (callable=callable@entry=0x7f88c84b7510, args=args@entry=0x7f88ca37f318 <_PyRuntime+88088>,
kwargs=kwargs@entry=0x7f88c2a1c240) at Objects/call.c:373
#52 0x00007f88ca0161ec in _PyEval_EvalFrameDefault (tstate=0x7f88ca3aebc0 <_PyRuntime+282816>, frame=0x7f88ca51ce78, throwflag=0)
at Python/generated_cases.c.h:1353
#53 0x00007f88ca022a66 in _PyEval_EvalFrame (tstate=tstate@entry=0x7f88ca3aebc0 <_PyRuntime+282816>, frame=<optimized out>,
throwflag=throwflag@entry=0) at ./Include/internal/pycore_ceval.h:119
#54 0x00007f88ca022ba9 in _PyEval_Vector (tstate=0x7f88ca3aebc0 <_PyRuntime+282816>, func=func@entry=0x7f88c8baa0c0,
locals=locals@entry=0x0, args=args@entry=0x7f88c8467e78, argcount=argcount@entry=1, kwnames=kwnames@entry=0x7f88c86437c0)
at Python/ceval.c:1806
#55 0x00007f88c9eea7bf in _PyFunction_Vectorcall (func=0x7f88c8baa0c0, stack=0x7f88c8467e78, nargsf=<optimized out>,
kwnames=0x7f88c86437c0) at Objects/call.c:413
#56 0x00007f88c9eec310 in _PyObject_VectorcallDictTstate (tstate=tstate@entry=0x7f88ca3aebc0 <_PyRuntime+282816>,
callable=callable@entry=0x7f88c8baa0c0, args=args@entry=0x7ffdb7759330, nargsf=<optimized out>, nargsf@entry=1,
kwargs=kwargs@entry=0x7f88c83977c0) at Objects/call.c:146
#57 0x00007f88c9eec41b in _PyObject_Call_Prepend (tstate=tstate@entry=0x7f88ca3aebc0 <_PyRuntime+282816>,
callable=callable@entry=0x7f88c8baa0c0, obj=obj@entry=0x7f88c84b76a0, args=args@entry=0x7f88ca37f318 <_PyRuntime+88088>,
kwargs=kwargs@entry=0x7f88c83977c0) at Objects/call.c:504
#58 0x00007f88c9f74087 in slot_tp_call (self=0x7f88c84b76a0, args=0x7f88ca37f318 <_PyRuntime+88088>, kwds=0x7f88c83977c0)
at Objects/typeobject.c:9534
#59 0x00007f88c9eea976 in _PyObject_MakeTpCall (tstate=tstate@entry=0x7f88ca3aebc0 <_PyRuntime+282816>,
callable=callable@entry=0x7f88c84b76a0, args=args@entry=0x7f88ca51c900, nargs=<optimized out>,
keywords=keywords@entry=0x7f88c88868c0) at Objects/call.c:242
#60 0x00007f88c9eeabc6 in _PyObject_VectorcallTstate (tstate=0x7f88ca3aebc0 <_PyRuntime+282816>,
callable=callable@entry=0x7f88c84b76a0, args=args@entry=0x7f88ca51c900, nargsf=<optimized out>, nargsf@entry=9223372036854775808,
kwnames=kwnames@entry=0x7f88c88868c0) at ./Include/internal/pycore_call.h:166
#61 0x00007f88c9eeac3b in PyObject_Vectorcall (callable=callable@entry=0x7f88c84b76a0, args=args@entry=0x7f88ca51c900,
nargsf=9223372036854775808, kwnames=kwnames@entry=0x7f88c88868c0) at Objects/call.c:327
#62 0x00007f88ca01692e in _PyEval_EvalFrameDefault (tstate=0x7f88ca3aebc0 <_PyRuntime+282816>, frame=0x7f88ca51c880, throwflag=0)
at Python/generated_cases.c.h:1500
#63 0x00007f88ca022a66 in _PyEval_EvalFrame (tstate=tstate@entry=0x7f88ca3aebc0 <_PyRuntime+282816>, frame=<optimized out>,
throwflag=throwflag@entry=0) at ./Include/internal/pycore_ceval.h:119
#64 0x00007f88ca022ba9 in _PyEval_Vector (tstate=0x7f88ca3aebc0 <_PyRuntime+282816>, func=func@entry=0x7f88c8baa0c0,
locals=locals@entry=0x0, args=args@entry=0x7f88c5ed9818, argcount=argcount@entry=1, kwnames=kwnames@entry=0x7f88c83da380)
at Python/ceval.c:1806
#65 0x00007f88c9eea7bf in _PyFunction_Vectorcall (func=0x7f88c8baa0c0, stack=0x7f88c5ed9818, nargsf=<optimized out>,
kwnames=0x7f88c83da380) at Objects/call.c:413
#66 0x00007f88c9eec310 in _PyObject_VectorcallDictTstate (tstate=tstate@entry=0x7f88ca3aebc0 <_PyRuntime+282816>,
callable=callable@entry=0x7f88c8baa0c0, args=args@entry=0x7ffdb7759700, nargsf=<optimized out>, nargsf@entry=1,
kwargs=kwargs@entry=0x7f88c83a57c0) at Objects/call.c:146
#67 0x00007f88c9eec41b in _PyObject_Call_Prepend (tstate=tstate@entry=0x7f88ca3aebc0 <_PyRuntime+282816>,
callable=callable@entry=0x7f88c8baa0c0, obj=obj@entry=0x7f88c84b7790, args=args@entry=0x7f88ca37f318 <_PyRuntime+88088>,
kwargs=kwargs@entry=0x7f88c83a57c0) at Objects/call.c:504
#68 0x00007f88c9f74087 in slot_tp_call (self=0x7f88c84b7790, args=0x7f88ca37f318 <_PyRuntime+88088>, kwds=0x7f88c83a57c0)
at Objects/typeobject.c:9534
#69 0x00007f88c9eea976 in _PyObject_MakeTpCall (tstate=tstate@entry=0x7f88ca3aebc0 <_PyRuntime+282816>,
callable=callable@entry=0x7f88c84b7790, args=args@entry=0x7f88ca51c608, nargs=<optimized out>,
keywords=keywords@entry=0x7f88c89df760) at Objects/call.c:242
#70 0x00007f88c9eeabc6 in _PyObject_VectorcallTstate (tstate=0x7f88ca3aebc0 <_PyRuntime+282816>,
callable=callable@entry=0x7f88c84b7790, args=args@entry=0x7f88ca51c608, nargsf=<optimized out>, nargsf@entry=9223372036854775808,
kwnames=kwnames@entry=0x7f88c89df760) at ./Include/internal/pycore_call.h:166
#71 0x00007f88c9eeac3b in PyObject_Vectorcall (callable=callable@entry=0x7f88c84b7790, args=args@entry=0x7f88ca51c608,
nargsf=9223372036854775808, kwnames=kwnames@entry=0x7f88c89df760) at Objects/call.c:327
#72 0x00007f88ca01692e in _PyEval_EvalFrameDefault (tstate=0x7f88ca3aebc0 <_PyRuntime+282816>, frame=0x7f88ca51c5a0, throwflag=0)
at Python/generated_cases.c.h:1500
#73 0x00007f88ca022a66 in _PyEval_EvalFrame (tstate=tstate@entry=0x7f88ca3aebc0 <_PyRuntime+282816>, frame=<optimized out>,
throwflag=throwflag@entry=0) at ./Include/internal/pycore_ceval.h:119
#74 0x00007f88ca022ba9 in _PyEval_Vector (tstate=0x7f88ca3aebc0 <_PyRuntime+282816>, func=func@entry=0x7f88c8baa0c0,
locals=locals@entry=0x0, args=args@entry=0x7f88c8467598, argcount=argcount@entry=1, kwnames=kwnames@entry=0x7f88c8ef05b0)
at Python/ceval.c:1806
#75 0x00007f88c9eea7bf in _PyFunction_Vectorcall (func=0x7f88c8baa0c0, stack=0x7f88c8467598, nargsf=<optimized out>,
kwnames=0x7f88c8ef05b0) at Objects/call.c:413
#76 0x00007f88c9eec310 in _PyObject_VectorcallDictTstate (tstate=tstate@entry=0x7f88ca3aebc0 <_PyRuntime+282816>,
callable=callable@entry=0x7f88c8baa0c0, args=args@entry=0x7ffdb7759ad0, nargsf=<optimized out>, nargsf@entry=1,
kwargs=kwargs@entry=0x7f88c83bb780) at Objects/call.c:146
#77 0x00007f88c9eec41b in _PyObject_Call_Prepend (tstate=tstate@entry=0x7f88ca3aebc0 <_PyRuntime+282816>,
callable=callable@entry=0x7f88c8baa0c0, obj=obj@entry=0x7f88c84b6a20, args=args@entry=0x7f88ca37f318 <_PyRuntime+88088>,
kwargs=kwargs@entry=0x7f88c83bb780) at Objects/call.c:504
#78 0x00007f88c9f74087 in slot_tp_call (self=0x7f88c84b6a20, args=0x7f88ca37f318 <_PyRuntime+88088>, kwds=0x7f88c83bb780)
at Objects/typeobject.c:9534
#79 0x00007f88c9eea976 in _PyObject_MakeTpCall (tstate=tstate@entry=0x7f88ca3aebc0 <_PyRuntime+282816>,
callable=callable@entry=0x7f88c84b6a20, args=args@entry=0x7f88ca51c1d8, nargs=<optimized out>,
keywords=keywords@entry=0x7f88c89dfe20) at Objects/call.c:242
#80 0x00007f88c9eeabc6 in _PyObject_VectorcallTstate (tstate=0x7f88ca3aebc0 <_PyRuntime+282816>,
callable=callable@entry=0x7f88c84b6a20, args=args@entry=0x7f88ca51c1d8, nargsf=<optimized out>, nargsf@entry=9223372036854775808,
kwnames=kwnames@entry=0x7f88c89dfe20) at ./Include/internal/pycore_call.h:166
#81 0x00007f88c9eeac3b in PyObject_Vectorcall (callable=callable@entry=0x7f88c84b6a20, args=args@entry=0x7f88ca51c1d8,
nargsf=9223372036854775808, kwnames=kwnames@entry=0x7f88c89dfe20) at Objects/call.c:327
#82 0x00007f88ca01692e in _PyEval_EvalFrameDefault (tstate=0x7f88ca3aebc0 <_PyRuntime+282816>, frame=0x7f88ca51c120, throwflag=0)
at Python/generated_cases.c.h:1500
#83 0x00007f88ca022a66 in _PyEval_EvalFrame (tstate=tstate@entry=0x7f88ca3aebc0 <_PyRuntime+282816>, frame=<optimized out>,
throwflag=throwflag@entry=0) at ./Include/internal/pycore_ceval.h:119
#84 0x00007f88ca022ba9 in _PyEval_Vector (tstate=tstate@entry=0x7f88ca3aebc0 <_PyRuntime+282816>, func=func@entry=0x7f88c9bd54e0,
locals=locals@entry=0x7f88c8ef4780, args=args@entry=0x0, argcount=argcount@entry=0, kwnames=kwnames@entry=0x0)
at Python/ceval.c:1806
#85 0x00007f88ca022c7a in PyEval_EvalCode (co=co@entry=0x7f88c9b89830, globals=globals@entry=0x7f88c8ef4780,
locals=locals@entry=0x7f88c8ef4780) at Python/ceval.c:596
#86 0x00007f88ca08a764 in run_eval_code_obj (tstate=tstate@entry=0x7f88ca3aebc0 <_PyRuntime+282816>, co=co@entry=0x7f88c9b89830,
globals=globals@entry=0x7f88c8ef4780, locals=locals@entry=0x7f88c8ef4780) at Python/pythonrun.c:1292
#87 0x00007f88ca08a941 in run_mod (mod=mod@entry=0x5653193896f8, filename=filename@entry=0x7f88c8ef48f0,
globals=globals@entry=0x7f88c8ef4780, locals=locals@entry=0x7f88c8ef4780, flags=flags@entry=0x7ffdb7759ff8,
arena=arena@entry=0x7f88c9b1fd10, interactive_src=0x0, generate_new_source=0) at Python/pythonrun.c:1377
#88 0x00007f88ca08b1df in pyrun_file (fp=fp@entry=0x5653192eaa60, filename=filename@entry=0x7f88c8ef48f0, start=start@entry=257,
globals=globals@entry=0x7f88c8ef4780, locals=locals@entry=0x7f88c8ef4780, closeit=closeit@entry=1, flags=0x7ffdb7759ff8)
at Python/pythonrun.c:1210
#89 0x00007f88ca08cb1a in _PyRun_SimpleFileObject (fp=fp@entry=0x5653192eaa60, filename=filename@entry=0x7f88c8ef48f0,
closeit=closeit@entry=1, flags=flags@entry=0x7ffdb7759ff8) at Python/pythonrun.c:459
#90 0x00007f88ca08cd2a in _PyRun_AnyFileObject (fp=fp@entry=0x5653192eaa60, filename=filename@entry=0x7f88c8ef48f0,
closeit=closeit@entry=1, flags=flags@entry=0x7ffdb7759ff8) at Python/pythonrun.c:77
#91 0x00007f88ca0b281c in pymain_run_file_obj (program_name=program_name@entry=0x7f88c8f4d930,
filename=filename@entry=0x7f88c8ef48f0, skip_source_first_line=0) at Modules/main.c:409
#92 0x00007f88ca0b293d in pymain_run_file (config=config@entry=0x7f88ca3812b8 <_PyRuntime+96184>) at Modules/main.c:428
#93 0x00007f88ca0b34a7 in pymain_run_python (exitcode=exitcode@entry=0x7ffdb775a164) at Modules/main.c:696
#94 0x00007f88ca0b36fd in Py_RunMain () at Modules/main.c:775
#95 0x00007f88ca0b377e in pymain_main (args=args@entry=0x7ffdb775a1c0) at Modules/main.c:805
#96 0x00007f88ca0b3855 in Py_BytesMain (argc=<optimized out>, argv=<optimized out>) at Modules/main.c:829
#97 0x00005652f235b186 in main (argc=<optimized out>, argv=<optimized out>) at ./Programs/python.c:15
```
CC @davidhewitt (this seems to be another problem fixed by https://github.com/PyO3/pyo3/pull/4324)
### CPython versions tested on:
CPython main branch
### Operating systems tested on:
Linux
### Output from running 'python -VV' on the command line:
Python 3.13.0rc1 (main, Aug 16 2024, 17:36:06) [GCC 14.2.0]
<!-- gh-linked-prs -->
### Linked PRs
* gh-123511
* gh-123600
* gh-123602
* gh-123622
<!-- /gh-linked-prs -->
| f1a0d96f41db9dfa5d7f0b32e72f6f7301a86f91 | 22fdb8cf899d2dd29f2ac0bf61309af6809719fb |
python/cpython | python__cpython-123279 | # Make WeakSet safe against concurrent mutation across threads while iterating
# Bug report
Currently if a `WeakSet` is being iterated then it is not safe against concurrent additions of weakrefs by other threads, this leads to spurious `RuntimeError`s being raised as the underlying set might resize. The existing `_IterationGuard` doesn't protect against this case.
To solve this I propose that we don't rely on `_IterationGuard` but while iterating take a copy of the underlying set, this way it is safe against concurrent mutations from other threads as copying a set is an atomic operation. The following patch implements this and all the existing tests pass.
<details>
<summary>Patch</summary>
```patch
From 4f81fb16d9259e5b86c40d791a377aad1cff4dfb Mon Sep 17 00:00:00 2001
From: Kumar Aditya <kumaraditya@python.org>
Date: Sat, 17 Aug 2024 00:57:47 +0530
Subject: [PATCH] avoid _IterationGuard for WeakSet, use copy of the set
instead
---
Lib/_weakrefset.py | 53 +++++++++-------------------------------------
1 file changed, 10 insertions(+), 43 deletions(-)
diff --git a/Lib/_weakrefset.py b/Lib/_weakrefset.py
index 489eec714e0..2071755d71d 100644
--- a/Lib/_weakrefset.py
+++ b/Lib/_weakrefset.py
@@ -36,41 +36,26 @@ def __exit__(self, e, t, b):
class WeakSet:
def __init__(self, data=None):
self.data = set()
+
def _remove(item, selfref=ref(self)):
self = selfref()
if self is not None:
- if self._iterating:
- self._pending_removals.append(item)
- else:
- self.data.discard(item)
+ self.data.discard(item)
+
self._remove = _remove
- # A list of keys to be removed
- self._pending_removals = []
- self._iterating = set()
if data is not None:
self.update(data)
- def _commit_removals(self):
- pop = self._pending_removals.pop
- discard = self.data.discard
- while True:
- try:
- item = pop()
- except IndexError:
- return
- discard(item)
-
def __iter__(self):
- with _IterationGuard(self):
- for itemref in self.data:
- item = itemref()
- if item is not None:
- # Caveat: the iterator will keep a strong reference to
- # `item` until it is resumed or closed.
- yield item
+ for itemref in self.data.copy():
+ item = itemref()
+ if item is not None:
+ # Caveat: the iterator will keep a strong reference to
+ # `item` until it is resumed or closed.
+ yield item
def __len__(self):
- return len(self.data) - len(self._pending_removals)
+ return len(self.data)
def __contains__(self, item):
try:
@@ -83,21 +68,15 @@ def __reduce__(self):
return self.__class__, (list(self),), self.__getstate__()
def add(self, item):
- if self._pending_removals:
- self._commit_removals()
self.data.add(ref(item, self._remove))
def clear(self):
- if self._pending_removals:
- self._commit_removals()
self.data.clear()
def copy(self):
return self.__class__(self)
def pop(self):
- if self._pending_removals:
- self._commit_removals()
while True:
try:
itemref = self.data.pop()
@@ -108,18 +87,12 @@ def pop(self):
return item
def remove(self, item):
- if self._pending_removals:
- self._commit_removals()
self.data.remove(ref(item))
def discard(self, item):
- if self._pending_removals:
- self._commit_removals()
self.data.discard(ref(item))
def update(self, other):
- if self._pending_removals:
- self._commit_removals()
for element in other:
self.add(element)
@@ -136,8 +109,6 @@ def difference(self, other):
def difference_update(self, other):
self.__isub__(other)
def __isub__(self, other):
- if self._pending_removals:
- self._commit_removals()
if self is other:
self.data.clear()
else:
@@ -151,8 +122,6 @@ def intersection(self, other):
def intersection_update(self, other):
self.__iand__(other)
def __iand__(self, other):
- if self._pending_removals:
- self._commit_removals()
self.data.intersection_update(ref(item) for item in other)
return self
@@ -184,8 +153,6 @@ def symmetric_difference(self, other):
def symmetric_difference_update(self, other):
self.__ixor__(other)
def __ixor__(self, other):
- if self._pending_removals:
- self._commit_removals()
if self is other:
self.data.clear()
else:
--
2.45.2.windows.1
```
</details>
<!-- gh-linked-prs -->
### Linked PRs
* gh-123279
<!-- /gh-linked-prs -->
| 03f5abf15a20f6e623282a393bc2a0affac69bb0 | 6754566a51a5706e8c9da0094b892113311ba20c |
python/cpython | python__cpython-123088 | # ``test_unittest`` raises a ``DeprecationWarning``
# Bug report
### Bug description:
```python
eclips4@nixos ~/p/p/cpython (main) [SIGINT]> ./python -m test -q test_unittest
Using random seed: 315532800
0:00:00 load avg: 11.34 Run 1 test sequentially in a single process
/home/eclips4/programming/programming-languages/cpython/Lib/test/test_unittest/testmock/testasync.py:234: DeprecationWarning: 'asyncio.iscoroutinefunction' is deprecated and slated for removal in Python 3.16; use inspect.iscoroutinefunction() instead
self.assertTrue(iscoroutinefunction(spec))
/home/eclips4/programming/programming-languages/cpython/Lib/test/test_unittest/testmock/testasync.py:276: DeprecationWarning: 'asyncio.iscoroutinefunction' is deprecated and slated for removal in Python 3.16; use inspect.iscoroutinefunction() instead
self.assertTrue(iscoroutinefunction(mock_method))
/home/eclips4/programming/programming-languages/cpython/Lib/test/test_unittest/testmock/testasync.py:749: DeprecationWarning: 'asyncio.iscoroutinefunction' is deprecated and slated for removal in Python 3.16; use inspect.iscoroutinefunction() instead
self.assertFalse(iscoroutinefunction(instance.__aiter__))
/home/eclips4/programming/programming-languages/cpython/Lib/test/test_unittest/testmock/testasync.py:750: DeprecationWarning: 'asyncio.iscoroutinefunction' is deprecated and slated for removal in Python 3.16; use inspect.iscoroutinefunction() instead
self.assertFalse(iscoroutinefunction(mock_instance.__aiter__))
/home/eclips4/programming/programming-languages/cpython/Lib/test/test_unittest/testmock/testasync.py:752: DeprecationWarning: 'asyncio.iscoroutinefunction' is deprecated and slated for removal in Python 3.16; use inspect.iscoroutinefunction() instead
self.assertTrue(iscoroutinefunction(instance.__anext__))
/home/eclips4/programming/programming-languages/cpython/Lib/test/test_unittest/testmock/testasync.py:753: DeprecationWarning: 'asyncio.iscoroutinefunction' is deprecated and slated for removal in Python 3.16; use inspect.iscoroutinefunction() instead
self.assertTrue(iscoroutinefunction(mock_instance.__anext__))
/home/eclips4/programming/programming-languages/cpython/Lib/test/test_unittest/testmock/testasync.py:609: DeprecationWarning: 'asyncio.iscoroutinefunction' is deprecated and slated for removal in Python 3.16; use inspect.iscoroutinefunction() instead
self.assertTrue(iscoroutinefunction(m_mock.__aenter__))
/home/eclips4/programming/programming-languages/cpython/Lib/test/test_unittest/testmock/testasync.py:610: DeprecationWarning: 'asyncio.iscoroutinefunction' is deprecated and slated for removal in Python 3.16; use inspect.iscoroutinefunction() instead
self.assertTrue(iscoroutinefunction(m_mock.__aexit__))
/home/eclips4/programming/programming-languages/cpython/Lib/test/test_unittest/testmock/testasync.py:809: DeprecationWarning: 'asyncio.iscoroutinefunction' is deprecated and slated for removal in Python 3.16; use inspect.iscoroutinefunction() instead
self.assertTrue(iscoroutinefunction(mock.async_method))
/home/eclips4/programming/programming-languages/cpython/Lib/test/test_unittest/testmock/testasync.py:173: DeprecationWarning: 'asyncio.iscoroutinefunction' is deprecated and slated for removal in Python 3.16; use inspect.iscoroutinefunction() instead
self.assertTrue(iscoroutinefunction(mock))
/home/eclips4/programming/programming-languages/cpython/Lib/test/test_unittest/testmock/testasync.py:178: DeprecationWarning: 'asyncio.iscoroutinefunction' is deprecated and slated for removal in Python 3.16; use inspect.iscoroutinefunction() instead
self.assertTrue(iscoroutinefunction(mock))
/home/eclips4/programming/programming-languages/cpython/Lib/test/test_unittest/testmock/testasync.py:191: DeprecationWarning: 'asyncio.iscoroutinefunction' is deprecated and slated for removal in Python 3.16; use inspect.iscoroutinefunction() instead
self.assertTrue(iscoroutinefunction(mock))
/home/eclips4/programming/programming-languages/cpython/Lib/test/test_unittest/testmock/testasync.py:124: DeprecationWarning: 'asyncio.iscoroutinefunction' is deprecated and slated for removal in Python 3.16; use inspect.iscoroutinefunction() instead
self.assertTrue(iscoroutinefunction(mock_method))
/home/eclips4/programming/programming-languages/cpython/Lib/test/test_unittest/testmock/testasync.py:158: DeprecationWarning: 'asyncio.iscoroutinefunction' is deprecated and slated for removal in Python 3.16; use inspect.iscoroutinefunction() instead
self.assertTrue(iscoroutinefunction(test_async))
/home/eclips4/programming/programming-languages/cpython/Lib/test/test_unittest/testmock/testasync.py:63: DeprecationWarning: 'asyncio.iscoroutinefunction' is deprecated and slated for removal in Python 3.16; use inspect.iscoroutinefunction() instead
self.assertTrue(iscoroutinefunction(mock_method))
/home/eclips4/programming/programming-languages/cpython/Lib/test/test_unittest/testmock/testasync.py:433: DeprecationWarning: 'asyncio.iscoroutinefunction' is deprecated and slated for removal in Python 3.16; use inspect.iscoroutinefunction() instead
self.assertTrue(iscoroutinefunction(mock))
/home/eclips4/programming/programming-languages/cpython/Lib/test/test_unittest/testmock/testasync.py:438: DeprecationWarning: 'asyncio.iscoroutinefunction' is deprecated and slated for removal in Python 3.16; use inspect.iscoroutinefunction() instead
self.assertTrue(iscoroutinefunction(mock.async_method))
/home/eclips4/programming/programming-languages/cpython/Lib/test/test_unittest/testmock/testasync.py:439: DeprecationWarning: 'asyncio.iscoroutinefunction' is deprecated and slated for removal in Python 3.16; use inspect.iscoroutinefunction() instead
self.assertFalse(iscoroutinefunction(mock.normal_method))
== Tests result: SUCCESS ==
Total duration: 8.0 sec
Total tests: run=1,061 skipped=2
Total test files: run=1/1
Result: SUCCESS
```
### CPython versions tested on:
CPython main branch
### Operating systems tested on:
Linux
<!-- gh-linked-prs -->
### Linked PRs
* gh-123088
<!-- /gh-linked-prs -->
| e6d5ff55d0816d7f5eb45e49c810e936b09d2be7 | 35d8ac7cd7ed6cd3d84af721dce970da59bd5f68 |
python/cpython | python__cpython-123125 | # Remove `shutil.ExecError`
# Feature or enhancement
As of Python 3.5 / GH-64943 / a0934b2c1b939fdebee8dc18d49a0f6c52324773, `shutil.ExecError` exceptions are not raised in any circumstances. I propose that we delete the `ExecError` class and remove it from `__all__`.
<!-- gh-linked-prs -->
### Linked PRs
* gh-123125
<!-- /gh-linked-prs -->
| 9dbd12375561a393eaec4b21ee4ac568a407cdb0 | f88c14d412522587085ae039ebe70b91d5b4e226 |
python/cpython | python__cpython-123092 | # `STORE_ATTR_WITH_HINT` has potential use-after-free
# Bug report
The order of operations in `STORE_ATTR_WITH_HINT` differs from the dictionary implementation in a way that is not safe:
https://github.com/python/cpython/blob/35d8ac7cd7ed6cd3d84af721dce970da59bd5f68/Python/bytecodes.c#L2235-L2242
It's not safe to call `_PyObject_GC_MAY_BE_TRACKED(value)` after the `Py_XDECREF` call. The dictionary may hold the only strong reference to `value` in `ep->me_value`, and that can be modified during the `Py_XDECREF` call.
Note that `dictobject.c` does the tracking *before* modifying the dictionary -- not after it -- and so avoids this problem.
<!-- gh-linked-prs -->
### Linked PRs
* gh-123092
* gh-123235
* gh-123237
<!-- /gh-linked-prs -->
| 297f2e093ec95800ae2184330b8408c875523467 | 4abc1c1456413f3d2692257545a33bb16b24f900 |
python/cpython | python__cpython-123077 | # configparser: unable to create unnamed section
Hi, just chiming in because I really love this new feature - however, I haven't managed to create a new INI file from scratch with an unnamed section yet. Is this possible? Here are my futile attempts with configparser 7.0.0 from backports:
```
Python 3.12.4 (tags/v3.12.4:8e8a4ba, Jun 6 2024, 19:30:16) [MSC v.1940 64 bit (AMD64)] on win32
>>> from backports.configparser import UNNAMED_SECTION, ConfigParser
>>> cp = ConfigParser(allow_unnamed_section=True)
>>> cp.set(UNNAMED_SECTION, "option1", "hello world")
Traceback (most recent call last):
super().set(section, option, value)
raise NoSectionError(section) from None
backports.configparser.NoSectionError: No section: <UNNAMED_SECTION>
>>> cp.add_section(UNNAMED_SECTION)
File "C:\Users\kerling\AppData\Local\pypoetry\Cache\virtualenvs\non-package-mode-l42eA81v-py3.12\Lib\site-packages\backports\configparser\__init__.py", line 1294, in _validate_value_types
raise TypeError("section names must be strings")
TypeError: section names must be strings
>>> cp[UNNAMED_SECTION]["option1"] = "hello world"
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\kerling\AppData\Local\pypoetry\Cache\virtualenvs\non-package-mode-l42eA81v-py3.12\Lib\site-packages\backports\configparser\__init__.py", line 1070, in __getitem__
raise KeyError(key)
KeyError: <UNNAMED_SECTION>
>>> cp[UNNAMED_SECTION] = { "option1": "hello world" }
>>> cp.sections()
['<UNNAMED_SECTION>']
>>> import io
>>> fp = io.StringIO()
>>> cp.write(fp)
>>> fp.getvalue()
'[<UNNAMED_SECTION>]\noption1 = hello world\n\n'
```
_Originally posted by @mtnpke in https://github.com/python/cpython/issues/66449#issuecomment-2290906624_
<!-- gh-linked-prs -->
### Linked PRs
* gh-123077
<!-- /gh-linked-prs -->
| be257c58152e9b960827362b11c9ef2223fd6267 | c15bfa9a71c8b7ce7ff6d8486f51aab566e8d81d |
python/cpython | python__cpython-123167 | # sys.monitoring branch for match case mapping to `None`
# Bug report
### Bug description:
With the code from [PR 122564](https://github.com/python/cpython/pull/122564), the destination of the "not taken" branch out of line 9 below, offset 46, maps (through `co_locations()`) to `None`, making it difficult (if not impossible) to interpret for coverage:
```python
x = 0
v = 1
match v:
case 1:
if x < 0:
x = 1
case 2:
if x < 0:
x = 1
x += 1
```
Result:
```
0 0 RESUME 0
1 2 LOAD_CONST 0 (0)
4 STORE_NAME 0 (x)
2 6 LOAD_CONST 1 (1)
8 STORE_NAME 1 (v)
3 10 LOAD_NAME 1 (v)
4 12 COPY 1
14 LOAD_CONST 1 (1)
16 COMPARE_OP 88 (bool(==))
20 POP_JUMP_IF_FALSE 12 (to L2)
24 NOT_TAKEN
26 POP_TOP
5 28 LOAD_NAME 0 (x)
30 LOAD_CONST 0 (0)
32 COMPARE_OP 18 (bool(<))
36 POP_JUMP_IF_FALSE 3 (to L1)
40 NOT_TAKEN
6 42 LOAD_CONST 1 (1)
44 STORE_NAME 0 (x)
-- L1: 46 JUMP_FORWARD 15 (to L3)
7 L2: 48 LOAD_CONST 2 (2)
50 COMPARE_OP 88 (bool(==))
54 POP_JUMP_IF_FALSE 10 (to L3)
58 NOT_TAKEN
8 60 LOAD_NAME 0 (x)
62 LOAD_CONST 0 (0)
64 COMPARE_OP 18 (bool(<))
68 POP_JUMP_IF_FALSE 3 (to L3)
72 NOT_TAKEN
9 74 LOAD_CONST 1 (1)
76 STORE_NAME 0 (x)
10 L3: 78 LOAD_NAME 0 (x)
80 LOAD_CONST 1 (1)
82 BINARY_OP 13 (+=)
86 STORE_NAME 0 (x)
88 RETURN_CONST 3 (None)
'<module>' branches:
ex9.py 4:9-4:10 "1" (<module>@20) -> 4:9-4:10 "1" (<module>@26) [case -> out]
ex9.py 4:9-4:10 "1" (<module>@20) -> 7:9-7:10 "2" (<module>@48) [case -> next case]
ex9.py 5:11-5:16 "x < 0" (<module>@36) -> 6:16-6:17 "1" (<module>@42) [if/while -> block]
ex9.py 5:11-5:16 "x < 0" (<module>@36) -> (start_line=None) (<module>@46) [(dst.start_line=None)]
ex9.py 7:9-7:10 "2" (<module>@54) -> 8:11-8:12 "x" (<module>@60) [case -> body]
ex9.py 7:9-7:10 "2" (<module>@54) -> 10:0-10:1 "x" (<module>@78) [case -> next stmt]
ex9.py 8:11-8:16 "x < 0" (<module>@68) -> 9:16-9:17 "1" (<module>@74) [if/while -> block]
ex9.py 8:11-8:16 "x < 0" (<module>@68) -> 10:0-10:1 "x" (<module>@78) [if/while -> next stmt]
```
This may be related to #123044.
@markshannon @nedbat
### CPython versions tested on:
CPython main branch
### Operating systems tested on:
macOS
<!-- gh-linked-prs -->
### Linked PRs
* gh-123167
* gh-123169
* gh-123170
<!-- /gh-linked-prs -->
| bffed80230f2617de2ee02bd4bdded1024234dab | 77133f570dcad599e5b1199c39e999bfac959ae2 |
python/cpython | python__cpython-123047 | # Running ``Lib/test/test_weakref.py`` directly fails
# Bug report
### Bug description:
```python
eclips4@nixos ~/p/p/cpython (main) [2]> ./python Lib/test/test_weakref.py
..................................................................................F....F.................................................
======================================================================
FAIL: test_proxy_repr (__main__.ReferencesTestCase.test_proxy_repr)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/eclips4/programming/programming-languages/cpython/Lib/test/test_weakref.py", line 232, in test_proxy_repr
self.assertRegex(repr(ref),
~~~~~~~~~~~~~~~~^^^^^^^^^^^
rf"<weakproxy at 0x[0-9a-fA-F]+; "
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
rf"to '{C.__module__}.{C.__qualname__}' "
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
rf"at 0x[0-9a-fA-F]+>")
^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: Regex didn't match: "<weakproxy at 0x[0-9a-fA-F]+; to '__main__.C' at 0x[0-9a-fA-F]+>" not found in "<weakproxy at 0x7ff9bb9e5ef0; to 'C' at 0x7ff9bbbdcd80>"
======================================================================
FAIL: test_ref_repr (__main__.ReferencesTestCase.test_ref_repr)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/eclips4/programming/programming-languages/cpython/Lib/test/test_weakref.py", line 126, in test_ref_repr
self.assertRegex(repr(ref),
~~~~~~~~~~~~~~~~^^^^^^^^^^^
rf"<weakref at 0x[0-9a-fA-F]+; "
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
rf"to '{C.__module__}.{C.__qualname__}' "
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
rf"at 0x[0-9a-fA-F]+>")
^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: Regex didn't match: "<weakref at 0x[0-9a-fA-F]+; to '__main__.C' at 0x[0-9a-fA-F]+>" not found in "<weakref at 0x7ff9bb9e7230; to 'C' at 0x7ff9bb9e7d30>"
----------------------------------------------------------------------
Ran 137 tests in 25.733s
FAILED (failures=2)
```
### CPython versions tested on:
CPython main branch
### Operating systems tested on:
Linux
<!-- gh-linked-prs -->
### Linked PRs
* gh-123047
* gh-123058
<!-- /gh-linked-prs -->
| 786cac0c64dc156dfee817e87f15ae56b7e3ed00 | f84cce6f2588c6437d69a30856d7c4ba00b70ae0 |
python/cpython | python__cpython-123219 | # Unnecessary specialization failures of `LOAD_ATTR` and `STORE_ATTR` when attributes are shadowed by the object's class.
This applies to both instances and classes.
If an object and it's class both have attributes with the same name, this prevents specialization of access to the object's attribute.
However, in this case specialization should only be prevented if the class's attribute is a data descriptor.
Example 1, instance:
```Py
class C:
x = 1
def __init__(self):
self.x = 2
C().x
```
`C().x` above is `2`. It doesn't matter that `C.x` exists, provided it isn't a data descriptor.
This failure shows up as "shadowed" in the [stats](https://github.com/faster-cpython/benchmarking/blob/main/results/bm-20240814-3.14.0a0-f84754b-PYTHON_UOPS/bm-20240814-azure-x86_64-python-main-3.14.0a0-f84754b-pystats.md#load_attr-1)
Example 2, class:
```Py
class Meta(type):
x = 1
class C(metaclass=Meta):
x = 1
C.x
```
`C.x` is `2`. `Meta.x` doesn't change that, as it isn't a data descriptor.
This failure shows up as "metaclass attribute" in the [stats](https://github.com/faster-cpython/benchmarking/blob/main/results/bm-20240814-3.14.0a0-f84754b-PYTHON_UOPS/bm-20240814-azure-x86_64-python-main-3.14.0a0-f84754b-pystats.md#load_attr-1)
<!-- gh-linked-prs -->
### Linked PRs
* gh-123219
<!-- /gh-linked-prs -->
| 5d3201fe3f76aeba33e9e5956ba80a116e422bd0 | 90b6d0e0f8f07d7443695e14a18488cb499d3b4d |
python/cpython | python__cpython-124485 | # Quitting interactive help when started without call duplicates prompt
# Bug report
### Bug description:
When exiting interactive help after starting it without calling `help`, i.e. just typing `help` on the prompt and hitting enter, the next prompt is duplicated.
```none
Python 3.13.0b4 (main, Jul 18 2024, 09:41:38) [GCC 13.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> help
>>> Welcome to Python 3.13's help utility! If this is your first time using
Python, you should definitely check out the tutorial at
https://docs.python.org/3.13/tutorial/.
Enter the name of any module, keyword, or topic to get help on writing
Python programs and using Python modules. To get a list of available
modules, keywords, symbols, or topics, enter "modules", "keywords",
"symbols", or "topics".
Each module also comes with a one-line summary of what it does; to list
the modules whose name or summary contain a given string such as "spam",
enter "modules spam".
To quit this help utility and return to the interpreter,
enter "q", "quit" or "exit".
help> quit
You are now leaving help and returning to the Python interpreter.
If you want to ask for help on a particular object directly from the
interpreter, you can type "help(object)". Executing "help('string')"
has the same effect as typing a particular string at the help> prompt.
>>> >>>
```
### CPython versions tested on:
3.13
### Operating systems tested on:
Linux
<!-- gh-linked-prs -->
### Linked PRs
* gh-124485
* gh-129155
<!-- /gh-linked-prs -->
| 5a9afe23620aadea30013076d64686be8bf66f7e | d147e5e52cdb90496ae5fe85b3263cdfa9407a28 |
python/cpython | python__cpython-123052 | # Crash in `Py_Initialize` in non-main thread in free-threading build
`Py_Initialize` will crash if in the free-threaded build if it's not called from the main thread. Additionally, background threads may crash if the program allocates lots of memory in total (>=30 TiB, not necessarily at one time.)
The problem is related to our use of mimalloc in the free-threaded build. We don't set mimalloc's "default heap" for threads, but a few code paths assume that there is a default heap.
Originally posted by @ngoldbaum in https://github.com/python/cpython/issues/122918#issuecomment-2289682050
> I'm seeing similar crashes in my PyO3 dev environment on MacOS. Interestingly, it *doesn't* happen if I use a debug python 3.13 free-threaded build.
>
> May be completely unrelated to the Windows-specific issues described above.
>
> Here's the traceback from the crash:
<details>
```
running 681 tests
test buffer::tests::test_compatible_size ... ok
test buffer::tests::test_element_type_from_format ... ok
test conversions::std::array::tests::array_try_from_fn ... ok
Process 18512 stopped
* thread #3, name = 'buffer::tests::test_bytes_buffer', stop reason = EXC_BAD_ACCESS (code=2, address=0x1015edb08)
frame #0: 0x000000010132d048 libpython3.13t.dylib`chacha_block(ctx=0x00000001015edac8) at random.c:67:20 [opt]
64
65 // add scrambled data to the initial state
66 for (size_t i = 0; i < 16; i++) {
-> 67 ctx->output[i] = x[i] + ctx->input[i];
68 }
69 ctx->output_available = 16;
70
Target 0: (pyo3-71e3a8c0dab6095a) stopped.
warning: libpython3.13t.dylib was compiled with optimization - stepping may behave oddly; variables may not be available.
(lldb) bt
* thread #3, name = 'buffer::tests::test_bytes_buffer', stop reason = EXC_BAD_ACCESS (code=2, address=0x1015edb08)
* frame #0: 0x000000010132d048 libpython3.13t.dylib`chacha_block(ctx=0x00000001015edac8) at random.c:67:20 [opt]
frame #1: 0x00000001013218d0 libpython3.13t.dylib`_mi_os_get_aligned_hint [inlined] chacha_next32(ctx=0x00000001015edac8) at random.c:83:5 [opt]
frame #2: 0x00000001013218bc libpython3.13t.dylib`_mi_os_get_aligned_hint [inlined] _mi_random_next(ctx=0x00000001015edac8) at random.c:149:25 [opt]
frame #3: 0x00000001013218bc libpython3.13t.dylib`_mi_os_get_aligned_hint [inlined] _mi_heap_random_next(heap=0x00000001015ecf80) at heap.c:258:10 [opt]
frame #4: 0x00000001013218b8 libpython3.13t.dylib`_mi_os_get_aligned_hint(try_alignment=33554432, size=1073741824) at os.c:118:19 [opt]
frame #5: 0x000000010132ee50 libpython3.13t.dylib`unix_mmap_prim(addr=0x0000000000000000, size=1073741824, try_alignment=33554432, protect_flags=3, flags=4162, fd=1677721600) at prim.c:190:18 [opt]
frame #6: 0x0000000101327f68 libpython3.13t.dylib`_mi_prim_alloc [inlined] unix_mmap(addr=0x0000000000000000, size=<unavailable>, try_alignment=<unavailable>, protect_flags=3, large_only=false, allow_large=<unavailable>, is_large=<unavailable>) at prim.c:297:9 [opt]
frame #7: 0x0000000101327ed4 libpython3.13t.dylib`_mi_prim_alloc(size=1073741824, try_alignment=33554432, commit=<unavailable>, allow_large=<unavailable>, is_large=0x0000000170211bdf, is_zero=<unavailable>, addr=0x0000000170211b78) at prim.c:334:11 [opt]
frame #8: 0x0000000101321c18 libpython3.13t.dylib`mi_os_prim_alloc(size=1073741824, try_alignment=33554432, commit=true, allow_large=<unavailable>, is_large=<unavailable>, is_zero=<unavailable>, stats=<unavailable>) at os.c:201:13 [opt]
frame #9: 0x000000010131a648 libpython3.13t.dylib`_mi_os_alloc_aligned [inlined] mi_os_prim_alloc_aligned(size=1073741824, alignment=33554432, commit=true, allow_large=<unavailable>, is_large=0x0000000170211bdf, is_zero=0x0000000170211bde, base=<unavailable>, stats=<unavailable>) at os.c:234:13 [opt]
frame #10: 0x000000010131a60c libpython3.13t.dylib`_mi_os_alloc_aligned(size=<unavailable>, alignment=33554432, commit=true, allow_large=<unavailable>, memid=0x0000000170211c68, tld_stats=<unavailable>) at os.c:320:13 [opt]
frame #11: 0x000000010131bb84 libpython3.13t.dylib`mi_reserve_os_memory_ex(size=1073741824, commit=true, allow_large=<unavailable>, exclusive=false, arena_id=0x0000000170211ccc) at arena.c:813:17 [opt]
frame #12: 0x0000000101319fd0 libpython3.13t.dylib`_mi_arena_alloc_aligned [inlined] mi_arena_reserve(req_size=33554432, allow_large=true, req_arena_id=0, arena_id=0x0000000170211ccc) at arena.c:362:11 [opt]
frame #13: 0x0000000101319f6c libpython3.13t.dylib`_mi_arena_alloc_aligned(size=33554432, alignment=33554432, align_offset=0, commit=true, allow_large=true, req_arena_id=0, memid=0x0000000170211da8, tld=0x00000001016cc828) at arena.c:383:11 [opt]
frame #14: 0x000000010132dde8 libpython3.13t.dylib`mi_segment_alloc [inlined] mi_segment_os_alloc(required=0, page_alignment=<unavailable>, eager_delayed=<unavailable>, req_arena_id=0, psegment_slices=<unavailable>, ppre_size=<unavailable>, pinfo_slices=<unavailable>, commit=<unavailable>, tld=0x00000001016cc490, os_tld=<unavailable>) at segment.c:823:42 [opt]
frame #15: 0x000000010132ddd0 libpython3.13t.dylib`mi_segment_alloc(required=0, page_alignment=<unavailable>, req_arena_id=0, tld=<unavailable>, os_tld=<unavailable>, huge_page=0x0000000000000000) at segment.c:882:27 [opt]
frame #16: 0x0000000101326a38 libpython3.13t.dylib`mi_segments_page_alloc [inlined] mi_segment_reclaim_or_alloc(heap=0x00000001016cac80, needed_slices=1, block_size=64, tld=0x00000001016cc490, os_tld=0x00000001016cc828) at segment.c:1489:10 [opt]
frame #17: 0x0000000101326788 libpython3.13t.dylib`mi_segments_page_alloc(heap=0x00000001016cac80, page_kind=<unavailable>, required=64, block_size=64, tld=0x00000001016cc490, os_tld=0x00000001016cc828) at segment.c:1508:9 [opt]
frame #18: 0x000000010132cc7c libpython3.13t.dylib`mi_page_fresh_alloc(heap=0x00000001016cac80, pq=0x00000001016cb150, block_size=64, page_alignment=<unavailable>) at page.c:284:21 [opt]
frame #19: 0x0000000101324044 libpython3.13t.dylib`mi_find_page [inlined] mi_page_fresh(heap=0x00000001016cac80, pq=0x00000001016cb150) at page.c:305:21 [opt]
frame #20: 0x0000000101324030 libpython3.13t.dylib`mi_find_page [inlined] mi_page_queue_find_free_ex(heap=0x00000001016cac80, pq=0x00000001016cb150, first_try=true) at page.c:782:12 [opt]
frame #21: 0x0000000101323ff0 libpython3.13t.dylib`mi_find_page [inlined] mi_find_free_page(heap=0x00000001016cac80, size=<unavailable>) at page.c:821:10 [opt]
frame #22: 0x0000000101323e6c libpython3.13t.dylib`mi_find_page(heap=0x00000001016cac80, size=64, huge_alignment=0) at page.c:920:12 [opt]
frame #23: 0x0000000101316158 libpython3.13t.dylib`_mi_malloc_generic(heap=0x00000001016cac80, size=<unavailable>, zero=<unavailable>, huge_alignment=0) at page.c:946:21 [opt]
frame #24: 0x0000000101422014 libpython3.13t.dylib`gc_alloc [inlined] _PyObject_MallocWithType(tp=<unavailable>, size=<unavailable>) at pycore_object_alloc.h:46:17 [opt]
frame #25: 0x0000000101421ff4 libpython3.13t.dylib`gc_alloc(tp=<unavailable>, basicsize=<unavailable>, presize=0) at gc_free_threading.c:1695:17 [opt]
frame #26: 0x0000000101421ea4 libpython3.13t.dylib`_PyObject_GC_New(tp=0x0000000101657268) at gc_free_threading.c:1716:20 [opt]
frame #27: 0x00000001012f266c libpython3.13t.dylib`PyDict_New [inlined] new_dict(interp=0x0000000101698e80, keys=<unavailable>, values=0x0000000000000000, used=0, free_values_on_failure=0) at dictobject.c:929:14 [opt]
frame #28: 0x00000001012f263c libpython3.13t.dylib`PyDict_New at dictobject.c:1026:12 [opt]
frame #29: 0x0000000101386050 libpython3.13t.dylib`_PyUnicode_InitGlobalObjects [inlined] init_interned_dict(interp=0x0000000101698e80) at unicodeobject.c:284:37 [opt]
frame #30: 0x000000010138604c libpython3.13t.dylib`_PyUnicode_InitGlobalObjects(interp=0x0000000101698e80) at unicodeobject.c:15016:9 [opt]
frame #31: 0x00000001014521f0 libpython3.13t.dylib`pycore_interp_init [inlined] pycore_init_global_objects(interp=0x0000000101698e80) at pylifecycle.c:702:14 [opt]
frame #32: 0x00000001014521dc libpython3.13t.dylib`pycore_interp_init(tstate=0x00000001016c9330) at pylifecycle.c:852:14 [opt]
frame #33: 0x000000010144f89c libpython3.13t.dylib`Py_InitializeFromConfig [inlined] pyinit_config(runtime=<unavailable>, tstate_p=<unavailable>, config=0x0000000170212130) at pylifecycle.c:933:14 [opt]
frame #34: 0x000000010144f784 libpython3.13t.dylib`Py_InitializeFromConfig [inlined] pyinit_core(runtime=<unavailable>, src_config=<unavailable>, tstate_p=<unavailable>) at pylifecycle.c:1096:18 [opt]
frame #35: 0x000000010144f784 libpython3.13t.dylib`Py_InitializeFromConfig(config=0x00000001702123a0) at pylifecycle.c:1398:14 [opt]
frame #36: 0x000000010144f9b0 libpython3.13t.dylib`Py_InitializeEx(install_sigs=<unavailable>) at pylifecycle.c:1436:14 [opt]
frame #37: 0x0000000100105b2c pyo3-71e3a8c0dab6095a`pyo3::gil::prepare_freethreaded_python::_$u7b$$u7b$closure$u7d$$u7d$::h2cd40f096e08bff0((null)={closure_env#0} @ 0x00000001702125c7, (null)=0x0000000170212640) at gil.rs:69:13
frame #38: 0x00000001000654fc pyo3-71e3a8c0dab6095a`std::sync::once::Once::call_once_force::_$u7b$$u7b$closure$u7d$$u7d$::hdab74cb30759684d(p=0x0000000170212640) at once.rs:208:40
frame #39: 0x0000000100314024 pyo3-71e3a8c0dab6095a`std::sys::sync::once::queue::Once::call::h9dcea807fd617ccf at queue.rs:183:21 [opt]
frame #40: 0x00000001000652f0 pyo3-71e3a8c0dab6095a`std::sync::once::Once::call_once_force::h6081e1899cf15adf(self=0x00000001004d8ea0, f={closure_env#0} @ 0x000000017021271f) at once.rs:208:9
frame #41: 0x0000000100000b0c pyo3-71e3a8c0dab6095a`pyo3::gil::prepare_freethreaded_python::hb6ac25f766ef5eb8 at gil.rs:66:5
frame #42: 0x0000000100000b7c pyo3-71e3a8c0dab6095a`pyo3::gil::GILGuard::acquire::hcdf69afc9ea1299e at gil.rs:174:21
frame #43: 0x00000001001a1708 pyo3-71e3a8c0dab6095a`pyo3::marker::Python::with_gil::h089ec9aca00e522e(f={closure_env#0} @ 0x000000017021279f) at marker.rs:403:21
frame #44: 0x0000000100216c2c pyo3-71e3a8c0dab6095a`pyo3::buffer::tests::test_bytes_buffer::h458708c8fd91dd1e at buffer.rs:849:9
frame #45: 0x0000000100035e40 pyo3-71e3a8c0dab6095a`pyo3::buffer::tests::test_bytes_buffer::_$u7b$$u7b$closure$u7d$$u7d$::h8009c230847e71d5((null)=0x00000001702127fe) at buffer.rs:848:27
```
</details>
Both the debug python build and the optimized, crashing Python are built from source using pyenv.
<!-- gh-linked-prs -->
### Linked PRs
* gh-123052
* gh-123114
<!-- /gh-linked-prs -->
| d061ffea7b408861d0a9d311e92c363da284971d | 40632b1f1da573f6d5e12453007474bcf70fba22 |
python/cpython | python__cpython-124467 | # test_time.TestStrftime4dyear.test_negative fails on Android Pixel 7
# Bug report
### Bug description:
This happens on the Pixel 7, but not on an emulator with the same API level (34). It may be caused by a bug in the underlying libc.
```
0:00:00 [1/1] test_time
test test_time failed -- Traceback (most recent call last):
File "/data/user/0/org.python.testbed/files/python/lib/python3.14/test/test_time.py", line 673, in test_negative
return super().test_negative()
~~~~~~~~~~~~~~~~~~~~~^^
File "/data/user/0/org.python.testbed/files/python/lib/python3.14/test/test_time.py", line 699, in test_negative
self.assertEqual(self.yearstr(-1234), '-1234')
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: '0$34' != '-1234'
- 0$34
+ -1234
test_time failed (1 failure)
```
### CPython versions tested on:
CPython main branch
### Operating systems tested on:
Other
<!-- gh-linked-prs -->
### Linked PRs
* gh-124467
* gh-124674
<!-- /gh-linked-prs -->
| 0a3577bdfcb7132c92a3f7fb2ac231bc346383c0 | 365dffbaada421db8fdb684a84d1fb311b75ec40 |
python/cpython | python__cpython-124458 | # "disallowed arm64 system call" crashes on Android API levels 26-30
# Crash report
### What happened?
I've seen two versions of this crash. The first one mostly affects the asyncio tests, but also some others, e.g. `test_type_params`.
It happens both on an emulator (API levels 26-29) and a physical device (Nexus 5X, API level 27). It does not happen on API levels 25 or 30 (but see the other crash below), nor on 34, which is the version that will be used by the buildbot.
Here's a log from API level 29. All the other versions are similar, except that API level 26 and 27 say "disallowed arm64 system call 0" instead of 434.
```
18:33:56.889 python.stdout I test_check_thread (test.test_asyncio.test_base_events.BaseEventLoopTests.test_check_thread) ...
18:33:56.932 python.stdout I ok
18:33:56.932 python.stdout I test_close (test.test_asyncio.test_base_events.BaseEventLoopTests.test_close) ...
18:33:56.933 python.stdout I ok
18:33:56.933 python.stdout I test_create_named_task_with_custom_factory (test.test_asyncio.test_base_events.BaseEventLoopTests.test_create_named_task_with_custom_factory) ...
18:33:56.934 libc A Fatal signal 31 (SIGSYS), code 1 (SYS_SECCOMP) in tid 6011 (.python.testbed), pid 6011 (.python.testbed)
18:33:56.954 crash_dump64 I obtaining output fd from tombstoned, type: kDebuggerdTombstone
18:33:56.957 DEBUG A *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
18:33:56.957 DEBUG A Build fingerprint: 'google/sdk_gphone64_arm64/emulator64_arm64:10/QSR1.211112.010/10744382:userdebug/dev-keys'
18:33:56.957 DEBUG A Revision: '0'
18:33:56.957 DEBUG A ABI: 'arm64'
18:33:56.958 DEBUG A Timestamp: 2024-08-14 18:33:56+0100
18:33:56.958 DEBUG A pid: 6011, tid: 6011, name: .python.testbed >>> org.python.testbed <<<
18:33:56.958 DEBUG A uid: 10144
18:33:56.958 DEBUG A signal 31 (SIGSYS), code 1 (SYS_SECCOMP), fault addr --------
18:33:56.958 DEBUG A Cause: seccomp prevented call to disallowed arm64 system call 434
18:33:56.958 DEBUG A x0 000000000000177b x1 0000000000000000 x2 0000007fd13766c0 x3 0000007fd1376740
18:33:56.958 DEBUG A x4 0000000000000200 x5 0000007fd1376628 x6 0000007fd1376628 x7 0000000000000002
18:33:56.958 DEBUG A x8 00000000000001b2 x9 bf29487f6e1cf2c9 x10 0000007fd1376a58 x11 0000007e3b9c662c
18:33:56.958 DEBUG A x12 000000000000010b x13 0000007e3b9c7f54 x14 0000000000000062 x15 0000000000000020
18:33:56.958 DEBUG A x16 0000007e3baea3c8 x17 0000007f27d44220 x18 0000000000000000 x19 0000007f2b950020
18:33:56.958 DEBUG A x20 0000007e3bb85fa8 x21 0000007e9e8616c0 x22 0000007e39411b70 x23 8000000000000002
18:33:56.958 DEBUG A x24 0000007e9e8616c0 x25 0000007e9e8616b0 x26 0000007e39411b70 x27 0000007e9e861648
18:33:56.958 DEBUG A x28 0000007e3bb85fa8 x29 0000007fd1376ab0
18:33:56.958 DEBUG A sp 0000007fd1376aa0 lr 0000007e3ba264ac pc 0000007f27d44240
```
<details>
<summary>Backtrace</summary>
```
18:33:57.041 DEBUG A
backtrace:
18:33:57.041 DEBUG A #00 pc 000000000007f240 /apex/com.android.runtime/lib64/bionic/libc.so (syscall+32) (BuildId: c042ffb4e195c9462700c20f99189c2b)
18:33:57.041 DEBUG A #01 pc 000000000040c4a8 /data/app/org.python.testbed--6MoesW_JSB_WMIUJ8RxCg==/lib/arm64/libpython3.14.so (BuildId: 7a9e2cc5793608ec69a9b011e3d402888fdc63dd)
18:33:57.041 DEBUG A #02 pc 0000000000293984 /data/app/org.python.testbed--6MoesW_JSB_WMIUJ8RxCg==/lib/arm64/libpython3.14.so (BuildId: 7a9e2cc5793608ec69a9b011e3d402888fdc63dd)
18:33:57.041 DEBUG A #03 pc 0000000000240f34 /data/app/org.python.testbed--6MoesW_JSB_WMIUJ8RxCg==/lib/arm64/libpython3.14.so (PyObject_Vectorcall+92) (BuildId: 7a9e2cc5793608ec69a9b011e3d402888fdc63dd)
18:33:57.041 DEBUG A #04 pc 0000000000377ba0 /data/app/org.python.testbed--6MoesW_JSB_WMIUJ8RxCg==/lib/arm64/libpython3.14.so (_PyEval_EvalFrameDefault+16500) (BuildId: 7a9e2cc5793608ec69a9b011e3d402888fdc63dd)
18:33:57.041 DEBUG A #05 pc 000000000024056c /data/app/org.python.testbed--6MoesW_JSB_WMIUJ8RxCg==/lib/arm64/libpython3.14.so (BuildId: 7a9e2cc5793608ec69a9b011e3d402888fdc63dd)
18:33:57.041 DEBUG A #06 pc 00000000002415fc /data/app/org.python.testbed--6MoesW_JSB_WMIUJ8RxCg==/lib/arm64/libpython3.14.so (BuildId: 7a9e2cc5793608ec69a9b011e3d402888fdc63dd)
18:33:57.041 DEBUG A #07 pc 00000000002d7bc8 /data/app/org.python.testbed--6MoesW_JSB_WMIUJ8RxCg==/lib/arm64/libpython3.14.so (BuildId: 7a9e2cc5793608ec69a9b011e3d402888fdc63dd)
18:33:57.041 DEBUG A #08 pc 00000000002c9f38 /data/app/org.python.testbed--6MoesW_JSB_WMIUJ8RxCg==/lib/arm64/libpython3.14.so (BuildId: 7a9e2cc5793608ec69a9b011e3d402888fdc63dd)
18:33:57.041 DEBUG A #09 pc 0000000000240754 /data/app/org.python.testbed--6MoesW_JSB_WMIUJ8RxCg==/lib/arm64/libpython3.14.so (_PyObject_MakeTpCall+296) (BuildId: 7a9e2cc5793608ec69a9b011e3d402888fdc63dd)
18:33:57.041 DEBUG A #10 pc 0000000000377ba0 /data/app/org.python.testbed--6MoesW_JSB_WMIUJ8RxCg==/lib/arm64/libpython3.14.so (_PyEval_EvalFrameDefault+16500) (BuildId: 7a9e2cc5793608ec69a9b011e3d402888fdc63dd)
18:33:57.041 DEBUG A #11 pc 0000000000243ca0 /data/app/org.python.testbed--6MoesW_JSB_WMIUJ8RxCg==/lib/arm64/libpython3.14.so (BuildId: 7a9e2cc5793608ec69a9b011e3d402888fdc63dd)
18:33:57.041 DEBUG A #12 pc 000000000037a4b4 /data/app/org.python.testbed--6MoesW_JSB_WMIUJ8RxCg==/lib/arm64/libpython3.14.so (_PyEval_EvalFrameDefault+27016) (BuildId: 7a9e2cc5793608ec69a9b011e3d402888fdc63dd)
18:33:57.041 DEBUG A #13 pc 000000000024056c /data/app/org.python.testbed--6MoesW_JSB_WMIUJ8RxCg==/lib/arm64/libpython3.14.so (BuildId: 7a9e2cc5793608ec69a9b011e3d402888fdc63dd)
18:33:57.041 DEBUG A #14 pc 00000000002415fc /data/app/org.python.testbed--6MoesW_JSB_WMIUJ8RxCg==/lib/arm64/libpython3.14.so (BuildId: 7a9e2cc5793608ec69a9b011e3d402888fdc63dd)
18:33:57.041 DEBUG A #15 pc 00000000002d0b80 /data/app/org.python.testbed--6MoesW_JSB_WMIUJ8RxCg==/lib/arm64/libpython3.14.so (BuildId: 7a9e2cc5793608ec69a9b011e3d402888fdc63dd)
18:33:57.041 DEBUG A #16 pc 0000000000240754 /data/app/org.python.testbed--6MoesW_JSB_WMIUJ8RxCg==/lib/arm64/libpython3.14.so (_PyObject_MakeTpCall+296) (BuildId: 7a9e2cc5793608ec69a9b011e3d402888fdc63dd)
18:33:57.041 DEBUG A #17 pc 0000000000375c50 /data/app/org.python.testbed--6MoesW_JSB_WMIUJ8RxCg==/lib/arm64/libpython3.14.so (_PyEval_EvalFrameDefault+8484) (BuildId: 7a9e2cc5793608ec69a9b011e3d402888fdc63dd)
18:33:57.041 DEBUG A #18 pc 0000000000243ca0 /data/app/org.python.testbed--6MoesW_JSB_WMIUJ8RxCg==/lib/arm64/libpython3.14.so (BuildId: 7a9e2cc5793608ec69a9b011e3d402888fdc63dd)
18:33:57.041 DEBUG A #19 pc 000000000037a4b4 /data/app/org.python.testbed--6MoesW_JSB_WMIUJ8RxCg==/lib/arm64/libpython3.14.so (_PyEval_EvalFrameDefault+27016) (BuildId: 7a9e2cc5793608ec69a9b011e3d402888fdc63dd)
18:33:57.041 DEBUG A #20 pc 000000000024056c /data/app/org.python.testbed--6MoesW_JSB_WMIUJ8RxCg==/lib/arm64/libpython3.14.so (BuildId: 7a9e2cc5793608ec69a9b011e3d402888fdc63dd)
18:33:57.041 DEBUG A #21 pc 00000000002415fc /data/app/org.python.testbed--6MoesW_JSB_WMIUJ8RxCg==/lib/arm64/libpython3.14.so (BuildId: 7a9e2cc5793608ec69a9b011e3d402888fdc63dd)
18:33:57.041 DEBUG A #22 pc 00000000002d0b80 /data/app/org.python.testbed--6MoesW_JSB_WMIUJ8RxCg==/lib/arm64/libpython3.14.so (BuildId: 7a9e2cc5793608ec69a9b011e3d402888fdc63dd)
18:33:57.041 DEBUG A #23 pc 0000000000240754 /data/app/org.python.testbed--6MoesW_JSB_WMIUJ8RxCg==/lib/arm64/libpython3.14.so (_PyObject_MakeTpCall+296) (BuildId: 7a9e2cc5793608ec69a9b011e3d402888fdc63dd)
18:33:57.041 DEBUG A #24 pc 0000000000377ba0 /data/app/org.python.testbed--6MoesW_JSB_WMIUJ8RxCg==/lib/arm64/libpython3.14.so (_PyEval_EvalFrameDefault+16500) (BuildId: 7a9e2cc5793608ec69a9b011e3d402888fdc63dd)
18:33:57.041 DEBUG A #25 pc 0000000000243ca0 /data/app/org.python.testbed--6MoesW_JSB_WMIUJ8RxCg==/lib/arm64/libpython3.14.so (BuildId: 7a9e2cc5793608ec69a9b011e3d402888fdc63dd)
18:33:57.041 DEBUG A #26 pc 000000000037a4b4 /data/app/org.python.testbed--6MoesW_JSB_WMIUJ8RxCg==/lib/arm64/libpython3.14.so (_PyEval_EvalFrameDefault+27016) (BuildId: 7a9e2cc5793608ec69a9b011e3d402888fdc63dd)
18:33:57.041 DEBUG A #27 pc 000000000024056c /data/app/org.python.testbed--6MoesW_JSB_WMIUJ8RxCg==/lib/arm64/libpython3.14.so (BuildId: 7a9e2cc5793608ec69a9b011e3d402888fdc63dd)
18:33:57.041 DEBUG A #28 pc 00000000002415fc /data/app/org.python.testbed--6MoesW_JSB_WMIUJ8RxCg==/lib/arm64/libpython3.14.so (BuildId: 7a9e2cc5793608ec69a9b011e3d402888fdc63dd)
18:33:57.041 DEBUG A #29 pc 00000000002d0b80 /data/app/org.python.testbed--6MoesW_JSB_WMIUJ8RxCg==/lib/arm64/libpython3.14.so (BuildId: 7a9e2cc5793608ec69a9b011e3d402888fdc63dd)
18:33:57.041 DEBUG A #30 pc 0000000000240754 /data/app/org.python.testbed--6MoesW_JSB_WMIUJ8RxCg==/lib/arm64/libpython3.14.so (_PyObject_MakeTpCall+296) (BuildId: 7a9e2cc5793608ec69a9b011e3d402888fdc63dd)
18:33:57.041 DEBUG A #31 pc 0000000000377ba0 /data/app/org.python.testbed--6MoesW_JSB_WMIUJ8RxCg==/lib/arm64/libpython3.14.so (_PyEval_EvalFrameDefault+16500) (BuildId: 7a9e2cc5793608ec69a9b011e3d402888fdc63dd)
18:33:57.041 DEBUG A #32 pc 0000000000373838 /data/app/org.python.testbed--6MoesW_JSB_WMIUJ8RxCg==/lib/arm64/libpython3.14.so (PyEval_EvalCode+308) (BuildId: 7a9e2cc5793608ec69a9b011e3d402888fdc63dd)
18:33:57.041 DEBUG A #33 pc 000000000037073c /data/app/org.python.testbed--6MoesW_JSB_WMIUJ8RxCg==/lib/arm64/libpython3.14.so (BuildId: 7a9e2cc5793608ec69a9b011e3d402888fdc63dd)
18:33:57.041 DEBUG A #34 pc 000000000037a8e8 /data/app/org.python.testbed--6MoesW_JSB_WMIUJ8RxCg==/lib/arm64/libpython3.14.so (_PyEval_EvalFrameDefault+28092) (BuildId: 7a9e2cc5793608ec69a9b011e3d402888fdc63dd)
18:33:57.041 DEBUG A #35 pc 0000000000373838 /data/app/org.python.testbed--6MoesW_JSB_WMIUJ8RxCg==/lib/arm64/libpython3.14.so (PyEval_EvalCode+308) (BuildId: 7a9e2cc5793608ec69a9b011e3d402888fdc63dd)
18:33:57.041 DEBUG A #36 pc 000000000037073c /data/app/org.python.testbed--6MoesW_JSB_WMIUJ8RxCg==/lib/arm64/libpython3.14.so (BuildId: 7a9e2cc5793608ec69a9b011e3d402888fdc63dd)
18:33:57.041 DEBUG A #37 pc 0000000000293984 /data/app/org.python.testbed--6MoesW_JSB_WMIUJ8RxCg==/lib/arm64/libpython3.14.so (BuildId: 7a9e2cc5793608ec69a9b011e3d402888fdc63dd)
18:33:57.041 DEBUG A #38 pc 0000000000240f34 /data/app/org.python.testbed--6MoesW_JSB_WMIUJ8RxCg==/lib/arm64/libpython3.14.so (PyObject_Vectorcall+92) (BuildId: 7a9e2cc5793608ec69a9b011e3d402888fdc63dd)
18:33:57.041 DEBUG A #39 pc 0000000000377ba0 /data/app/org.python.testbed--6MoesW_JSB_WMIUJ8RxCg==/lib/arm64/libpython3.14.so (_PyEval_EvalFrameDefault+16500) (BuildId: 7a9e2cc5793608ec69a9b011e3d402888fdc63dd)
18:33:57.041 DEBUG A #40 pc 0000000000401108 /data/app/org.python.testbed--6MoesW_JSB_WMIUJ8RxCg==/lib/arm64/libpython3.14.so (BuildId: 7a9e2cc5793608ec69a9b011e3d402888fdc63dd)
18:33:57.041 DEBUG A #41 pc 0000000000400704 /data/app/org.python.testbed--6MoesW_JSB_WMIUJ8RxCg==/lib/arm64/libpython3.14.so (Py_RunMain+1544) (BuildId: 7a9e2cc5793608ec69a9b011e3d402888fdc63dd)
18:33:57.041 DEBUG A #42 pc 00000000000012a8 /data/app/org.python.testbed--6MoesW_JSB_WMIUJ8RxCg==/lib/arm64/libmain_activity.so (Java_org_python_testbed_PythonTestRunner_runPython+420) (BuildId: 35a3871328d919cad4212115b139c278b49fe120)
```
</details>
### CPython versions tested on:
CPython main branch
### Operating systems tested on:
Other
### Output from running 'python -VV' on the command line:
CPython 3.14.0a0 (heads/android-test-script-dirty:ae3a460a043, Aug 12 2024, 22:45:13) [Clang 17.0.2 (https://android.googlesource.com/toolchain/llvm-project d9f89f4d1
<!-- gh-linked-prs -->
### Linked PRs
* gh-124458
* gh-124543
<!-- /gh-linked-prs -->
| c58c572a65eb5b93d054e779df289e975a0b9864 | 461c12b43870d51ea29eae7b0969b20565d50eb6 |
python/cpython | python__cpython-123007 | # enum.Flag __len__ missing "Added in version 3.11." in description
# Documentation
\_\_len\_\_ is missing the tag "Added in version 3.11." in its description.
Page: https://docs.python.org/3/library/enum.html#enum.Flag
<!-- gh-linked-prs -->
### Linked PRs
* gh-123007
* gh-123025
* gh-123026
<!-- /gh-linked-prs -->
| 8e2dc7f380c7ffe6b0fe525b4d0558aaed9d7145 | f84754b70506f03bcbf9fb0265e327d05a1a4b51 |
python/cpython | python__cpython-123002 | # What’s the difference between “linesep” and “self.policy.linesep” in Lib.email.generator.Generator._write_headers?
https://github.com/python/cpython/blob/325e9b8ef400b86fb077aa40d5cb8cec6e4df7bb/Lib/email/generator.py#L230
Is there something special in the difference between `linesep` or `self.policy.linesep` or is it just a typo?
<!-- gh-linked-prs -->
### Linked PRs
* gh-123002
* gh-123012
<!-- /gh-linked-prs -->
| 91ff700de28f3415cbe44f58ce84a2670b8c9f15 | 135dad9bd70bba5a7b432c744f2993476915cf07 |
python/cpython | python__cpython-123001 | # 3.13 Regression: `inspect.getsource()` returns incorrect source code
# Bug report
### Bug description:
In Python 3.13rc1, `inspect.getsource()` sometimes returns a "random" line for some objects.
For example, here's [`ssl.AlertDescription`](https://github.com/python/cpython/blob/v3.13.0rc1/Lib/ssl.py#L133-L136):
```shell
$ docker run --rm python:3.13-rc python -c "import inspect, ssl; print(inspect.getsource(ssl.AlertDescription))"
super().shutdown(how)
```
This line is likely https://github.com/python/cpython/blob/v3.13.0rc1/Lib/ssl.py#L1334.
In contrast, on 3.12 and below, this raises an OSError (not ideal but also not wrong):
```shell
$ docker run --rm python:3.12-rc python -c "import inspect, ssl; print(inspect.getsource(ssl.AlertDescription))"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/local/lib/python3.12/inspect.py", line 1285, in getsource
lines, lnum = getsourcelines(object)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/inspect.py", line 1267, in getsourcelines
lines, lnum = findsource(object)
^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/inspect.py", line 1112, in findsource
raise OSError('could not find class definition')
OSError: could not find class definition
```
I'm not sure why this is happening, but it also affects [pytest.PytestAssertRewriteWarning](https://github.com/pytest-dev/pytest/blob/38ad84bafd18d15ceff1960d636c693560337844/src/_pytest/warning_types.py#L20) and [pluggy.PluggyTeardownRaisedWarning](https://github.com/pytest-dev/pluggy/blob/5c16e15a963d5e66f37d05b1ccfb90adf71e8e0f/src/pluggy/_warnings.py#L11), which both extend custom classes that override `__module__`.
### CPython versions tested on:
3.8, 3.9, 3.10, 3.11, 3.12, 3.13
### Operating systems tested on:
Linux
<!-- gh-linked-prs -->
### Linked PRs
* gh-123001
* gh-123182
<!-- /gh-linked-prs -->
| f88c14d412522587085ae039ebe70b91d5b4e226 | bb1d30336e83837d4191a016107fd501cd230328 |
python/cpython | python__cpython-123071 | # Spurious `-Warray-bounds` warning on GCC 11 in free-threaded build
After https://github.com/python/cpython/pull/122418, GCC 11+ now emits a (spurious) warning in optimized builds, but not debug builds. Clang does not issue a warning
```
Objects/longobject.c: In function ‘_PyLong_FromMedium’:
./Include/internal/pycore_object.h:310:19: warning: array subscript ‘PyHeapTypeObject {aka struct _heaptypeobject}[0]’ is partly outside array bounds of ‘PyTypeObject[1]’ {aka ‘struct _typeobject[1]’} [-Warray-bounds]
310 | if ((size_t)ht->unique_id < (size_t)tstate->types.size) {
| ~~^~~~~~~~~~~
Ojects/longobject.c:6596:14: note: while referencing ‘PyLong_Type’
6596 | PyTypeObject PyLong_Type = {
| ^~~~~~~~~~~
```
GCC is clever enough to inline the `_Py_INCREF_TYPE` call on `PyLong_Type`, but not clever enough to understand the `_PyType_HasFeature(type, Py_TPFLAGS_HEAPTYPE)` guard.
https://github.com/python/cpython/blob/db6f5e193315a3bbfa7b0b6644203bae3f76b638/Include/internal/pycore_object.h#L296-L322
I don't see a great way to rewrite `_Py_INCREF_TYPE` to avoid the warning, so maybe we should just use a `#pragma` to suppress the `Warray-bounds` warnings in that function.
<!-- gh-linked-prs -->
### Linked PRs
* gh-123071
<!-- /gh-linked-prs -->
| 40632b1f1da573f6d5e12453007474bcf70fba22 | 44e458357fca05ca0ae2658d62c8c595b048b5ef |
python/cpython | python__cpython-122966 | # "test" GitHub Action workflow cannot be run manually
# Bug report
### Bug description:
With the inclusion of `build_msi` into the `Change detection` job of `test` workflow in #121778 it isn't possible to **manually** run the workflow anymore:

This seems to be because the `Ana06/get-changed-files` action doesn't support `workflow_dispatch`:

This type of error apparently does block CI.
I think the fix would be as simple as adding a condition that `github.event_name == 'pull_request'` to the `Get a list of the MSI installer-related files` step of the `Compute changed files` job.
Attn: @webknjaz
### CPython versions tested on:
CPython main branch
### Operating systems tested on:
Linux, macOS
<!-- gh-linked-prs -->
### Linked PRs
* gh-122966
* gh-123008
* gh-123009
<!-- /gh-linked-prs -->
| 6ae942f412492b840fc6b43d39ba9133aa890ee7 | eec7bdaf01a5c1f89265565876964c825ea334fc |
python/cpython | python__cpython-124039 | # `test_asyncio` `test_to_thread_concurrent` flaky
The `call_count` counter on `mock.Mock` is not atomic, so updates may be lost:
https://github.com/python/cpython/blob/ab094d1b2b348f670743f88e52d1a3f2cab5abd5/Lib/test/test_asyncio/test_threads.py#L32-L41
This leads to occasional errors like:
```
File "Lib/test/test_asyncio/test_threads.py", line 41, in test_to_thread_concurrent
self.assertEqual(func.call_count, 10)
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
AssertionError: 9 != 10
```
I think the update is not actually atomic even with the GIL because of the use of `_delegating_property` in `Mock`, but I'm not entirely sure. The failures are definitely more likely to occur in the free-threaded build.
<!-- gh-linked-prs -->
### Linked PRs
* gh-124039
* gh-124067
<!-- /gh-linked-prs -->
| eadb9660ed836b40667d4f662eae90287ff18397 | 9f42b62db998131bb5cd555e2fa72ba7e06e3130 |
python/cpython | python__cpython-124998 | # Simplify the grammar of the `assignment` rule
# Feature or enhancement
### Proposal:
I don't know all the nuances of the new grammar but I think that the `assignment` rule can be simplified in the following way:
```diff
assignment[stmt_ty]:
| a=NAME ':' b=expression c=['=' d=annotated_rhs { d }] {
CHECK_VERSION(
stmt_ty,
6,
"Variable annotation syntax is",
_PyAST_AnnAssign(CHECK(expr_ty, _PyPegen_set_expr_context(p, a, Store)), b, c, 1, EXTRA)
) }
| a=('(' b=single_target ')' { b }
| single_subscript_attribute_target) ':' b=expression c=['=' d=annotated_rhs { d }] {
CHECK_VERSION(stmt_ty, 6, "Variable annotations syntax is", _PyAST_AnnAssign(a, b, c, 0, EXTRA)) }
- | a[asdl_expr_seq*]=(z=star_targets '=' { z })+ b=(yield_expr | star_expressions) !'=' tc=[TYPE_COMMENT] {
+ | a[asdl_expr_seq*]=(z=star_targets '=' { z })+ b=annotated_rhs !'=' tc=[TYPE_COMMENT] {
_PyAST_Assign(a, b, NEW_TYPE_COMMENT(p, tc), EXTRA) }
- | a=single_target b=augassign ~ c=(yield_expr | star_expressions) {
+ | a=single_target b=augassign ~ c=annotated_rhs {
_PyAST_AugAssign(a, b->kind, c, EXTRA) }
| invalid_assignment
annotated_rhs[expr_ty]: yield_expr | star_expressions
```
That is, just reusing `annotated_rhs` instead of writing out `(yield_expr | star_expressions)`.
There was a [similar issue](https://github.com/python/cpython/issues/116988) before that fixed some cases, but this one remained. I can submit a PR if this is considered worthwhile but anyone feel free to pick this up :)
### 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:
https://github.com/python/cpython/issues/116988
<!-- gh-linked-prs -->
### Linked PRs
* gh-124998
<!-- /gh-linked-prs -->
| 39c859f6ffd8dee7f48b2181c6cb59cffe8125ff | 16cd6cc86b3ba20074ae3eefb61aeb24ee1544f7 |
python/cpython | python__cpython-122949 | # Incorrect prompt strings in The Python Tutorial
When one enters a string consisting exclusively of a comment [like "# this is a comment" (without quotes)], the next prompt string should be ">>>", and it actually is so in 14 places in 4 files in _The Python Tutorial_ listed below. Yet in 9 other places in 4 files in _The Python Tutorial_, the next prompt string is "...". I think that it should be corrected. Of course, the "..." prompt string is suitable sometimes, but where? In _compound statements_, such as _while_, whereas comments do not belong to this category.
### Wrong prompt strings ("...", after strings consisting exclusively of a comment)
[introduction.rst](https://raw.githubusercontent.com/python/cpython/main/Doc/tutorial/introduction.rst)
line 503
```
>>> # Fibonacci series:
... # the sum of two elements defines the next
```
[controlflow.rst](https://raw.githubusercontent.com/python/cpython/main/Doc/tutorial/controlflow.rst)
line 63
```
>>> # Measure some strings:
... words = ['cat', 'window', 'defenestrate']
```
line 447
```
>>> # Now call the function we just defined:
... fib(2000)
```
[datastructures.rst](https://raw.githubusercontent.com/python/cpython/main/Doc/tutorial/datastructures.rst)
line 385
```
>>> # Tuples may be nested:
... u = t, (1, 2, 3, 4, 5)
```
line 389
```
>>> # Tuples are immutable:
... t[0] = 88888
```
line 394
```
>>> # but they can contain mutable objects:
... v = ([1, 2, 3], [3, 2, 1])
```
line 467
```
>>> # Demonstrate set operations on unique letters from two words
...
```
[inputoutput.rst](https://raw.githubusercontent.com/python/cpython/main/Doc/tutorial/inputoutput.rst)
line 89
```
>>> # The repr() of a string adds string quotes and backslashes:
... hello = 'hello, world\n'
```
line 94
```
>>> # The argument to repr() may be any Python object:
... repr((x, y, ('spam', 'eggs')))
```
### Correct prompt strings (">>>", after strings consisting exclusively of a comment)
[introduction.rst](https://raw.githubusercontent.com/python/cpython/main/Doc/tutorial/introduction.rst)
line 219
```
>>> # 3 times 'un', followed by 'ium'
>>> 3 * 'un' + 'ium'
```
line 461
```
>>> # replace some values
>>> letters[2:5] = ['C', 'D', 'E']
```
line 465
```
>>> # now remove them
>>> letters[2:5] = []
```
line 469
```
>>> # clear the list by replacing all the elements with an empty list
>>> letters[:] = []
```
[datastructures.rst](https://raw.githubusercontent.com/python/cpython/main/Doc/tutorial/datastructures.rst)
line 252
```
>>> # create a new list with the values doubled
>>> [x*2 for x in vec]
```
line 255
```
>>> # filter the list to exclude negative numbers
>>> [x for x in vec if x >= 0]
```
line 258
```
>>> # apply a function to all the elements
>>> [abs(x) for x in vec]
```
line 261
```
>>> # call a method on each element
>>> freshfruit = [' banana', ' loganberry ', 'passion fruit ']
```
line 265
```
>>> # create a list of 2-tuples like (number, square)
>>> [(x, x**2) for x in range(6)]
```
line 268
```
>>> # the tuple must be parenthesized, otherwise an error is raised
>>> [x, x**2 for x in range(6)]
```
line 274
```
>>> # flatten a list using a listcomp with two 'for'
>>> vec = [[1,2,3], [4,5,6], [7,8,9]]
```
[inputoutput.rst](https://raw.githubusercontent.com/python/cpython/main/Doc/tutorial/inputoutput.rst)
line 354
```
>>> # We can check that the file has been automatically closed.
>>> f.closed
```
[stdlib.rst](https://raw.githubusercontent.com/python/cpython/main/Doc/tutorial/stdlib.rst)
line 218
```
>>> # dates are easily constructed and formatted
>>> from datetime import date
```
line 226
```
>>> # dates support calendar arithmetic
>>> birthday = date(1964, 7, 31)
```
<!-- gh-linked-prs -->
### Linked PRs
* gh-122949
* gh-122954
* gh-122955
<!-- /gh-linked-prs -->
| be90648fb2de58b148dcc7553a08ca646911baf2 | 1795d6cebaee07f30804d490fa90e3e516dfed79 |
python/cpython | python__cpython-122945 | # Re-work support of var-positional parameters in Argument Clinic
When fixing some bugs (#118814, #122688) I noticed also design problems in `_PyArg_UnpackKeywordsWithVararg()`.
* Its `vararg` parameter is always equal to `maxpos`, therefore it is redundant.
* Inserting a new tuple between values for positional and keyword-only parameters adds complexity in the `_PyArg_UnpackKeywordsWithVararg()` code which caused bugs.
* Since it is the only argument value which is a strong reference, it adds complexity for cleanup after calling `_PyArg_UnpackKeywordsWithVararg()`.
* This large code is mostly a duplication of `_PyArg_UnpackKeywords()`.
* But it lacks some microoptimizations.
* And produces wrong error messages in some corner cases.
* Also some cases (like var-positional parameter after optional parameters) were not supported.
So I re-worked it in several steps:
* Removed the `vararg` parameter from `_PyArg_UnpackKeywordsWithVararg()`.
* Moved creation of the tuple for var-positional parameter out from `_PyArg_UnpackKeywordsWithVararg()`.
* Refactored Argument Clinic code: it now generates similar code for var-positional parameter in functions with and without keyword parameters. The generated code is now more optimal and more cases are now supported. This is a large step.
* Finally, `_PyArg_UnpackKeywordsWithVararg()` was merged with `_PyArg_UnpackKeywords()` which now got a new flag.
<!-- gh-linked-prs -->
### Linked PRs
* gh-122945
* gh-126560
* gh-126564
* gh-126575
<!-- /gh-linked-prs -->
| 1f777396f52a4cf7417f56097f10add8042295f4 | 09d6f5dc7824c74672add512619e978844ff8051 |
python/cpython | python__cpython-122913 | # urllib.request: ftp_open error handling code passes the wrong type of object to URLError
# Bug report
### Bug description:
There's a raw log of an example failure below. The problem is that ftp_open passes an exception object to URLError() when it should pass a string describing the error.
2024-08-07T17:16:46.3124967Z ======================================================================
2024-08-07T17:16:46.3126394Z ERROR: test_ftp (test.test_urllib2net.OtherNetworkTests.test_ftp) (url='ftp://www.pythontest.net/README')
2024-08-07T17:16:46.3127731Z ----------------------------------------------------------------------
2024-08-07T17:16:46.3128700Z Traceback (most recent call last):
2024-08-07T17:16:46.3129959Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/urllib/request.py", line 1541, in ftp_open
2024-08-07T17:16:46.3131290Z fw = self.connect_ftp(user, passwd, host, port, dirs, req.timeout)
2024-08-07T17:16:46.3133275Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/urllib/request.py", line 1585, in connect_ftp
2024-08-07T17:16:46.3134619Z self.cache[key] = ftpwrapper(user, passwd, host, port,
2024-08-07T17:16:46.3135409Z ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-08-07T17:16:46.3136086Z dirs, timeout)
2024-08-07T17:16:46.3136735Z ^^^^^^^^^^^^^^
2024-08-07T17:16:46.3138015Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/urllib/request.py", line 2394, in __init__
2024-08-07T17:16:46.3139073Z self.init()
2024-08-07T17:16:46.3139474Z ~~~~~~~~~^^
2024-08-07T17:16:46.3140512Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/urllib/request.py", line 2404, in init
2024-08-07T17:16:46.3141625Z self.ftp.login(self.user, self.passwd)
2024-08-07T17:16:46.3142262Z ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
2024-08-07T17:16:46.3143380Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/ftplib.py", line 414, in login
2024-08-07T17:16:46.3144486Z resp = self.sendcmd('PASS ' + passwd)
2024-08-07T17:16:46.3145655Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/ftplib.py", line 281, in sendcmd
2024-08-07T17:16:46.3146651Z return self.getresp()
2024-08-07T17:16:46.3147132Z ~~~~~~~~~~~~^^
2024-08-07T17:16:46.3148166Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/ftplib.py", line 254, in getresp
2024-08-07T17:16:46.3149173Z raise error_perm(resp)
2024-08-07T17:16:46.3149923Z ftplib.error_perm: 500 OOPS: cannot change directory:/nonexistent
2024-08-07T17:16:46.3150523Z
2024-08-07T17:16:46.3150989Z The above exception was the direct cause of the following exception:
2024-08-07T17:16:46.3151632Z
2024-08-07T17:16:46.3151862Z Traceback (most recent call last):
2024-08-07T17:16:46.3153340Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/test/support/socket_helper.py", line 249, in transient_internet
2024-08-07T17:16:46.3154580Z yield
2024-08-07T17:16:46.3155723Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/test/test_urllib2net.py", line 261, in _test_urls
2024-08-07T17:16:46.3156974Z f = urlopen(url, req, support.INTERNET_TIMEOUT)
2024-08-07T17:16:46.3158337Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/test/test_urllib2net.py", line 29, in wrapped
2024-08-07T17:16:46.3159556Z return _retry_thrice(func, exc, *args, **kwargs)
2024-08-07T17:16:46.3160983Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/test/test_urllib2net.py", line 25, in _retry_thrice
2024-08-07T17:16:46.3162134Z raise last_exc
2024-08-07T17:16:46.3163329Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/test/test_urllib2net.py", line 21, in _retry_thrice
2024-08-07T17:16:46.3164734Z return func(*args, **kwargs)
2024-08-07T17:16:46.3165888Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/urllib/request.py", line 489, in open
2024-08-07T17:16:46.3166946Z response = self._open(req, data)
2024-08-07T17:16:46.3168424Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/urllib/request.py", line 506, in _open
2024-08-07T17:16:46.3169693Z result = self._call_chain(self.handle_open, protocol, protocol +
2024-08-07T17:16:46.3170584Z '_open', req)
2024-08-07T17:16:46.3171860Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/urllib/request.py", line 466, in _call_chain
2024-08-07T17:16:46.3172951Z result = func(*args)
2024-08-07T17:16:46.3174102Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/urllib/request.py", line 1558, in ftp_open
2024-08-07T17:16:46.3175195Z raise URLError(exp) from exp
2024-08-07T17:16:46.3176154Z urllib.error.URLError: <urlopen error 500 OOPS: cannot change directory:/nonexistent>
2024-08-07T17:16:46.3176931Z
2024-08-07T17:16:46.3177384Z During handling of the above exception, another exception occurred:
2024-08-07T17:16:46.3178025Z
2024-08-07T17:16:46.3178249Z Traceback (most recent call last):
2024-08-07T17:16:46.3179836Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/test/test_urllib2net.py", line 259, in _test_urls
2024-08-07T17:16:46.3181178Z with socket_helper.transient_internet(url):
2024-08-07T17:16:46.3181912Z ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^
2024-08-07T17:16:46.3183252Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/contextlib.py", line 162, in __exit__
2024-08-07T17:16:46.3184362Z self.gen.throw(value)
2024-08-07T17:16:46.3184879Z ~~~~~~~~~~~~~~^^^^^^^
2024-08-07T17:16:46.3186366Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/test/support/socket_helper.py", line 264, in transient_internet
2024-08-07T17:16:46.3187719Z filter_error(err)
2024-08-07T17:16:46.3188195Z ~~~~~~~~~~~~^^^^^
2024-08-07T17:16:46.3189586Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/test/support/socket_helper.py", line 237, in filter_error
2024-08-07T17:16:46.3190947Z (("ConnectionRefusedError" in err.reason) or
2024-08-07T17:16:46.3191673Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-08-07T17:16:46.3192728Z TypeError: argument of type 'error_perm' is not a container or iterable
### CPython versions tested on:
CPython main branch
### Operating systems tested on:
_No response_
<!-- gh-linked-prs -->
### Linked PRs
* gh-122913
<!-- /gh-linked-prs -->
| 77133f570dcad599e5b1199c39e999bfac959ae2 | 0480052ea1567d50e9772b836bc9f90bee11c2f7 |
python/cpython | python__cpython-122952 | # Compilation is broken with `HAVE_DYNAMIC_LOADING=0`
# Bug report
### Bug description:
When compiling for Wasm with `--disable-wasm-dynamic-linking`, we end up with `HAVE_DYNAMIC_LOADING=0`, which is currently broken with the following linking errors:
```
wasm-ld: error: Python/import.o: undefined symbol: _Py_ext_module_loader_info_init_for_builtin
wasm-ld: error: Python/import.o: undefined symbol: _PyImport_RunModInitFunc
wasm-ld: error: Python/import.o: undefined symbol: _Py_ext_module_loader_result_apply_error
wasm-ld: error: Python/import.o: undefined symbol: _Py_ext_module_loader_result_clear
wasm-ld: error: Python/import.o: undefined symbol: _Py_ext_module_loader_result_clear
wasm-ld: error: Python/import.o: undefined symbol: _Py_ext_module_loader_info_clear
wasm-ld: error: Python/import.o: undefined symbol: _PyImport_RunModInitFunc
wasm-ld: error: Python/import.o: undefined symbol: _Py_ext_module_loader_result_apply_error
wasm-ld: error: Python/import.o: undefined symbol: _Py_ext_module_loader_result_clear
```
I believe its a regression introduced in https://github.com/python/cpython/commit/529a160be6733e04d2a44051d3f42f6ada8c1015.
@ericsnowcurrently, would you be able to take a look into fixing this?
### CPython versions tested on:
CPython main branch
### Operating systems tested on:
Linux
<!-- gh-linked-prs -->
### Linked PRs
* gh-122952
* gh-122984
<!-- /gh-linked-prs -->
| ee1b8ce26e700350e47a5f65201097121c41912e | 5f6851152254b4b9d70af4ae5aea3f20965cee28 |
python/cpython | python__cpython-122906 | # Malformed payload can lead to infinite loops in zipfile.Path
As reported in https://github.com/jaraco/zipp/issues/119, malformed paths in a zipfile can lead to undesirable behaviors (infinite loops) when traversed using zipfile.Path.
This issue tracks porting that fix to CPython.
<!-- gh-linked-prs -->
### Linked PRs
* gh-122906
* gh-122922
* gh-122923
* gh-122925
* gh-123160
* gh-123161
* gh-123162
<!-- /gh-linked-prs -->
| 9cd03263100ddb1657826cc4a71470786cab3932 | 4534068f22f07a8ab9871bc16abf03c478ee2532 |
python/cpython | python__cpython-122908 | # zipfile.Path.glob fails to match directories
As reported in https://github.com/jaraco/zipp/issues/121, the glob logic in `zipfile.Path` doesn't honor directories.
This issue tracks porting the fix here.
<!-- gh-linked-prs -->
### Linked PRs
* gh-122908
* gh-122926
* gh-122927
<!-- /gh-linked-prs -->
| 6aa35f3002dda25858d47e702e750e2871e42a7c | 9cd03263100ddb1657826cc4a71470786cab3932 |
python/cpython | python__cpython-122897 | # pathlib copy methods do not work across partitions
# Bug report
### Bug description:
On linux, after compiling latest `main` branch:
```
$ ./python
Python 3.14.0a0 (heads/main:5580f31c56e, Aug 10 2024, 22:50:58) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pathlib
>>> pathlib.Path("python").copy("/tmp/foo")
Traceback (most recent call last):
...
OSError: [Errno 18] Invalid cross-device link: 'python' -> '/tmp/foo'
>>> pathlib.Path("Lib").copytree("/tmp/bar")
Traceback (most recent call last):
...
OSError: [Errno 18] Invalid cross-device link: 'Lib/ast.py' -> '/tmp/bar/ast.py'
>>>
```
On this computer, `/home` and `/tmp` are on different partitions. If I copy within the same partition (e.g. `./python` to `/home/akuli/foo`), that works.
### CPython versions tested on:
CPython main branch
### Operating systems tested on:
Linux
<!-- gh-linked-prs -->
### Linked PRs
* gh-122897
<!-- /gh-linked-prs -->
| c4ee4e756a311f03633723445299bde90eb7b79c | 127660bcdb28294c3817f955cabd85afb6828ffc |
python/cpython | python__cpython-122889 | # Incorrect argument type for `str()` crashes the interpreter
# Crash report
### What happened?
Using a byte string for the encoding parameter of `str()` results in a crash (instead of the expected TypeError):
```python
str(b"hello", b"ascii")
```
Here is the output I get on macos, 3.13.0b4:
```sh
% python
Python 3.13.0b4 (main, Jul 24 2024, 12:21:52) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> str(b"hello", b"ascii")
Fatal Python error: _Py_CheckFunctionResult: a function returned a result with an exception set
Python runtime state: initialized
TypeError: str() argument 'encoding' must be str, not bytes
The above exception was the direct cause of the following exception:
SystemError: <class 'str'> returned a result with an exception set
Current thread 0x00000002064b0c00 (most recent call first):
File "<python-input-0>", line 1 in <module>
File "/Users/phillipschanely/.pyenv/versions/3.13.0b4-debug/lib/python3.13/code.py", line 91 in runcode
File "/Users/phillipschanely/.pyenv/versions/3.13.0b4-debug/lib/python3.13/_pyrepl/console.py", line 200 in runsource
File "/Users/phillipschanely/.pyenv/versions/3.13.0b4-debug/lib/python3.13/code.py", line 303 in push
File "/Users/phillipschanely/.pyenv/versions/3.13.0b4-debug/lib/python3.13/_pyrepl/simple_interact.py", line 156 in run_multiline_interactive_console
File "/Users/phillipschanely/.pyenv/versions/3.13.0b4-debug/lib/python3.13/_pyrepl/main.py", line 57 in interactive_console
File "/Users/phillipschanely/.pyenv/versions/3.13.0b4-debug/lib/python3.13/_pyrepl/__main__.py", line 6 in <module>
File "/Users/phillipschanely/.pyenv/versions/3.13.0b4-debug/lib/python3.13/runpy.py", line 88 in _run_code
File "/Users/phillipschanely/.pyenv/versions/3.13.0b4-debug/lib/python3.13/runpy.py", line 198 in _run_module_as_main
zsh: abort python
```
### CPython versions tested on:
CPython main branch
### Operating systems tested on:
macOS
### Output from running 'python -VV' on the command line:
Python 3.13.0b4 (main, Jul 24 2024, 12:21:52) [Clang 15.0.0 (clang-1500.3.9.4)]
<!-- gh-linked-prs -->
### Linked PRs
* gh-122889
* gh-122947
<!-- /gh-linked-prs -->
| 53ebb6232a8ebc03827cf2251bfc67f1886ffd70 | 7c22ab5b38a1350c976ef35453d9b3ab7a294812 |
python/cpython | python__cpython-125310 | # Typo in the Python Tutorial
# Documentation
In "The Python Tutorial", [chapter "3. An Informal Introduction to Python"](https://docs.python.org/3/tutorial/introduction.html), section "3.1.2. Text", in the 3rd sentence of the 2nd paragraph under the 4th example, the following phrase contains a typo:
"End of lines are automatically included in the string"
Should be: "Ends of lines ..." (the letter 's' after "End" is missing).
<!-- gh-linked-prs -->
### Linked PRs
* gh-125310
* gh-130315
* gh-130316
<!-- /gh-linked-prs -->
| 73801864d866c76ae26a120b9db9de21b08f8b50 | ccf17323c218a2fdcf7f4845d3eaa74ebddefa44 |
python/cpython | python__cpython-122884 | # Allow "-m json" instead of "-m json.tool"
# Feature or enhancement
### Proposal:
This is a feature proposal for allowing `python3 -m json` to work in addition to `python -m json.tool` and softly deprecating the use of `python3 -m json.tool`.
I [made a branch](https://github.com/python/cpython/compare/main...treyhunner:cpython:json-script2) to see what these changes might look like.
[Here is a separate branch](https://github.com/python/cpython/compare/main...treyhunner:cpython:json-script) which issues a `DeprecationWarning` .
However, since `json.tool` will continue working that warning may cause more hassle for end users than is worthwhile.
I think the no-warning approach may be more sensible.
### Has this already been discussed elsewhere?
I have already discussed this feature proposal on Discourse
### Links to previous discussion of this feature:
[Discussion in Ideas discuss thread](https://discuss.python.org/t/allow-python-m-json-to-work-in-addition-to-python-m-json-tool/59835)
<!-- gh-linked-prs -->
### Linked PRs
* gh-122884
<!-- /gh-linked-prs -->
| 906b796af8388174cf493e23f29720eaed9fdf03 | db6f5e193315a3bbfa7b0b6644203bae3f76b638 |
python/cpython | python__cpython-122936 | # JIT does not build on the main branch
# Bug report
### Bug description:
Configuring with `--enable-experimental-jit` and then trying to build causes the following error (same as in #118343):
```
In file included from Python/optimizer_analysis.c:437:
Python/optimizer_cases.c.h: In function ‘optimize_uops’:
Python/optimizer_cases.c.h:548:23: error: assignment to ‘_PyInterpreterFrame *’ from incompatible pointer type ‘_Py_UopsSymbol *’ [-Wincompatible-pointer-types]
548 | new_frame = sym_new_not_null(ctx);
| ^
Python/optimizer_cases.c.h:1176:23: error: assignment to ‘_PyInterpreterFrame *’ from incompatible pointer type ‘_Py_UopsSymbol *’ [-Wincompatible-pointer-types]
1176 | new_frame = sym_new_not_null(ctx);
```
Note that this doesn't occur on the 3.13 branch!
### CPython versions tested on:
CPython main branch
### Operating systems tested on:
Linux
<!-- gh-linked-prs -->
### Linked PRs
* gh-122936
<!-- /gh-linked-prs -->
| 1795d6cebaee07f30804d490fa90e3e516dfed79 | 53ebb6232a8ebc03827cf2251bfc67f1886ffd70 |
python/cpython | python__cpython-122870 | # Hosted documentation has not been updated in over a week
# Documentation
I tried viewing the [Changelog](https://docs.python.org/3/whatsnew/changelog.html) to see what was included in the Python 3.12.5 release, and I noticed the page states "Last updated on Jul 31, 2024 (11:04 UTC)". I checked several other pages on the 3.12 documentation site, and they all have the same date. I checked the 3.13 and 3.14 docs, and both of them were built earlier today. The older documentation should be rebuilt whenever there is a release so the changelog can be read.
<!-- gh-linked-prs -->
### Linked PRs
* gh-122870
* gh-122871
* gh-122872
* gh-122891
* gh-122893
* gh-122894
<!-- /gh-linked-prs -->
| 0fd97e46c75bb3060485b796ca597b13af7e6bec | d3239976a8e66ae3e2f4314a6889d79cdc9a9625 |
python/cpython | python__cpython-124845 | # Running ``Lib/test/test_funcattrs.py`` directly fails
# Bug report
### Bug description:
```python
eclips4@nixos ~/p/p/cpython (tests_for_ast_opt) [1]> ./python Lib/test/test_funcattrs.py
............F.....................
======================================================================
FAIL: test___builtins__ (__main__.FunctionPropertiesTest.test___builtins__)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/eclips4/programming/programming-languages/cpython/Lib/test/test_funcattrs.py", line 101, in test___builtins__
self.assertIs(self.b.__builtins__, __builtins__)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: {'__name__': 'builtins', '__doc__': "Built-in functions, types, exceptions, and other objects.\n\nThis module provides direct access to all 'built-in'\nidentifiers of Python; for example, builtins.len is\nthe full name for the built-in function len().\n\nThis module is not normally accessed explicitly by most\napplications, but can be useful in modules that provide\nobjects with the same name as a built-in value, but in\nwhich the built-in of that name is also needed.", '__package__': '', '__loader__': <class '_frozen_importlib.BuiltinImporter'>, '__spec__': ModuleSpec(name='builtins', loader=<class '_frozen_importlib.BuiltinImporter'>, origin='built-in'), '__build_class__': <built-in function __build_class__>, '__import__': <built-in function __import__>, 'abs': <built-in function abs>, 'all': <built-in function all>, 'any': <built-in function any>, 'ascii': <built-in function ascii>, 'bin': <built-in function bin>, 'breakpoint': <built-in function breakpoint>, 'callable': <built-in function callable>, 'chr': <built-in function chr>, 'compile': <built-in function compile>, 'delattr': <built-in function delattr>, 'dir': <built-in function dir>, 'divmod': <built-in function divmod>, 'eval': <built-in function eval>, 'exec': <built-in function exec>, 'format': <built-in function format>, 'getattr': <built-in function getattr>, 'globals': <built-in function globals>, 'hasattr': <built-in function hasattr>, 'hash': <built-in function hash>, 'hex': <built-in function hex>, 'id': <built-in function id>, 'input': <built-in function input>, 'isinstance': <built-in function isinstance>, 'issubclass': <built-in function issubclass>, 'iter': <built-in function iter>, 'aiter': <built-in function aiter>, 'len': <built-in function len>, 'locals': <built-in function locals>, 'max': <built-in function max>, 'min': <built-in function min>, 'next': <built-in function next>, 'anext': <built-in function anext>, 'oct': <built-in function oct>, 'ord': <built-in function ord>, 'pow': <built-in function pow>, 'print': <built-in function print>, 'repr': <built-in function repr>, 'round': <built-in function round>, 'setattr': <built-in function setattr>, 'sorted': <built-in function sorted>, 'sum': <built-in function sum>, 'vars': <built-in function vars>, 'None': None, 'Ellipsis': Ellipsis, 'NotImplemented': NotImplemented, 'False': False, 'True': True, 'bool': <class 'bool'>, 'memoryview': <class 'memoryview'>, 'bytearray': <class 'bytearray'>, 'bytes': <class 'bytes'>, 'classmethod': <class 'classmethod'>, 'complex': <class 'complex'>, 'dict': <class 'dict'>, 'enumerate': <class 'enumerate'>, 'filter': <class 'filter'>, 'float': <class 'float'>, 'frozenset': <class 'frozenset'>, 'property': <class 'property'>, 'int': <class 'int'>, 'list': <class 'list'>, 'map': <class 'map'>, 'object': <class 'object'>, 'range': <class 'range'>, 'reversed': <class 'reversed'>, 'set': <class 'set'>, 'slice': <class 'slice'>, 'staticmethod': <class 'staticmethod'>, 'str': <class 'str'>, 'super': <class 'super'>, 'tuple': <class 'tuple'>, 'type': <class 'type'>, 'zip': <class 'zip'>, '__debug__': True, 'BaseException': <class 'BaseException'>, 'BaseExceptionGroup': <class 'BaseExceptionGroup'>, 'Exception': <class 'Exception'>, 'GeneratorExit': <class 'GeneratorExit'>, 'KeyboardInterrupt': <class 'KeyboardInterrupt'>, 'SystemExit': <class 'SystemExit'>, 'ArithmeticError': <class 'ArithmeticError'>, 'AssertionError': <class 'AssertionError'>, 'AttributeError': <class 'AttributeError'>, 'BufferError': <class 'BufferError'>, 'EOFError': <class 'EOFError'>, 'ImportError': <class 'ImportError'>, 'LookupError': <class 'LookupError'>, 'MemoryError': <class 'MemoryError'>, 'NameError': <class 'NameError'>, 'OSError': <class 'OSError'>, 'ReferenceError': <class 'ReferenceError'>, 'RuntimeError': <class 'RuntimeError'>, 'StopAsyncIteration': <class 'StopAsyncIteration'>, 'StopIteration': <class 'StopIteration'>, 'SyntaxError': <class 'SyntaxError'>, 'SystemError': <class 'SystemError'>, 'TypeError': <class 'TypeError'>, 'ValueError': <class 'ValueError'>, 'Warning': <class 'Warning'>, 'FloatingPointError': <class 'FloatingPointError'>, 'OverflowError': <class 'OverflowError'>, 'ZeroDivisionError': <class 'ZeroDivisionError'>, 'BytesWarning': <class 'BytesWarning'>, 'DeprecationWarning': <class 'DeprecationWarning'>, 'EncodingWarning': <class 'EncodingWarning'>, 'FutureWarning': <class 'FutureWarning'>, 'ImportWarning': <class 'ImportWarning'>, 'PendingDeprecationWarning': <class 'PendingDeprecationWarning'>, 'ResourceWarning': <class 'ResourceWarning'>, 'RuntimeWarning': <class 'RuntimeWarning'>, 'SyntaxWarning': <class 'SyntaxWarning'>, 'UnicodeWarning': <class 'UnicodeWarning'>, 'UserWarning': <class 'UserWarning'>, 'BlockingIOError': <class 'BlockingIOError'>, 'ChildProcessError': <class 'ChildProcessError'>, 'ConnectionError': <class 'ConnectionError'>, 'FileExistsError': <class 'FileExistsError'>, 'FileNotFoundError': <class 'FileNotFoundError'>, 'InterruptedError': <class 'InterruptedError'>, 'IsADirectoryError': <class 'IsADirectoryError'>, 'NotADirectoryError': <class 'NotADirectoryError'>, 'PermissionError': <class 'PermissionError'>, 'ProcessLookupError': <class 'ProcessLookupError'>, 'TimeoutError': <class 'TimeoutError'>, 'IndentationError': <class 'IndentationError'>, '_IncompleteInputError': <class '_IncompleteInputError'>, 'IndexError': <class 'IndexError'>, 'KeyError': <class 'KeyError'>, 'ModuleNotFoundError': <class 'ModuleNotFoundError'>, 'NotImplementedError': <class 'NotImplementedError'>, 'PythonFinalizationError': <class 'PythonFinalizationError'>, 'RecursionError': <class 'RecursionError'>, 'UnboundLocalError': <class 'UnboundLocalError'>, 'UnicodeError': <class 'UnicodeError'>, 'BrokenPipeError': <class 'BrokenPipeError'>, 'ConnectionAbortedError': <class 'ConnectionAbortedError'>, 'ConnectionRefusedError': <class 'ConnectionRefusedError'>, 'ConnectionResetError': <class 'ConnectionResetError'>, 'TabError': <class 'TabError'>, 'UnicodeDecodeError': <class 'UnicodeDecodeError'>, 'UnicodeEncodeError': <class 'UnicodeEncodeError'>, 'UnicodeTranslateError': <class 'UnicodeTranslateError'>, 'ExceptionGroup': <class 'ExceptionGroup'>, 'EnvironmentError': <class 'OSError'>, 'IOError': <class 'OSError'>, 'open': <built-in function open>, 'quit': Use quit() or Ctrl-D (i.e. EOF) to exit, 'exit': Use exit() or Ctrl-D (i.e. EOF) to exit, 'copyright': Copyright (c) 2001-2024 Python Software Foundation.
All Rights Reserved.
Copyright (c) 2000 BeOpen.com.
All Rights Reserved.
Copyright (c) 1995-2001 Corporation for National Research Initiatives.
All Rights Reserved.
Copyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam.
All Rights Reserved., 'credits': Thanks to CWI, CNRI, BeOpen.com, Zope Corporation and a cast of thousands
for supporting Python development. See www.python.org for more information., 'license': Type license() to see the full license text, 'help': Type help() for interactive help, or help(object) for help about object.} is not <module 'builtins' (built-in)>
----------------------------------------------------------------------
Ran 34 tests in 0.007s
FAILED (failures=1)
```
### CPython versions tested on:
CPython main branch
### Operating systems tested on:
Linux
<!-- gh-linked-prs -->
### Linked PRs
* gh-124845
* gh-124884
* gh-124885
<!-- /gh-linked-prs -->
| 8fbf10d6cfd9c69ffcc1f80fa0c5f33785197af7 | 6737333ac5777345d058271621ccb3c2d11dc81e |
python/cpython | python__cpython-122861 | # Dead code in ceval_macros.h and ceval_gil.c
The `_Py_atomic_load_relaxed_int32` macro is no longer used:
https://github.com/python/cpython/blob/d3239976a8e66ae3e2f4314a6889d79cdc9a9625/Python/ceval_macros.h#L378-L383
https://github.com/python/cpython/blob/d3239976a8e66ae3e2f4314a6889d79cdc9a9625/Python/ceval_gil.c#L52-L57
<!-- gh-linked-prs -->
### Linked PRs
* gh-122861
<!-- /gh-linked-prs -->
| 1069190bad99701bf565497fa1e46575470bf237 | bc9d92c67933917b474e61905451c6408c68e71d |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.