[issue40479] Port _hashlib to OpenSSL 3.0.0

2022-02-07 Thread miss-islington


miss-islington  added the comment:


New changeset 3ceff9968be059209f0d7271365f38895207b24d by Miss Islington (bot) 
in branch '3.10':
bpo-40479: Fix undefined behavior in Modules/_hashopenssl.c (GH-31153)
https://github.com/python/cpython/commit/3ceff9968be059209f0d7271365f38895207b24d


--

___
Python tracker 

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



[issue40479] Port _hashlib to OpenSSL 3.0.0

2022-02-07 Thread miss-islington


miss-islington  added the comment:


New changeset 0892a0e3ec925ac959bc959b985293b4b96ef863 by Miss Islington (bot) 
in branch '3.9':
bpo-40479: Fix undefined behavior in Modules/_hashopenssl.c (GH-31153)
https://github.com/python/cpython/commit/0892a0e3ec925ac959bc959b985293b4b96ef863


--

___
Python tracker 

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



[issue24904] Provide a way for potentially long runtime difflib algorithms to be aborted by the caller (and report progress?)

2022-02-07 Thread Gregory P. Smith


Gregory P. Smith  added the comment:

The way I'd go about this is to support some form of periodic checkpoint in the 
algorithm where it checks in with code supplied by the difflib user. 
Traditionally that'd have been via callbacks, there might be an async style way 
to express that these days. Those could indicate that they want the operation 
to be aborted. If it is possible to estimate progress, supplying that as input 
to the checkpoint API would be useful.

This leaves decision logic on when to abort something entirely up to the user 
rather than being clock based which is often not what the user wants.

I'm re-titling the issue as the original patch and proposal of a timeout isn't 
the direction several core devs have suggested we head.

--
nosy: +gregory.p.smith
stage:  -> needs patch
title: Patch: add timeout to difflib SequenceMatcher ratio() and quick_ratio() 
-> Provide a way for potentially long runtime difflib algorithms to be aborted 
by the caller (and report progress?)

___
Python tracker 

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



[issue20342] Endianness not detected correctly due to AC_RUN_IFELSE macros

2022-02-07 Thread Gregory P. Smith


Gregory P. Smith  added the comment:

any idea if this is still relevant?

--
components: +Cross-Build
nosy: +Alex.Willmer, gregory.p.smith

___
Python tracker 

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



[issue46648] `test.test_urllib2.MiscTests.test_issue16464` flaky due to external connection

2022-02-07 Thread Nikita Sobolev


Change by Nikita Sobolev :


--
pull_requests: +29357
stage: needs patch -> patch review
pull_request: https://github.com/python/cpython/pull/31186

___
Python tracker 

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



[issue46657] Add mimalloc memory allocator

2022-02-07 Thread Erlend E. Aasland


Change by Erlend E. Aasland :


--
nosy: +erlendaasland

___
Python tracker 

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



[issue46648] `test.test_urllib2.MiscTests.test_issue16464` flaky due to external connection

2022-02-07 Thread Gregory P. Smith


Change by Gregory P. Smith :


--
assignee:  -> sobolevn

___
Python tracker 

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



[issue20342] Endianness not detected correctly due to AC_RUN_IFELSE macros

2022-02-07 Thread Yury V. Zaytsev


Yury V. Zaytsev  added the comment:

Well, the machine that I had the problem on does no longer exist and I'm not 
sure whether this is a generic POWER issue.

The problem was that I had to cross-compile Python on one generation of POWER 
machines for another POWER chip using its own special toolchain. I can't tell 
whether Python build system was doing something wrong, or else whether it was a 
problem with the toolchain. In theory, both are valid options.

Also, I can't test whether the current version of Python has this problem or 
not with this particular chip / toolchain anymore. Maybe someone who has 
interest in POWER could try to cross-compile from AMD64 to POWER and check 
whether the result is still subtly broken... this should be much easier, and if 
there is a genuine problem with Python build system, it will probably expose it 
just as well.

--

___
Python tracker 

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



[issue46611] Improve coverage of `__instancecheck__` and `__subclasscheck__` methods in `typing.py`

2022-02-07 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset c1ff4cb98b11c00aee765019364544c71e7dd2df by Nikita Sobolev in 
branch '3.10':
[3.10] bpo-46611: add coverage to instance and class checks in `typing.py` 
(GH-31078) (GH-31182)
https://github.com/python/cpython/commit/c1ff4cb98b11c00aee765019364544c71e7dd2df


--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue46611] Improve coverage of `__instancecheck__` and `__subclasscheck__` methods in `typing.py`

2022-02-07 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Thanks Nikita.

--
components: +Tests -Library (Lib)
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
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



[issue20342] Endianness not detected correctly due to AC_RUN_IFELSE macros

2022-02-07 Thread Gregory P. Smith


Gregory P. Smith  added the comment:

I'll leave it open, nothing about this should be ppc64 vs ppc64el specific. Our 
cross compilation story has historically been not great.  

Building for a target of one endianness from a build host of other 
endianness... sounds like exactly one of many kinds of thing that we might have 
a mess with until someone can confirm.  (I'm not setup with a big endian 
toolchain to build for a qemu target right now so I can't easily confirm)

--

___
Python tracker 

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



[issue46663] test_math test_cmath test_complex fails on Fedora Rawhide buildbots

2022-02-07 Thread Mark Dickinson


Mark Dickinson  added the comment:

@vstinner What was the change that caused the buildbots to start failing? Did 
the GCC version get updated on those machines between the last runs and this 
one, or was the change due to recent PRs in Python?

--
nosy: +mark.dickinson

___
Python tracker 

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



[issue46673] Py_BuildValue tuple creation segfaults in python3.9..3.11

2022-02-07 Thread Olli Lupton

New submission from Olli Lupton :

The following function, compiled and linked into a shared library, segfaults 
when called from Python:
```
#define PY_SSIZE_T_CLEAN
#include 
extern "C" PyObject* my_func() {
  return Py_BuildValue("(O)", Py_None);
}
```
called using ctypes:
```
from ctypes import CDLL
h = CDLL('./libtest.so’)
h.my_func()”
```
crashes with a stacktrace
```
Program received signal SIGSEGV, Segmentation fault.
_PyObject_GC_TRACK_impl (filename=0x7fffed7ab1b0 "src/Objects/tupleobject.c", 
lineno=36, op=(0x0,)) at src/Include/internal/pycore_object.h:43
(gdb) bt
#0  _PyObject_GC_TRACK_impl (filename=0x7fffed7ab1b0 
"src/Objects/tupleobject.c", lineno=36,
op=(0x0,)) at src/Include/internal/pycore_object.h:43
#1  tuple_gc_track (op=0x7fffe5e42dc0) at src/Objects/tupleobject.c:36
#2  PyTuple_New (size=) at src/Objects/tupleobject.c:124
#3  PyTuple_New (size=size@entry=1) at src/Objects/tupleobject.c:100
#4  0x7fffed7031eb in do_mktuple (p_format=0x7fffa8d0, 
p_va=0x7fffa8d8, endchar=, n=1, flags=1) at 
src/Python/modsupport.c:259
#5  0x7fffed703358 in va_build_value (format=, 
va=va@entry=0x7fffa918, flags=flags@entry=1) at src/Python/modsupport.c:562
#6  0x7fffed7036d9 in _Py_BuildValue_SizeT (format=) at 
src/Python/modsupport.c:530
#7  0x7fffedae6126 in my_func () at test.cpp:4
#8  0x7fffedaf1c9d in ffi_call_unix64 () from libffi.so.7
#9  0x7fffedaf0623 in ffi_call_int () from libffi.so.7
…
```
this is reproducible on RHEL7 (Python 3.9.7 built with GCC 11.2) and macOS 
(Python 3.9.10, 3.10.2 and 3.11.0a4 installed via MacPorts).
It does not crash with Python 3.8, I tested on RHEL7 (Python 3.8.3 built with 
GCC 9.3.0) and macOS (Python 3.8.12 installed via MacPorts).

This is meant to be a minimal example. It seems to be important that 
`Py_BuildValue` is returning a tuple, but the size of that tuple is not 
important.
`"O"` and `Py_None` are also not important, it still crashes with `"i"` and 
`42`.
The definition of `PY_SSIZE_T_CLEAN` also does not seem to be important; the 
only obvious difference it makes is whether I see `_Py_BuildValue_SizeT` or 
`Py_BuildValue` in the backtrace.

This seems to be a bit of an unlikely bug, so apologies in advance if I have 
missed something obvious. I tried to be thorough, but I do not have a lot of 
experience working with the Python C API.

--
components: C API, Extension Modules, ctypes
messages: 412725
nosy: olupton
priority: normal
severity: normal
status: open
title: Py_BuildValue tuple creation segfaults in python3.9..3.11
type: crash
versions: Python 3.10, 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



[issue46674] Two if in a row in generators

2022-02-07 Thread Ramil Nugmanov


New submission from Ramil Nugmanov :

treat without error two if in generators.

>>>[x for x in [1, 2, 3] if 1 if 1]
[1, 2, 3]

>>>[x for x in [1, 2, 3] if 0 if 1]
[]

expected syntax error

--
components: Parser
messages: 412726
nosy: lys.nikolaou, pablogsal, stsouko
priority: normal
severity: normal
status: open
title: Two if in a row in generators
type: behavior
versions: Python 3.8

___
Python tracker 

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



[issue46674] Two if in a row in generators

2022-02-07 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

It is valid syntax.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue46640] Python can now use the C99 NAN constant or __builtin_nan()

2022-02-07 Thread Petr Viktorin


Petr Viktorin  added the comment:

Adding new C99 features needs a change in PEP 7 
(https://www.python.org/dev/peps/pep-0007/#c-dialect)

--
nosy: +petr.viktorin
status: closed -> open

___
Python tracker 

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



[issue46672] NameError in asyncio.gather when passing a invalid type as an arg with multiple awaitables

2022-02-07 Thread Nikita Sobolev


Change by Nikita Sobolev :


--
keywords: +patch
nosy: +sobolevn
nosy_count: 3.0 -> 4.0
pull_requests: +29358
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/31187

___
Python tracker 

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



[issue41021] ctypes callback with structure crashes in Python 3.8 on Windows x86

2022-02-07 Thread Andreas Skaar


Andreas Skaar  added the comment:

Steve Dower do you have any links to the issues you mention? Are these now 
solved?

I am not able to see if the fix is straightforward, but from the information 
from Eryk Sun it sounds like it should be?

--

___
Python tracker 

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



[issue46665] IDLE Windows shortcuts by default

2022-02-07 Thread Alex Waygood


Alex Waygood  added the comment:

As a longtime Windows user, I also generally expect ctrl+Y to redo an action in 
most programs, FWIW.

--
nosy: +AlexWaygood

___
Python tracker 

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



[issue38605] [typing] PEP 563: Postponed evaluation of annotations: enable it by default in Python 3.11

2022-02-07 Thread Jakub Wilk


Change by Jakub Wilk :


--
nosy: +jwilk

___
Python tracker 

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



[issue46674] Two if in a row in generators

2022-02-07 Thread Batuhan Taskaya


Batuhan Taskaya  added the comment:

As Serhiy mentioned, this is a valid syntax.

--
nosy: +BTaskaya
resolution:  -> not a bug
stage:  -> 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



[issue46673] Py_BuildValue tuple creation segfaults in python3.9..3.11

2022-02-07 Thread Olli Lupton


Olli Lupton  added the comment:

With apologies for the noise, I realise that the posted example does not handle 
the GIL correctly.

--
resolution:  -> not a bug
stage:  -> 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



[issue46159] Segfault when using trace functions in 3.11a3

2022-02-07 Thread Mark Shannon


Mark Shannon  added the comment:

Can you reproduce this failure with just Python?
If not, with just cryptography and not tox?

--

___
Python tracker 

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



[issue46161] `class A(1, 2, 3, **d): pass` gives bad bytecode

2022-02-07 Thread Mark Shannon


Mark Shannon  added the comment:

Qiang Zhang, thanks for fixing this.

--
resolution:  -> fixed
stage:  -> 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



[issue46675] Allow more than 16 items in split-keys dicts and "virtual" object dicts.

2022-02-07 Thread Mark Shannon


New submission from Mark Shannon :

https://bugs.python.org/issue45340 and 
https://github.com/python/cpython/pull/28802 allowed "virtual" object dicts 
(see faster-cpython/ideas#72  for full details).

In order for this to work, we need to keep the insertion order on the values. 
The initial version (https://github.com/python/cpython/pull/28802) used a 64 
bit value as a vector of 16 4-bit values, which allows only 16 items per values 
array.

Stats gathered from the standard benchmark suite and informal evidence from 
elsewhere suggests that this causes a significant (5% and upwards) of these 
dicts to be materialized due to exceeding the 16 item limit.

An alternative design that would allow up to ~254 items in the values array is 
to make the insertion order vector an array of bytes. The capacity is 254 as we 
need a byte for size, and another for capacity.
This will increase the size of the values a bit for sizes from 7 to 15, but 
save a lot of memory for sizes 17+, as keys could still be shared.

Pros:
No need to materialize dicts of size 16+, saving ~3/4 of the memory per 
dict and helping specialization.

Cons:
Extra memory write to store a value*
1 extra word for values of size 7 to 14, 2 extra for size 15.
Some extra complexity.

*In a hypothetical optimized JIT, the insertion order vector would be stored as 
a single write for several writes, so this would make no difference.

--
assignee: Mark.Shannon
messages: 412735
nosy: Mark.Shannon
priority: normal
severity: normal
status: open
title: Allow more than 16 items in split-keys dicts and "virtual" object dicts.
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



[issue46674] Two if in a row in generators

2022-02-07 Thread Ramil Nugmanov


Ramil Nugmanov  added the comment:

Yes,

[x for x in [1, 2, 3] if 1 if 1]

can be replaced with:

for x in [1, 2, 3]:
if 1:
if 1:
yield x

However this syntax is strange and leads to errors like:

[x for x in [1, 2, 3] if x is not None] >> [x for x in [1, 2, 3] if x if not 
None]

--
resolution: not a bug -> 
status: closed -> open

___
Python tracker 

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



[issue46323] Use _PyObject_Vectorcall in Modules/_ctypes/callbacks.c

2022-02-07 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +29359
pull_request: https://github.com/python/cpython/pull/31188

___
Python tracker 

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



[issue46648] `test.test_urllib2.MiscTests.test_issue16464` flaky due to external connection

2022-02-07 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 8e98175a03fe03d62822d96007a74e5273013764 by Nikita Sobolev in 
branch 'main':
bpo-46648: Rewrite test_urllib2.test_issue16464() with a local HTTP server 
(GH-31186)
https://github.com/python/cpython/commit/8e98175a03fe03d62822d96007a74e5273013764


--
nosy: +vstinner

___
Python tracker 

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



[issue46648] `test.test_urllib2.MiscTests.test_issue16464` flaky due to external connection

2022-02-07 Thread miss-islington


Change by miss-islington :


--
pull_requests: +29360
pull_request: https://github.com/python/cpython/pull/31189

___
Python tracker 

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



[issue46648] `test.test_urllib2.MiscTests.test_issue16464` flaky due to external connection

2022-02-07 Thread miss-islington


Change by miss-islington :


--
pull_requests: +29361
pull_request: https://github.com/python/cpython/pull/31190

___
Python tracker 

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



[issue46674] Two if in a row in generators

2022-02-07 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

Please, stop reopening the issue.

The syntax is valid python syntax and we will not be able to make it invalid

--
resolution:  -> not a bug
status: open -> closed

___
Python tracker 

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



[issue46668] encodings: the "mbcs" alias doesn't work

2022-02-07 Thread STINNER Victor


STINNER Victor  added the comment:

I don't think that this fallback is needed anymore. Which Windows code page can 
be used as ANSI code page which is not already implemented as a Python codec?

--

___
Python tracker 

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



[issue46648] `test.test_urllib2.MiscTests.test_issue16464` flaky due to external connection

2022-02-07 Thread miss-islington


miss-islington  added the comment:


New changeset 0d74efc54fa811def386d2cde00986204ba18569 by Miss Islington (bot) 
in branch '3.9':
bpo-46648: Rewrite test_urllib2.test_issue16464() with a local HTTP server 
(GH-31186)
https://github.com/python/cpython/commit/0d74efc54fa811def386d2cde00986204ba18569


--

___
Python tracker 

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



[issue46657] Add mimalloc memory allocator

2022-02-07 Thread Christian Heimes


Christian Heimes  added the comment:

ICC might be a problem. Apparently some version have an incomplete stdatomic.h, 
see bpo-37415.

--

___
Python tracker 

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



[issue46663] test_math test_cmath test_complex fails on Fedora Rawhide buildbots

2022-02-07 Thread STINNER Victor


STINNER Victor  added the comment:

> @vstinner What was the change that caused the buildbots to start failing? Did 
> the GCC version get updated on those machines between the last runs and this 
> one, or was the change due to recent PRs in Python?

It's a GCC regression. GCC is updated frequently on the Rawhide buildbots.

It's unrelated to Python. It's just that Python uses (Py_HUGE_VAL * 0.) for 
Py_NAN and this code is impacted by the bug.

But I wrote https://github.com/python/cpython/pull/31134 since GCC 12 will no 
longer compute (Py_HUGE_VAL * 0.) during the compilation: it will be computed 
at runtime.

See also https://bugzilla.redhat.com/show_bug.cgi?id=2050736 for details.

--

The GCC regression is fixed in gcc-12.0.1-0.6.fc36 package. It will be deployed 
on buildbots shortly (and automatically).

--

___
Python tracker 

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



[issue24904] Provide a way for potentially long runtime difflib algorithms to be aborted by the caller (and report progress?)

2022-02-07 Thread STINNER Victor


Change by STINNER Victor :


--
nosy:  -vstinner

___
Python tracker 

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



[issue46640] Python can now use the C99 NAN constant or __builtin_nan()

2022-02-07 Thread STINNER Victor


STINNER Victor  added the comment:

> Adding new C99 features needs a change in PEP 7 
> (https://www.python.org/dev/peps/pep-0007/#c-dialect)

IMO this PEP is outdated for a long time.

C99 standard is wide. Do we have to explicitly list every single function, 
macro or constant used by Python? It doesn't sound reasonable to me. IMO saying 
that we use "C99 except of these few features: <...>" would be closer to the 
reality. I don't know which features are not used.

Well, if you ask me, I would simply require a C99 compiler. That's all :-)

Note: Python uses C11 , but it remains an optional requirement.

--

___
Python tracker 

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



[issue46323] Use _PyObject_Vectorcall in Modules/_ctypes/callbacks.c

2022-02-07 Thread STINNER Victor


STINNER Victor  added the comment:

A benchmark on calling C functions using ctypes sounds better than a benchmark 
calling Python functions. For Python functions, Python objects are converted to 
C types, and then C types are convered back to Python objects, the Python 
result is converted to a C type, and then the C type is converted back to a 
Python object for the final result...

It would be nice to have a benchmark on different number of arguments. Like: 0, 
1, 3, 5, 8, 10.

--

___
Python tracker 

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



[issue46323] Use _PyObject_Vectorcall in Modules/_ctypes/callbacks.c

2022-02-07 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 4cce1352bb47babaeefb68fcfcc48ffa073745c3 by Victor Stinner in 
branch 'main':
bpo-46323: _ctypes.CFuncPtr fails if _argtypes_ is too long (GH-31188)
https://github.com/python/cpython/commit/4cce1352bb47babaeefb68fcfcc48ffa073745c3


--

___
Python tracker 

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



[issue46670] Build Python with -Wundef: don't use undefined macros

2022-02-07 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +29362
pull_request: https://github.com/python/cpython/pull/31192

___
Python tracker 

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



[issue46670] Build Python with -Wundef: don't use undefined macros

2022-02-07 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +29363
pull_request: https://github.com/python/cpython/pull/31193

___
Python tracker 

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



[issue46670] Build Python with -Wundef: don't use undefined macros

2022-02-07 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +29364
pull_request: https://github.com/python/cpython/pull/31194

___
Python tracker 

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



[issue46670] Build Python with -Wundef: don't use undefined macros

2022-02-07 Thread STINNER Victor


STINNER Victor  added the comment:

-Wexpansion-to-defined and -Wunused-macros options are also interesting.

--

___
Python tracker 

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



[issue39277] _PyTime_FromDouble() fails to detect an integer overflow when converting a C double to a C int64_t

2022-02-07 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +29365
pull_request: https://github.com/python/cpython/pull/31195

___
Python tracker 

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



[issue46670] Build Python with -Wundef: don't use undefined macros

2022-02-07 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +29366
pull_request: https://github.com/python/cpython/pull/31196

___
Python tracker 

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



[issue46640] Python can now use the C99 NAN constant or __builtin_nan()

2022-02-07 Thread STINNER Victor


STINNER Victor  added the comment:

> Well, if you ask me, I would simply require a C99 compiler. That's all :-)

Done in https://github.com/python/peps/pull/2309

--

___
Python tracker 

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



[issue46640] Python can now use the C99 NAN constant or __builtin_nan()

2022-02-07 Thread Petr Viktorin


Petr Viktorin  added the comment:

> IMO this PEP is outdated for a long time.

It is not. Even if it is, it should be marked as such, and that is not a 
decision that should be done in this issue.

Please, don't break the rules because you think they're outdated.

> Well, if you ask me, I would simply require a C99 compiler. That's all :-)

Please propose that change. Perhaps it would be a good change to make, but I 
don't even know how to determine that.
Nor can I list the places where the change should be made -- at least there 
should be a What's New entry like 
https://docs.python.org/3.10/whatsnew/3.6.html#build-and-c-api-changes

> Note: Python uses C11 , but it remains an optional requirement.

That's fine. You can still build with an older compiler.

--

___
Python tracker 

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



[issue46657] Add mimalloc memory allocator

2022-02-07 Thread Christian Heimes


Christian Heimes  added the comment:

References:

- C11 stdatomic.h https://en.cppreference.com/w/c/atomic
- mimalloc-atomic.h 
https://github.com/microsoft/mimalloc/blob/master/include/mimalloc-atomic.h
- MSVC Interlocked Variable Access 
https://docs.microsoft.com/de-de/windows/win32/sync/interlocked-variable-access

--

___
Python tracker 

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



[issue46675] Allow more than 16 items in split-keys dicts and "virtual" object dicts.

2022-02-07 Thread Mark Shannon


Change by Mark Shannon :


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

___
Python tracker 

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



[issue46072] Unify handling of stats in the CPython VM

2022-02-07 Thread Mark Shannon


Mark Shannon  added the comment:


New changeset 062460e8fd54e53c9a1a6f175ef49c9d730851b8 by Mark Shannon in 
branch 'main':
bpo-46072: Improve LOAD_METHOD stats (GH-31104)
https://github.com/python/cpython/commit/062460e8fd54e53c9a1a6f175ef49c9d730851b8


--

___
Python tracker 

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



[issue46072] Unify handling of stats in the CPython VM

2022-02-07 Thread Mark Shannon


Change by Mark Shannon :


--
pull_requests: +29368
pull_request: https://github.com/python/cpython/pull/31197

___
Python tracker 

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



[issue46639] Ceil division with math.ceildiv

2022-02-07 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

I don't understand why math.ceildiv couldn't ducktype. There's no rule that 
says it *must* convert arguments to float first, that's just a convention, and 
we've broken it before.

>>> math.prod([Fraction(1, 3), 7])
Fraction(7, 3)

Couldn't math.ceildiv(x, y) be implemented as -(-x//y) in a type-agnostic 
fashion?


Perhaps it is too late in the night for me, but I have no idea what ceilrem(x, 
y) would do or why anyone might want it.

I agree with Vladimir that the import thing is not an issue. If we can require 
an import for much more important functions as sin, cos, tan, log, etc, then 
requiring an import is not excessive for a function of secondary importance.

Feature-bloat: its taken 30 years for somebody to request ceildiv. At that 
rate, it will take another 500 years for us to catch up to mpz in terms of 
features/bloat. I'm not losing sleep over that :-)

--
nosy: +steven.daprano

___
Python tracker 

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



[issue46667] SequenceMatcher & autojunk - false negative

2022-02-07 Thread Jonathan


Jonathan  added the comment:

I still don't get how UNIQUESTRING is the longest even with autojunk=True, but 
that's an implementation detail and I'll trust you that it's working as 
expected.

Given this, I'd suggest the following then:

* `Autojunk=False` should be the default unless there's some reason to believe 
SequenceMatcher is mostly used for code comparisons.

* If - for whatever reason - the default can't be changed, I'd suggest a nice 
big docs "Warning" (at a minimum a "Note") saying something like "The default 
autojunk=True is not suitable for normal string comparison. See autojunk for 
more information".

* Human-friendly doc explanation for autojunk. The current explanation is only 
going to be helpful to the tiny fraction of users who understand the algorithm. 
Your explanation is a good start:
"Autojunk was introduced as a way to greatly speed comparing files of 
code, viewing them as sequences of lines. But it more often backfires when 
comparing strings (viewed as sequences of characters)"

Put simply: The current docs aren't helpful to users who don't have text 
matching expertise, nor do they emphasise the huge caveat that autojunk=True 
raises.

--

___
Python tracker 

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



[issue46670] Build Python with -Wundef: don't use undefined macros

2022-02-07 Thread Mark Shannon


Mark Shannon  added the comment:


New changeset 4b603f628207b380a8a2f22d7ff5d2dbb0853e2e by Victor Stinner in 
branch 'main':
bpo-46670: Remove unused macros in ceval.c (GH-31196)
https://github.com/python/cpython/commit/4b603f628207b380a8a2f22d7ff5d2dbb0853e2e


--
nosy: +Mark.Shannon

___
Python tracker 

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



[issue39277] _PyTime_FromDouble() fails to detect an integer overflow when converting a C double to a C int64_t

2022-02-07 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset d3e53bc5321a9f08c7ed5b9383eefb2e03dfa6e2 by Victor Stinner in 
branch 'main':
bpo-39277: Fix PY_TIMEOUT_MAX cast in _threadmodule.c (GH-31195)
https://github.com/python/cpython/commit/d3e53bc5321a9f08c7ed5b9383eefb2e03dfa6e2


--

___
Python tracker 

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



[issue46670] Build Python with -Wundef: don't use undefined macros

2022-02-07 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 4f1d3f33dd8b37a151b73533f18b08b0500223e5 by Victor Stinner in 
branch 'main':
 bpo-46670: Remove unused macros in the Modules directory (GH-31194)
https://github.com/python/cpython/commit/4f1d3f33dd8b37a151b73533f18b08b0500223e5


--

___
Python tracker 

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



[issue46670] Build Python with -Wundef: don't use undefined macros

2022-02-07 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 760349198dbd8771629753e096a885c1aa28a1ca by Victor Stinner in 
branch 'main':
bpo-46670: Remove unused macros in the Objects directory (GH-31193)
https://github.com/python/cpython/commit/760349198dbd8771629753e096a885c1aa28a1ca


--

___
Python tracker 

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



[issue46670] Build Python with -Wundef: don't use undefined macros

2022-02-07 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 7d8b69e1d1f125454d8cec81ff0dee72f2bef957 by Victor Stinner in 
branch 'main':
bpo-46670: Remove unused macros in the Python directory (GH-31192)
https://github.com/python/cpython/commit/7d8b69e1d1f125454d8cec81ff0dee72f2bef957


--

___
Python tracker 

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



[issue46670] Build Python with -Wundef: don't use undefined macros

2022-02-07 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset f20ca766fe404a20daea29230f161a0eb71bb489 by Victor Stinner in 
branch 'main':
bpo-46670: Fix #ifdef in sha3module.c (GH-31180)
https://github.com/python/cpython/commit/f20ca766fe404a20daea29230f161a0eb71bb489


--

___
Python tracker 

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



[issue46323] Use _PyObject_Vectorcall in Modules/_ctypes/callbacks.c

2022-02-07 Thread hydroflask


hydroflask  added the comment:

> A benchmark on calling C functions using ctypes sounds better than a 
> benchmark calling Python functions.

Calling C functions from Python is not the code path handled by 
_CallPythonObject() so no difference in run-time would theoretically be 
observed by that benchmark for this patch. This bug report pertains to code 
paths where a C function calls back into a Python function. A practical example 
is using Python with an event loop library written in C.

--

___
Python tracker 

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



[issue46323] Use _PyObject_Vectorcall in Modules/_ctypes/callbacks.c

2022-02-07 Thread STINNER Victor


STINNER Victor  added the comment:

Oh ok, thanks for the clarification :-)

--

___
Python tracker 

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



[issue46166] Get "self" args or non-null co_varnames from frame object with C-API

2022-02-07 Thread Aaron Gokaslan


Aaron Gokaslan  added the comment:

The frame object I am referring to was:

PyFrameObject *frame = PyThreadState_GetFrame(PyThreadState_Get());

This frame can not be used with PyObject_GetAttrString. Is there anyway to get 
the PyObject* associated with a PyFrameObject*? It seems weird that some 
functionality is just not accessible using the Stable ABI of 
PyThreadState_GetFrame . 

To elabroate: I was referring to the migration guide in the changelog btw:

f_code: removed, use PyFrame_GetCode() instead. Warning: the function 
returns a strong reference, need to call Py_DECREF().

f_back: changed (see below), use PyFrame_GetBack().

f_builtins: removed, use PyObject_GetAttrString(frame, "f_builtins").
  
// this frame object actually has to be a PyObject*, the old one was a  
PyFrameObject* . Dropping this in does not work. 
f_globals: removed, use PyObject_GetAttrString(frame, "f_globals").

f_locals: removed, use PyObject_GetAttrString(frame, "f_locals").

f_lasti: removed, use PyObject_GetAttrString(frame, "f_lasti").


I tried importing sys._getframe(), but that gave an attribute error 
interestingly enough. Run a full code snippit here works: 
https://github.com/pybind/pybind11/blob/96b943be1d39958661047eadac506745ba92b2bc/include/pybind11/pybind11.h#L2429,
 but is really slow and we would like avoid having to rely on it. Not to 
mention relying on a function that is an starts with an underscore seems like 
it really should be avoided.

--

___
Python tracker 

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



[issue46166] Get "self" args or non-null co_varnames from frame object with C-API

2022-02-07 Thread STINNER Victor


STINNER Victor  added the comment:

Example of C code that I added to _testcapi:
---
static PyObject *
get_caller_locals(PyObject *self, PyObject *Py_UNUSED(args))
{
PyFrameObject *frame = PyThreadState_GetFrame(PyThreadState_Get());
if (frame == NULL) {
Py_RETURN_NONE;
}
return PyObject_GetAttrString(frame, "f_locals");
}
---

Python example:
---
import _testcapi

def f():
x = 1
y = 2
print(_testcapi.get_caller_locals())

f()
---

Output on Python 3.11:
---
{'x': 1, 'y': 2}
---

=> it just works.

A PyFrameObject is a regular Python object, you can use functions like 
PyObject_GetAttrString().

Maybe I missed something, correct me if I'm wrong.

--

___
Python tracker 

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



[issue46166] Get "self" args or non-null co_varnames from frame object with C-API

2022-02-07 Thread STINNER Victor


STINNER Victor  added the comment:

> Is there anyway to get the PyObject* associated with a PyFrameObject*?

Ah. I see. If you pass a PyFrameObject* frame to PyObject_GetAttrString(), you 
get a compiler warning.

You should cast it explicitly: PyObject_GetAttrString((PyObject*)frame, 
"f_locals").

--

___
Python tracker 

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



[issue46166] Get "self" args or non-null co_varnames from frame object with C-API

2022-02-07 Thread STINNER Victor


Change by STINNER Victor :


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

___
Python tracker 

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



[issue46166] Get "self" args or non-null co_varnames from frame object with C-API

2022-02-07 Thread STINNER Victor


STINNER Victor  added the comment:

I proposed GH-31198 to fix the compiler warnings in the doc.

--

___
Python tracker 

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



[issue46323] Use _PyObject_Vectorcall in Modules/_ctypes/callbacks.c

2022-02-07 Thread hydroflask


hydroflask  added the comment:

Just to clarify further, the original benchmark by corona10 did indeed lead to 
`_CallPythonObject` being invoked but it was not quite the normal use-case. In 
the original benchmark it invoked the generated ctypes thunk via Python so as 
vstinner said it was doing this:

Python -> converters -> thunk-> _CallPythonObject -> converters-> Python

Namely using `PyCFuncPtr_call` to invoke the thunk generated by 
`_ctypes_alloc_callback`. Normally when invoking C functions via 
`PyCFuncPtr_call` it looks like this:

Python -> converters -> C_function

In the original benchmark setup no significant reduction in runtime was 
observed by this patch.  I noticed that it was not a typical use of 
`_CallPythonObject`, where instead it would be a top-level C function calling 
back into Python. Something like this:

C -> thunk -> _CallPythonObject() -> Python

The benchmark I provided exercises that use case and the >=10% reduction in 
runtime was observed. Thanks to both corona10 and vstinner, I appreciate their 
effort in this issue.

--

___
Python tracker 

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



[issue46166] [C API] Get "self" args or non-null co_varnames from frame object with C-API

2022-02-07 Thread STINNER Victor


Change by STINNER Victor :


--
title: Get "self" args or non-null co_varnames from frame object with C-API -> 
[C API] Get "self" args or non-null co_varnames from frame object with C-API

___
Python tracker 

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



[issue46655] typing.TypeAlias is not in the list of allowed plain _SpecialForm typeforms

2022-02-07 Thread Guido van Rossum


Guido van Rossum  added the comment:


New changeset e2eeffefed32bb8c47c09bdd94e27a4e949894ef by Gregory Beauregard in 
branch '3.10':
[3.10] bpo-46655: allow stringized TypeAlias with get_type_hints (GH-31156). 
(#31175)
https://github.com/python/cpython/commit/e2eeffefed32bb8c47c09bdd94e27a4e949894ef


--

___
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

2022-02-07 Thread pmp-p


Change by pmp-p :


--
nosy: +pmpp

___
Python tracker 

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



[issue46647] `test_functools` unexpected failures when C `_functoolsmodule` is missing

2022-02-07 Thread Hai Shi


Hai Shi  added the comment:

> _functoolsmodule is a core bootstrap module and defined in 
> Modules/Setup.bootstrap. It has no external dependencies. There is no reason 
> and no point to disable the module.

+1. 

> Cristian, in this case - is there a reason to keep `skipUnless(c_functools)` 
> around? 
> If we are sure that it is always available - then it should be always tested. 

Hm. Personally, I suggest to keep the `skipUnless` to aovid the code churn.
Or maybe you have other cases to show the functools module will missing 
unexpectly?

--

___
Python tracker 

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



[issue46166] [C API] Get "self" args or non-null co_varnames from frame object with C-API

2022-02-07 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset a89772c79183e3e62bf61b92077a04f6ebcc4a2b by Victor Stinner in 
branch 'main':
bpo-46166: Fix compiler warnings in What's New in Python 3.11 (GH-31198)
https://github.com/python/cpython/commit/a89772c79183e3e62bf61b92077a04f6ebcc4a2b


--

___
Python tracker 

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



[issue46072] Unify handling of stats in the CPython VM

2022-02-07 Thread Mark Shannon


Mark Shannon  added the comment:


New changeset 9c979d7afd839abbb080028bdfeb73727e5cf633 by Mark Shannon in 
branch 'main':
bpo-46072: Merge dxpairs into py_stats. (GH-31197)
https://github.com/python/cpython/commit/9c979d7afd839abbb080028bdfeb73727e5cf633


--

___
Python tracker 

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



[issue46638] Inconsistent registry virtualization in Windows Store package

2022-02-07 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 4.0 -> 5.0
pull_requests: +29370
pull_request: https://github.com/python/cpython/pull/31199

___
Python tracker 

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



[issue46638] Inconsistent registry virtualization in Windows Store package

2022-02-07 Thread miss-islington


Change by miss-islington :


--
pull_requests: +29371
pull_request: https://github.com/python/cpython/pull/31200

___
Python tracker 

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



[issue46638] Inconsistent registry virtualization in Windows Store package

2022-02-07 Thread Steve Dower


Steve Dower  added the comment:


New changeset 3a5afc14e16370c1f4f72d43cb553298ad9a1fa4 by Steve Dower in branch 
'main':
bpo-46638: Makes registry virtualisation setting stable when building MSIX 
packages (GH-31130)
https://github.com/python/cpython/commit/3a5afc14e16370c1f4f72d43cb553298ad9a1fa4


--

___
Python tracker 

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



[issue41021] ctypes callback with structure crashes in Python 3.8 on Windows x86

2022-02-07 Thread Steve Dower


Steve Dower  added the comment:

Only by following the link I posted and searching for issues that sound like 
this one.

Which I just did for you: https://github.com/libffi/libffi/issues/367

There may be more, though. I just grabbed the first one that looked like a 
match.

--

___
Python tracker 

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



[issue46669] Add types.Self

2022-02-07 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

On a related note, is this the correct way to annotate __exit__?


Exc = TypeVar('Exc', bound=Exception)

def __exit__(self, exctype: Optional[Type[Exc]], excinst: Optional[Exc], exctb: 
Any) -> None:

--

___
Python tracker 

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



[issue12029] Allow catching virtual subclasses in except clauses

2022-02-07 Thread Václav Dvořák

Change by Václav Dvořák :


--
nosy: +Václav Dvořák

___
Python tracker 

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



[issue46638] Inconsistent registry virtualization in Windows Store package

2022-02-07 Thread miss-islington


miss-islington  added the comment:


New changeset 9c45390208df712126c59f7c2b6f8d2b4e19ccf7 by Miss Islington (bot) 
in branch '3.10':
bpo-46638: Makes registry virtualisation setting stable when building MSIX 
packages (GH-31130)
https://github.com/python/cpython/commit/9c45390208df712126c59f7c2b6f8d2b4e19ccf7


--

___
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

2022-02-07 Thread pmp-p


pmp-p  added the comment:

There's some side effects with "buffer.h" inclusion in Panda3D when building 
againt 3.11a5, project manager concerns are here 
https://github.com/python/cpython/pull/29991#issuecomment-1031731100

--

___
Python tracker 

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



[issue46638] Inconsistent registry virtualization in Windows Store package

2022-02-07 Thread Steve Dower


Steve Dower  added the comment:


New changeset 76b072717a160c44cb8d54be3d5e878bc31f2c38 by Miss Islington (bot) 
in branch '3.9':
bpo-46638: Makes registry virtualisation setting stable when building MSIX 
packages (GH-31130)
https://github.com/python/cpython/commit/76b072717a160c44cb8d54be3d5e878bc31f2c38


--

___
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

2022-02-07 Thread STINNER Victor


STINNER Victor  added the comment:

> There's some side effects with "buffer.h" inclusion in Panda3D when building 
> againt 3.11a5, project manager concerns are here 
> https://github.com/python/cpython/pull/29991#issuecomment-1031731100

Copy of rdb's message:
"""
This change broke our project build because when cpython/object.h is including 
buffer.h it is forcing it to resolve along the search path, and the compiler is 
hitting the buffer.h in our project rather than the one in the Python include 
directory.

Should it not be using a relative include, ie. #include "../buffer.h" ? I think 
otherwise this change will cause breakage for many projects given how common 
the header name "buffer.h" may be.
"""

In Python.h, buffer.h is included before object.h. But object.h includes 
buffer.h. I suggest to include buffer.h before object.h and remove #include 
"buffer.h" from Include/cpython/buffer.h.

Also, I agree that renaming buffer.h to pybuffer.h would reduce issues like 
that. Moreover, this header file exposes the "Py_buffer" API, so "pybuffer.h" 
sounds like a better name ;-)

--
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



[issue12029] Allow catching virtual subclasses in except clauses

2022-02-07 Thread Václav Dvořák

Change by Václav Dvořák :


--
versions: +Python 3.9

___
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

2022-02-07 Thread rdb


Change by rdb :


--
nosy: +rdb

___
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

2022-02-07 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +29372
stage: resolved -> patch review
pull_request: https://github.com/python/cpython/pull/31201

___
Python tracker 

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



[issue46668] encodings: the "mbcs" alias doesn't work

2022-02-07 Thread Eryk Sun


Eryk Sun  added the comment:

> I don't think that this fallback is needed anymore. Which Windows
> code page can be used as ANSI code page which is not already 
> implemented as a Python codec?

Python has full coverage of the ANSI and OEM code pages in the standard Windows 
locales, but I don't have any experience with custom (i.e. supplemental or 
replacement) locales.

https://docs.microsoft.com/en-us/windows/win32/intl/custom-locales 

Here's a simple script to check the standard locales.

import codecs
import ctypes
kernel32 = ctypes.WinDLL('kernel32', use_last_error=True)

LOCALE_ALL = 0
LOCALE_WINDOWS = 1
LOCALE_IDEFAULTANSICODEPAGE = 0x1004
LOCALE_IDEFAULTCODEPAGE = 0x000B # OEM

EnumSystemLocalesEx = kernel32.EnumSystemLocalesEx
GetLocaleInfoEx = kernel32.GetLocaleInfoEx
GetCPInfoExW = kernel32.GetCPInfoExW

EnumLocalesProcEx = ctypes.WINFUNCTYPE(ctypes.c_int,
ctypes.c_wchar_p, ctypes.c_ulong, ctypes.c_void_p)

class CPINFOEXW(ctypes.Structure):
 _fields_ = (('MaxCharSize', ctypes.c_uint),
 ('DefaultChar', ctypes.c_ubyte * 2),
 ('LeadByte', ctypes.c_ubyte * 12),
 ('UnicodeDefaultChar', ctypes.c_wchar),
 ('CodePage', ctypes.c_uint),
 ('CodePageName', ctypes.c_wchar * 260))

def get_all_locale_code_pages():
result = []
seen = set()
info = (ctypes.c_wchar * 100)()

@EnumLocalesProcEx
def callback(locale, flags, param):
for lctype in (LOCALE_IDEFAULTANSICODEPAGE, 
LOCALE_IDEFAULTCODEPAGE):
if (GetLocaleInfoEx(locale, lctype, info, len(info)) and
  info.value not in ('0', '1')):
cp = int(info.value)
if cp in seen:
continue
seen.add(cp)
cp_info = CPINFOEXW()
if not GetCPInfoExW(cp, 0, ctypes.byref(cp_info)):
cp_info.CodePage = cp
cp_info.CodePageName = str(cp)
result.append(cp_info)
return True

if not EnumSystemLocalesEx(callback, LOCALE_WINDOWS, None, None):
raise ctypes.WinError(ctypes.get_last_error())

result.sort(key=lambda x: x.CodePage)
return result

supported = []
unsupported = []
for cp_info in get_all_locale_code_pages():
cp = cp_info.CodePage
try:
codecs.lookup(f'cp{cp}')
except LookupError:
unsupported.append(cp_info)
else:
supported.append(cp_info)

if unsupported:
print('Unsupported:\n')
for cp_info in unsupported:
print(cp_info.CodePageName)
print('\nSupported:\n')
else:
print('All Supported:\n')
for cp_info in supported:
print(cp_info.CodePageName)


Output:

All Supported:

437   (OEM - United States)
720   (Arabic - Transparent ASMO)
737   (OEM - Greek 437G)
775   (OEM - Baltic)
850   (OEM - Multilingual Latin I)
852   (OEM - Latin II)
855   (OEM - Cyrillic)
857   (OEM - Turkish)
862   (OEM - Hebrew)
866   (OEM - Russian)
874   (ANSI/OEM - Thai)
932   (ANSI/OEM - Japanese Shift-JIS)
936   (ANSI/OEM - Simplified Chinese GBK)
949   (ANSI/OEM - Korean)
950   (ANSI/OEM - Traditional Chinese Big5)
1250  (ANSI - Central Europe)
1251  (ANSI - Cyrillic)
1252  (ANSI - Latin I)
1253  (ANSI - Greek)
1254  (ANSI - Turkish)
1255  (ANSI - Hebrew)
1256  (ANSI - Arabic)
1257  (ANSI - Baltic)
1258  (ANSI/OEM - Viet Nam)

Some locales are Unicode only (e.g. Hindi-India) or have no OEM code page, 
which the above code skips by checking for "0" or "1" as the code page value. 
Windows 10+ allows setting the system locale to a Unicode-only locale, for 
which it uses UTF-8 (65001) for ANSI and OEM.

The OEM code page matters because the console input and output code pages 
default to OEM, e.g. for os.device_encoding(). The console's I/O code pages are 
used in Python by low-level os.read() and os.write(). Note that the console 
doesn't properly implement using UTF-8 (65001) as the input code page. In this 
case, input read from the console via ReadFile() or ReadConsoleA() has a null 
byte in place of each non-ASCII character.

--

___
Python tracker 

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



[issue46669] Add types.Self

2022-02-07 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> Implementing PEP 673 (Self type)

___
Python tracker 

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



[issue12029] Allow catching virtual subclasses in except clauses

2022-02-07 Thread Guido van Rossum


Guido van Rossum  added the comment:

Fixing the version field. Since it's a feature, this could not go into any 
version before 3.11.

Maybe Irit can look through the discussion and patch and see if there's value 
to doing this? (Feel free to decline!)

--
nosy: +iritkatriel
versions: +Python 3.11 -Python 3.4, Python 3.5, Python 3.6, Python 3.7, Python 
3.8, Python 3.9

___
Python tracker 

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



[issue46667] SequenceMatcher & autojunk - false negative

2022-02-07 Thread Tim Peters


Tim Peters  added the comment:

We can't change defaults without superb reason - Python has millions of users, 
and changing the output of code "that works" is almost always a non-starter.

Improvements to the docs are welcome.

In your example, try running this code after using autojunk=True:

pending = ""
for ch in first:
if ch in sm.bpopular:
if pending:
print(repr(pending))
pending = ""
else:
pending += ch
print(repr(pending))

That shows how `first` is effectively broken into tiny pieces given that the 
"popular" chaaracters act like walls. Here's the start of the output:

'\nUN'
'QUESTR'
'NG\nL'
'x'
'f'
'.'
'L'
'b'
"'"
'x'
'v'
'1500'
','

and on & on. `QUESTER' is the longest common contiguous substring remaining.

--

___
Python tracker 

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



[issue46639] Ceil division with math.ceildiv

2022-02-07 Thread Mark Dickinson


Mark Dickinson  added the comment:

> Couldn't math.ceildiv(x, y) be implemented as -(-x//y) in a type-agnostic 
> fashion?

Ah, good point. Yes, that could work.

We'd have to decide what to do about Decimal if we took this approach, since 
the -(-x//y) trick doesn't work there. (Document the issue? Try to make things 
work for Decimal?)

--

___
Python tracker 

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



[issue46676] ParamSpec args and kwargs are not equal to themselves.

2022-02-07 Thread Gregory Beauregard


New submission from Gregory Beauregard :

from typing import ParamSpec
P = ParamSpec("P")
print(P.args == P.args)  # False
print(P.kwargs == P.kwargs)  # False

ParamSpec args and kwargs are not equal to themselves; this can cause problems 
for unit tests and type introspection w/ e.g. `get_type_hints`.

I will fix this by adding an __eq__ method like other places in typing.py

--
components: Library (Lib)
messages: 412781
nosy: GBeauregard, Jelle Zijlstra
priority: normal
severity: normal
status: open
title: ParamSpec args and kwargs are not equal to themselves.
type: behavior
versions: Python 3.10, Python 3.11

___
Python tracker 

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



[issue46676] ParamSpec args and kwargs are not equal to themselves.

2022-02-07 Thread Gregory Beauregard


Change by Gregory Beauregard :


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

___
Python tracker 

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



[issue42548] debugger stops at breakpoint of `pass` that is not actually reached

2022-02-07 Thread Andy S


Andy S  added the comment:

Can reproduce this on 3.9. Is the fact 3.9 is in `bugfix` status enough to 
backport any fixing changes from 3.11 (if that's true and the bug was fixed)?

--

___
Python tracker 

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



[issue42548] debugger stops at breakpoint of `pass` that is not actually reached

2022-02-07 Thread Irit Katriel


Irit Katriel  added the comment:

It depends how risky the 3.9 release manager would consider the fix to be. The 
first step would be to find out which commit(s) fixed it.

--

___
Python tracker 

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



[issue46677] TypedDict docs are incomplete

2022-02-07 Thread Jelle Zijlstra


New submission from Jelle Zijlstra :

https://docs.python.org/3.10/library/typing.html#typing.TypedDict

It says:

> To allow using this feature with older versions of Python that do not support 
> PEP 526, TypedDict supports two additional equivalent syntactic forms

But there is another reason to use the equivalent forms: if your keys aren't 
valid Python names. There's an example in typeshed that uses "in" (a keyword) 
as a TypedDict key, and I've seen others with keys that have hyphens in them.

Also:

- The docs mention attributes like `__required_keys__`, but don't clearly say 
what is in these attributes. We should document them explicitly with the 
standard syntax for attributes.
- There is no mention of one TypedDict inheriting from another.

--
assignee: docs@python
components: Documentation
messages: 412784
nosy: 97littleleaf11, AlexWaygood, Jelle Zijlstra, docs@python, sobolevn
priority: normal
severity: normal
status: open
title: TypedDict docs are incomplete
versions: Python 3.10, 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



[issue42548] debugger stops at breakpoint of `pass` that is not actually reached

2022-02-07 Thread Andy S


Andy S  added the comment:

Then maybe those RMs (for 3.9 and 3.10) should decide on their own? That should 
mean the bug should be reopened for them to get assigned to.

--

___
Python tracker 

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



[issue20779] Add pathlib.chown method

2022-02-07 Thread Jaspar S.


Jaspar S.  added the comment:

I would love to use chown for a pathlib Path, too.

It may not be used often, but if anyone want's to change all the os references 
from a file, it would be cool to have it on pathlib!

--
nosy: +y0urself

___
Python tracker 

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



[issue46669] Add types.Self

2022-02-07 Thread Jelle Zijlstra


Jelle Zijlstra  added the comment:

The conventional way is to write

def __exit__(
self,
__typ: type[BaseException] | None,
__exc: BaseException | None,
__tb: types.TracebackType | None,
) -> None: ...

But there are two invariants about how __exit__ works in practice that this 
doesn't capture:
1. The arguments are either all None, or none of them are
2. If they are not None, then the typ argument is the type of the exception 
passed to the exc argument

I believe these invariants are always true in 3.11 thanks to Irit's work, but 
previously there could be rare circumstances where they didn't hold. You 
probably know the details better than I do.

We could support the first invariant by using two overloads, one where the 
arguments are all None and one where they aren't. I don't think that's 
generally worth doing though: it's a lot of verbose code and doesn't fix many 
real problems.

Your suggested signature looks like it's trying to support the second 
invariant, but it doesn't quite: if the types don't match, the type checker 
will just set T to the common base type of the two arguments.

--

___
Python tracker 

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



[issue42548] debugger stops at breakpoint of `pass` that is not actually reached

2022-02-07 Thread Irit Katriel

Irit Katriel  added the comment:

Fine, I’ll reopen it for 3.9. However, realistically the release managers are 
unlikely to investigate how this bug got fixed between 3.9 and 3.11 so if you 
think this is important you might want to do that work.

--
resolution: out of date -> 
status: closed -> open
versions: +Python 3.9 -Python 3.7

___
Python tracker 

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



  1   2   >