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

2021-09-27 Thread Andreas Skaar


Andreas Skaar  added the comment:

What is the next steps on this bug?

Have you created a bug with libffi if this is not working correctly eryksun? 
Sounds like you understand what the bug report need to contain.

On implementing a workaround in ctypes. Is this possible?

--
nosy: +xs_iceman

___
Python tracker 

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



[issue41994] Refcount issues in import

2021-09-27 Thread Petr Viktorin


Petr Viktorin  added the comment:

Please don't use private API. The underscore at the beginning marks the 
function as private.
(This has been the case for a long time; in 3.10 it is finally officially 
documented: https://docs.python.org/3.10/c-api/stable.html#stable )

It has been removed in alpha5; I'm afraid rc2 is too late to put it back. 
(Especially since we'd need to put it back as public API, as CPython doesn't 
need it any more.)


Please, if you see the need for any other private APIs, could you file bugs to 
make them public (or better, to support the use case they're needed for)? If 
they are useful, they should have documentation, tests, and better backwards 
compatibility expecations.

--

___
Python tracker 

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



[issue45296] IDLE: Change Ctrl-Z note in exit/quit repr on Windows

2021-09-27 Thread E. Paine


E. Paine  added the comment:

> How about "Control-D (end-of-file, a.k.a. EOF)"

I doubt beginners care that it's EOF.

> or even just "Control-D"

I'd be a lot more inclined towards this.

> IDLE uses the latter [Ctrl-D] even on Windows, and Ctrl-Z does not work.

Is it worth considering changing this behaviour? IMO Ctrl-D is better for 
consistency between platforms, but wanted to throw the idea out there for 
discussion.

--

___
Python tracker 

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



[issue41994] Refcount issues in import

2021-09-27 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

_PyImport_FindExtensionObject is a private API. It was added in 3.3 because 
import.c and importdl.c needed to share code. Since 3.5 it was only used in 
import.c, so there is no longer need to expose it. It was removed in 3.10 
because there was an issue with this API: it returned a borroved reference 
which could be invalid at the time of returning.

I can restore and fix _PyImport_FindExtensionObject in 3.10, but is not it too 
later to do after 3.10.0rc2?

If it is essential to you, propose to add a new public API (perhaps better 
designed).

--

___
Python tracker 

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



[issue45295] _PyObject_GetMethod/LOAD_METHOD for C classmethods

2021-09-27 Thread Ken Jin


Change by Ken Jin :


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

___
Python tracker 

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



[issue24391] Better repr for threading objects

2021-09-27 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

In the last version of PR 20534, the reprs will be similar to proposed by Larry 
in msg244958, except that a colon is used to separate an address from status, 
and keyword names are used for values.









It is closer to existing reprs, I'm going to rewrite reprs of locks, conditions 
and synchronization primitives in asyncio and multiprocessing to match this 
style: move status after type and address, remove parenthesis, brackets and 
commas, use "=" instead of ":" for named values, use "/" with maximal values, 
etc.

--

___
Python tracker 

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



[issue24391] Better repr for threading objects

2021-09-27 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
versions: +Python 3.11 -Python 3.5, Python 3.6

___
Python tracker 

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



[issue45288] Inspect - Added sort_result parameter on getmembers function.

2021-09-27 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

It depends on what you want to get. In general, it is difficult if interpret 
your request literally. For example, if you define class A in module a, class B 
in module b, and class C which inherits from classes A and B in module c, then 
what members of C are defined first: inherited from A or inherited from B? Oh, 
and some members can be defined in a metaclass of A, B or C. And what order of 
members inherited from the object class or other builtin classes? And what to 
do with members excluded from __dir__()? And dynamic members provided by 
__getattr__() or __getattribute__()? You need to specify in more detail what 
you want to get a meaningful answer. It may be that you actually do not need 
all these details and can just look in type's dicts in the mro order.

--

___
Python tracker 

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



[issue45261] Unreliable (?) results from timeit (cache issue?)

2021-09-27 Thread STINNER Victor


Change by STINNER Victor :


--
resolution:  -> not a bug

___
Python tracker 

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



[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-09-27 Thread Vedran Čačić

Vedran Čačić  added the comment:

Just wanted to say that 
"raise SystemExit" is shorter than 
"import sys; sys.exit()", has no special characters (just letters and space) 
and is really much quicker to write. Yes, it doesn't work if someone rebound 
SystemExit, but if that's your problem, you have weird coworkers. ;-)

--

___
Python tracker 

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



[issue39359] zipfile: add missing "pwd: expected bytes, got str" exception message

2021-09-27 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Why do you set the ZipFile.pwd attribute directly?

--

___
Python tracker 

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



[issue40346] Add random.BaseRandom to ease implementation of subclasses

2021-09-27 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

That you need to override the __new__ method? I don't know whether it is 
documented specially. But the constructor calls __new__() and then __init__(). 
If changing the argument in __init__ does not help, it is because it was 
already proceeded in __new__.

If you ask about changes in 3.11, it is a side effect of issue44260.

--

___
Python tracker 

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



[issue45274] Race condition in Thread._wait_for_tstate_lock()

2021-09-27 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset a22be4943c119fecf5433d999227ff78fc2e5741 by Victor Stinner in 
branch 'main':
bpo-45274: Fix Thread._wait_for_tstate_lock() race condition (GH-28532)
https://github.com/python/cpython/commit/a22be4943c119fecf5433d999227ff78fc2e5741


--

___
Python tracker 

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



[issue45274] Race condition in Thread._wait_for_tstate_lock()

2021-09-27 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 5.0 -> 6.0
pull_requests: +26962
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/28579

___
Python tracker 

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



[issue45274] Race condition in Thread._wait_for_tstate_lock()

2021-09-27 Thread miss-islington


Change by miss-islington :


--
pull_requests: +26963
pull_request: https://github.com/python/cpython/pull/28580

___
Python tracker 

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



[issue39359] zipfile: add missing "pwd: expected bytes, got str" exception message

2021-09-27 Thread Daniel Hillier


Daniel Hillier  added the comment:

I agree it is bad form but I would accidentally do it when I couldn't remember 
the proper API and took a stab in the dark without looking up the docs. I 
unfortunately used it in an example in the docs for pyzipper and started 
getting a few bug reports even after fixing my docs.

--

___
Python tracker 

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



[issue45274] Race condition in Thread._wait_for_tstate_lock()

2021-09-27 Thread miss-islington


miss-islington  added the comment:


New changeset 1ecb641b887af2feb026a266e2fceedee0815ca8 by Miss Islington (bot) 
in branch '3.9':
bpo-45274: Fix Thread._wait_for_tstate_lock() race condition (GH-28532)
https://github.com/python/cpython/commit/1ecb641b887af2feb026a266e2fceedee0815ca8


--

___
Python tracker 

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



[issue45274] Race condition in Thread._wait_for_tstate_lock()

2021-09-27 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset fae2694bea5e9e5a114af8cb40b60e7131a6340c by Miss Islington (bot) 
in branch '3.10':
bpo-45274: Fix Thread._wait_for_tstate_lock() race condition (GH-28532) 
(GH-28580)
https://github.com/python/cpython/commit/fae2694bea5e9e5a114af8cb40b60e7131a6340c


--

___
Python tracker 

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



[issue45274] Race condition in Thread._wait_for_tstate_lock()

2021-09-27 Thread STINNER Victor


Change by STINNER Victor :


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

___
Python tracker 

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



[issue45026] More compact range iterator

2021-09-27 Thread Łukasz Langa

Łukasz Langa  added the comment:

Dennis, run your benchmarks with --rigorous to avoid "Benchmark hidden because 
not significant".

I note that the second and third benchmarks aren't useful as written because 
the iterators are exhausted after first repetition. I could see this in my 
results, note how the values don't rise with the iterator size:

for i in it_10: pass: Mean +- std dev: 25.0 ns +- 0.3 ns
for i in it_100: pass: Mean +- std dev: 25.1 ns +- 0.5 ns
for i in it_1000: pass: Mean +- std dev: 25.0 ns +- 0.3 ns
for i in it_1: pass: Mean +- std dev: 25.0 ns +- 0.3 ns
for i in it_10: pass: Mean +- std dev: 25.6 ns +- 0.5 ns

deque(it_10): Mean +- std dev: 334 ns +- 8 ns
deque(it_100): Mean +- std dev: 338 ns +- 9 ns
deque(it_1000): Mean +- std dev: 335 ns +- 9 ns
deque(it_1): Mean +- std dev: 336 ns +- 10 ns
deque(it_10): Mean +- std dev: 338 ns +- 11 ns

When I modified those to recreate the iterator on every run, the story was much 
different.

--

___
Python tracker 

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



[issue45300] Building Python documentation with doctest logs a ResourceWarning in Doc/library/nntplib.rst

2021-09-27 Thread STINNER Victor


New submission from STINNER Victor :

Build Python documentatioin with:

make -C Doc/ PYTHON=../python venv
LANG= PYTHONTRACEMALLOC=10 make -C Doc/ PYTHON=../python SPHINXOPTS="-q -W 
-j10" doctest 2>&1|tee log

See the logs:

/home/vstinner/python/main/Lib/socket.py:776: ResourceWarning: unclosed 

  self._sock = None
Object allocated at (most recent call last):
  File 
"/home/vstinner/python/main/Doc/venv/lib/python3.11/site-packages/sphinx/builders/__init__.py",
 lineno 361
self.write(docnames, list(updated_docnames), method)
  File 
"/home/vstinner/python/main/Doc/venv/lib/python3.11/site-packages/sphinx/ext/doctest.py",
 lineno 366
self.test_doc(docname, doctree)
  File 
"/home/vstinner/python/main/Doc/venv/lib/python3.11/site-packages/sphinx/ext/doctest.py",
 lineno 470
self.test_group(group)
  File 
"/home/vstinner/python/main/Doc/venv/lib/python3.11/site-packages/sphinx/ext/doctest.py",
 lineno 554
self.test_runner.run(test, out=self._warn_out, clear_globs=False)
  File "/home/vstinner/python/main/Lib/doctest.py", lineno 1495
return self.__run(test, compileflags, out)
  File "/home/vstinner/python/main/Lib/doctest.py", lineno 1348
exec(compile(example.source, filename, "single",
  File "", lineno 1
  File "/home/vstinner/python/main/Lib/nntplib.py", lineno 334
self.sock = self._create_socket(timeout)
  File "/home/vstinner/python/main/Lib/nntplib.py", lineno 399
return socket.create_connection((self.host, self.port), timeout)
  File "/home/vstinner/python/main/Lib/socket.py", lineno 828
sock = socket(af, socktype, proto)

--
assignee: docs@python
components: Documentation
messages: 402709
nosy: docs@python, vstinner
priority: normal
severity: normal
status: open
title: Building Python documentation with doctest logs a ResourceWarning in 
Doc/library/nntplib.rst
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



[issue45274] Race condition in Thread._wait_for_tstate_lock()

2021-09-27 Thread Eryk Sun


Eryk Sun  added the comment:

This is the same as bpo-21822, so I suppose it should be closed as well with a 
reference to this issue.

--

___
Python tracker 

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



[issue43914] Highlight invalid ranges in SyntaxErrors

2021-09-27 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 6.0 -> 7.0
pull_requests: +26964
pull_request: https://github.com/python/cpython/pull/28582

___
Python tracker 

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



[issue43914] Highlight invalid ranges in SyntaxErrors

2021-09-27 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:


New changeset e5f13ce5b48b551c09fdd0faeafa6ecf860de51c by Pablo Galindo Salgado 
in branch 'main':
bpo-43914: Correctly highlight SyntaxError exceptions for invalid generator 
expression in function calls (GH-28576)
https://github.com/python/cpython/commit/e5f13ce5b48b551c09fdd0faeafa6ecf860de51c


--

___
Python tracker 

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



[issue45026] More compact range iterator

2021-09-27 Thread Łukasz Langa

Łukasz Langa  added the comment:

Benchmarks for PGO builds on macOS 10.15 Catalina, Intel MBP 2018.

Like in Dennis' case, 20e3149c175a24466c7d1c352f8ff2c11effc489 is GH-27986 and 
cffa90a8b0057d7e7456571045f2fb7b9ceb426f is GH-28176. The difference is that 
`it_` benchmarks create the iterator on each execution. In this case the 
explicit iterator versions of the for-loop are indistinguishable from the ones 
using `range()` directly.


❯ python -m pyperf compare_to 
/tmp/20e3149c175a24466c7d1c352f8ff2c11effc489-2.json 
/tmp/cffa90a8b0057d7e7456571045f2fb7b9ceb426f-2.json -G
Slower (11):
- deque(it_100): 886 ns +- 22 ns -> 944 ns +- 12 ns: 1.07x slower
- list(iter(range(100))): 856 ns +- 17 ns -> 882 ns +- 17 ns: 1.03x slower
- for i in range(10): pass: 2.20 ms +- 0.02 ms -> 2.26 ms +- 0.03 ms: 1.02x 
slower
- for i in range(1): pass: 219 us +- 1 us -> 223 us +- 5 us: 1.02x slower
- for i in it_1: pass: 219 us +- 1 us -> 223 us +- 5 us: 1.02x slower
- for i in it_10: pass: 2.20 ms +- 0.03 ms -> 2.24 ms +- 0.04 ms: 1.02x 
slower
- for i in it_1000: pass: 20.1 us +- 0.1 us -> 20.4 us +- 0.4 us: 1.02x slower
- for i in range(1000): pass: 20.2 us +- 0.4 us -> 20.5 us +- 0.3 us: 1.02x 
slower
- for i in range(100): pass: 1.50 us +- 0.03 us -> 1.52 us +- 0.03 us: 1.01x 
slower
- list(iter(range(10))): 317 ns +- 9 ns -> 320 ns +- 6 ns: 1.01x slower
- for i in it_100: pass: 1.53 us +- 0.01 us -> 1.54 us +- 0.02 us: 1.01x slower

Faster (8):
- list(iter(range(10))): 2.25 ms +- 0.05 ms -> 2.12 ms +- 0.03 ms: 1.06x 
faster
- deque(it_1): 145 us +- 2 us -> 142 us +- 1 us: 1.03x faster
- list(iter(range(1000))): 12.6 us +- 0.2 us -> 12.3 us +- 0.1 us: 1.02x faster
- deque(it_10): 1.47 ms +- 0.01 ms -> 1.45 ms +- 0.02 ms: 1.02x faster
- for i in it_10: pass: 309 ns +- 6 ns -> 304 ns +- 3 ns: 1.02x faster
- list(iter(range(1))): 147 us +- 2 us -> 145 us +- 2 us: 1.01x faster
- deque(it_10): 544 ns +- 19 ns -> 537 ns +- 10 ns: 1.01x faster
- deque(it_1000): 12.6 us +- 0.2 us -> 12.5 us +- 0.2 us: 1.01x faster

Benchmark hidden because not significant (1): for i in range(10): pass

Geometric mean: 1.00x slower


The results look like a wash here. Let me compare both to `main`.

--

___
Python tracker 

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



[issue29971] Lock.acquire() not interruptible on Windows

2021-09-27 Thread STINNER Victor


STINNER Victor  added the comment:

Copy of Antoine Pitrou's msg316024 (bpo-21822):

multiprocessing semaphores support Ctrl-C under Windows, so it should be doable 
for regular locks as well (notice the `sigint_event`):
https://github.com/python/cpython/blob/master/Modules/_multiprocessing/semaphore.c#L109-L146

--
nosy: +vstinner

___
Python tracker 

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



[issue43914] Highlight invalid ranges in SyntaxErrors

2021-09-27 Thread miss-islington


miss-islington  added the comment:


New changeset 9e209d48cac35108f3955d3f610b6ce60b574ecc by Miss Islington (bot) 
in branch '3.10':
bpo-43914: Correctly highlight SyntaxError exceptions for invalid generator 
expression in function calls (GH-28576)
https://github.com/python/cpython/commit/9e209d48cac35108f3955d3f610b6ce60b574ecc


--

___
Python tracker 

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



[issue21822] [Windows] KeyboardInterrupt during Thread.join hangs that Thread

2021-09-27 Thread STINNER Victor


STINNER Victor  added the comment:

> I am having the same blocked signal issue on Windows when using Thread.join. 
> This program does not print "interrupted" after pressing Ctrl+C:

This is a different issue: bpo-29971. Currently, threading.Lock.acquire() 
cannot be interrupted by CTRL+C.

--
nosy: +vstinner

___
Python tracker 

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



[issue21822] [Windows] KeyboardInterrupt during Thread.join hangs that Thread

2021-09-27 Thread STINNER Victor


STINNER Victor  added the comment:

I mark this issue as a duplicate of bpo-45274.

--

I fixed bpo-45274 with this change:

New changeset a22be4943c119fecf5433d999227ff78fc2e5741 by Victor Stinner in 
branch 'main':
bpo-45274: Fix Thread._wait_for_tstate_lock() race condition (GH-28532)
https://github.com/python/cpython/commit/a22be4943c119fecf5433d999227ff78fc2e5741

I tested join.py with the fix. It nows displays:
---
vstinner@DESKTOP-DK7VBIL C:\vstinner\python\main>python x.py
Running Debug|x64 interpreter...
started. Press Ctrl-C now
Ctrl-C [2.99]  done=True  alive=False
finish [2.99]  done=True  alive=False
Terminate batch job (Y/N)? n
---

The script no longer hangs.

--
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> Race condition in Thread._wait_for_tstate_lock()

___
Python tracker 

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



[issue45274] Race condition in Thread._wait_for_tstate_lock()

2021-09-27 Thread STINNER Victor


STINNER Victor  added the comment:

> This is the same as bpo-21822, so I suppose it should be closed as well with 
> a reference to this issue.

You're right. I marked bpo-21822 as a duplicate of this issue.

--

___
Python tracker 

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



[issue29971] Lock.acquire() not interruptible on Windows

2021-09-27 Thread STINNER Victor


STINNER Victor  added the comment:

See also bpo-21822: some comments are about this issue. It's a duplicate of 
bpo-45274 "Race condition in Thread._wait_for_tstate_lock()".

--

___
Python tracker 

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



[issue45294] Conditional import fails and produce UnboundLocalError, if a variable machting import name is used before

2021-09-27 Thread arts stars


arts stars  added the comment:

It is not for debuging my code. your answer is really middleclass sorry to say 
that.

you admit its a due the undefined name of var DiaObjectFactoryHelper
that is exactly I wanted to point out. 

I solved my issue not having answer like in the FAQ like you simply repeated 
here.

This is a parsing issue error I revealed here. The if... should pe 
PRIORITARIZED before checking what it is said in the FAQ.

--

___
Python tracker 

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



[issue29971] Lock.acquire() not interruptible on Windows

2021-09-27 Thread STINNER Victor


STINNER Victor  added the comment:

See also bpo-45301 "pycore_condvar.h: remove Windows conditonal variable 
emulation".

--

___
Python tracker 

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



[issue45301] pycore_condvar.h: remove Windows conditonal variable emulation

2021-09-27 Thread STINNER Victor


New submission from STINNER Victor :

I recently worked on time.sleep() enhancement (bpo-21302) and threading 
bugfixes (bpo-45274, bpo-1596321). I saw one more time that Python emulates 
conditional variables to support Windows XP and older. But Python 3.11 requires 
Windows 8.1 or newer. IMO it's time to remove _PY_EMULATED_WIN_CV code path 
from pycore_condvar.h.

--
components: Library (Lib)
messages: 402720
nosy: paul.moore, steve.dower, tim.golden, vstinner, zach.ware
priority: normal
severity: normal
status: open
title: pycore_condvar.h: remove Windows conditonal variable emulation
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



[issue45301] pycore_condvar.h: remove Windows conditonal variable emulation

2021-09-27 Thread STINNER Victor


STINNER Victor  added the comment:

See also bpo-29971 "Lock.acquire() not interruptible on Windows".

--

___
Python tracker 

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



[issue45295] Speed up classmethod calls via LOAD_METHOD

2021-09-27 Thread Ken Jin


Change by Ken Jin :


--
title: _PyObject_GetMethod/LOAD_METHOD for C classmethods -> Speed up 
classmethod calls via LOAD_METHOD

___
Python tracker 

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



[issue45294] Conditional import fails and produce UnboundLocalError, if a variable machting import name is used before

2021-09-27 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

I'm glad that you fixed the bug in your code, but this is not a bug in 
Python. It isn't "a parsing issue", the code is parsed fine. What you 
did was no different from:

def func():
print(x)
x = 1

except that the binding operation was an import, not an assignment. You 
get exactly the same error here:

def func():
print(math)
import math

That's the way the language is defined. Imports and assignments are both 
binding operations and are treated the same by the interpreter. It's not 
an accident or a mistake or a parsing issue or a bug, it is the way the 
language is supposed to work.

--

___
Python tracker 

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



[issue45026] More compact range iterator

2021-09-27 Thread Łukasz Langa

Łukasz Langa  added the comment:

Well, this is kind of disappointing on my end. I attach the full result of a 
three-way comparison between `main` at the time of Serhiy's last merge 
(3f8b23f8ddab75d9b77a3997d54e663187e12cc8) with GH-27986 
(20e3149c175a24466c7d1c352f8ff2c11effc489) and GH-28176 
(cffa90a8b0057d7e7456571045f2fb7b9ceb426f). The gist is this:


Geometric mean 
==

20e3149c175a24466c7d1c352f8ff2c11effc489-2: 1.01x slower
cffa90a8b0057d7e7456571045f2fb7b9ceb426f-2: 1.01x slower


At least on my Macbook Pro, all PGO builds, looks like the status quo is on 
average faster than any of the candidate PRs.

--
Added file: https://bugs.python.org/file50306/three-way-comparison.log

___
Python tracker 

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



[issue45301] pycore_condvar.h: remove Windows conditonal variable emulation

2021-09-27 Thread Eryk Sun


Eryk Sun  added the comment:

>  IMO it's time to remove _PY_EMULATED_WIN_CV code path from 
> pycore_condvar.h.

SleepConditionVariableSRW() can't be interrupted in PyCOND_WAIT() and 
PyCOND_TIMEDWAIT(). Maybe a hybrid solution could be adopted. Use native 
condition variables for the GIL, where performance matters and the ability to 
interrupt the wait doesn't matter. Otherwise use the semaphore implementation, 
for which the wait implementation can be modified to use 
WaitForMultipleObjects(), and include the Ctrl+C event.

--
nosy: +eryksun

___
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-09-27 Thread Eric Snow


Change by Eric Snow :


--
pull_requests: +26965
pull_request: https://github.com/python/cpython/pull/28583

___
Python tracker 

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



[issue36819] Crash during encoding using UTF-16/32 and custom error handler

2021-09-27 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

I am working on it, since it is more complex issue, and PR 13134 does not solve 
it.

1. This bug affects also other codecs implemented in C: ASCII, Latin1, UTF-8, 
etc.
2. It still crashes in UTF-16/32 encoders if the error handler returns a 
position less than the current position.
3. Incorrect exception can be raised if the error handler returns invalid 
string/bytes: a non-ASCII string or a bytes object consisting of not a whole 
number of units.
4. The code for standard error handlers and for decoders needs a revision too. 
I have some suspects.

We could just forbid error handlers returning position not in the range (start 
, end], but it can break some code, so it is better to do this only in a new 
release.

--

___
Python tracker 

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



[issue40059] Provide a toml module in the standard library

2021-09-27 Thread Sebastian Koslowski


Change by Sebastian Koslowski :


--
nosy: +skoslowski

___
Python tracker 

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



[issue45302] basic builtin functions missing __text_signature__ attributes

2021-09-27 Thread xloem


New submission from xloem <0xl...@gmail.com>:

As there is no __text_signature__ nor __signature__ attribute on basic builtin 
functions such as print or open, inspect.signature() cannot enumerate their 
parameters.

It seems adding these might not be a complex task for somebody familiar with 
the code.

--
components: Argument Clinic, Interpreter Core
messages: 402727
nosy: larry, xloem
priority: normal
severity: normal
status: open
title: basic builtin functions missing __text_signature__ attributes
type: enhancement
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



[issue15870] PyType_FromSpec should take metaclass as an argument

2021-09-27 Thread Josh Haberman


Josh Haberman  added the comment:

> I consider Py_tp_bases to be a mistake: it's an extra way of doing things 
> that doesn't add any extra functionality

I think it does add one extra bit of functionality: Py_tp_bases allows the 
bases to be retrieved with PyType_GetSlot().

This isn't quite as applicable to the metaclass, since that can easily be 
retrieved with Py_TYPE(type).

> but is sometimes not correct (and it might not be obvious when it's not 
> correct).

Yes I guess that most all slots are ok to share across sub-interpreters.  I can 
see the argument for aiming to keep slots sub-interpreter-agnostic.

As a tangential point, I think that the DLL case on Windows may be a case where 
Windows is not compliant with the C standard: 
https://mail.python.org/archives/list/python-...@python.org/thread/2WUFTVQA7SLEDEDYSRJ75XFIR3EUTKKO/

Practically speaking this doesn't change anything (extensions that want to be 
compatible with Windows DLLs will still want to avoid this kind of 
initialization) but I think the docs may be incorrect on this point when they 
describe Windows as "strictly standard conforming in this particular behavior."

--

___
Python tracker 

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



[issue45303] ast module classes missing __text_signature__ attribute

2021-09-27 Thread xloem


New submission from xloem <0xl...@gmail.com>:

The ast module has no signature information on its types.  The types are 
generated in a uniform way, so it should be reasonable to add 
__text_signature__ or __signature__ fields to all of them at once.

--
components: Argument Clinic, Interpreter Core, Library (Lib)
messages: 402728
nosy: larry, xloem
priority: normal
severity: normal
status: open
title: ast module classes missing __text_signature__ attribute
type: enhancement

___
Python tracker 

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



[issue16974] when "python -c command" does a traceback, it open the file ""

2021-09-27 Thread Irit Katriel


Change by Irit Katriel :


--
resolution:  -> duplicate
stage: needs patch -> resolved
status: open -> closed
superseder:  -> Traceback display code can attempt to open a file named 
""

___
Python tracker 

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



[issue45211] Useful (expensive) information is discarded in getpath.c.

2021-09-27 Thread Eric Snow


Eric Snow  added the comment:


New changeset ae7839bbe817329dd015f9195da308a0f3fbd3e2 by Eric Snow in branch 
'main':
bpo-45211: Move helpers from getpath.c to internal API. (gh-28550)
https://github.com/python/cpython/commit/ae7839bbe817329dd015f9195da308a0f3fbd3e2


--

___
Python tracker 

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



[issue29971] Lock.acquire() not interruptible on Windows

2021-09-27 Thread STINNER Victor


STINNER Victor  added the comment:

time.sleep() is now implemented with a waitable timer and 
WaitForMultipleObjects() on Windows. It uses _PyOS_SigintEvent() so it can be 
interrupted with CTRL+C.

commit 58f8adfda3c2b42f654a55500e8e3a6433cb95f2
Author: Victor Stinner 
Date:   Wed Sep 22 16:09:30 2021 +0200

bpo-21302: time.sleep() uses waitable timer on Windows (GH-28483)

On Windows, time.sleep() now uses a waitable timer which has a
resolution of 100 ns (10^-7 sec). Previously, it had a solution of 1
ms (10^-3 sec).

* On Windows, time.sleep() now calls PyErr_CheckSignals() before
  resetting the SIGINT event.
* Add _PyTime_As100Nanoseconds() function.
* Complete and update time.sleep() documentation.

Co-authored-by: Livius 

--

___
Python tracker 

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



[issue45211] Useful (expensive) information is discarded in getpath.c.

2021-09-27 Thread Eric Snow


Change by Eric Snow :


--
pull_requests: +26966
pull_request: https://github.com/python/cpython/pull/28584

___
Python tracker 

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



[issue17838] Can't assign a different value for sys.stdin in IDLE

2021-09-27 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
resolution:  -> fixed

___
Python tracker 

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



[issue45301] pycore_condvar.h: remove Windows conditonal variable emulation

2021-09-27 Thread Steve Dower


Steve Dower  added the comment:

> SleepConditionVariableSRW() can't be interrupted in PyCOND_WAIT() and 
> PyCOND_TIMEDWAIT()

This was my immediate reaction as well.

Unfortunately, we keep seeing that all waits need to be interruptible, so 
either a WaitForMultipleObjects or a slow spinlock.

--

___
Python tracker 

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



[issue2821] IDLE: unittest.py sys.exit error

2021-09-27 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
title: unittest.py sys.exit error -> IDLE: unittest.py sys.exit error

___
Python tracker 

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



[issue15870] PyType_FromSpec should take metaclass as an argument

2021-09-27 Thread Steve Dower


Steve Dower  added the comment:

> As a tangential point, I think that the DLL case on Windows may be a case 
> where Windows is not compliant with the C standard

I wasn't aware the C standard covered dynamic symbol resolution? "static" 
anything in C is completely irrelevant to how symbols are looked up and 
resolved between modules, and how addresses are relocated in PE binaries, by 
the Windows loader.

So this point isn't even tangential - it's nowhere near the surface ;)

--

___
Python tracker 

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



[issue41468] IDLE: "Unrecoverable server exiting" message

2021-09-27 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
title: Unrecoverable server exiting -> IDLE: "Unrecoverable server exiting" 
message

___
Python tracker 

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



[issue45211] Useful (expensive) information is discarded in getpath.c.

2021-09-27 Thread Eric Snow


Change by Eric Snow :


--
pull_requests: +26967
pull_request: https://github.com/python/cpython/pull/28585

___
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-09-27 Thread Barry A. Warsaw


Change by Barry A. Warsaw :


--
nosy: +barry

___
Python tracker 

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



[issue15870] PyType_FromSpec should take metaclass as an argument

2021-09-27 Thread Josh Haberman


Josh Haberman  added the comment:

> "static" anything in C is completely irrelevant to how symbols are looked up 
> and resolved between modules

That is not true.  On ELF/Mach-O the "static" storage-class specifier in C will 
prevent a symbol from being added to the dynamic symbol table, which will make 
it unavailable for use across modules.

> I wasn't aware the C standard covered dynamic symbol resolution?

Well the Python docs invoke the C standard to justify the behavior of DLL 
symbol resolution on Windows, using incorrect arguments about what the standard 
says: https://docs.python.org/3/c-api/typeobj.html#c.PyTypeObject.tp_base

Fixing those docs would be a good first step.

--

___
Python tracker 

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



[issue15870] PyType_FromSpec should take metaclass as an argument

2021-09-27 Thread Josh Haberman


Josh Haberman  added the comment:

> On ELF/Mach-O...

nvm, I just realized that you were speaking about Windows specifically here.  I 
believe you that on Windows "static" makes no difference in this case.

The second point stands: if you consider LoadLibrary()/dlopen() to be outside 
the bounds of what the C standard speaks to, then the docs shouldn't invoke the 
C standard to explain the behavior.

--

___
Python tracker 

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



[issue45304] Supporting out-of-band buffers (pickle protocol 5) in multiprocessing

2021-09-27 Thread jakirkham


New submission from jakirkham :

In Python 3.8+, pickle protocol 5 ( PEP<574> ) was added, which supports 
out-of-band buffer collection[1]. The idea being that when pickling an object 
with a large amount of data attached to it (like an array, dataframe, etc.) one 
could collect this large amount of data alongside the normal pickled data 
without causing a copy. This is important in particular when serializing data 
for communication between two python instances. IOW this is quite valuable when 
using a `multiprocessing.pool.Pool`[2] or a 
`concurrent.futures.ProcessPoolExecutor`[3]. However AFAICT neither of these 
leverage this functionality[4][5]. To ensure zero-copy processing of large 
data, it would be helpful for pickle protocol 5 to be used in both of these 
pools.


[1] https://docs.python.org/3/library/pickle.html#pickle-oob
[2] 
https://docs.python.org/3/library/multiprocessing.html#multiprocessing.pool.Pool
[3] 
https://docs.python.org/3/library/concurrent.futures.html#concurrent.futures.ProcessPoolExecutor
[4] 
https://github.com/python/cpython/blob/16b5bc68964c6126845f4cdd54b24996e71ae0ba/Lib/multiprocessing/queues.py#L372
[5] 
https://github.com/python/cpython/blob/16b5bc68964c6126845f4cdd54b24996e71ae0ba/Lib/multiprocessing/queues.py#L245

--
components: IO, Library (Lib)
messages: 402736
nosy: jakirkham
priority: normal
severity: normal
status: open
title: Supporting out-of-band buffers (pickle protocol 5) in multiprocessing
type: performance
versions: Python 3.10, Python 3.11, 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



[issue41226] Supporting `strides` in `memoryview.cast`

2021-09-27 Thread jakirkham


Change by jakirkham :


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



[issue43096] Adding `read_into` method to `asyncio.StreamReader`

2021-09-27 Thread jakirkham


Change by jakirkham :


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



[issue41223] `object`-backed `memoryview`'s `tolist` errors

2021-09-27 Thread jakirkham


Change by jakirkham :


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



[issue40718] Support out-of-band pickling for builtin types

2021-09-27 Thread jakirkham


Change by jakirkham :


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



[issue15870] PyType_FromSpec should take metaclass as an argument

2021-09-27 Thread Steve Dower

Steve Dower  added the comment:

The section of documentation you reference explains that this behaviour is  not 
covered by the standard ("applied to a non-static variable like 
PyBaseObject_Type() is not required to produce an address constant"), and so 
static addresses of exported symbols do not have to be supported.

It also says that gcc supports it (I assume by generating dynamic code for 
getting the address) while MSVC does not (requiring you to write your own 
dynamic code). 

The conclusion, "tp_base should be set in the extension module’s init 
function," is exactly the right conclusion if you want your code to work across 
all the supported compilers. Invoking the C standard to explain why this looks 
similar to standard code but actually is not is totally fine.

Though I do note that the text can obviously be clearer. I assume it was 
written this way because of a discussion that started "but the C standard says 
..." and so it was clarified to point out that this isn't actually the part of 
the spec that someone thought it was. If we can make it clearer, happy to, but 
it's certainly not incorrect as it stands.

--

___
Python tracker 

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



[issue45211] Useful (expensive) information is discarded in getpath.c.

2021-09-27 Thread Eric Snow


Change by Eric Snow :


--
pull_requests: +26968
pull_request: https://github.com/python/cpython/pull/28586

___
Python tracker 

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



[issue15870] PyType_FromSpec should take metaclass as an argument

2021-09-27 Thread Josh Haberman

Josh Haberman  added the comment:

This behavior is covered by the standard.  The following C translation unit is 
valid according to C99:

  struct PyTypeObject;
  extern struct PyTypeObject Foo_Type;
  struct PyTypeObject *ptr = &Foo_Type;

Specifically, &Foo_Type is an "address constant" per the standard because it is 
a pointer to an object of static storage duration (6.6p9).

The Python docs contradict this with the following incorrect statement:

> However, the unary ‘&’ operator applied to a non-static variable like 
> PyBaseObject_Type() is not required to produce an address constant.

This statement is incorrect:

1. PyBaseObject_Type is an object of static storage duration.  (Note, this is 
true even though it does not use the "static" keyword -- the "static" 
storage-class specifier and "static storage duration" are separate concepts).

2. It follows that &PyBaseObject_Type is required to produce an address 
constant. because it is a pointer to an object of static storage duration.

MSVC rejects this standard-conforming TU when __declspec(dllimport) is added: 
https://godbolt.org/z/GYrfTqaGn  I am pretty sure this is out of compliance 
with C99.

--

___
Python tracker 

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



[issue45234] copy_file raises FileNotFoundError when src is a directory

2021-09-27 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
resolution:  -> fixed

___
Python tracker 

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



[issue45249] Update doctect SyntaxErrors for location range

2021-09-27 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:


New changeset 20f439b6b9e1032930a31b88694ab9f37a09e6b4 by Pablo Galindo Salgado 
in branch 'main':
bpo-45249: Ensure the traceback module prints correctly syntax errors with 
ranges (GH-28575)
https://github.com/python/cpython/commit/20f439b6b9e1032930a31b88694ab9f37a09e6b4


--

___
Python tracker 

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



[issue45249] Update doctect SyntaxErrors for location range

2021-09-27 Thread miss-islington


Change by miss-islington :


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

___
Python tracker 

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



[issue1596321] KeyError at exit after 'import threading' in other thread

2021-09-27 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 95d31370829b7d729667588e0a9943217401ea5b by Victor Stinner in 
branch 'main':
bpo-1596321: Fix threading._shutdown() for the main thread (GH-28549)
https://github.com/python/cpython/commit/95d31370829b7d729667588e0a9943217401ea5b


--

___
Python tracker 

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



[issue1596321] KeyError at exit after 'import threading' in other thread

2021-09-27 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 15.0 -> 16.0
pull_requests: +26970
pull_request: https://github.com/python/cpython/pull/28588

___
Python tracker 

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



[issue1596321] KeyError at exit after 'import threading' in other thread

2021-09-27 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +26971
pull_request: https://github.com/python/cpython/pull/28589

___
Python tracker 

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



[issue45301] pycore_condvar.h: remove Windows conditonal variable emulation, use Windows native conditional variable

2021-09-27 Thread STINNER Victor


STINNER Victor  added the comment:

Eryk:
> SleepConditionVariableSRW() can't be interrupted in PyCOND_WAIT() and 
> PyCOND_TIMEDWAIT().

Oh. A comment on StackOverlow says: 

"The WaitForXxx functions accept parameters of the generic HANDLE type, which 
represents a handle to a kernel object. Condition variables are user-mode 
objects, not kernel objects, so you cannot use them with these functions, since 
they work only with kernel objects."

https://stackoverflow.com/questions/37522108/can-you-really-wait-on-condition-variable-with-waitfor-objects

I only created this issue because of this comment in pycore_condvar.h:
---
/* non-emulated condition variables are provided for those that want
 * to target Windows Vista.  Modify this macro to enable them.
 */
#ifndef _PY_EMULATED_WIN_CV
#define _PY_EMULATED_WIN_CV 1  /* use emulated condition variables */
#endif
---

--
title: pycore_condvar.h: remove Windows conditonal variable emulation -> 
pycore_condvar.h: remove Windows conditonal variable emulation, use Windows 
native conditional variable

___
Python tracker 

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



[issue45249] Update doctect SyntaxErrors for location range

2021-09-27 Thread miss-islington


miss-islington  added the comment:


New changeset c7fdd6879b5c8447ee65b1bec95a1db43837a7a5 by Miss Islington (bot) 
in branch '3.10':
bpo-45249: Ensure the traceback module prints correctly syntax errors with 
ranges (GH-28575)
https://github.com/python/cpython/commit/c7fdd6879b5c8447ee65b1bec95a1db43837a7a5


--

___
Python tracker 

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



[issue45305] Incorrect record of call_args_list when using multiple side_effect in mock.patch

2021-09-27 Thread Dave McNulla


New submission from Dave McNulla :

https://gist.github.com/dmcnulla/ecec8fc96a2fd07082f240eeff6888d9
I'm trying to reproduce an error in a call to a method, forcing a second call 
to the method. In my test, the call_args_list is showing incorrectly (both in 
debugging or running unittest normally).

I am not certain what other circumstances this is happening or not happening. I 
was able to reduce the code to reproduce it quite a bit. I am certain that the 
first call to the method is not matching correctly in my criteria to what I 
expect based on my debugging.

I am using python 3.7. I can reproduce in IntelliJ or by commandline `python3 
-m pytest test_multiple_side_effect.py`

--
components: Tests
messages: 402743
nosy: dmcnulla
priority: normal
severity: normal
status: open
title: Incorrect record of call_args_list when using multiple side_effect in 
mock.patch
versions: Python 3.7

___
Python tracker 

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



[issue1596321] KeyError at exit after 'import threading' in other thread

2021-09-27 Thread miss-islington


miss-islington  added the comment:


New changeset 38c67738c64304928c68d5c2bd78bbb01d979b94 by Miss Islington (bot) 
in branch '3.10':
bpo-1596321: Fix threading._shutdown() for the main thread (GH-28549)
https://github.com/python/cpython/commit/38c67738c64304928c68d5c2bd78bbb01d979b94


--

___
Python tracker 

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



[issue1596321] KeyError at exit after 'import threading' in other thread

2021-09-27 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 94d19f606fa18a1c4d2faca1caf2f470a8ce6d46 by Victor Stinner in 
branch '3.9':
bpo-1596321: Fix threading._shutdown() for the main thread (GH-28549) (GH-28589)
https://github.com/python/cpython/commit/94d19f606fa18a1c4d2faca1caf2f470a8ce6d46


--

___
Python tracker 

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



[issue1596321] KeyError at exit after 'import threading' in other thread

2021-09-27 Thread STINNER Victor


STINNER Victor  added the comment:

Better late than never. I only took 15 years to fix this old bug :-D

--
versions: +Python 3.10, Python 3.11, Python 3.9 -Python 2.7, Python 3.2

___
Python tracker 

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



[issue45288] Inspect - Added sort_result parameter on getmembers function.

2021-09-27 Thread Cristobal Riaga


Cristobal Riaga  added the comment:

I'm don't really need inherit order, neither built-in members.
e.g.:
```py
a = 3 # First

class B: # Second
pass

def foo(): # Third
pass

```
Or in a more complex module:
```py
class A: # First
pass

class B: # Second
pass

class C(A, B): # Third
pass
```
The order should be:
- A (class)
- B (class)
- C (class): inherited from A and B.

Here is the link to the script I'm using to inspect a module: 
https://github.com/Patitotective/PyAPIReference/blob/main/PyAPIReference/inspect_object.py.

--

___
Python tracker 

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



[issue29971] threading.Lock.acquire() not interruptible on Windows

2021-09-27 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
title: Lock.acquire() not interruptible on Windows -> threading.Lock.acquire() 
not interruptible on Windows

___
Python tracker 

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



[issue45288] Inspect - Added sort_result parameter on getmembers function.

2021-09-27 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Ah, if you only need a module, then just use its __dict__ (or vars()).

--

___
Python tracker 

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



[issue41214] -O0: Segmentation fault in _PyArg_UnpackStack

2021-09-27 Thread Irit Katriel


Irit Katriel  added the comment:

Python 3.7 is no longer maintained. Please create a new issue if you see this 
problem on a current version (>= 3.9).

--
nosy: +iritkatriel
resolution:  -> out of date
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



[issue45288] Inspect - Added sort_result parameter on getmembers function.

2021-09-27 Thread Cristobal Riaga

Cristobal Riaga  added the comment:

That worked 🙃, thank you for your time and answer.
I will keep working on PyAPIReference.
Also I will close the pull request I created on GitHub.

--

___
Python tracker 

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



[issue15870] PyType_FromSpec should take metaclass as an argument

2021-09-27 Thread Steve Dower


Steve Dower  added the comment:

> MSVC rejects this standard-conforming TU when __declspec(dllimport) is added: 
> https://godbolt.org/z/GYrfTqaGn  I am pretty sure this is out of compliance 
> with C99.

Windows/MSVC defines DLLs as separate programs, with their own lifetime and 
entry point (e.g. you can reload a DLL multiple times and it will be 
reinitialised each time). So there's no conflict with the standard here, and 
certainly nothing that affects the real discussion.

If you'd like to continue this sideline, feel free to take it elsewhere - I'm 
done with it. Let's keep the focus on making sure the added feature is useful 
for users.

--

___
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-09-27 Thread Eric Snow


Change by Eric Snow :


--
pull_requests: +26972
pull_request: https://github.com/python/cpython/pull/28590

___
Python tracker 

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



[issue45306] Docs are incorrect re: constant initialization in the C99 standard

2021-09-27 Thread Josh Haberman

New submission from Josh Haberman :

I believe the following excerpt from the docs is incorrect 
(https://docs.python.org/3/c-api/typeobj.html#c.PyTypeObject.tp_base):

> Slot initialization is subject to the rules of initializing
> globals. C99 requires the initializers to be “address
> constants”. Function designators like PyType_GenericNew(),
> with implicit conversion to a pointer, are valid C99 address
> constants.
>
> However, the unary ‘&’ operator applied to a non-static
> variable like PyBaseObject_Type() is not required to produce
> an address constant. Compilers may support this (gcc does),
> MSVC does not. Both compilers are strictly standard
> conforming in this particular behavior.
>
> Consequently, tp_base should be set in the extension module’s init function.

I explained why in 
https://mail.python.org/archives/list/python-...@python.org/thread/2WUFTVQA7SLEDEDYSRJ75XFIR3EUTKKO/
 and on https://bugs.python.org/msg402738.

The short version: &foo is an "address constant" according to the standard 
whenever "foo" has static storage duration.  Variables declared "extern" have 
static storage duration. Therefore strictly conforming implementations should 
accept &PyBaseObject_Type as a valid constant initializer.

I believe the text above could be replaced by something like:

> MSVC does not support constant initialization of of an address
> that comes from another DLL, so extensions should be set in the
> extension module's init function.

--
assignee: docs@python
components: Documentation
messages: 402752
nosy: docs@python, jhaberman
priority: normal
severity: normal
status: open
title: Docs are incorrect re: constant initialization in the C99 standard

___
Python tracker 

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



[issue15870] PyType_FromSpec should take metaclass as an argument

2021-09-27 Thread Josh Haberman


Josh Haberman  added the comment:

> Windows/MSVC defines DLLs as separate programs, with their own lifetime and 
> entry point (e.g. you can reload a DLL multiple times and it will be 
> reinitialised each time).

All of this is true of so's in ELF also.  It doesn't mean that the 
implementation needs to reject standards-conforming programs.

I still think the Python documentation is incorrect on this point.  I filed 
https://bugs.python.org/issue45306 to track this separately.

--

___
Python tracker 

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



[issue45307] Removal of _PyImport_FindExtensionObject() in 3.10 limits custom extension module loaders

2021-09-27 Thread Gregory Szorc


New submission from Gregory Szorc :

https://bugs.python.org/issue41994 / commit 
4db8988420e0a122d617df741381b0c385af032c removed 
_PyImport_FindExtensionObject() from the C API and it is no longer available in 
CPython 3.10 after alpha 5.

At least py2exe and PyOxidizer rely on this API for implementing a custom 
module loader for extension modules. Essentially, both want to implement a 
custom Loader.create_module() so they can use a custom mechanism for injecting 
a shared library into the process. While the details shouldn't be important 
beyond "they can't use imp.create_dynamic()," both use a similar technique that 
hooks LoadLibrary() on Windows to enable them to load a DLL from memory (as 
opposed to a file).

While I don't have the extension module loading mechanism fully paged in to my 
head at the moment, I believe the reason that _PyImport_FindExtensionObject() 
(now effectively import_find_extension()) is important for py2exe and 
PyOxidizer is because they need to support at most once initialization, 
including honoring the multi-phase initialization semantics. Since the state of 
extension modules is stored in `static PyObject *extensions` and the thread 
state (which are opaque to the C API), the loss of 
_PyImport_FindExtensionObject() means there is no way to check for and use an 
existing extension module module object from the bowels of the importer 
machinery. And I think this means it isn't possible to implement well-behaved 
alternate extension module loaders any more.

I'm aware the deleted API was "private" and probably shouldn't have been used 
in the first place. And what py2exe and PyOxidizer are doing here is rather 
unorthodox.

In my mind the simplest path forward is restoring 
_PyImport_FindExtensionObject(). But a properly designed public API is probably 
a better solution.

Until 3.10 makes equivalent functionality available or another workaround is 
supported, PyOxidizer won't be able to support loading extension modules from 
memory on Windows on Python 3.10. This is unfortunate. But probably not a deal 
breaker and I can probably go several months shipping PyOxidizer with this 
regression without too many complaints.

--
components: C API
messages: 402754
nosy: indygreg, petr.viktorin, serhiy.storchaka, vstinner
priority: normal
severity: normal
status: open
title: Removal of _PyImport_FindExtensionObject() in 3.10 limits custom 
extension module loaders
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



[issue41994] Refcount issues in import

2021-09-27 Thread Gregory Szorc


Gregory Szorc  added the comment:

I didn't want to derail this old issue too much. So I filed issue45307 to track 
a solution.

--

___
Python tracker 

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



[issue36521] Consider removing docstrings from co_consts in code objects

2021-09-27 Thread Inada Naoki


Inada Naoki  added the comment:

Mark, would you take a look, please?

--

___
Python tracker 

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



[issue45301] pycore_condvar.h: remove Windows conditonal variable emulation, use Windows native conditional variable

2021-09-27 Thread Eryk Sun


Eryk Sun  added the comment:

FYI, waiting for a condition variable can cause a thread to enter a wait state 
that's interruptible, in theory, but the mechanism is different since condition 
variables and SRW locks are pointer-sized values in user space, instead of NT 
objects in kernel space. The current implementation is based on the system call 
NtWaitForAlertByThreadId(address, timeout), which enters the 
"WrAlertByThreadId" wait state. The address parameter is that of the SRW lock. 
The kernel sets this as the 'object' for the wait, but the wait is actually 
satisfied by alerting the thread directly via NtAlertThreadByThreadId(tid). 
ISTM, they could have added a function that calls the latter to cancel a wait 
on a given thread. That would have been useful for Ctrl+C since the handler 
executes on a new thread.

--

___
Python tracker 

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