[issue45113] [subinterpreters][C API] Add a new function to create PyStructSequence from Heap.

2021-10-13 Thread Hai Shi


Hai Shi  added the comment:

> The only thing the proposed PR adds is a way to set ht_module, which actually 
> isn't very useful (it's used for module state access.

Hm, there have some static types. so I create the 
PyStructSequence_FromModuleAndDes() could receive tp_flags and try convert 
those static types to the heap type. eg: 
https://github.com/python/cpython/blob/main/Python/sysmodule.c#L2837-L2839
We can not do this converting operation by calling PyStructSequence_NewType(), 
no?

This is my *reason* to create PR-28573 :)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45405] configure fails on macOS with non-Apple clang version 13 which implements --print-multiarch

2021-10-13 Thread Ned Deily


Ned Deily  added the comment:

> The point I was trying to make is that clang 13 generically implemented 
> --print-multiarch and the triple logic in configure related to MULTIARCH 
> applies to all platforms, not just macOS.

If there are still issues on other supported platforms, PRs are welcome.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45456] operator 'pass' in 'if-else' linear expression

2021-10-13 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

Evgeniy, please leave this closed and take the proposal to the python-ideas 
mailing list.   There is no further progress that can be made in this tracker 
issue.  We can’t discern any part of your proposal that would make sense for 
improving the language.

--
nosy: +rhettinger
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45447] IDLE: Support syntax highlighting for .pyi stub files

2021-10-13 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

I am going to call the file util.py and will work on a PR.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45456] operator 'pass' in 'if-else' linear expression

2021-10-13 Thread Evgeniy Ivanov


Evgeniy Ivanov  added the comment:

What about this?

if x > 2: my_func(x)

ok this code at 1 line, this code work, but...

PEP 8: E701 multiple statements on one line (colon)


Well f//k it with a pass
Why not add an empty action operator? What is the problem? Such an instruction 
has existed since the days of assembler - nop

--
status: closed -> open

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40413] Py_RunMain() crashes on subsequence call

2021-10-13 Thread Gregory Szorc


Gregory Szorc  added the comment:

I can't remember the circumstances of me reproducing this. The added test 
demonstrating that the interpreter can be initialized/finalized within a single 
process seems like a reasonable solution to ensure this is supported.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45405] configure fails on macOS with non-Apple clang version 13 which implements --print-multiarch

2021-10-13 Thread Gregory Szorc


Gregory Szorc  added the comment:

> Can you be more specific? This particular issue isn't about cross-compiling.

The point I was trying to make is that clang 13 generically implemented 
--print-multiarch and the triple logic in configure related to MULTIARCH 
applies to all platforms, not just macOS.

I was able to perturb this same error on Linux with an x86_64 Clang 13 with 
configure options --build=x86_64-unknown-linux-gnu 
--host=i686-unknown-linux-gnu. 
https://github.com/indygreg/python-build-standalone/runs/3853832124?check_suite_focus=true
 should work if you are logged into GitHub. Not the exact same failure, but 
related since it involves --print-multiarch suddenly working.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45444] test.test_concurrent_futures fail in x86_ 64 architecture

2021-10-13 Thread tongxiaoge


tongxiaoge  added the comment:

I reproduced the same problem in Python 3-3.11.0a1 and increased two failure 
test cases: test_ exceptions and test_ Tools, detailed log is as follows:

[ 1937s] 0:27:53 load avg: 5.11 running: test_capi (27 min 51 sec)
[ 1966s] 0:28:23 load avg: 5.03 [423/423/3] test_capi passed (28 min 19 sec)
[ 1966s]
[ 1966s] == Tests result: FAILURE ==
[ 1966s]
[ 1966s] 401 tests OK.
[ 1966s]
[ 1966s] 10 slowest tests:
[ 1966s] - test_capi: 28 min 19 sec
[ 1966s] - test_faulthandler: 21 min 7 sec
[ 1966s] - test_concurrent_futures: 18 min 53 sec
[ 1966s] - test_io: 3 min 23 sec
[ 1966s] - test_peg_generator: 3 min 5 sec
[ 1966s] - test_subprocess: 2 min 49 sec
[ 1966s] - test_multiprocessing_spawn: 2 min 36 sec
[ 1966s] - test_audit: 2 min 15 sec
[ 1966s] - test_multiprocessing_forkserver: 1 min 43 sec
[ 1966s] - test_regrtest: 1 min 42 sec
[ 1966s]
[ 1966s] 3 tests failed:
[ 1966s] test_concurrent_futures test_exceptions test_tools
[ 1966s]
[ 1966s] 19 tests skipped:
[ 1966s] test_curses test_devpoll test_ioctl test_kqueue test_msilib
[ 1966s] test_ossaudiodev test_smtpnet test_socketserver test_startfile
[ 1966s] test_tix test_tk test_ttk_guionly test_urllib2net test_urllibnet
[ 1966s] test_winconsoleio test_winreg test_winsound test_xmlrpc_net
[ 1966s] test_zipfile64
[ 1966s] 0:28:23 load avg: 5.03
[ 1966s] 0:28:23 load avg: 5.03 Re-running failed tests in verbose mode
[ 1966s] 0:28:23 load avg: 5.03 Re-running test_exceptions in verbose mode 
(matching: test_name_error_suggestions_do_not_trigger_for_too_many_locals)
[ 1966s] test_name_error_suggestions_do_not_trigger_for_too_many_locals 
(test.test_exceptions.NameErrorTests) ... test test_exceptions failed
[ 1966s] FAIL
[ 1966s]
[ 1966s] ==
[ 1966s] FAIL: test_name_error_suggestions_do_not_trigger_for_too_many_locals 
(test.test_exceptions.NameErrorTests)
[ 1966s] --
[ 1966s] Traceback (most recent call last):
[ 1966s]   File 
"/home/abuild/rpmbuild/BUILD/Python-3.11.0a1/Lib/test/test_exceptions.py", line 
1843, in test_name_error_suggestions_do_not_trigger_for_too_many_locals
[ 1966s] self.assertNotIn("a1", err.getvalue())
[ 1966s] ^^
[ 1966s] AssertionError: 'a1' unexpectedly found in 'Traceback (most recent 
call last):\n  File 
"/home/abuild/rpmbuild/BUILD/Python-3.11.0a1/Lib/test/test_exceptions.py", line 
1838, in test_name_error_suggestions_do_not_trigger_for_too_many_locals\n
f()\n^^^\n  File 
"/home/abuild/rpmbuild/BUILD/Python-3.11.0a1/Lib/test/test_exceptions.py", line 
1835, in f\nprint(a0)\n  ^^\nNameError: name \'a0\' is not 
defined\n'
[ 1966s]
[ 1966s] --
[ 1966s] Ran 1 test in 0.004s
[ 1966s]
[ 1966s] FAILED (failures=1)
[ 1966s] 0:28:23 load avg: 5.03 Re-running test_tools in verbose mode 
(matching: test_sundry)
[ 1966s] test_analyze_dxp_import 
(test.test_tools.test_sundry.TestSundryScripts) ... ok
[ 1966s] test_sundry (test.test_tools.test_sundry.TestSundryScripts) ... ERROR
[ 1966s] test_sundry_windows (test.test_tools.test_sundry.TestSundryScripts) 
... test test_tools failed
[ 1966s] skipped 'Windows-only test'
[ 1966s]
[ 1966s] ==
[ 1966s] ERROR: test_sundry (test.test_tools.test_sundry.TestSundryScripts)
[ 1966s] --
[ 1966s] Traceback (most recent call last):
[ 1966s]   File 
"/home/abuild/rpmbuild/BUILD/Python-3.11.0a1/Lib/test/test_tools/test_sundry.py",
 line 43, in test_sundry
[ 1966s] import_tool(name)
[ 1966s] ^
[ 1966s]   File 
"/home/abuild/rpmbuild/BUILD/Python-3.11.0a1/Lib/test/test_tools/__init__.py", 
line 35, in import_tool
[ 1966s] return importlib.import_module(toolname)
[ 1966s]^
[ 1966s]   File 
"/home/abuild/rpmbuild/BUILD/Python-3.11.0a1/Lib/importlib/__init__.py", line 
126, in import_module
[ 1966s] return _bootstrap._gcd_import(name[level:], package, level)
[ 1966s]
[ 1966s]   File "", line 1072, in _gcd_import
[ 1966s]   File "", line 1044, in _find_and_load
[ 1966s]   File "", line 1015, in 
_find_and_load_unlocked
[ 1966s]   File "", line 689, in _load_unlocked
[ 1966s]   File "", line 894, in 
exec_module
[ 1966s]   File "", line 241, in 
_call_with_frames_removed
[ 1966s]   File 
"/home/abuild/rpmbuild/BUILD/Python-3.11.0a1/Tools/scripts/freeze_modules.py", 
line 37, in 
[ 1966s] sys.exit("ERROR: missing _freeze_module")
[ 1966s] ^
[ 1966s] SystemExit: ERROR: missing _freeze_module
[ 1966s]
[ 1966s] --
[ 

[issue30782] Allow limiting the number of concurrent tasks in asyncio.as_completed

2021-10-13 Thread Jack Wong


Change by Jack Wong :


--
nosy: +iforapsy

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45465] logging messages are needlessly reformatted for every handler

2021-10-13 Thread Роман Донченко

New submission from Роман Донченко :

Consider this code:

```
import logging

class MyLogRecord(logging.LogRecord):
def getMessage(self):
print("Help! I am being formatted!")
return super().getMessage()

logging.setLogRecordFactory(MyLogRecord)

logger = logging.getLogger("test")
logger.addHandler(logging.StreamHandler())
logger.addHandler(logging.StreamHandler())

logger.error("%d", 123)
```

Its output is:

```
Help! I am being formatted!
123
Help! I am being formatted!
123
```

In other words, the record's `getMessage` method is called once for every 
handler. That seems quite unnecessary, especially since the formatted message 
is saved in the `message` field of the record by `Formatter.format`. 
`Formatter` could check whether the message has already been formatted, and if 
so, use the saved message.

--
components: Library (Lib)
messages: 403879
nosy: SpecLad
priority: normal
severity: normal
status: open
title: logging messages are needlessly reformatted for every handler
type: enhancement
versions: Python 3.10

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45439] [C API] Move usage of tp_vectorcall_offset from public headers to the internal C API

2021-10-13 Thread STINNER Victor


STINNER Victor  added the comment:

Using LTO, the PR 28893 *increases* the stack memory usage. It's the opposite 
:-)


PyObject_CallOneArg(): 672 bytes/call => 688 bytes/call (+16 bytes)
PyObject_CallNoArg(): 640 bytes/call => 672 bytes/call (+32 bytes)
_PyObject_CallNoArg(): 640 bytes/call => 672 bytes/call (+32 bytes)


clang with LTO:

./configure --with-lto CC=clang LD=lld LDFLAGS="-fuse-ld=lld"
make

=== ref ===

$ ./python stack_overflow-4.py
test_python_call: 9187 calls before crash, stack: 912 bytes/call
test_python_getitem: 15868 calls before crash, stack: 528 bytes/call
test_python_iterator: 11901 calls before crash, stack: 704 bytes/call
test_callonearg: 12468 calls before crash, stack: 672 bytes/call
test_callnoargs: 13091 calls before crash, stack: 640 bytes/call
test_callnoargs_inline: 13092 calls before crash, stack: 640 bytes/call

=> total: 75607 calls, 4096 bytes

=== PR ===

$ ./python stack_overflow-4.py
test_python_call: 9186 calls before crash, stack: 912 bytes/call
test_python_getitem: 15400 calls before crash, stack: 544 bytes/call
test_python_iterator: 11384 calls before crash, stack: 736 bytes/call
test_callonearg: 12177 calls before crash, stack: 688 bytes/call
test_callnoargs: 12468 calls before crash, stack: 672 bytes/call
test_callnoargs_inline: 12467 calls before crash, stack: 672 bytes/call

=> total: 73082 calls, 4224 bytes

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45020] Freeze all modules imported during startup.

2021-10-13 Thread Eric Snow


Change by Eric Snow :


--
pull_requests: +27229
pull_request: https://github.com/python/cpython/pull/28940

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45439] [C API] Move usage of tp_vectorcall_offset from public headers to the internal C API

2021-10-13 Thread STINNER Victor


STINNER Victor  added the comment:

I measured the stack consumption using attached sys_call.patch and 
stack_overflow-4.py.

Using gcc -O3, the stack consumption with PR 28893 is *way better* on the 6 
benchmarks (6 ways to call functions), especially:

PyObject_CallOneArg(): 624 bytes/call => 528 bytes/call (-96 bytes)
PyObject_CallNoArg(): 608 bytes/call => 512 bytes/call (-96 bytes)
_PyObject_CallNoArg(): 608 bytes/call => 512 bytes/call (-96 bytes)


Python built in release mode with gcc -O3:

   ./configure && make

=== ref ===

$ ./python stack_overflow-4.py
test_python_call: 10070 calls before crash, stack: 832 bytes/call
test_python_getitem: 16894 calls before crash, stack: 496 bytes/call
test_python_iterator: 12773 calls before crash, stack: 656 bytes/call
test_callonearg: 13428 calls before crash, stack: 624 bytes/call
test_callnoargs: 13779 calls before crash, stack: 608 bytes/call
test_callnoargs_inline: 13782 calls before crash, stack: 608 bytes/call

=> total: 80726 calls, 3824 bytes


=== PR ===

$ ./python stack_overflow-4.py
test_python_call: 11901 calls before crash, stack: 704 bytes/call
test_python_getitem: 18703 calls before crash, stack: 448 bytes/call
test_python_iterator: 14961 calls before crash, stack: 560 bytes/call
test_callonearg: 15868 calls before crash, stack: 528 bytes/call
test_callnoargs: 16366 calls before crash, stack: 512 bytes/call
test_callnoargs_inline: 16365 calls before crash, stack: 512 bytes/call

=> total: 94164 calls, 3264 bytes

--
Added file: https://bugs.python.org/file50356/stack_overflow-4.py

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45439] [C API] Move usage of tp_vectorcall_offset from public headers to the internal C API

2021-10-13 Thread STINNER Victor


Change by STINNER Victor :


Added file: https://bugs.python.org/file50355/sys_call.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30528] ipaddress.IPv{4,6}Network.reverse_pointer is broken

2021-10-13 Thread Foster Snowhill


Change by Foster Snowhill :


--
nosy: +forst

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44559] Enum: revert to 3.9

2021-10-13 Thread Ethan Furman


Ethan Furman  added the comment:

Going back through the various bug fixes that got cut from 3.10 to re-add to 
3.10.1.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42248] Raised exception in Enum keeping user objects alive unnecessarily

2021-10-13 Thread Ethan Furman


Ethan Furman  added the comment:

Going back through the various bug fixes that got cut from 3.10 to re-add to 
3.10.1.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45461] UnicodeDecodeError: 'unicodeescape' codec can't decode byte 0x5c in position 8191: \ at end of string

2021-10-13 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
keywords: +patch
pull_requests: +27228
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/28939

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45440] [C API] Py_IS_INFINITY() macro doesn't work in the limited C API if isinf() is not defined

2021-10-13 Thread STINNER Victor


STINNER Victor  added the comment:

> [C API] Py_IS_INFINITY() macro doesn't work in the limited C API if isinf() 
> is not defined

Well, the final fix is to remove the code path when isinf() is not available 
and require it to build Python ;-)

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45440] [C API] Py_IS_INFINITY() macro doesn't work in the limited C API if isinf() is not defined

2021-10-13 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 194a9526d8ee6abbbe58ef48520ec87a7e83f327 by Victor Stinner in 
branch 'main':
bpo-45440: Require math.h isinf() to build (GH-28894)
https://github.com/python/cpython/commit/194a9526d8ee6abbbe58ef48520ec87a7e83f327


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24444] In argparse empty choices cannot be printed in the help

2021-10-13 Thread Łukasz Langa

Łukasz Langa  added the comment:

Thanks, Andrei! ✨  ✨

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
versions: +Python 3.10, Python 3.11, Python 3.9 -Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24444] In argparse empty choices cannot be printed in the help

2021-10-13 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset fb7203453855a43907048ff2b8f9b890305b3d15 by Miss Islington (bot) 
in branch '3.9':
[3.9] bpo-2: fix an error in argparse help when help for an option is blank 
(GH-28050) (GH-28932)
https://github.com/python/cpython/commit/fb7203453855a43907048ff2b8f9b890305b3d15


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45464] TypeError when inheriting from both OSError and AttributeError

2021-10-13 Thread Marek Marczykowski-Górecki

New submission from Marek Marczykowski-Górecki :

In Python 3.10 it is no longer possible to create an exception type that 
inherits from both OSError and AttributeError. This has worked in Python 3.9.
I don't see anything in changelog/release notes that would suggest it being 
intentional.

Behavior in Python 3.9:

Python 3.9.2 (default, Feb 28 2021, 17:03:44) 
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> class C(OSError, AttributeError): pass
... 
>>> C



Behavior in Python 3.10:

Python 3.10.0 (default, Oct  4 2021, 00:00:00) [GCC 11.2.1 20210728 (Red Hat 
11.2.1-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> class C(OSError, AttributeError): pass
... 
Traceback (most recent call last):
  File "", line 1, in 
TypeError: multiple bases have instance lay-out conflict


My (very) wild guess is this being related to https://bugs.python.org/issue38530

--
components: Interpreter Core
messages: 403870
nosy: marmarek
priority: normal
severity: normal
status: open
title: TypeError when inheriting from both OSError and AttributeError
type: behavior
versions: Python 3.10

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45448] PIP package installation failure for multiple packages

2021-10-13 Thread Zayden Micheal James


Zayden Micheal James  added the comment:

I am using Python 3.10 and PIP 21.2.4. All installations worked fine with 
Python 3.9. 

I tried combinations such as:

["pip", "pip3", "python3 -m pip", "python -m pip3", "python -m pip","python3 -m 
pip3"]

So far documented modules with problems are:

["numpy", "pandas", "tensorflow", "matplotlib"]

It is impossible for all of these libraries to be broken all at once with 
Python 3.10, PIP 21.2.4 and not be a problem with Python/PIP.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45126] [sqlite3] cleanup and harden Connection and Cursor __init__

2021-10-13 Thread Diego Ramirez


Change by Diego Ramirez :


--
nosy: +DiddiLeija

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45448] PIP package installation failure for multiple packages

2021-10-13 Thread Zayden Micheal James


Zayden Micheal James  added the comment:

This issue is still persisting with other libraries aswell such as matplotlib 
and the above mentioned.

--
nosy:  -eric.smith
resolution: third party -> 
status: closed -> open
type: compile error -> behavior

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45461] UnicodeDecodeError: 'unicodeescape' codec can't decode byte 0x5c in position 8191: \ at end of string

2021-10-13 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
assignee:  -> serhiy.storchaka
versions: +Python 3.10, Python 3.11, Python 3.9 -Python 3.8

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35228] Index search in CHM help crashes viewer

2021-10-13 Thread Stephen Paul Chappell


Change by Stephen Paul Chappell :


--
nosy: +Zero

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45386] xmlrpc.client unimportable due to strfmt ValueError

2021-10-13 Thread Łukasz Langa

Łukasz Langa  added the comment:

Thanks, R! ✨  ✨

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
type:  -> behavior
versions: +Python 3.11, Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45386] xmlrpc.client unimportable due to strfmt ValueError

2021-10-13 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset 9210eff61b75edabbe9263df0c4a303fc2149a22 by Miss Islington (bot) 
in branch '3.9':
bpo-45386: Handle strftime's ValueError graciously in xmlrpc.client (GH-28765) 
(GH-28935)
https://github.com/python/cpython/commit/9210eff61b75edabbe9263df0c4a303fc2149a22


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45386] xmlrpc.client unimportable due to strfmt ValueError

2021-10-13 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset f40b230df91f29fa4a84c1d127b4eab56a6eda27 by Miss Islington (bot) 
in branch '3.10':
bpo-45386: Handle strftime's ValueError graciously in xmlrpc.client (GH-28765) 
(GH-28934)
https://github.com/python/cpython/commit/f40b230df91f29fa4a84c1d127b4eab56a6eda27


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45463] Documentation inconsistency on the number of identifiers allowed in global stmt

2021-10-13 Thread Luca


New submission from Luca :

The global statement allows specifying a list of identifiers, as correctly 
reported in the "Simple statements" chapter: 
https://docs.python.org/3/reference/simple_stmts.html#the-global-statement.

Inconsistently, however, the "Execution model" chapter describes the global 
statement as if it only allowed one single name.

This can be addressed by pluralizing the word "name" in the appropriate places 
in the "Execution model" chapter.

--
assignee: docs@python
components: Documentation
messages: 403864
nosy: docs@python, lucach
priority: normal
pull_requests: 27227
severity: normal
status: open
title: Documentation inconsistency on the number of identifiers allowed in 
global stmt

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44559] Enum: revert to 3.9

2021-10-13 Thread Antoine Pitrou


Antoine Pitrou  added the comment:

It seems the revert was not done properly: it removed from 3.10 some bugfixes 
that had been applied to 3.9 (see issue42248 for an example).

--
nosy: +pitrou
stage: resolved -> 
status: closed -> open

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42248] Raised exception in Enum keeping user objects alive unnecessarily

2021-10-13 Thread Antoine Pitrou


Antoine Pitrou  added the comment:

It seems the problem is that bpo-44559 reset the enum module to a previous 
state without the bugfix.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42248] Raised exception in Enum keeping user objects alive unnecessarily

2021-10-13 Thread Antoine Pitrou


Antoine Pitrou  added the comment:

Indeed, changeset  8c14f5a787b21d5a1eae5d5ee981431d1c0e055f is part of git 
main, but is not on the 3.10 branch AFAICT.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42248] Raised exception in Enum keeping user objects alive unnecessarily

2021-10-13 Thread Antoine Pitrou


Antoine Pitrou  added the comment:

It appears this is *not* fixed in 3.10.0:

Python 3.10.0 (default, Oct 13 2021, 08:45:17) [GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import signal, gc
>>> class App: pass
... 
>>> def create_app():
...   app = App()
...   signal.signal(signal.SIGINT, signal.SIG_DFL)
... 
>>> [obj for obj in gc.get_objects() if type(obj) is App]
[]
>>> create_app()
>>> [obj for obj in gc.get_objects() if type(obj) is App]
[<__main__.App object at 0x7f2d3f3f1c30>]

--
nosy: +pitrou
resolution: fixed -> 
status: closed -> open

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45434] [C API] Clean-up the Python.h header file

2021-10-13 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset aac29af6785712019d34f1a7f15b3c408a4f68ae by Victor Stinner in 
branch 'main':
bpo-45434: pyport.h no longer includes  (GH-28914)
https://github.com/python/cpython/commit/aac29af6785712019d34f1a7f15b3c408a4f68ae


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24444] In argparse empty choices cannot be printed in the help

2021-10-13 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset fd2be6da2ffec2301a58aefa92f17f0c567fbc55 by Miss Islington (bot) 
in branch '3.10':
bpo-2: fix an error in argparse help when help for an option is blank 
(GH-28050) (GH-28931)
https://github.com/python/cpython/commit/fd2be6da2ffec2301a58aefa92f17f0c567fbc55


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45239] email.utils.parsedate_tz raises UnboundLocalError if time has more than 2 dots in it

2021-10-13 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset f8473f6f7603f8cc3307d4cb853587be41b3 by Łukasz Langa in 
branch '3.10':
[3.10] bpo-45239: Fix parsedate_tz when time has more than 2 dots in it 
(GH-28452) (GH-28930)
https://github.com/python/cpython/commit/f8473f6f7603f8cc3307d4cb853587be41b3


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45229] Always use unittest for collecting tests in regrtests

2021-10-13 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset 5d747130933a25a3984f78ae32d2e74a0d2dc5d1 by Łukasz Langa in 
branch '3.9':
[3.9] bpo-45229: Make tkinter tests discoverable (GH-28637) (GH-28929)
https://github.com/python/cpython/commit/5d747130933a25a3984f78ae32d2e74a0d2dc5d1


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45239] email.utils.parsedate_tz raises UnboundLocalError if time has more than 2 dots in it

2021-10-13 Thread Łukasz Langa

Łukasz Langa  added the comment:

Thanks, Ben! ✨  ✨

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
type:  -> behavior
versions: +Python 3.11

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45445] Fail if an invalid -X option is provided

2021-10-13 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:


New changeset db2b6a20cd35781b2f5e798e880e57e6cf9b97aa by Pablo Galindo Salgado 
in branch 'main':
bpo-45445: Fail if an invalid X-option is provided in the command line 
(GH-28823)
https://github.com/python/cpython/commit/db2b6a20cd35781b2f5e798e880e57e6cf9b97aa


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45461] UnicodeDecodeError: 'unicodeescape' codec can't decode byte 0x5c in position 8191: \ at end of string

2021-10-13 Thread STINNER Victor


Change by STINNER Victor :


--
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45229] Always use unittest for collecting tests in regrtests

2021-10-13 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset 151234f5da4b1922e3d91233a6eddda92d7269b0 by Miss Islington (bot) 
in branch '3.10':
bpo-45229: Make tkinter tests discoverable (GH-28637) (GH-28927)
https://github.com/python/cpython/commit/151234f5da4b1922e3d91233a6eddda92d7269b0


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45239] email.utils.parsedate_tz raises UnboundLocalError if time has more than 2 dots in it

2021-10-13 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset 5638618845752f713c00d69dbe705fed16761948 by Miss Islington (bot) 
in branch '3.9':
bpo-45239: Fix parsedate_tz when time has more than 2 dots in it (GH-28452) 
(GH-28928)
https://github.com/python/cpython/commit/5638618845752f713c00d69dbe705fed16761948


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45256] Remove the usage of the C stack in Python to Python calls

2021-10-13 Thread Mark Shannon


Change by Mark Shannon :


--
pull_requests: +27226
pull_request: https://github.com/python/cpython/pull/28937

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45462] Speed up re.match with pre-compiled patterns

2021-10-13 Thread Jonas H.


Change by Jonas H. :


--
keywords: +patch
pull_requests: +27224
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/28936

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45462] Speed up re.match with pre-compiled patterns

2021-10-13 Thread Jonas H.


New submission from Jonas H. :

re.match(p, ...) with a pre-compiled pattern p = re.compile(...) can be much 
slower than calling p.match(...). Probably mostly in cases with "easy" patterns 
and/or short strings.

The culprit is that re.match -> re._compile can spend a lot of time looking up 
p its internal _cache, where it will never find p:

def _compile(pattern, flags):
...
try:
return _cache[type(pattern), pattern, flags]
except KeyError:
pass
if isinstance(pattern, Pattern):
...
return pattern
...
_cache[type(pattern), pattern, flags] = p
...

_compile will always return before the _cache is set if given a Pattern object.

By simply reordering the isinstance(..., Pattern) check we can safe a lot of 
time.

I've seen speedups in the range of 2x-5x on some of my data. As an example:

Raw speed of re.compile(p, ...).match():
time ./python.exe -c 'import re'\n'pat = re.compile(".").match'\n'for _ in 
range(1_000_000): pat("asdf")'
Executed in  190.59 millis

Speed with this optimization:
time ./python.exe -c 'import re'\n'pat = re.compile(".")'\n'for _ in 
range(1_000_000): re.match(pat, "asdf")'
Executed in  291.39 millis

Speed without this optimization:
time ./python.exe -c 'import re'\n'pat = re.compile(".")'\n'for _ in 
range(1_000_000): re.match(pat, "asdf")'
Executed in  554.42 millis

--
components: Regular Expressions
messages: 403851
nosy: ezio.melotti, jonash, mrabarnett
priority: normal
severity: normal
status: open
title: Speed up re.match with pre-compiled patterns
type: performance
versions: Python 3.11

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45386] xmlrpc.client unimportable due to strfmt ValueError

2021-10-13 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 3.0 -> 4.0
pull_requests: +27222
pull_request: https://github.com/python/cpython/pull/28934

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45386] xmlrpc.client unimportable due to strfmt ValueError

2021-10-13 Thread miss-islington


Change by miss-islington :


--
pull_requests: +27223
pull_request: https://github.com/python/cpython/pull/28935

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45386] xmlrpc.client unimportable due to strfmt ValueError

2021-10-13 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset 1c831353816ff699b54e804047a7242a09e98f5b by rtobar in branch 
'main':
bpo-45386: Handle strftime's ValueError graciously in xmlrpc.client (GH-28765)
https://github.com/python/cpython/commit/1c831353816ff699b54e804047a7242a09e98f5b


--
nosy: +lukasz.langa

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24444] In argparse empty choices cannot be printed in the help

2021-10-13 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 3.0 -> 4.0
pull_requests: +27220
pull_request: https://github.com/python/cpython/pull/28931

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24444] In argparse empty choices cannot be printed in the help

2021-10-13 Thread miss-islington


Change by miss-islington :


--
pull_requests: +27221
pull_request: https://github.com/python/cpython/pull/28932

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24444] In argparse empty choices cannot be printed in the help

2021-10-13 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset 6fafc25aea8689048314b5bf7a9bb986bb1ce238 by andrei kulakov in 
branch 'main':
bpo-2: fix an error in argparse help when help for an option is blank 
(GH-28050)
https://github.com/python/cpython/commit/6fafc25aea8689048314b5bf7a9bb986bb1ce238


--
nosy: +lukasz.langa

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45239] email.utils.parsedate_tz raises UnboundLocalError if time has more than 2 dots in it

2021-10-13 Thread Łukasz Langa

Change by Łukasz Langa :


--
pull_requests: +27219
pull_request: https://github.com/python/cpython/pull/28930

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45229] Always use unittest for collecting tests in regrtests

2021-10-13 Thread Łukasz Langa

Change by Łukasz Langa :


--
pull_requests: +27218
pull_request: https://github.com/python/cpython/pull/28929

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45461] UnicodeDecodeError: 'unicodeescape' codec can't decode byte 0x5c in position 8191: \ at end of string

2021-10-13 Thread Matthew Barnett


Matthew Barnett  added the comment:

It can be shortened to this:

buffer = b"a" * 8191 + b"\\r\\n"

with open("bug_csv.csv", "wb") as f:
f.write(buffer)

with open("bug_csv.csv", encoding="unicode_escape", newline="") as f:
f.readline()

To me it looks like it's reading in blocks of 8K and then decoding them,  but 
it isn't correctly handling an escape sequence that happens to cross a block 
boundary.

--
nosy: +mrabarnett

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45239] email.utils.parsedate_tz raises UnboundLocalError if time has more than 2 dots in it

2021-10-13 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 3.0 -> 4.0
pull_requests: +27217
pull_request: https://github.com/python/cpython/pull/28928

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45239] email.utils.parsedate_tz raises UnboundLocalError if time has more than 2 dots in it

2021-10-13 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset b9e687618d3489944f29adbd2be50b46940c9e70 by Ben Hoyt in branch 
'main':
bpo-45239: Fix parsedate_tz when time has more than 2 dots in it (GH-28452)
https://github.com/python/cpython/commit/b9e687618d3489944f29adbd2be50b46940c9e70


--
nosy: +lukasz.langa

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45229] Always use unittest for collecting tests in regrtests

2021-10-13 Thread miss-islington


Change by miss-islington :


--
pull_requests: +27216
pull_request: https://github.com/python/cpython/pull/28927

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45229] Always use unittest for collecting tests in regrtests

2021-10-13 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset f59ed3c310a7ceebf2a56a84ea969a7f75d95b64 by Serhiy Storchaka in 
branch 'main':
bpo-45229: Make tkinter tests discoverable (GH-28637)
https://github.com/python/cpython/commit/f59ed3c310a7ceebf2a56a84ea969a7f75d95b64


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45446] Add a way to hide fields in dataclasses

2021-10-13 Thread Eric V. Smith


Eric V. Smith  added the comment:

"hide" is not a good name for this.

Does attrs have anything equivalent? This seems like a pretty niche usage, so 
I'm not inclined to include it without evidence of a wide-spread need for it.

--
assignee:  -> eric.smith

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45410] python -m test -jN: write stderr in stdout to get messages in order

2021-10-13 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 676201a59f90caace606d11d4172aa74c1cd4992 by Victor Stinner in 
branch 'main':
bpo-45410: regrtest replaces print_warning.orig_stderr (GH-28926)
https://github.com/python/cpython/commit/676201a59f90caace606d11d4172aa74c1cd4992


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45434] [C API] Clean-up the Python.h header file

2021-10-13 Thread STINNER Victor


STINNER Victor  added the comment:

PyRun_InteractiveOneObjectEx() returns a single error code of errcode.h: E_EOF 
(11):

if (mod == NULL) {
_PyArena_Free(arena);
if (errcode == E_EOF) {
PyErr_Clear();
return E_EOF;
}
return -1;
}

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45434] [C API] Clean-up the Python.h header file

2021-10-13 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 713bb19356bce9b8f2b95461834fe1dae505f889 by Victor Stinner in 
branch 'main':
bpo-45434: Mark the PyTokenizer C API as private (GH-28924)
https://github.com/python/cpython/commit/713bb19356bce9b8f2b95461834fe1dae505f889


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45434] [C API] Clean-up the Python.h header file

2021-10-13 Thread STINNER Victor


STINNER Victor  added the comment:

Oh, Include/errcode.h *is* used by PyRun_InteractiveOneFlags() and its 
variants. It's mentioned in its documentation:

   Returns ``0`` when the input was
   executed successfully, ``-1`` if there was an exception, or an error code
   from the :file:`errcode.h` include file distributed as part of Python if
   there was a parse error.  (Note that :file:`errcode.h` is not included by
   :file:`Python.h`, so must be included specifically if needed.)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45410] python -m test -jN: write stderr in stdout to get messages in order

2021-10-13 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +27215
pull_request: https://github.com/python/cpython/pull/28926

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45461] UnicodeDecodeError: 'unicodeescape' codec can't decode byte 0x5c in position 8191: \ at end of string

2021-10-13 Thread Anatoly Myachev


Anatoly Myachev  added the comment:

Hello!

I can reduce it a little.
The buffer shoudln't be decreased, as it seems there is a some kind relation 
with the buffer size for IO operations.

buffer = 
b'col1,col2,col3,col4,col5,col6\\r\\n0,2000-01-01,0,00:00:00,DuBFsyerJU,1809.3924826424557\\r\\n10,2000-01-01,10,01:00:00,AlwGHbVPpB,2853.2392617952996\\r\\n20,2000-01-01,20,02:00:00,TEkGgsYXYz,9933.278931158615\\r\\n30,2000-01-01,30,03:00:00,tfvnynVSfp,8574.917426248916\\r\\n40,2000-01-01,40,04:00:00,YOGjhztMWe,3768.71871233428\\r\\n50,2000-01-01,50,05:00:00,vkTOJSeQmU,6330.252072351792\\r\\n60,2000-01-01,60,06:00:00,LeolDfaGyv,5052.618993456892\\r\\n70,2000-01-01,70,07:00:00,OcyrbYVtyr,4287.371622852719\\r\\n80,2000-01-01,80,08:00:00,VUwDPNhcFV,3589.697826814614\\r\\n90,2000-01-01,90,09:00:00,KOadtzcNyK,4794.158259020925\\r\\n100,2000-01-01,100,10:00:00,rdSOjXJBWC,8826.736894397129\\r\\n110,2000-01-01,110,11:00:00,qzwVBOklhk,8086.105782454443\\r\\n120,2000-01-01,120,12:00:00,UTRlqVfKoD,1012.5061461339624\\r\\n130,2000-01-01,130,13:00:00,wKqEkRhkfw,2511.3137510933934\\r\\n140,2000-01-01,140,14:00:00,LxklWJbgxo,406.7116346419042\\r\\n150,2000-01-01,150,15:00:00,SxmZkdUgHv,84
 
24.978062284761\\r\\n160,2000-01-01,160,16:00:00,nEvzypASGb,9890.252156059063\\r\\n170,2000-01-01,170,17:00:00,xiFkkjoDPB,2728.8359201479675\\r\\n180,2000-01-01,180,18:00:00,boMmgpBXgL,4231.680208002166\\r\\n190,2000-01-01,190,19:00:00,dXLJXWiXZI,7757.44902751916\\r\\n200,2000-01-01,200,20:00:00,PBdjwKoCMD,4915.090357003991\\r\\n210,2000-01-01,210,21:00:00,zGWLALpmoA,359.5243650158153\\r\\n220,2000-01-01,220,22:00:00,CfpZJoOqGZ,704.7990862762942\\r\\n230,2000-01-01,230,23:00:00,DrkxpLhpEN,520.3290677592321\\r\\n240,2000-01-02,240,00:00:00,TDKEBbZAzQ,5218.671660857721\\r\\n250,2000-01-02,250,01:00:00,gULwzvNeWO,4218.66872701774\\r\\n260,2000-01-02,260,02:00:00,ogSyzHWmNY,9026.657391329585\\r\\n270,2000-01-02,270,03:00:00,NetmmthtzN,2027.8312539582244\\r\\n280,2000-01-02,280,04:00:00,PoYiHipTzR,7667.627476518046\\r\\n290,2000-01-02,290,05:00:00,MjHIRGmsoq,4144.001792539834\\r\\n300,2000-01-02,300,06:00:00,qESRSNnNnO,5348.024681284471\\r\\n310,2000-01-02,310,07:00:00,sSIjcXWhLC,3622.46
 
73907599413\\r\\n320,2000-01-02,320,08:00:00,IvjrlljbeB,7500.419388155823\\r\\n330,2000-01-02,330,09:00:00,aVWVRXZjZy,3686.5972529264213\\r\\n340,2000-01-02,340,10:00:00,QKeTjcNlCG,1228.9751449454411\\r\\n350,2000-01-02,350,11:00:00,phEdHCVsbe,4254.15983968718\\r\\n360,2000-01-02,360,12:00:00,ursHJjQxRK,6099.131673115221\\r\\n370,2000-01-02,370,13:00:00,JvjcRlYcYG,1503.3586866746164\\r\\n380,2000-01-02,380,14:00:00,gzCyqHPRRb,7816.898213939008\\r\\n390,2000-01-02,390,15:00:00,lQZmobRwzt,8295.113759829599\\r\\n400,2000-01-02,400,16:00:00,qspiYGfTou,1987.8215069414816\\r\\n410,2000-01-02,410,17:00:00,mcqWMMzomf,15.878728570531964\\r\\n420,2000-01-02,420,18:00:00,fiPsxulpGU,5380.485947841902\\r\\n430,2000-01-02,430,19:00:00,gTAyTkpeez,4720.7159908343565\\r\\n440,2000-01-02,440,20:00:00,hzFbhAPvFX,946.5797295044975\\r\\n450,2000-01-02,450,21:00:00,NYNcYxsyVl,7333.850198973723\\r\\n460,2000-01-02,460,22:00:00,wvgMmIxLzo,7399.341315026157\\r\\n470,2000-01-02,470,23:00:00,bZoyzAGgEC,5464.0
 
53510955946\\r\\n480,2000-01-03,480,00:00:00,jZNaceUYyr,1390.8829937709977\\r\\n490,2000-01-03,490,01:00:00,sbfLgcCpru,9626.900131786555\\r\\n500,2000-01-03,500,02:00:00,MHpAkHfnmV,9406.471079089133\\r\\n510,2000-01-03,510,03:00:00,ENdFBGtRCq,3740.8773019724517\\r\\n520,2000-01-03,520,04:00:00,FzqXhMLHLY,4270.3585910905\\r\\n530,2000-01-03,530,05:00:00,wWinjEGhAj,8548.152649813675\\r\\n540,2000-01-03,540,06:00:00,LcxAImCvxt,4097.693176523874\\r\\n550,2000-01-03,550,07:00:00,sDhzGBYKpt,1673.7466277500146\\r\\n560,2000-01-03,560,08:00:00,jhagjcZhGU,4103.702089490347\\r\\n570,2000-01-03,570,09:00:00,ZIkRwPWyWP,9368.662605679918\\r\\n580,2000-01-03,580,10:00:00,uphgoCQwZY,3321.0096306747137\\r\\n590,2000-01-03,590,11:00:00,jEKaqqScLF,8442.084614664149\\r\\n600,2000-01-03,600,12:00:00,kSIJFBHVnL,4065.19226287942\\r\\n610,2000-01-03,610,13:00:00,YRhoANskYn,5089.668482943252\\r\\n620,2000-01-03,620,14:00:00,SnlwCSdkWf,5738.46737129545\\r\\n630,2000-01-03,630,15:00:00,ANfpLOiJTV,393.7754525
 

[issue45405] configure fails on macOS with non-Apple clang version 13 which implements --print-multiarch

2021-10-13 Thread David Bohman


David Bohman  added the comment:

Thank you for your help, Ned.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45461] UnicodeDecodeError: 'unicodeescape' codec can't decode byte 0x5c in position 8191: \ at end of string

2021-10-13 Thread STINNER Victor


STINNER Victor  added the comment:

Can you please try write a simpler (shorter) reproducer?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45461] UnicodeDecodeError: 'unicodeescape' codec can't decode byte 0x5c in position 8191: \ at end of string

2021-10-13 Thread Anatoly Myachev


New submission from Anatoly Myachev :

Expected behavior - if `read()` function works correctly, then `readline()` 
should also works.

Reproducer in file - just run: `python test.py`.

Traceback (most recent call last):
  File "test.py", line 11, in 
f.readline()
  File 
"C:\Users\amyachev\Miniconda3\envs\modin\lib\encodings\unicode_escape.py", line 
26, in decode
return codecs.unicode_escape_decode(input, self.errors)[0]
UnicodeDecodeError: 'unicodeescape' codec can't decode byte 0x5c in position 
8191: \ at end of string

--
components: Unicode
files: test.py
messages: 403837
nosy: anmyachev, ezio.melotti, vstinner
priority: normal
severity: normal
status: open
title: UnicodeDecodeError: 'unicodeescape' codec can't decode byte 0x5c in 
position 8191: \ at end of string
type: behavior
versions: Python 3.8
Added file: https://bugs.python.org/file50354/test.py

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45460] distutils.sysconfig.get_python_lib() does not respect sysconfig/distutils install schemes

2021-10-13 Thread Miro Hrončok

Miro Hrončok  added the comment:

> so distributors could patch the install schemes in there and distutils 
> (whether the one in the standard library or a third party fork).

Somehow, this sentence is not finished properly.

...so distributors could patch the install schemes in there and distutils 
(whether the one in the standard library or a third party fork) would respect 
it.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41282] Deprecate and remove distutils

2021-10-13 Thread Miro Hrončok

Miro Hrončok  added the comment:

Related: https://bugs.python.org/issue45460

--
nosy: +hroncok

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45460] distutils.sysconfig.get_python_lib() does not respect sysconfig/distutils install schemes

2021-10-13 Thread Miro Hrončok

New submission from Miro Hrončok :

In https://github.com/python/cpython/pull/24549 (Load install schemes from 
sysconfig) we have assumed that distutils will simply read all information from 
sysconfig, so distributors could patch the install schemes in there and 
distutils (whether the one in the standard library or a third party fork).

However, in https://github.com/pypa/pip/issues/10151#issuecomment-942162384 we 
have figured out that distutils.sysconfig.get_python_lib() does not respect the 
schemes from sysconfig at all, instead, it creates the paths from scratch.

This might be too late for Python 3.10, but in Python 3.11 I'd like 
distutils.sysconfig.get_python_lib() to return paths defined by sysconfig 
install schemes. That way, we can more easily move that from the standard 
library to a third-party project with an independent delivery mechanism.

--
components: Distutils
messages: 403834
nosy: FFY00, dstufft, eric.araujo, frenzy, hroncok, jaraco, petr.viktorin, 
vstinner
priority: normal
severity: normal
status: open
title: distutils.sysconfig.get_python_lib() does not respect 
sysconfig/distutils install schemes
versions: Python 3.11

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45434] [C API] Clean-up the Python.h header file

2021-10-13 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +27214
pull_request: https://github.com/python/cpython/pull/28924

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36424] Pickle fails on frozen dataclass that has slots

2021-10-13 Thread David Hagen


David Hagen  added the comment:

Because the implementation in GH-25786 relies on the new 
`dataclass(slots=True)` feature (i.e. it does not work if the slots are 
specified with `__slots__`), I don't think this can be trivially backported to 
versions before 3.10.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45256] Remove the usage of the C stack in Python to Python calls

2021-10-13 Thread Mark Shannon


Mark Shannon  added the comment:


New changeset 3901c081143ef29624f9c1cb49cc70a70321d139 by Pablo Galindo Salgado 
in branch 'main':
bpo-45256: Fix cleanup of stolen locals for Python-to-Python calls (GH-28905)
https://github.com/python/cpython/commit/3901c081143ef29624f9c1cb49cc70a70321d139


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45434] [C API] Clean-up the Python.h header file

2021-10-13 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset bbe7497c5a44c2b4ec726605cf5a9086ba02daf1 by Victor Stinner in 
branch 'main':
bpo-45434: Remove pystrhex.h header file (GH-28923)
https://github.com/python/cpython/commit/bbe7497c5a44c2b4ec726605cf5a9086ba02daf1


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45340] Lazily create dictionaries for plain Python objects

2021-10-13 Thread Mark Shannon


Mark Shannon  added the comment:


New changeset a8b9350964f43cb648c98c179c8037fbf3ff8a7d by Mark Shannon in 
branch 'main':
bpo-45340: Don't create object dictionaries unless actually needed (GH-28802)
https://github.com/python/cpython/commit/a8b9350964f43cb648c98c179c8037fbf3ff8a7d


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45434] [C API] Clean-up the Python.h header file

2021-10-13 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 97308dfcdc0696e0b116c37386e2ff4d72e6c3f4 by Victor Stinner in 
branch 'main':
bpo-45434: Move _Py_BEGIN_SUPPRESS_IPH to pycore_fileutils.h (GH-28922)
https://github.com/python/cpython/commit/97308dfcdc0696e0b116c37386e2ff4d72e6c3f4


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45434] [C API] Clean-up the Python.h header file

2021-10-13 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +27213
pull_request: https://github.com/python/cpython/pull/28923

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45434] [C API] Clean-up the Python.h header file

2021-10-13 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +27212
pull_request: https://github.com/python/cpython/pull/28922

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45459] Limited API support for Py_buffer

2021-10-13 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

ndim is not known before calling PyObject_GetBuffer(), so we will need a new 
API which combines PyObject_GetBuffer() and PyBuffer_New().

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45410] python -m test -jN: write stderr in stdout to get messages in order

2021-10-13 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 773330773968f211c77abc7b5b525faa7b3c35a2 by Victor Stinner in 
branch 'main':
bpo-45410: regrtest -W leaves stdout/err FD unchanged (GH-28915)
https://github.com/python/cpython/commit/773330773968f211c77abc7b5b525faa7b3c35a2


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45438] inspect not capturing type annotations created by __class_getitem__

2021-10-13 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

The cause is that isinstance(list[int], type) returns True. It can cause bugs 
in other parts of the code which test for instance of type. For example:

>>> types.resolve_bases((typing.List[int],))
(, )
>>> types.resolve_bases((list[int],))
(list[int],)

>>> types.prepare_class('A', (int,), {'metaclass': typing.Type[int]})
(typing.Type[int], {}, {})
>>> types.prepare_class('A', (int,), {'metaclass': type[int]})
Traceback (most recent call last):
  File "", line 1, in 
  File "/home/serhiy/py/cpython/Lib/types.py", line 125, in prepare_class
meta = _calculate_meta(meta, bases)
   
  File "/home/serhiy/py/cpython/Lib/types.py", line 139, in _calculate_meta
if issubclass(base_meta, winner):
   ^
TypeError: issubclass() argument 2 cannot be a parameterized generic

>>> @functools.singledispatch
... def g(a): pass
... 
>>> @g.register
... def g2(a: typing.List[int]): pass
... 
Traceback (most recent call last):
  File "", line 2, in 
  File "/home/serhiy/py/cpython/Lib/functools.py", line 863, in register
raise TypeError(

TypeError: Invalid annotation for 'a'. typing.List[int] is not a class.
>>> @g.register(list[int])
... def g2(a): pass
... 
>>> @g.register
... def g3(a: typing.List[int]): pass
... 
Traceback (most recent call last):
  File "", line 2, in 
  File "/home/serhiy/py/cpython/Lib/functools.py", line 863, in register
raise TypeError(

TypeError: Invalid annotation for 'a'. typing.List[int] is not a class.
>>> @g.register
... def g3(a: list[int]): pass
... 

And many other examples, too many to show here.

Was it mistake to make isinstance(list[int], type) returning True?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45459] Limited API support for Py_buffer

2021-10-13 Thread Christian Heimes


Christian Heimes  added the comment:

IIRC shape, strides, and suboffsets are all arrays of ndims length.

We could optimize allocation if we would require users to specify the value of 
ndims and don't allow them to change the value afterwards. PyBuffer_New(int 
ndims) then would allocate view of size sizeof(Py_buffer) + (3 * ndims * 
sizeof(Py_ssize_t *)). This would give us sufficient space to memcpy() shape, 
strides, and suboffsets arguments into memory after the Py_buffer struct.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45443] 'ThreadPoolExecutor' object has no attribute 'map'

2021-10-13 Thread Zohim Chandani


Zohim Chandani  added the comment:

Please see attached. I have printed out the python version. Running this on VS 
code.

--
Added file: https://bugs.python.org/file50353/Screenshot 2021-10-13 at 
12.45.04.png

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45247] [C API] Add explicit support for Cython to the C API

2021-10-13 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

I agree with Mark. Instead of exposing internal details in low-level API we 
should add more high-level API to satisfy concrete needs. It will give us more 
freedom of changing internals in future.

--
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45459] Limited API support for Py_buffer

2021-10-13 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

shape is a pointer to array of Py_ssize_t of size ndim. array and memoryview do 
a trick to avoid memory allocation, but _testbuffer.ndarray allocates it 
dynamically in the heap. We can add a small static buffer in Py_buffer to avoid 
additional memory allocation in common cases.

--
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45247] [C API] Add explicit support for Cython to the C API

2021-10-13 Thread STINNER Victor


STINNER Victor  added the comment:

> Rather than have Cython laboriously create a Python frame with fake code 
> object, etc., it would make much more sense for us to offer an API to insert 
> a "native" frame into the stack and update the line number.

I agree with that.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45459] Limited API support for Py_buffer

2021-10-13 Thread STINNER Victor


STINNER Victor  added the comment:

Py_buffer.shape requires a Py_ssize_t* pointer. It's not convenient. For 
example, the array module uses:

static int
array_buffer_getbuf(arrayobject *self, Py_buffer *view, int flags)
{
...
if ((flags & PyBUF_ND)==PyBUF_ND) {
view->shape = &((PyVarObject*)self)->ob_size;
}
...
return 0;
}

This code is not compatible with a fully opaque PyObject structure:
https://bugs.python.org/issue39573#msg401395

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45247] [C API] Add explicit support for Cython to the C API

2021-10-13 Thread Mark Shannon


Mark Shannon  added the comment:

I disagree. All that is doing is locking in the current poor interface.

We do need to extend the C API for these uses, yes. But we need an API that 
addresses Cython's needs directly and at a higher level.

For example, Cython often wants to insert a frame into the call stack for 
debugging and introspection.

Rather than have Cython laboriously create a Python frame with fake code 
object, etc., it would make much more sense for us to offer an API to insert a 
"native" frame into the stack and update the line number.

E.g. something like:

int PushNativeFrame(const char *filename);
void PopNativeFrame(void);
int CurrentNativeFrame_SetLineNumber(int lineno);

We might even want to use such an API ourselves in some modules.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42345] Equality of typing.Literal depends on the order of arguments

2021-10-13 Thread Ken Jin


Ken Jin  added the comment:

@Alick yes. To be specific, 3.9.1 and above. 3.9.0 still has the old
behavior.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45453] test_embed.StdPrinterTests() crash if stdout FD is not 1 or 2

2021-10-13 Thread STINNER Victor


Change by STINNER Victor :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
title: test_embed: random crash on AMD64 Fedora Rawhide Clang 3.x -> 
test_embed.StdPrinterTests() crash if stdout FD is not 1 or 2
versions: +Python 3.10

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45453] test_embed: random crash on AMD64 Fedora Rawhide Clang 3.x

2021-10-13 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 7e74d99c532f3eb55a86d10d30c068b03f2ad025 by Miss Islington (bot) 
in branch '3.10':
bpo-45453: Fix test_embed.StdPrinterTests (GH-28916) (GH-28917)
https://github.com/python/cpython/commit/7e74d99c532f3eb55a86d10d30c068b03f2ad025


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40421] [C API] Add getter functions for PyFrameObject and maybe move PyFrameObject to the internal C API

2021-10-13 Thread STINNER Victor


STINNER Victor  added the comment:

See also bpo-45247: [C API] Add explicit support for Cython to the C API.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39947] [C API] Make the PyThreadState structure opaque (move it to the internal C API)

2021-10-13 Thread STINNER Victor


STINNER Victor  added the comment:

See also bpo-45247: [C API] Add explicit support for Cython to the C API.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45247] [C API] Add explicit support for Cython to the C API

2021-10-13 Thread STINNER Victor


Change by STINNER Victor :


--
title: Add explicit support for Cython to the C API. -> [C API] Add explicit 
support for Cython to the C API

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40421] [C API] Add getter functions for PyFrameObject and maybe move PyFrameObject to the internal C API

2021-10-13 Thread STINNER Victor


STINNER Victor  added the comment:

The coverage project has a ctrace C extension which access 
PyFrameObject.f_lasti which is gone in Python 3.11. It uses MyFrame_lasti() 
helper to handle Python 3.10 lasti change:
---
// The f_lasti field changed meaning in 3.10.0a7. It had been bytes, but
// now is instructions, so we need to adjust it to use it as a byte index.
#if PY_VERSION_HEX >= 0x030A00A7
#define MyFrame_lasti(f)(f->f_lasti * 2)
#else
#define MyFrame_lasti(f)f->f_lasti
#endif // 3.10.0a7
---

f_lasti is used for two things in coverage/ctracer/tracer.c:

(1) get the last opcode:

/* Need to distinguish between RETURN_VALUE and YIELD_VALUE. Read
 * the current bytecode to see what it is.  In unusual circumstances
 * (Cython code), co_code can be the empty string, so range-check
 * f_lasti before reading the byte.
 */
int bytecode = RETURN_VALUE;
PyObject * pCode = MyFrame_GetCode(frame)->co_code;
int lasti = MyFrame_lasti(frame);

if (lasti < PyBytes_GET_SIZE(pCode)) {
bytecode = PyBytes_AS_STRING(pCode)[lasti];
}
if (bytecode != YIELD_VALUE) {
int first = MyFrame_GetCode(frame)->co_firstlineno;
if (CTracer_record_pair(self, self->pcur_entry->last_line, 
-first) < 0) {
goto error;
}
}


(2) get the line number, with a special case for generator which is not started 
yet (lasti < 0)
---
/* A call event is really a "start frame" event, and can happen for
 * re-entering a generator also.  f_lasti is -1 for a true call, and a
 * real byte offset for a generator re-entry.
 */
if (frame->f_lasti < 0) {
self->pcur_entry->last_line = -MyFrame_GetCode(frame)->co_firstlineno;
}
else {
self->pcur_entry->last_line = PyFrame_GetLineNumber(frame);
}
---

Since Python 3.10.0a3, PyFrame_GetLineNumber() handles the case of negative 
f_lasti, thanks to the commit 877df851c3ecdb55306840e247596e7b7805a60a related 
to the PEP 626 implementation:
---
int
PyCode_Addr2Line(PyCodeObject *co, int addrq)
{
if (addrq < 0) {
return co->co_firstlineno;
}
...
}
---


=> coverage would need an abstraction to get the last opcode: use case (1).


I recall that an old version of asyncio also had to get latest opcode, in pure 
Python, to workaround the CPython bpo-21209 bug:

+# Check for CPython issue #21209
+def has_yield_from_bug():
+class MyGen:
+def __init__(self):
+self.send_args = None
+def __iter__(self):
+return self
+def __next__(self):
+return 42
+def send(self, *what):
+self.send_args = what
+return None
+def yield_from_gen(gen):
+yield from gen
+value = (1, 2, 3)
+gen = MyGen()
+coro = yield_from_gen(gen)
+next(coro)
+coro.send(value)
+return gen.send_args != (value,)
+_YIELD_FROM_BUG = has_yield_from_bug()
+del has_yield_from_bug

(...)

+if _YIELD_FROM_BUG:
+# For for CPython issue #21209: using "yield from" and a custom
+# generator, generator.send(tuple) unpacks the tuple instead of passing
+# the tuple unchanged. Check if the caller is a generator using "yield
+# from" to decide if the parameter should be unpacked or not.
+def send(self, *value):
+frame = sys._getframe()
+caller = frame.f_back
+assert caller.f_lasti >= 0
+if caller.f_code.co_code[caller.f_lasti] != _YIELD_FROM:
+value = value[0]
+return self.gen.send(value)
+else:
+def send(self, value):
+return self.gen.send(value)

Hopefully, this code could be be removed from asyncio, since the bug was fixed 
(and asyncio is now only maintained in the Python stdlib, it's not longer a 
third party module).

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45459] Limited API support for Py_buffer

2021-10-13 Thread Christian Heimes


New submission from Christian Heimes :

Currently all APIs related to Py_buffer are excluded from the limited API. It's 
neither possible to use Py_buffer from a C extension with limited API nor is it 
possible to define heap types with buffer support using the stable ABI.

The lack of Py_buffer support prevents prominent projects like NumPy or Pillow 
to use the limited API and produce abi3 binary wheel. To be fair it's not the 
only reason why these projects have not adopted the stable abi3 yet. Still 
Py_buffer is a necessary but not sufficient condition. Stable abi3 support 
would enable NumPy stack to build binary wheels that work with any Python 
version >= 3.11, < 4.0.

The limited API excludes any C API that references Py_buffer:

- 8 PyBuffer_*() functions
- 21 PyBUF_* constants
- PyMemoryView_FromBuffer()
- PyObject_GetBuffer
- Py_bf_getbuffer / Py_bf_releasebuffer type slots for PyBufferProcs

It should not be terribly complicated to add Py_buffer to the stable API. All 
it takes are an opaque struct definition of Py_buffer, an allocate function, a 
free function and a bunch of getters and setters. The hard part is to figure 
out which getters and setters are needed and how many struct members must be 
exposed by getters and setters. I recommend to get feedback from NumPy, Pillow, 
and Cython devs first.


Prototype
-

typedef struct bufferinfo Py_buffer;

/* allocate a new Py_buffer object on the heap and initialize all members to 
NULL / 0 */
Py_buffer*
PyBuffer_New()
{
Py_buffer *view = PyMem_Calloc(1, sizeof(Py_buffer));
if (view == NULL) {
PyErr_NoMemory();
}
return view;
}

/* convenience function */
Py_buffer*
PyBuffer_NewEx(PyObject *obj, void *buf,  Py_ssize_t len, Py_ssize_t itemsize,
   int readonly, int ndim, char *format, Py_ssize_t *shape, 
Py_ssize_t *strides,
   Py_ssize_t *suboffsets, void *internal)
{
...
}

/* release and free buffer */
void
PyBuffer_Free(Py_buffer *view)
{
if (view != NULL) {
PyBuffer_Release(view);
PyMem_Free(view);
}
}

--
components: C API
messages: 403813
nosy: christian.heimes, petr.viktorin, vstinner
priority: normal
severity: normal
status: open
title: Limited API support for Py_buffer
type: enhancement
versions: Python 3.11

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



  1   2   >