[issue42850] Process hangs when calling urllib.request in a multiprocessing.Process with import of sounddevice package

2021-01-08 Thread Robin Scheibler


Robin Scheibler  added the comment:

Thanks for the suggestion. I had indeed run into some issues with fork vs spawn 
before.

I have tested with 3.8.5 and 3.9.1 and the bug doesn't occur with these more 
recent versions.

Should I leave the bug open since 3.7 is still supported ?

--

___
Python tracker 

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



[issue42800] Traceback objects allow accessing frame objects without triggering audit hooks

2021-01-08 Thread Ryan Hileman


Ryan Hileman  added the comment:

Oops, by tb_code I meant traceback.tb_frame.f_code. So you can get to a frame 
from traceback.tb_frame (without triggering audit) or sys._getframe (which has 
an audit hook already), and you can get to __code__ from a frame via 
frame.f_code (without triggering audit).

Here's a patch for both frame.f_code and traceback.tb_frame:
https://github.com/lunixbochs/cpython/commit/2334a00c833874b7a2427e88abc9b51315bb010c

---

Benchmarks follow this section, made using the commit I linked (and the parent 
commit without the patch for comparison). My takeaways from playing around:

1. You probably shouldn't install a Python audit hook if you care about 
performance.
2. C audit hook performance impact shows up in microbenchmarking but only have 
a small impact on real workloads (see the traceback.format_tb benchmark at the 
end).
3. Performance impact of this change when you _don't_ have an audit hook 
installed is very small.
4. This seems to mostly impact debugging and test code. A quick check of the 
stdlib shows:
- traceback.tb_frame usage seems to be entirely in debugger, traceback, and 
testing code: https://github.com/python/cpython/search?l=Python=3=tb_frame
- frame.f_code primarily has similar debug use (dis, warnings, profiling, 
inspect): https://github.com/python/cpython/search?l=Python=3=f_code

Attached (c_audit_ext.zip) is the empty C audit hook I used for the benchmarks. 
`python3 setup.py build_ext` builds a `c_audit` module which registers an empty 
audit hook on import.


 frame.f_code object.__getattr__ audit hook

# Testing frame.f_code impact (no audit hook installed):
./python.exe -m timeit -s 'frame = sys._getframe()' -- 'frame.f_code'

with patch 2334a00c833874b7a2427e88abc9b51315bb010c
2000 loops, best of 5: 19.1 nsec per loop
2000 loops, best of 5: 18.7 nsec per loop
2000 loops, best of 5: 19.1 nsec per loop

without patch 2334a00c833874b7a2427e88abc9b51315bb010c
2000 loops, best of 5: 17 nsec per loop
2000 loops, best of 5: 16.7 nsec per loop
2000 loops, best of 5: 17 nsec per loop

# Testing frame.f_code impact (C audit hook installed):
python.exe -m timeit -s 'import c_audit; frame = sys._getframe()' -- 
'frame.f_code'

with patch 2334a00c833874b7a2427e88abc9b51315bb010c
500 loops, best of 5: 66.1 nsec per loop
500 loops, best of 5: 66.1 nsec per loop
500 loops, best of 5: 66.5 nsec per loop

without patch 2334a00c833874b7a2427e88abc9b51315bb010c
2000 loops, best of 5: 16.9 nsec per loop
2000 loops, best of 5: 16.9 nsec per loop
2000 loops, best of 5: 16.8 nsec per loop

# Testing frame.f_code impact (pure Python audit hook installed):
./python.exe -m timeit -s 'frame = sys._getframe(); sys.addaudithook(lambda *a: 
None)' -- 'frame.f_code'

with patch 2334a00c833874b7a2427e88abc9b51315bb010c
50 loops, best of 5: 1.02 usec per loop
50 loops, best of 5: 1.04 usec per loop
50 loops, best of 5: 1.02 usec per loop

without patch 2334a00c833874b7a2427e88abc9b51315bb010c
2000 loops, best of 5: 16.8 nsec per loop
2000 loops, best of 5: 17.1 nsec per loop
2000 loops, best of 5: 16.8 nsec per loop


 tb.tb_frame object.__getattr__ audit hook

# Testing tb.tb_frame impact (no audit hook installed)
./python.exe -m timeit -s "$(echo -e "try: a\nexcept Exception as e: tb = 
e.__traceback__")" -- 'tb.tb_frame'

with patch 2334a00c833874b7a2427e88abc9b51315bb010c
2000 loops, best of 5: 19.2 nsec per loop
2000 loops, best of 5: 18.9 nsec per loop
2000 loops, best of 5: 18.9 nsec per loop

without patch 2334a00c833874b7a2427e88abc9b51315bb010c
2000 loops, best of 5: 17 nsec per loop
2000 loops, best of 5: 16.7 nsec per loop
2000 loops, best of 5: 16.8 nsec per loop

# Testing tb.tb_frame impact (C audit hook installed)
./python.exe -m timeit -s "$(echo -e "import c_audit\ntry: a\nexcept Exception 
as e: tb = e.__traceback__")" -- 'tb.tb_frame'

with patch 2334a00c833874b7a2427e88abc9b51315bb010c
500 loops, best of 5: 64.8 nsec per loop
500 loops, best of 5: 64.8 nsec per loop
500 loops, best of 5: 64.8 nsec per loop

without patch 2334a00c833874b7a2427e88abc9b51315bb010c
2000 loops, best of 5: 16.7 nsec per loop
2000 loops, best of 5: 16.9 nsec per loop
2000 loops, best of 5: 16.9 nsec per loop

# Testing tb.tb_frame impact (pure Python audit hook installed)
./python.exe -m timeit -s "$(echo -e "sys.addaudithook(lambda *a: None)\ntry: 
a\nexcept Exception as e: tb = e.__traceback__")" -- 'tb.tb_frame'

with patch 2334a00c833874b7a2427e88abc9b51315bb010c
50 loops, best of 5: 1.04 usec per loop
50 loops, best of 5: 1.02 usec per loop
50 loops, best of 5: 1.04 usec per loop

without patch 2334a00c833874b7a2427e88abc9b51315bb010c
2000 loops, best of 5: 16.9 nsec per loop

[issue42871] Regex compilation crashed if I change order of alternatives under quantifier

2021-01-08 Thread Renji


Renji  added the comment:

I through "forward reference" is "\1 (abcd)". Not "some sort of reference in 
second repetition to data from first repetition".

Ok. In other words refers from on repetition to other supported, but with 
purely formal restrictions. And remove this restrictions don't planned. Than 
this issue may be closed.

--

___
Python tracker 

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



[issue42871] Regex compilation crashed if I change order of alternatives under quantifier

2021-01-08 Thread Matthew Barnett


Matthew Barnett  added the comment:

Example 1:

((a)|b\2)*
 ^^^   Group 2

((a)|b\2)*
  ^^   Reference to group 2

The reference refers backwards to the group.

Example 2:

(b\2|(a))*
 ^^^   Group 2

(b\2|(a))*
  ^^   Reference to group 2

The reference refers forwards to the group.

As I said, the re module doesn't support forward references to groups.

If you have a regex where forward references are unavoidable, try the 3rd-party 
'regex' module instead. It's available on PyPI.

--

___
Python tracker 

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



[issue42800] Traceback objects allow accessing frame objects without triggering audit hooks

2021-01-08 Thread Ryan Hileman


Ryan Hileman  added the comment:

I'm definitely not proposing to hook all of object.__getattr__, as my intuition 
says that would be very slow. I simply refer to "object.__getattr__" as the 
event name used by a couple of rare event audit hooks. This is how getting 
__code__ is emitted: 
https://github.com/python/cpython/blob/7301979b23406220510dd2c7934a21b41b647119/Objects/funcobject.c#L250

However, there's not much point in the sys._getframe and func.__code__ family 
of audit hooks right now as tracebacks expose the same information (and may 
even do so accidentally). I am personally interested in these hooks for non 
sandbox reasons in a production application that cares about perf, FWIW.

I think this would be implemented by extending the traceback object's getters 
to include tb_code and tb_frame: 
https://github.com/python/cpython/blob/7301979b23406220510dd2c7934a21b41b647119/Python/traceback.c#L156-L159

I project it won't have any noticeable perf impact (especially if the audit 
hook is written in C), as most reasons to inspect a traceback object will be 
exceptional and not in critical paths.

I'd be happy to write a proposed patch if that would help.

--

___
Python tracker 

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



[issue42871] Regex compilation crashed if I change order of alternatives under quantifier

2021-01-08 Thread Renji


Renji  added the comment:

In my example reference and capture group presents in two difference 
alternatives. They don't follow each other, but executed in random order. If 
this don't supported in one case, why it supported in other case?

--

___
Python tracker 

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



[issue42871] Regex compilation crashed if I change order of alternatives under quantifier

2021-01-08 Thread Matthew Barnett


Matthew Barnett  added the comment:

It's not a crash. It's complaining that you're referring to group 2 before 
defining it. The re module doesn't support forward references to groups, but 
only backward references to them.

--

___
Python tracker 

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



[issue42840] `type` takes **kwargs for __init_subclass__

2021-01-08 Thread Erik Soma


Erik Soma  added the comment:

Seems I misframed the issue a bit. I didn't realize keyword arguments besides 
'metaclass' were introduced with PEP 3115 with Python 3.0.


In any case I've posted a PR to update the docs and typeshed.
Typeshed PR for reference: https://github.com/python/typeshed/pull/4918

--

___
Python tracker 

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



[issue42800] Traceback objects allow accessing frame objects without triggering audit hooks

2021-01-08 Thread STINNER Victor


STINNER Victor  added the comment:

Even if no audit hook is registered, adding an audit event on a function has a 
cost on runtime performance. object.__getattr__() is a core Python function, if 
an event is added, we should properly measure the performance overhead to 
decide if it's acceptable or not.

--

___
Python tracker 

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



[issue42800] Traceback objects allow accessing frame objects without triggering audit hooks

2021-01-08 Thread STINNER Victor


STINNER Victor  added the comment:

I don't think that audit hooks should be seen as a way to build a robust 
sandbox.
https://www.python.org/dev/peps/pep-0578/#why-not-a-sandbox

--

___
Python tracker 

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



[issue42800] Traceback objects allow accessing frame objects without triggering audit hooks

2021-01-08 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



[issue42800] Traceback objects allow accessing frame objects without triggering audit hooks

2021-01-08 Thread Ryan Hileman


Ryan Hileman  added the comment:

traceback's `tb_code` attribute also allows you to bypass the 
`object.__getattr__` audit event for `__code__`.

Perhaps accessing a traceback object's `tb_code` and `tb_frame` should both 
raise an `object.__getattr__` event?

--
nosy: +lunixbochs2

___
Python tracker 

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



[issue42871] Regex compilation crashed if I change order of alternatives under quantifier

2021-01-08 Thread Renji


New submission from Renji :

I can compile "((a)|b\2)*" expression and this expression successfully return 
captures from first repetition and second repetition in one time. But if I 
write (b\2|(a))* expression, I get "invalid group reference 2 at position 3" 
error. Either first or second behavior incorrect.
python3 --version Python 3.7.3

import re
text="aba"
#match=re.search(r"(b\2|(a))*",text) - not worked
match=re.search(r"((a)|b\2)*",text)
if(match):
#show aba ba a
print(match.group(0)+" "+match.group(1)+" "+match.group(2))

--
components: Regular Expressions
messages: 384703
nosy: Renji, ezio.melotti, mrabarnett
priority: normal
severity: normal
status: open
title: Regex compilation crashed if I change order of alternatives under 
quantifier
type: behavior
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



[issue42867] Entry Widget not editable on Windows 10, but is on Linux Ubuntu 16.04

2021-01-08 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

I added this note to #9673 after rereading the posts and the 2010 tkinter list 
thread.

"My testing was inadequate.  From #42867, it appears that 0. the bug is limited 
to Windows; 1. opening a canned dialog or message box is part of getting the 
buggy behavior; 2. timing is involved; 3. the bug can be exhibited on Windows 
directly with wish/tk, so that it is a 3rd party tcl/tk issue and not a tkinter 
issue.  Hence changing the issue resolution.

A workaround mentioned in both the referenced tkinter thread and #42867 is to 
call after_idle() at some point."

Paine, thank you for verifying both the bug and workaround directly with tk.  I 
am closing this also as 3rd party.

--
resolution:  -> third party
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



[issue9673] Entry Widget Not Editable under Windows XP with dialog call.

2021-01-08 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

My testing was inadequate.  From #42867, it appears that 0. the bug is limited 
to Windows; 1. opening a canned dialog or message box is part of getting the 
buggy behavior; 2. timing is involved; 3. the bug can be exhibited on Windows 
directly with wish/tk, so that it is a 3rd party tcl/tk issue and not a tkinter 
issue.  Hence changing the issue resolution.

A workaround mentioned in both the referenced tkinter thread and #42867 is to 
call after_idle() at some point.

--
resolution: out of date -> third party
title: Entry Widget Not Editable under Windows XP -> Entry Widget Not Editable 
under Windows XP with dialog call.

___
Python tracker 

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



[issue9694] argparse required arguments displayed under "optional arguments"

2021-01-08 Thread Miro Hrončok

Miro Hrončok  added the comment:

https://bugs.python.org/issue42870

--

___
Python tracker 

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



[issue42870] Document changed argparse output wrt optional arguments in What's new in Python 3.10

2021-01-08 Thread Miro Hrončok

New submission from Miro Hrončok :

A followup from https://bugs.python.org/issue9694

Could the change in output please be mentioned on 
https://docs.python.org/3.10/whatsnew/3.10.html ?

In Fedora, at least 3 packages fail tests because of the change:

ipython: https://github.com/ipython/ipython/pull/12759
m2r: https://github.com/miyakogi/m2r/pull/62
sphinxcontrib-autoprogram: https://bugzilla.redhat.com/show_bug.cgi?id=1914341

Thanks.

--
assignee: docs@python
components: Documentation
messages: 384699
nosy: docs@python, hroncok, paul.j3, rhettinger
priority: normal
severity: normal
status: open
title: Document changed argparse output wrt optional arguments in What's new in 
Python 3.10
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



[issue42849] pool worker can't be terminated

2021-01-08 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

3.7 has not gotten bug fixes for a couple of years.  This needs to be verified 
on a current release.

--
nosy: +davin, pitrou, terry.reedy

___
Python tracker 

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



[issue42802] distutils: Remove bdist_wininst command

2021-01-08 Thread STINNER Victor


Change by STINNER Victor :


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

___
Python tracker 

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



[issue42820] Sphinx conf.py needs_version entry is outdated

2021-01-08 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

This is related to #42843, which is about deciding what the min sphinx should 
be.  Since the alternative to 3.2 is some 2.x, 1,8 is certainly wrong.

--
nosy: +terry.reedy

___
Python tracker 

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



[issue42802] distutils: Remove bdist_wininst command

2021-01-08 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 0e2a0f72cc9af0899eacb5604e44a563c0b06110 by Victor Stinner in 
branch 'master':
bpo-42802: Remove distutils bdist_wininst command (GH-24043)
https://github.com/python/cpython/commit/0e2a0f72cc9af0899eacb5604e44a563c0b06110


--

___
Python tracker 

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



[issue42825] Build libraries with "/OPT:REF" linker optimization on Windows

2021-01-08 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

The PR says that this deletes "uncalled code".  I imagine that this is safe for 
a .exe.  But for a .dll?  As i understand it, one can, from python code, access 
any function via ctypes, so it seems to me that there is no way for the linker 
to know which callable functions in a .dll can be safely deleted.  Am I missing 
something?

--
nosy: +terry.reedy

___
Python tracker 

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



[issue42820] Sphinx conf.py needs_version entry is outdated

2021-01-08 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
nosy: +mdk

___
Python tracker 

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



[issue1635741] Py_Finalize() doesn't clear all Python objects at exit

2021-01-08 Thread Erlend Egeberg Aasland


Change by Erlend Egeberg Aasland :


--
pull_requests: +23002
pull_request: https://github.com/python/cpython/pull/24175

___
Python tracker 

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



[issue42869] pydoc does not append .html to documentation

2021-01-08 Thread Julien Palard


Julien Palard  added the comment:

This is now fixed on the docs server thanks to [1], so it should work for 
already release Python 3.9 :)

[1]: https://github.com/python/psf-salt/pull/198

I still did a PR on cpython to avoid a redirection, and get cpython itself out 
of the "people use this temporary fix as a feature now".

--

___
Python tracker 

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



[issue42869] pydoc does not append .html to documentation

2021-01-08 Thread Julien Palard


Change by Julien Palard :


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

___
Python tracker 

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



[issue42869] pydoc does not append .html to documentation

2021-01-08 Thread Julien Palard


New submission from Julien Palard :

Running `python3 -m pydoc ensurepip` gives me:

https://docs.python.org/3.9/library/ensurepip
but it should be:

https://docs.python.org/3.9/library/ensurepip.html

Issue is in getdocloc function on the line:

docloc = "%s/%s" % (docloc.rstrip("/"), object.__name__.lower())

But it previously worked as the nginx config for the doc server contains:

# Emulate Apache's content-negotiation. Was a temporary measure,
# but now people are using it like a feature.
location ~ ^/((2|3)(\.[0-8])?|dev)/\w+/[\d\w\.]+(?!\.html)$ {
if (-f "${request_filename}.html") {
return 301 https://$host:$request_uri.html;
}
}

(So yes "people are using it like a feature" contains pydoc :))

Notice the [0-8], which does not match for my /3.9/.

I propose to fix the issue on both sides:
- On psf-salt to allow 3.9 to get the "temporary" measure.
- pydoc side to simplify the code

--
assignee: docs@python
components: Documentation
messages: 384693
nosy: docs@python, mdk
priority: normal
severity: normal
status: open
title: pydoc does not append .html to documentation
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



[issue42812] @overload-ing method of parent class without actual implementation

2021-01-08 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
nosy: +gvanrossum, levkivskyi

___
Python tracker 

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



[issue42807] smtplib send_message should gives more clear exception if the msg is None

2021-01-08 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

I am not familiar with either smtp or email, but I can make some general 
comments.

1. "AttributeError: 'NoneType' object has no attribute 'get_all'" seems pretty 
straightforward to me.  Hard to debug?  Depends on knowledge and experience. 
When coming from library code, it nearly always means that one called a library 
function with an invalid argument.  None, with only standard dunder attributes, 
is perhaps the most common bad argument.  Look in the traceback to find the bad 
call in one's own code, where one must have passed None, even if not by that 
name.  In this case, if one does not know that 'get_all' is a method of the two 
email message classes, this can be discovered in the document index.

2. It is not a bug for a function to expect users to know the above and in 
effect say "Don't do that!" when an attribute reference fails.  So I see this 
as an enhancement request, not a bugfix report.  But why add a check for None 
to this particular function?

3. Python functions often use duck-typing, allowing arguments that act 
sufficiently well like the documented requirement.  While 
https://docs.python.org/3/library/smtplib.html#smtplib.SMTP.send_message  says 
that msg should be a Message object, this may not be an exact requirement.  
Indeed, 
https://docs.python.org/3/library/smtplib.html#smtplib.SMTP.send_message starts 
with "The Message class is very similar to the EmailMessage class ...".  So I 
wonder, "Is EmailMessage is also allowed?"  Or, "Do  any users pass instances 
of custom message classes?"

If so, perhaps the doc should be augmented.  But checking only for Message 
would be wrong, and would break code passing non-Message instances.

--
nosy: +barry, maxking, r.david.murray, terry.reedy
stage:  -> test needed
type: behavior -> enhancement

___
Python tracker 

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



[issue42862] Use functools.lru_cache iso. _sqlite.Cache in sqlite3 module

2021-01-08 Thread Erlend Egeberg Aasland


Erlend Egeberg Aasland  added the comment:

$ python3.10 -m timeit -s 'import sqlite3; con = sqlite3.connect(":memory:"); 
query="select * from sqlite_master"' 'con.execute(query); con.execute(query)'
10 loops, best of 5: 2.95 usec per loop
$ ./python.exe -m timeit -s 'import sqlite3; con = sqlite3.connect(":memory:"); 
query="select * from sqlite_master"' 'con.execute(query); con.execute(query)'
10 loops, best of 5: 2.68 usec per loop

--

___
Python tracker 

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



[issue42840] `type` takes **kwargs for __init_subclass__

2021-01-08 Thread Erik Soma


Change by Erik Soma :


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

___
Python tracker 

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



[issue42780] os.set_inheritable() fails for O_PATH file descriptors on Linux

2021-01-08 Thread cptpcrd


Change by cptpcrd :


--
pull_requests: +22999
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/24172

___
Python tracker 

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



[issue42269] Add ability to set __slots__ in dataclasses

2021-01-08 Thread Yurii Karabas


Yurii Karabas <1998uri...@gmail.com> added the comment:

Hi Eric, I tried to help you with this feature and have opened a PR. I thought 
that you are too busy to implement this feature, so that's why I decided to 
help you (It almost two months since your last message in this thread).

--

___
Python tracker 

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



[issue42269] Add ability to set __slots__ in dataclasses

2021-01-08 Thread Yurii Karabas


Change by Yurii Karabas <1998uri...@gmail.com>:


--
keywords: +patch
nosy: +uriyyo
nosy_count: 5.0 -> 6.0
pull_requests: +22998
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/24171

___
Python tracker 

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



[issue42863] Python venv inconsistent folder structure on windows

2021-01-08 Thread Jeff Moguillansky


Jeff Moguillansky  added the comment:

Thanks for the feedback, I understand

--

___
Python tracker 

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



[issue42863] Python venv inconsistent folder structure on windows

2021-01-08 Thread Paul Moore


Paul Moore  added the comment:

Many tools hard code the "if windows then 'Scripts' else 'bin'" logic. They 
will simply fail to work with environments that don't have that layout. Yes, 
they probably should use sysconfig, but many don't (and sometimes for arguably 
good reasons, for example tools run using one Python interpreter that 
manipulate the environment of a different one).

It's something that *could* be changed, but the cost would be significant, the 
work needed to manage the transition is non-trivial, and the benefit isn't 
particularly obvious - "consistency" is never very compelling in isolation, and 
"works better with meson" is likely to be met with the argument that Python's 
layout has been around longer than meson, so it's on meson to accommodate 
Python, not the other way around.

I'm not actively against the idea, but neither do I particularly support it 
(I'm pretty sure it would require work for pip, for no benefit to pip's 
existing users, so it's a net loss for me personally).

If you're interested in pushing for this change go for it - I suspect that it 
would probably need a PEP, and at the very least it would need a community 
discussion - but be prepared for it to meet with a certain amount of resistance.

--

___
Python tracker 

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



[issue42863] Python venv inconsistent folder structure on windows

2021-01-08 Thread Jeff Moguillansky


Jeff Moguillansky  added the comment:

Maybe we can consider adding additional params and a new code path to python -m 
venv?  This way we don't break any existing functionality?

e.g. -includedir=... -libdir=... -bindir=...
?

--

___
Python tracker 

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



[issue24464] "sqlite3_enable_shared_cache" deprecation warning when compiling with macOS system SQLite3

2021-01-08 Thread Erlend Egeberg Aasland


Change by Erlend Egeberg Aasland :


--
pull_requests: +22997
pull_request: https://github.com/python/cpython/pull/24170

___
Python tracker 

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



[issue42863] Python venv inconsistent folder structure on windows

2021-01-08 Thread Steve Dower


Steve Dower  added the comment:

> From the perspective of the overall system, I think it would simplify 
> integration and reduce complexity if we normalize folder structures across 
> platforms instead of having different folder structures.

I agree. But from the perspective of not breaking every existing system out 
there, it makes more sense to not suddenly change it.

If you'd like to champion the 2-3 year (a.k.a. 2-3 release) migration effort to 
get there, I'm more than happy to make sure you're taken seriously by the rest 
of the core team. I'm just not prepared to champion it myself :) I have other 
concerns to use my OSS time for.

--

___
Python tracker 

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



[issue42851] Subclassing Enum with ipaddress.IPv4Network/IPv6Network raises TypeError.

2021-01-08 Thread Ethan Furman


Change by Ethan Furman :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
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



[issue42863] Python venv inconsistent folder structure on windows

2021-01-08 Thread Jeff Moguillansky


Jeff Moguillansky  added the comment:

To give more context regarding this issue:
I'm currently using meson build system to generate the pkg-config files, and it 
seems that the paths "include", "lib" are hardcoded.  

>From the perspective of the overall system, I think it would simplify 
>integration and reduce complexity if we normalize folder structures across 
>platforms instead of having different folder structures.

--

___
Python tracker 

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



[issue9694] argparse required arguments displayed under "optional arguments"

2021-01-08 Thread paul j3


paul j3  added the comment:

Since this issue is closed it might be a good idea to open a new one with this 
problem.  And if possible identify the failed tests.  

We forgot to allow for the fact that working code/tests might be checking for 
specific help messages, checks the will fail when this group label is changed.

--

___
Python tracker 

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



[issue42863] Python venv inconsistent folder structure on windows

2021-01-08 Thread Steve Dower


Steve Dower  added the comment:

I'm afraid not, at least not without breaking everyone who has hardcoded the 
paths already. And I'm pretty sure that include directory is never used 
anymore, either (at least not by distutils, and not by default).

The sysconfig module provides the programmatic interface to the directory 
structure - I'd suggest using "sysconfig.get_paths()" to find the locations 
where files may be written to.

I'd also suggest building your native C library to a wheel and then installing 
that into the virtual environment, as that's the supported way of adding files. 
In that case, there's other tooling for specifying the destination for 
particular files, and it all already takes into account the layout on different 
platforms.

--

___
Python tracker 

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



[issue42867] Entry Widget not editable on Windows 10, but is on Linux Ubuntu 16.04

2021-01-08 Thread John McCabe


John McCabe  added the comment:

@epaine Thank you for your comments. Although the order of events in the 
example you quoted isn't the same as in the application I'm using 
(tk.messagebox.askquestion() is called a long time before the Enter widget is 
created in the application, not the other way round), what you've suggested, 
and a bit of extra thought, has led to a solution for me. I wrapped the 
self.createWidgets call in self.after_idle() (so 
self.after_idle(self.createWidgets)) and that appears to do the job.

Many thanks; it's appreciated.

--

___
Python tracker 

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



[issue42850] Process hangs when calling urllib.request in a multiprocessing.Process with import of sounddevice package

2021-01-08 Thread Ned Deily


Ned Deily  added the comment:

Also note that there are known problems with using the "fork" start method of 
multiprocessing on macOS. As of Python 3.8, the default start methord on macOS 
is now "spawn":

https://docs.python.org/3.9/library/multiprocessing.html#contexts-and-start-methods

Try using "spawn" and/or upgrade to a more recent version of Python 3 (3.9.1 is 
current).

--
nosy: +ned.deily

___
Python tracker 

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



[issue42865] sysconfig appends CFLAGS to LD

2021-01-08 Thread Ned Deily


Change by Ned Deily :


--
nosy: +ned.deily

___
Python tracker 

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



[issue42798] pip search fails

2021-01-08 Thread Benjamin Peterson


Change by Benjamin Peterson :


--
resolution:  -> third party
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



[issue41116] build on macOS 11 (beta) does not find system-supplied third-party libraries

2021-01-08 Thread Ned Deily


Ned Deily  added the comment:

> I am running macOS Big Sur Version 11.1 on Silicon and still get the error 
> about the missing lzma.h file.

Unfortunately, Apple does not include the XZ library with macOS so, to build 
that module, you will need to supply a copy from another source, either build 
it yourself or from a third-party library provider like Homebrew or MacPorts.  
The Python Developer's Guid has some suggestions:

https://devguide.python.org/setup/#macos-and-os-x

--

___
Python tracker 

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



[issue41116] build on macOS 11 (beta) does not find system-supplied third-party libraries

2021-01-08 Thread seb


seb  added the comment:

I am running macOS Big Sur Version 11.1 on Silicon and still get the error 
about the missing lzma.h file. I can confirm that I use the latest Python 3.9.1 
version which includes the patches of this issue.

gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv 
-O3 -Wall -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter 
-Wno-missing-field-initializers -Wstrict-prototypes 
-Werror=implicit-function-declaration -fvisibility=hidden -I./Include/internal 
-I./Include -I. -I/usr/local/include 
-I/Users/dev/Downloads/Python-3.9.1/Include -I/Users/dev/Downloads/Python-3.9.1 
-c /Users/dev/Downloads/Python-3.9.1/Modules/_lzmamodule.c -o 
build/temp.macosx-11.1-arm64-3.9/Users/dev/Downloads/Python-3.9.1/Modules/_lzmamodule.o
/Users/dev/Downloads/Python-3.9.1/Modules/_lzmamodule.c:16:10: fatal error: 
'lzma.h' file not found
#include 

Is this supposed to be still the case? Thank you!

--
nosy: +seb

___
Python tracker 

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



[issue41742] Request for docs.python.org/3/library/configparser.html#exceptions improvement

2021-01-08 Thread Irit Katriel


Change by Irit Katriel :


--
keywords: +easy

___
Python tracker 

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



[issue42867] Entry Widget not editable on Windows 10, but is on Linux Ubuntu 16.04

2021-01-08 Thread E. Paine


E. Paine  added the comment:

This is a Tk/Windows issue, not tkinter. I tested the following on Windows 10 
using Tk 8.6.9:

# Our entry
pack [entry .e]

# Causes the entry to fail
#tk_messageBox -title Title -message Message
#after 0 tk_messageBox -title Title -message Message

# Does not cause the entry to fail
#after 1 tk_messageBox -title Title -message Message
after idle tk_messageBox -title Title -message Message

I have not tried on a later version of Tk so it may be fixed but it also may be 
a fundamental Windows issue. The workaround would be to either use .after(1, 
...) or .after_idle(...)

--
nosy: +epaine
versions: +Python 3.10, Python 3.8

___
Python tracker 

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



[issue42269] Add ability to set __slots__ in dataclasses

2021-01-08 Thread lcy


Change by lcy :


--
nosy: +lcy0321

___
Python tracker 

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



[issue9694] argparse required arguments displayed under "optional arguments"

2021-01-08 Thread Miro Hrončok

Miro Hrončok  added the comment:

Coudl this please be mentioned on 
https://docs.python.org/3.10/whatsnew/3.10.html ?

At least two packages fail tests because of the change (ipython and 
sphinxcontrib-autoprogram).

--
nosy: +hroncok

___
Python tracker 

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



[issue31213] __context__ reset to None in nested exception

2021-01-08 Thread Irit Katriel


Irit Katriel  added the comment:

This seems to be deliberately done here in order to prevent context cycles from 
forming: 
https://github.com/python/cpython/blob/fe6e5e7cfd68eeaa69fd1511f354a1b4d8d90990/Python/errors.c#L148

In your code you are creating a cycle where foo is the context (and cause) for 
bar which is the context (and cause) of the second time foo is raised. 

If you create a new instance of foo for the second raise then there is no cycle 
and you get what you expect:

try:
try:
raise Exception('foo')
except Exception as foo:
print("1--", foo, foo.__context__, foo.__cause__)
try:
raise Exception('bar') from foo
except Exception as bar:
print("2--", bar, bar.__context__, bar.__context__.__context__)
raise Exception('foo2') from bar
except Exception as foo:
wat = foo

print("3--", wat, wat.__context__, wat.__context__.__context__)
print("4--", wat, wat.__cause__, wat.__cause__.__context__)
print("5--", wat, wat.__cause__, wat.__cause__.__cause__)


Output is:

1-- foo None None
2-- bar foo None
3-- foo2 bar foo
4-- foo2 bar foo
5-- foo2 bar foo


I think the bug is in your code - you can't create an exception chain that 
contains the same exception instance more than once.

--
nosy: +iritkatriel

___
Python tracker 

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



[issue42866] test test_multibytecodec: Test_IncrementalEncoder.test_subinterp() leaks references

2021-01-08 Thread STINNER Victor


STINNER Victor  added the comment:

Ok, it's now fixed.

To make sure that a heap type can be deleted, it must by a GC type, has a 
traverse function, and it must track its instances. We should take this in 
account when we convert static types to heap types. In practice, deleting a 
type is mostly an issue when we check for reference leak and an instance is 
kept alive until the last GC collection, at the end of Py_EndInterpreter().

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

___
Python tracker 

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



[issue42868] SpooledTemporaryFile.__iter__ is not transparent to rollover

2021-01-08 Thread Jin-oh Kang


New submission from Jin-oh Kang :

In tempfile, SpooledTemporaryFile.__iter__ is defined as follows:

# file protocol
def __iter__(self):
return self._file.__iter__()

A rollover would switch the underlying _file object from a BytesIO to a 
TemporaryFile, thereby leaving the original iterator stale.

This may be fixed by:

def __iter__(self):
while True:
line = self._file.readline()
if not line:
break
yield line

Or perhaps:

def __iter__(self):
while True:
file = self._file
for line in file:
yield line
if file is not self._file:
break
else:
break

--
components: Library (Lib)
messages: 384674
nosy: jinoh.kang.kr
priority: normal
severity: normal
status: open
title: SpooledTemporaryFile.__iter__ is not transparent to rollover
type: behavior
versions: Python 3.10

___
Python tracker 

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



[issue42866] test test_multibytecodec: Test_IncrementalEncoder.test_subinterp() leaks references

2021-01-08 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 11ef53aefbecfac18b63cee518a7184f771f708c by Victor Stinner in 
branch 'master':
bpo-42866: Add traverse func to _multibytecodec.MultibyteCodec (GH-24166)
https://github.com/python/cpython/commit/11ef53aefbecfac18b63cee518a7184f771f708c


--

___
Python tracker 

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



[issue42867] Entry Widget not editable on Windows 10, but is on Linux Ubuntu 16.04

2021-01-08 Thread John McCabe


John McCabe  added the comment:

Thank you.

Wrt to your initial suggestion, I recognise Python's popularity will make 
things busy, and I will ask if anyone knows of a workaround in other fora, but 
a bug's a bug and, IMO, if something behaves differently on different 
platforms, using packages that are part of the Python install, for no apparent 
reason, then that's a bug! (Especially as the same thing was reported over 10 
years ago, on what would be a very different version of Python).

--

___
Python tracker 

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



[issue42866] test test_multibytecodec: Test_IncrementalEncoder.test_subinterp() leaks references

2021-01-08 Thread Erlend Egeberg Aasland


Erlend Egeberg Aasland  added the comment:

Ah, thanks! I also found that info in the docs: 
https://docs.python.org/3/c-api/typeobj.html#c.PyTypeObject.tp_free

--

___
Python tracker 

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



[issue42866] test test_multibytecodec: Test_IncrementalEncoder.test_subinterp() leaks references

2021-01-08 Thread miss-islington


Change by miss-islington :


--
pull_requests: +22996
pull_request: https://github.com/python/cpython/pull/24168

___
Python tracker 

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



[issue42866] test test_multibytecodec: Test_IncrementalEncoder.test_subinterp() leaks references

2021-01-08 Thread miss-islington


Change by miss-islington :


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

___
Python tracker 

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



[issue42866] test test_multibytecodec: Test_IncrementalEncoder.test_subinterp() leaks references

2021-01-08 Thread STINNER Victor


STINNER Victor  added the comment:

typo: My PR uses the generic tp->tp_free which *is* PyObject_GC_Del().

--

___
Python tracker 

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



[issue42866] test test_multibytecodec: Test_IncrementalEncoder.test_subinterp() leaks references

2021-01-08 Thread STINNER Victor


STINNER Victor  added the comment:

> Don't you need to free memory using PyObject_GC_Del when you allocate using 
> PyObject_GC_New?

My PR uses the generic tp->tp_free which PyObject_GC_Del().

--

___
Python tracker 

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



[issue42867] Entry Widget not editable on Windows 10, but is on Linux Ubuntu 16.04

2021-01-08 Thread Christian Heimes


Christian Heimes  added the comment:

I'm involving TJ and Serhiy. They might have free resources and might be able 
to assist.

I initially suggested to get assistance in user forums, because we have very 
limited resources. To give you an impression, there are more than 7,500 open 
bugs on BPO and more than 1,400 open PRs on Github..

--
nosy: +serhiy.storchaka, terry.reedy

___
Python tracker 

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



[issue42866] test test_multibytecodec: Test_IncrementalEncoder.test_subinterp() leaks references

2021-01-08 Thread Erlend Egeberg Aasland


Erlend Egeberg Aasland  added the comment:

Ref. https://docs.python.org/3/c-api/typeobj.html#Py_TPFLAGS_HAVE_GC

--

___
Python tracker 

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



[issue30701] Exception parsing certain invalid email address headers

2021-01-08 Thread Irit Katriel


Change by Irit Katriel :


--
resolution:  -> out of date
stage:  -> resolved
status: pending -> closed

___
Python tracker 

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



[issue42867] Entry Widget not editable on Windows 10, but is on Linux Ubuntu 16.04

2021-01-08 Thread John McCabe


John McCabe  added the comment:

In addition, changing "Entry" to "Text" (+ necessary associated changes) makes 
no difference to the outcome. Removing the call to tk.messagebox.askquestion() 
does. It appears that tk.messagebox.askquestion() is screwing something up on 
Windows; perhaps it's locking some resources, or not correctly releasing them.

--

___
Python tracker 

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



[issue42866] test test_multibytecodec: Test_IncrementalEncoder.test_subinterp() leaks references

2021-01-08 Thread Erlend Egeberg Aasland


Erlend Egeberg Aasland  added the comment:

Don't you need to free memory using PyObject_GC_Del when you allocate using 
PyObject_GC_New?

--

___
Python tracker 

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



[issue42867] Entry Widget not editable on Windows 10, but is on Linux Ubuntu 16.04

2021-01-08 Thread John McCabe


John McCabe  added the comment:

It's reproducible in both 3.8 and 3.9 on Windows 10.

--
versions: +Python 3.9 -Python 3.6

___
Python tracker 

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



[issue42867] Entry Widget not editable on Windows 10, but is on Linux Ubuntu 16.04

2021-01-08 Thread Christian Heimes


Christian Heimes  added the comment:

Can your produce the issue with Python 3.8 or newer on any platform? 3.6 and 
3.7 are in security fix-only mode. If it's truly a bug in Python, then we won't 
fix the issue any way.

--

___
Python tracker 

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



[issue42866] test test_multibytecodec: Test_IncrementalEncoder.test_subinterp() leaks references

2021-01-08 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +22994
pull_request: https://github.com/python/cpython/pull/24166

___
Python tracker 

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



[issue42866] test test_multibytecodec: Test_IncrementalEncoder.test_subinterp() leaks references

2021-01-08 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset e542d417b96077d04aec089505eacb990c9799ae by Victor Stinner in 
branch 'master':
bpo-42866: Fix refleak in CJK getcodec() (GH-24165)
https://github.com/python/cpython/commit/e542d417b96077d04aec089505eacb990c9799ae


--

___
Python tracker 

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



[issue42866] test test_multibytecodec: Test_IncrementalEncoder.test_subinterp() leaks references

2021-01-08 Thread STINNER Victor


STINNER Victor  added the comment:

Calling gc.collect() twice works around the issue, which sounds like a missing 
traverse function somewhere.

diff --git a/Python/pystate.c b/Python/pystate.c
index c791b23999..66bbe1bf7d 100644
--- a/Python/pystate.c
+++ b/Python/pystate.c
@@ -321,6 +321,7 @@ interpreter_clear(PyInterpreterState *interp, PyThreadState 
*tstate)
 
 /* Last garbage collection on this interpreter */
 _PyGC_CollectNoFail(tstate);
+_PyGC_CollectNoFail(tstate);
 _PyGC_Fini(tstate);
 
 /* We don't clear sysdict and builtins until the end of this function.

--

___
Python tracker 

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



[issue42867] Entry Widget not editable on Windows 10, but is on Linux Ubuntu 16.04

2021-01-08 Thread John McCabe


John McCabe  added the comment:

Is behaviour that differs between platforms, using components that are listed 
in the "classification" -> "Components" section NOT a bug then?

--

___
Python tracker 

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



[issue14655] traceback module docs should show how to print/fomat an exception object

2021-01-08 Thread Irit Katriel


Irit Katriel  added the comment:

In issue 26389 the api was changed so that now format_exception(exc) works.

--
resolution:  -> duplicate
stage: needs patch -> resolved
status: open -> closed
superseder:  -> Expand traceback module API to accept just an exception as an 
argument

___
Python tracker 

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



[issue42853] `OverflowError: signed integer is greater than maximum` in ssl.py for files larger than 2GB

2021-01-08 Thread Christian Heimes


Christian Heimes  added the comment:

That's a good idea, Ronald! socket.c:sock_send_impl() already clamps the input 
length on Windows:

#ifdef MS_WINDOWS
if (ctx->len > INT_MAX)
ctx->len = INT_MAX;
ctx->result = send(s->sock_fd, ctx->buf, (int)ctx->len, ctx->flags);
#else
ctx->result = send(s->sock_fd, ctx->buf, ctx->len, ctx->flags);
#endif

I could implement a similar logic for SSLSocket. Applications have to check the 
return value of send() any way or use sendall(). The socket.send() method / 
send(2) libc function may also write less bytes.

--

___
Python tracker 

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



[issue42867] Entry Widget not editable on Windows 10, but is on Linux Ubuntu 16.04

2021-01-08 Thread Christian Heimes


Christian Heimes  added the comment:

Hi,

bugs.python.org is an issue tracker for bugs and feature requests. Please use 
platforms like Python user mailing list, stack overflow, or reddit for general 
help with Python and libraries.

--
nosy: +christian.heimes

___
Python tracker 

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



[issue42867] Entry Widget not editable on Windows 10, but is on Linux Ubuntu 16.04

2021-01-08 Thread John McCabe


New submission from John McCabe :

I've built an application using tkinter (see below). I'm fairly new to tkinter, 
despite having substantial software experience (33 years), so the layout might 
be a bit odd/wrong, and the example obviously doesn't follow PEP-8 guidelines, 
however...

Basically this application (which is a bit more than minimal, but should be 
easy to follow) is designed to manage pairs of text values as JSON, 
saving/loading from a file. When it starts, the user is asked if they want to 
read in an existing file of data; if they select NO, a fairly empty frame with 
3 buttons showing "+", "Save" and "Quit" is displayed.

At this point, if "+" is pressed, a new row with two labels and two Entry 
widgets is added to the frame.

However (and this is the problem which appears to be identical to that reported 
in Issue #9673), it is not possible to set focus into either of the Entry 
widgets on Windows 10; there is no problem doing this on Ubuntu 16.04 (although 
I've only got Python 3.5 on there)

If the "Save" button is then pressed, a message box pops up telling the use 
that no changes have been saved. Once OK has been pressed on that, it becomes 
possible to set focus into the Entry widgets.

One of the problems with Issue #9673 was that no 'minimal' example was provided 
showing this behaviour, and the very minimal example given in 
https://bugs.python.org/issue9673#msg218765 doesn't exhibit the problem, hence 
the example below being a bit more than minimal, while still not being 
particularly complicated.


#!/usr/bin/python3

import os
import tkinter as tk
from tkinter import filedialog, messagebox
import json

class Application(tk.Frame):

def __init__(self, master):
super().__init__(master)
self.master = master
self.grid()
self.originalJson = {}
self.inFileName = ""
self.leftRightEntries = []
self.fileDlgOpts = { "initialdir"   : os.getcwd(),
 "initialfile"  : "file.json",
 "filetypes": (("JSON File", "*.json"), 
("All Files","*.*")),
 "defaultextension" : '.json',
 "title": "Select A File" }
self.createWidgets()

def openInFile(self):
fileName = ""
reuse = tk.messagebox.askquestion("Use An Existing File", "Do you want 
to load and use an existing file?")
if reuse == "yes":
fileName = tk.filedialog.askopenfilename(**self.fileDlgOpts)
if fileName is not "":
try:
with open(fileName, 'r') as json_file:
self.originalJson = json.load(json_file)
json_file.close()
except Exception:
tk.messagebox.showerror("Use An Existing File", "File could 
not be loaded; continuing without one.")
fileName = ""
else:
tk.messagebox.showwarning("Use An Existing File", "No existing 
file specified; continuing without one.")

return fileName

def createWidgets(self):
self.inFileName = self.openInFile()

# We add the buttons to some huge numbered row because we might want to 
insert more
# rows, and the layout manager will collapse everything in between. 
Also we
# add these first because of the way the tab order is set up
self.addBtn = tk.Button(self.master, text = "+", command = self.addNew)
self.addBtn.grid(row = 100, column = 0, sticky = tk.W)

# Save button; pretty self-explanatory
self.saveBtn = tk.Button(self.master, text = "Save", command = 
self.save)
self.saveBtn.grid(row = 100, column = 2, sticky = tk.W)

# Quit button; pretty self-explanatory
self.quitBtn = tk.Button(self.master, text = "QUIT", fg = "red", 
command = self.quit)
self.quitBtn.grid(row = 100, column = 3, sticky = tk.E)

# If there is original json, work through each key and put the fields 
on the display
rowNum = 0
for leftText in sorted(self.originalJson.keys()):
self.insertRow(rowNum, leftText);
rowNum = rowNum + 1

self.nextEmptyRow = rowNum

self.redoPadding()

def redoPadding(self):
for child in self.master.winfo_children():
child.grid_configure(padx = 5, pady = 5)

def focusNextWidget(self, event):
event.widget.tk_focusNext().focus()
return("break")

def insertRow(self, rowNum, initialLeft = None):
tk.Label(self.master, height = 1, text = "Left: ").grid(row = rowNum, 
column = 0, sticky = tk.W)
leftBox = tk.Entry(self.master, width = 20)
leftBox.grid(row = rowNum, column = 1, sticky = tk.W)
leftBox.bind("", self.focusNextWidget)
if initialLeft is not None:
leftBox.insert(tk.END, initialLeft)
tk.Label(self.master, height = 1, 

[issue42866] test test_multibytecodec: Test_IncrementalEncoder.test_subinterp() leaks references

2021-01-08 Thread STINNER Victor


STINNER Victor  added the comment:

> encodings._cache['cp932'] = _codecs_jp.getcodec('cp932')

* encodings._cache is kept alive by encodings.search_function.__globals__
* encodings.search_function function is kept alive by 
PyInterpreterState.codec_search_path list. The function by _PyCodec_Register() 
in encodings/__init__.py: codecs.register(search_function).

For example, unregistering the search function prevents the leak:

import encodings
import _codecs_jp
encodings._cache['cp932'] = _codecs_jp.getcodec('cp932')

import codecs
codecs.unregister(encodings.search_function)

The PyInterpreterState.codec_search_path list is cleared at Python exit by 
interpreter_clear().

The weird part is that the _codecs_jp.getcodec('cp932') codec object *is* 
deleted. I checked and multibytecodec_dealloc() is called with the object 
stored in the encodings cache.

A _multibytecodec.MultibyteCodec instance (MultibyteCodecObject* structure in 
C) is a simple type: it only stores pointer to C functions and C strings. It 
doesn't contain any Python object. So I don't see how it could be part of a 
reference cycle by itself. Moreover, again, it is deleted.

--

___
Python tracker 

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



[issue42866] test test_multibytecodec: Test_IncrementalEncoder.test_subinterp() leaks references

2021-01-08 Thread STINNER Victor


STINNER Victor  added the comment:

See also bpo-42671 "Make the Python finalization more deterministic" but it 
seems like PR 23826 makes the leak worse (+2000 leaked references instead of 
+200) :-)

--

___
Python tracker 

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



[issue42866] test test_multibytecodec: Test_IncrementalEncoder.test_subinterp() leaks references

2021-01-08 Thread STINNER Victor


STINNER Victor  added the comment:

Links about ref leaks related to encodings:

* https://bugs.python.org/issue1635741#msg364833 
* https://bugs.python.org/issue1635741#msg364968
* https://bugs.python.org/issue36854#msg357160
* https://github.com/python/cpython/compare/master...phsilva:remove-codec-caches

--

___
Python tracker 

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



[issue42866] test test_multibytecodec: Test_IncrementalEncoder.test_subinterp() leaks references

2021-01-08 Thread STINNER Victor


STINNER Victor  added the comment:

The leak can be simplified to:

@support.cpython_only
def test_subinterp(self):
import _testcapi
code = textwrap.dedent("""
import encodings
import _codecs_jp
encodings._cache['cp932'] = _codecs_jp.getcodec('cp932')
""")
res = _testcapi.run_in_subinterp(code)
self.assertEqual(res, 0)

--

___
Python tracker 

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



[issue42866] test test_multibytecodec: Test_IncrementalEncoder.test_subinterp() leaks references

2021-01-08 Thread STINNER Victor


STINNER Victor  added the comment:

PR 24165 fix one reference leak in the getcodec() function of CJK codecs. But 
it doesn't fix all ref leaks of this issue.

--

___
Python tracker 

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



[issue42866] test test_multibytecodec: Test_IncrementalEncoder.test_subinterp() leaks references

2021-01-08 Thread STINNER Victor


Change by STINNER Victor :


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

___
Python tracker 

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



[issue42853] `OverflowError: signed integer is greater than maximum` in ssl.py for files larger than 2GB

2021-01-08 Thread Ronald Oussoren


Ronald Oussoren  added the comment:

The API documentation already implies that write might not write the entire 
buffer because it returns the number of bytes actually written (just like 
os.write).  

A possible workaround on the SSL layer is hence to clamp the amount of bytes to 
write to MAX_INT (or later MAX_SSIZE_T) bytes. 

That said, this does require checking that users of the SSL layer write method 
in the stdib actually check for the number of bytes written, otherwise we'd 
exchange the exception to a silent error.

--
nosy: +ronaldoussoren

___
Python tracker 

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



[issue42866] test test_multibytecodec: Test_IncrementalEncoder.test_subinterp() leaks references

2021-01-08 Thread Erlend Egeberg Aasland


Erlend Egeberg Aasland  added the comment:

Thank you so much for taking the time to write these blog posts, Victor, and 
for explaining your fixes is such great detail. It is very helpful!

--

___
Python tracker 

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



[issue42866] test test_multibytecodec: Test_IncrementalEncoder.test_subinterp() leaks references

2021-01-08 Thread STINNER Victor


STINNER Victor  added the comment:

By the way, I wrote an article "Leaks discovered by subinterpreters":
https://vstinner.github.io/subinterpreter-leaks.html

This leak may be new kind related to capsule, I'm not sure so far.

--

___
Python tracker 

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



[issue1635741] Py_Finalize() doesn't clear all Python objects at exit

2021-01-08 Thread STINNER Victor


STINNER Victor  added the comment:

> New changeset 0b858cdd5d114f0890b11b6c4d6559d0ceb468ab by Erlend Egeberg 
> Aasland in branch 'master':
> bpo-1635741: Convert _multibytecodec to multi-phase init (GH-24095)

This change introduced two regressions:

* bpo-42846: "Using _multibytecodec module on Windows, test_threading/embed get 
failure" (FIXED)
* bpo-42866: "test test_multibytecodec: 
Test_IncrementalEncoder.test_subinterp() leaks references"

--

___
Python tracker 

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



[issue42866] test test_multibytecodec: Test_IncrementalEncoder.test_subinterp() leaks references

2021-01-08 Thread STINNER Victor


Change by STINNER Victor :


--
nosy: +corona10, erlendaasland

___
Python tracker 

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



[issue42866] test test_multibytecodec: Test_IncrementalEncoder.test_subinterp() leaks references

2021-01-08 Thread STINNER Victor


STINNER Victor  added the comment:

I added the test which leaks in bpo-42846.

commit 07f2cee93f1b619650403981c455f47bfed8d818
Author: Victor Stinner 
Date:   Fri Jan 8 00:15:22 2021 +0100

bpo-42846: Convert CJK codec extensions to multiphase init (GH-24157)

Convert the 6 CJK codec extension modules (_codecs_cn, _codecs_hk,
_codecs_iso2022, _codecs_jp, _codecs_kr and _codecs_tw) to the
multiphase initialization API (PEP 489).

Remove getmultibytecodec() local cache: always import
_multibytecodec. It should be uncommon to get a codec. For example,
this function is only called once per CJK codec module.

Fix a reference leak in register_maps() error path.

I don't think that the leak is new. It's just that it wasn't seen previously.

--

___
Python tracker 

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



[issue42846] Using _multibytecodec module on Windows, test_threading/embed get failure

2021-01-08 Thread STINNER Victor


STINNER Victor  added the comment:

> bpo-42846: Convert CJK codec extensions to multiphase init (GH-24157)

I added a new test and new test spotted a reference leak, likely an existing 
one: bpo-42866 "test test_multibytecodec: 
Test_IncrementalEncoder.test_subinterp() leaks references".

--

___
Python tracker 

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



[issue42866] test test_multibytecodec: Test_IncrementalEncoder.test_subinterp() leaks references

2021-01-08 Thread STINNER Victor


New submission from STINNER Victor :

$ ./python -m test test_multibytecodec -m 
test.test_multibytecodec.Test_IncrementalEncoder.test_subinterp -R 3:3
(...)
test_multibytecodec leaked [258, 258, 258] references, sum=774

I simplified the code. The following test leaks references:

def test_subinterp(self):
import _testcapi
code = textwrap.dedent("""
import _codecs_jp
codec = _codecs_jp.getcodec('cp932')
codec = None
""")
_testcapi.run_in_subinterp(code)

_codecs_jp.getcodec() is defined in Modules/cjkcodecs/cjkcodecs.h. Extract:

cofunc = getmultibytecodec();
...
codecobj = PyCapsule_New((void *)codec, PyMultibyteCodec_CAPSULE_NAME, 
NULL);
if (codecobj == NULL)
return NULL;

r = PyObject_CallOneArg(cofunc, codecobj);
Py_DECREF(codecobj);

getmultibytecodec() is the _multibytecodec.__create_codec() which is defined in 
Modules/cjkcodecs/multibytecodec.c. Simplified code:

codec = PyCapsule_GetPointer(arg, PyMultibyteCodec_CAPSULE_NAME);
_multibytecodec_state *state = _multibytecodec_get_state(module);
self = PyObject_New(MultibyteCodecObject, state->multibytecodec_type);
self->codec = codec;
return (PyObject *)self;

--
components: Library (Lib)
messages: 384643
nosy: vstinner
priority: normal
severity: normal
status: open
title: test test_multibytecodec: Test_IncrementalEncoder.test_subinterp() leaks 
references
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



[issue42860] Incompatible types in Python grammar

2021-01-08 Thread Tobias Kohn


Tobias Kohn  added the comment:

Great, thanks a lot!

--

___
Python tracker 

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