[issue41272] New clause in FOR and WHILE instead of ELSE

2020-07-18 Thread Vedran Čačić

Vedran Čačić  added the comment:

I completely agree that we should reject this, but you commit a very frequent 
mistake in programming try-expressions. The problem is, if the first option 
contains a NameError, second option will be executed.

It should be:

try: i001
except NameError: 
else: 

And similarly for break001. You see, dependent `else` is needed sometimes. But 
of course Guido already covered this. :-)

--
nosy: +veky

___
Python tracker 

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



[issue41311] Add a function to get a random sample from an iterable (reservoir sampling)

2020-07-18 Thread Tim Peters


Tim Peters  added the comment:

The lack of exactness (and possibility of platform-dependent results, 
including, e.g., when a single platform changes its math libraries) certainly 
works against it.

But I think Raymond is more bothered by that there's no apparently _compelling_ 
use case, in the sense of something frequent enough in real life to warrant 
including it in the standard library.

For example, there's really no problem right now if you have a giant iterable 
_and_ you know its length.  I had a case where I had to sample a few hundred 
doubles from giant binary files of floats.  The "obvious" solution worked great:

for o in sorted(random.sample(range(0, file_size, 8), 1000)):
seek to offset o and read up 8 bytes

Now random access to that kind of iterable is doable, but a similar approach 
works fine too if it's sequential-only access to a one-shot iterator of known 
length:  pick the indices in advance, and skip over the iterator until each 
index is hit in turn.

It doesn't score much points for being faster than materializing a set or dict 
into a sequence first, since that's a micro-optimization justified only by 
current CPython implementation accidents.

Where it's absolutely needed is when there's a possibly-giant iterable of 
unknown length. Unlike Raymond, I think that's possibly worth addressing (it's 
not hard to find people asking about it on the web). But it's not a problem 
I've had in real life, so, ya, it's hard to act enthusiastic ;-)

PS: you should also guard against W > 1.0. No high-quality math library will 
create such a thing given these inputs, but testing only for exact equality to 
1.0 is no cheaper and so needlessly optimistic.

--

___
Python tracker 

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



[issue41324] Add a minimal decimal capsule API

2020-07-18 Thread Karthikeyan Singaravelan

Change by Karthikeyan Singaravelan :


--
title: En az ondalık kapsül API ekleme -> Add a minimal decimal capsule API

___
Python tracker 

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



[issue41324] En az ondalık kapsül API ekleme

2020-07-18 Thread Abdulkadir Özbudak

Change by Abdulkadir Özbudak :


--
title: Add a minimal decimal capsule API -> En az ondalık kapsül API ekleme

___
Python tracker 

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



[issue36723] Unittest Discovery for namespace subpackages dot notation fails

2020-07-18 Thread Inada Naoki


Change by Inada Naoki :


--
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> unittest discovery doesn't detect namespace packages when given 
no parameters

___
Python tracker 

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



[issue36723] Unittest Discovery for namespace subpackages dot notation fails

2020-07-18 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +inada.naoki

___
Python tracker 

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



[issue23882] unittest discovery doesn't detect namespace packages when given no parameters

2020-07-18 Thread Inada Naoki


Inada Naoki  added the comment:

Searching into directory without __init__.py recursively is not only 
inefficient, but also dangerous.

 project/
   - mylib/
  - __init__.py
  - foo.py
   - tests/
  - __init__.py
  - test_foo.py
   - tools/
  - bin/
  - dangerous_script.py

What happens if `python -m unittest` is run in the project root?
Who excepts tools/bin/dangarous.py is executed?

My conclution is:

* People shouldn't abuse PEP 420.  Omitting __init__.py is allowed only for 
namespace package.
* Namespace package should be searched based on PEP 420 rule. Don't search into 
regular directory unless it is specified.

--

___
Python tracker 

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



[issue35617] unittest discover does not work with implicit namespaces

2020-07-18 Thread Inada Naoki


Change by Inada Naoki :


--
resolution:  -> duplicate
stage: patch review -> resolved
status: open -> closed
superseder:  -> unittest discovery doesn't detect namespace packages when given 
no parameters

___
Python tracker 

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



[issue23882] unittest discovery doesn't detect namespace packages when given no parameters

2020-07-18 Thread Inada Naoki


Inada Naoki  added the comment:

I think people misunderstanding and misusing PEP 420, withouth knowing what is 
namespace package for.

I had wrote an article to describe namespace package is not a regular package.
https://dev.to/methane/don-t-omit-init-py-3hga

--

___
Python tracker 

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



[issue23882] unittest discovery doesn't detect namespace packages when given no parameters

2020-07-18 Thread Inada Naoki


Inada Naoki  added the comment:

I had rejected this idea in #29642. This is a copy of my comments in the issue.

---

I'm afraid this change makes testloader searches unrelated directory contains 
massive files (like node_modules).

I don't think loading all tests from whole namespace package is not usual use 
case.

When using import, (namespace) package name is explicitly specified.
Only specified name is searched.

In test loader's case, there are no such limit.
Loader may search millions of completely unrelated directories.
It may include directories in NFS or samba over slow network.

--
nosy: +inada.naoki
versions: +Python 3.10 -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



[issue29642] Why does unittest.TestLoader.discover still rely on existence of __init__.py files?

2020-07-18 Thread Inada Naoki


Change by Inada Naoki :


--
superseder:  -> unittest discovery doesn't detect namespace packages when given 
no parameters

___
Python tracker 

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



[issue41295] CPython 3.8.4 regression on __setattr__ in multiinheritance with metaclasses

2020-07-18 Thread kam193


kam193  added the comment:

@Stefan: Today I run unit tests for Flask-SQLAlchemy (v2.4.3) as well as for 
aioxmpp (another library reported this problem 
https://github.com/horazont/aioxmpp/issues/342). In both cases patch is 
successful: tests fail on Python 3.8.4 but pass on patched Python.

As for me it looks done. Thanks for everyone involved!

--

___
Python tracker 

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



[issue39603] [security] http.client: HTTP Header Injection in the HTTP method

2020-07-18 Thread M W


Change by M W :


--
assignee:  -> christian.heimes
components: +SSL
nosy: +M W2, christian.heimes

___
Python tracker 

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



[issue41295] CPython 3.8.4 regression on __setattr__ in multiinheritance with metaclasses

2020-07-18 Thread Guido van Rossum


Guido van Rossum  added the comment:

We have a buildbot failure: test_asyncio altered the execution environment. 
What does that mean? Victor?

--
nosy: +gvanrossum

___
Python tracker 

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



[issue41295] CPython 3.8.4 regression on __setattr__ in multiinheritance with metaclasses

2020-07-18 Thread miss-islington


miss-islington  added the comment:


New changeset 38d930f2ccbff6f93c4c54a7a6a1759266136504 by Miss Islington (bot) 
in branch '3.8':
bpo-41295: Reimplement the Carlo Verre "hackcheck" (GH-21528)
https://github.com/python/cpython/commit/38d930f2ccbff6f93c4c54a7a6a1759266136504


--

___
Python tracker 

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



[issue41295] CPython 3.8.4 regression on __setattr__ in multiinheritance with metaclasses

2020-07-18 Thread miss-islington


miss-islington  added the comment:


New changeset 01ab9634601fc1a4f9ac5d72ddc022239d2543fe by Miss Islington (bot) 
in branch '3.9':
bpo-41295: Reimplement the Carlo Verre "hackcheck" (GH-21528)
https://github.com/python/cpython/commit/01ab9634601fc1a4f9ac5d72ddc022239d2543fe


--

___
Python tracker 

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



[issue41295] CPython 3.8.4 regression on __setattr__ in multiinheritance with metaclasses

2020-07-18 Thread miss-islington


miss-islington  added the comment:


New changeset c53b310e5926266ce267c44a168165cacd786d6e by scoder in branch 
'master':
bpo-41295: Reimplement the Carlo Verre "hackcheck" (GH-21528)
https://github.com/python/cpython/commit/c53b310e5926266ce267c44a168165cacd786d6e


--
nosy: +miss-islington

___
Python tracker 

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



[issue41295] CPython 3.8.4 regression on __setattr__ in multiinheritance with metaclasses

2020-07-18 Thread miss-islington


Change by miss-islington :


--
pull_requests: +20683
pull_request: https://github.com/python/cpython/pull/21541

___
Python tracker 

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



[issue41295] CPython 3.8.4 regression on __setattr__ in multiinheritance with metaclasses

2020-07-18 Thread miss-islington


Change by miss-islington :


--
pull_requests: +20682
pull_request: https://github.com/python/cpython/pull/21540

___
Python tracker 

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



[issue29778] [CVE-2020-15523] _Py_CheckPython3 uses uninitialized dllpath when embedder sets module path with Py_SetPath

2020-07-18 Thread Eryk Sun


Eryk Sun  added the comment:

> If you can put files in the root of the hard drive where Windows was
> installed, surely you have other, easier attack vectors.

A rooted path is resolved relative to the process working directory, and Python 
can be started with any current working directory. 

The default access control set on the root directory of a filesystem allows any 
authenticated user to create files or directories, such as "D:\python3.dll". 
That's if a filesystem even supports security. Removable drives are often 
formatted as FAT32 or exFAT, and FAT filesystems have no security.

The system drive (almost always "C:") has to be an NTFS filesystem, and its 
root directory is locked down a bit more. It's at high integrity level with a 
no-write-up rule for files, but not for directories. Only a logon at elevated 
integrity level (high or system level) can create "C:\python3.dll". OTOH, any 
authenticated user is still allowed to create a directory, such as "C:\DLLs", 
and is granted the right to create files in it such as "C:\DLLs\python3.dll".

--
nosy: +eryksun

___
Python tracker 

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



[issue39603] [security] http.client: HTTP Header Injection in the HTTP method

2020-07-18 Thread miss-islington


miss-islington  added the comment:


New changeset 27b811057ff5e93b68798e278c88358123efdc71 by Miss Islington (bot) 
in branch '3.9':
bpo-39603: Prevent header injection in http methods (GH-18485)
https://github.com/python/cpython/commit/27b811057ff5e93b68798e278c88358123efdc71


--

___
Python tracker 

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



[issue39603] [security] http.client: HTTP Header Injection in the HTTP method

2020-07-18 Thread miss-islington


miss-islington  added the comment:


New changeset 668d321476d974c4f51476b33aaca870272523bf by Miss Islington (bot) 
in branch '3.8':
bpo-39603: Prevent header injection in http methods (GH-18485)
https://github.com/python/cpython/commit/668d321476d974c4f51476b33aaca870272523bf


--

___
Python tracker 

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



[issue39603] [security] http.client: HTTP Header Injection in the HTTP method

2020-07-18 Thread Guido van Rossum


Guido van Rossum  added the comment:

The 3.9 and 3.8 backports are waiting for tests to complete. The 3.7 and 3.6 
backports need to be merged by the RM (Ned). Then someone can close this issue.

--
nosy: +gvanrossum

___
Python tracker 

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



[issue39603] [security] http.client: HTTP Header Injection in the HTTP method

2020-07-18 Thread miss-islington


Change by miss-islington :


--
pull_requests: +20681
pull_request: https://github.com/python/cpython/pull/21539

___
Python tracker 

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



[issue39603] [security] http.client: HTTP Header Injection in the HTTP method

2020-07-18 Thread miss-islington


Change by miss-islington :


--
pull_requests: +20680
pull_request: https://github.com/python/cpython/pull/21538

___
Python tracker 

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



[issue39603] [security] http.client: HTTP Header Injection in the HTTP method

2020-07-18 Thread miss-islington


Change by miss-islington :


--
pull_requests: +20679
pull_request: https://github.com/python/cpython/pull/21537

___
Python tracker 

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



[issue39603] [security] http.client: HTTP Header Injection in the HTTP method

2020-07-18 Thread miss-islington


miss-islington  added the comment:


New changeset 8ca8a2e8fb068863c1138f07e3098478ef8be12e by AMIR in branch 
'master':
bpo-39603: Prevent header injection in http methods (GH-18485)
https://github.com/python/cpython/commit/8ca8a2e8fb068863c1138f07e3098478ef8be12e


--
nosy: +miss-islington

___
Python tracker 

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



[issue39603] [security] http.client: HTTP Header Injection in the HTTP method

2020-07-18 Thread miss-islington


Change by miss-islington :


--
pull_requests: +20678
pull_request: https://github.com/python/cpython/pull/21536

___
Python tracker 

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



[issue41272] New clause in FOR and WHILE instead of ELSE

2020-07-18 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

I think this should be closed as 'rejected'.

1. I am strongly opposed to giving keywords strongly context-dependent 
alternate meanings.  I also don't think that the proposal could be parsed.  
Currently, 'if' introduces a new, independent statement, and making it 
dependent is not backwards compatible.

2. The proposal is unnecessary as the conditions can already be detected, and 
being explicit is much more flexible than the proposal.

for i001 in iterable: pass  # i001 is a new local name.

try:
i001

except NameError:


for i in range(5):
if i > 3:
break001 = True  # New local.
break

try:
break001
< loop broke>
except NameError:
< loop exited normally>

--
nosy: +terry.reedy

___
Python tracker 

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



[issue20840] AttributeError: 'module' object has no attribute 'ArgumentParser'

2020-07-18 Thread David Friedman


David Friedman  added the comment:

I know this is 6 years too late, but I had this problem a few minutes ago on 
Python2.7.  Googling didn't find me anything relevant except this bug entry.  
However, I found the cause myself: I had a test file named argparse.py (and an 
argparse.pyc) in the current directory (i.e. $PYTHONPATH) which was overriding 
the one in the main python library path. Once I renamed my argparse.py and 
argparse.pyc to something else, python found the real argparse and that message 
(the same one you saw) disappeared.

--
nosy: +David Friedman

___
Python tracker 

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



[issue41336] Random segfaults during zoneinfo object creation stopped using Ctrl-C

2020-07-18 Thread Karthikeyan Singaravelan


New submission from Karthikeyan Singaravelan :

I get segfaults on random basis in the below program I wrote for issue41321 
while trying to use Ctrl-C to stop the program. I used faulthandler but 
couldn't get to the exact case where it occurs. I tested it on Python 3.9 from 
deadsnakes ppa and it crashes. I tried using gdb to get a backtrace but using 
ctrl-C is caught by gdb. I tried using "handle SIGINT noprint pass" to ensure 
the ctrl-C is passed to the program by gdb and attached below is a backtrace 
during a sample segfault. I am wording it as during zoneinfo creation but 
isolated object creation under an infinite loop where ctrl-c is passed doesn't 
trigger this. Feel free to modify this as needed and also to add more since I 
am not good with debugging C issues.

import datetime
import zoneinfo

timezones = zoneinfo.available_timezones()
for year in range(1900, 2020):
for tz in timezones:
d1 = datetime.datetime(year, 5, 4, 7, 13, 22, 
tzinfo=zoneinfo.ZoneInfo(tz)).timestamp()
d2 = datetime.datetime(year, 5, 4, 0, 0, 0, 
tzinfo=zoneinfo.ZoneInfo(tz)).timestamp()
diff = d1 - d2
if diff != 26002:
print(year, diff, tz)

for tz in timezones:
d1 = datetime.datetime(year, 5, 2, 7, 13, 22, 
tzinfo=zoneinfo.ZoneInfo(tz)).timestamp()
d2 = datetime.datetime(year, 5, 2, 0, 0, 0, 
tzinfo=zoneinfo.ZoneInfo(tz)).timestamp()
diff = d1 - d2
if diff != 26002:
print("Diff using second day", year, diff, tz)

$ python3.9 -X faulthandler ../backups/bpo41321.py
^CFatal Python error: Segmentation fault

Current thread 0x7f23bb2b9740 (most recent call first):
  File "/root/cpython/../backups/bpo41321.py", line 7 in 
[1]1234 segmentation fault (core dumped)  python3.9 -X faulthandler 
../backups/bpo41321.py

Debug build on master branch

$  ./python -X faulthandler ../backups/bpo41321.py
^Cpython: Objects/typeobject.c:3244: _PyType_Lookup: Assertion 
`!PyErr_Occurred()' failed.
Fatal Python error: Aborted

Current thread 0x7f28c2256080 (most recent call first):
  File "/root/cpython/../backups/bpo41321.py", line 14 in 
[1]1386 abort (core dumped)  ./python -X faulthandler ../backups/bpo41321.py


(gdb) r
Starting program: /root/cpython/python ../backups/bpo41321.py
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
^C
Program received signal SIGSEGV, Segmentation fault.
zoneinfo_no_cache (cls=, args=, 
kwargs=) at /root/cpython/Modules/_zoneinfo.c:380
380 PyObject *out = zoneinfo_new_instance(cls, key);
(gdb) bt
#0  zoneinfo_no_cache (cls=, args=, 
kwargs=) at /root/cpython/Modules/_zoneinfo.c:380
#1  0x765ff826 in zoneinfo_new (
type=0x76801480 , args=, 
kw=) at /root/cpython/Modules/_zoneinfo.c:274
#2  0x5562a635 in type_call (
type=type@entry=0x76801480 , 
args=args@entry=0x76fb7520, kwds=kwds@entry=0x0)
at Objects/typeobject.c:1020
#3  0x555c3018 in _PyObject_MakeTpCall (
tstate=tstate@entry=0x55b2c350, 
callable=callable@entry=0x76801480 , 
args=args@entry=0x76f20df8, nargs=, keywords=0x0)
at Objects/call.c:191
#4  0x555ab48b in _PyObject_VectorcallTstate (kwnames=, 
nargsf=, args=, callable=, 
tstate=) at ./Include/cpython/abstract.h:112
#5  PyObject_Vectorcall (kwnames=, nargsf=, 
args=, callable=)
at ./Include/cpython/abstract.h:123
#6  call_function (tstate=tstate@entry=0x55b2c350, 
pp_stack=pp_stack@entry=0x7fffdf30, oparg=, 
kwnames=kwnames@entry=0x0) at Python/ceval.c:5121
#7  0x555b17dd in _PyEval_EvalFrameDefault (tstate=, 
f=, throwflag=) at Python/ceval.c:3516
#8  0x556864f5 in _PyEval_EvalFrame (throwflag=0, f=0x76f20c40, 
tstate=0x55b2c350) at ./Include/internal/pycore_ceval.h:40
#9  _PyEval_EvalCode (qualname=0x76e860f0, name=0x76e860f0, 
closure=0x0, 
kwdefs=0x0, defcount=0, defs=0x0, kwstep=2, kwcount=0, kwargs=0x0, 
kwnames=0x0, argcount=0, args=0x0, locals=0x0, globals=0x55b2c350, 
_co=0x76ee6d40, tstate=0x55b2c350) at Python/ceval.c:4376
#10 _PyEval_EvalCodeWithName (qualname=0x0, name=0x0, closure=0x0, kwdefs=0x0, 
defcount=0, defs=0x0, kwstep=2, kwcount=0, kwargs=0x0, kwnames=0x0, 
argcount=0, args=0x0, locals=locals@entry=0x0, 
globals=globals@entry=0x55b2c350, _co=0x76ee6d40, 
_co@entry=0x76f20da0) at Python/ceval.c:4408
#11 PyEval_EvalCodeEx (closure=0x0, kwdefs=0x0, defcount=0, defs=0x0, 
kwcount=0, 
kws=0x0, argcount=0, args=0x0, locals=locals@entry=0x0, 
globals=globals@entry=0x55b2c350, _co=0x76ee6d40, 
_co@entry=0x76f20da0) at Python/ceval.c:4424
---Type  to continue, or q  to quit---
#12 PyEval_EvalCode (co=co@entry=0x76ee6d40, 
globals=globals@entry=0x76f4e440, locals=locals@entry=0x76f4e440)
at Python/ceval.c:857
#13 

[issue41335] free(): invalid pointer in list_ass_item() in Python 3.7.3

2020-07-18 Thread Howard A. Landman


Change by Howard A. Landman :


--
hgrepos:  -389

___
Python tracker 

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



[issue41335] free(): invalid pointer in list_ass_item() in Python 3.7.3

2020-07-18 Thread Howard A. Landman


New submission from Howard A. Landman :

I have a program qtd.py that reliably dies with free(): invalid pointer after 
about 13 hours of runtime (on a RPi3B+). This is hard to debug because (1) 
try:except: will not catch SIGABRT
(2) signal.signal(signal.SIGABRT, sigabrt_handler) also fails to catch SIGABRT
(3) python3-dbg does not work with libraries like RPi.GPIO and spidev()
This happens under both Buster and Stretch, so I don't think it's OS-dependent.

I managed to get a core dump and gdb back trace gives:
warning: core file may not match specified executable file.
[New LWP 10277]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/arm-linux-gnueabihf/libthread_db.so.1".
Core was generated by `python3 qtd.py'.
Program terminated with signal SIGABRT, Aborted.
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
50  ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x76c5e308 in __GI_abort () at abort.c:100
#2  0x76cae51c in __libc_message (action=action@entry=do_abort, 
fmt=) at ../sysdeps/posix/libc_fatal.c:181
#3  0x76cb5044 in malloc_printerr (str=) at malloc.c:5341
#4  0x76cb6d50 in _int_free (av=0x76d917d4 , 
p=0x43417c , have_lock=)
at malloc.c:4165
#5  0x001b3bb4 in list_ass_item (a=, i=, 
v=, a=, i=, v=)
at ../Objects/listobject.c:739
Backtrace stopped: Cannot access memory at address 0x17abeff8

So, as far as I can tell, it looks like list_ass_item() is where the error 
happens. I'm willing to help debug and maybe even fix this, but is there any 
way to remove any of the roadblocks (1-3) above?

NOTE: qtd.py will exit unless there is a Texas Instruments TDC7201 chip 
attached to the RPI's SPI pins.

--
components: Interpreter Core
hgrepos: 389
messages: 373911
nosy: Howard_Landman
priority: normal
severity: normal
status: open
title: free(): invalid pointer in list_ass_item() in Python 3.7.3
type: crash
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



[issue41324] Add a minimal decimal capsule API

2020-07-18 Thread Stefan Krah


Stefan Krah  added the comment:

It looks like the API would be usable, so the PR now has documentation.

--

___
Python tracker 

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



[issue39093] tkinter objects garbage collected from non-tkinter thread cause crash

2020-07-18 Thread E. Paine


Change by E. Paine :


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

___
Python tracker 

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



[issue39093] tkinter objects garbage collected from non-tkinter thread cause crash

2020-07-18 Thread E. Paine


Change by E. Paine :


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

___
Python tracker 

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



[issue21625] Make help() beginner helpful when no PAGER or LESS variable

2020-07-18 Thread Nagarajan


Nagarajan  added the comment:

I would request us to think about a couple more options while this is under 
consideration...

Do we want to also add the flags -X and -F to the less options?

The -X flag gets less to show its output inline, instead of a separate screen. 
The advantage here is that users can now see the last viewed help page right 
above the prompt even after quitting help. It helps immensely to be able to see 
the help and write statements based on the help. The minor downside is that the 
last statements typed on the python prompt have now scrolled farther up.

The -F (or --quit-if-one-screen) flag exits helps automatically if the help 
contents fit less than one screen-full. This is only useful when used in 
conjunction with the -X flag. If we do decide to use the -X flag, then this 
flag becomes an obvious choice.

If we do choose to use these flags, the less command now becomes

less "-P?e(END) .(q to exit help) " -X --quit-if-one-screen --quit-at-eof

--
nosy: +nagarajan

___
Python tracker 

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



[issue39093] tkinter objects garbage collected from non-tkinter thread cause crash

2020-07-18 Thread E. Paine


Change by E. Paine :


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

___
Python tracker 

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



[issue39093] tkinter objects garbage collected from non-tkinter thread cause crash

2020-07-18 Thread E. Paine


E. Paine  added the comment:

It appears there are issues with this issue and so the PR for it is 
https://github.com/python/cpython/pull/21532

--

___
Python tracker 

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



[issue39093] tkinter objects garbage collected from non-tkinter thread cause crash

2020-07-18 Thread E. Paine


Change by E. Paine :


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

___
Python tracker 

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



[issue41314] PEP 563 and annotations __future__ mandatory version

2020-07-18 Thread Guido van Rossum


Guido van Rossum  added the comment:

The PEP now says 3.10, so the docs for __future__ should be fixed.

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

___
Python tracker 

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



[issue41334] Convert str(), bytes() and bytearray() to Argument Clinic

2020-07-18 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +xtreak

___
Python tracker 

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



[issue41334] Convert str(), bytes() and bytearray() to Argument Clinic

2020-07-18 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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

___
Python tracker 

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



[issue41334] Convert str(), bytes() and bytearray() to Argument Clinic

2020-07-18 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

Constructors str(), bytes() and bytearray() were not converted to Argument 
Clinic because it was not possible to generate correct signature for them. But 
now there is other reason of using Argument Clinic -- it generates more 
efficient code for parsing arguments.

The proposed PR converts str(), bytes() and bytearray() to Argument Clinic but 
generated docstrings are not used.

$ ./python -m pyperf timeit -q --compare-to=../cpython-release2/python "str()"
Mean +- std dev: [/home/serhiy/py/cpython-release2/python] 81.9 ns +- 4.5 ns -> 
[/home/serhiy/py/cpython-release/python] 60.0 ns +- 1.9 ns: 1.36x faster (-27%)
$ ./python -m pyperf timeit -q --compare-to=../cpython-release2/python 
"str('abcdefgh')"
Mean +- std dev: [/home/serhiy/py/cpython-release2/python] 121 ns +- 3 ns -> 
[/home/serhiy/py/cpython-release/python] 87.6 ns +- 2.8 ns: 1.38x faster (-28%)
$ ./python -m pyperf timeit -q --compare-to=../cpython-release2/python 
"str(12345)"
Mean +- std dev: [/home/serhiy/py/cpython-release2/python] 188 ns +- 8 ns -> 
[/home/serhiy/py/cpython-release/python] 149 ns +- 5 ns: 1.27x faster (-21%)
$ ./python -m pyperf timeit -q --compare-to=../cpython-release2/python 
"str(b'abcdefgh', 'ascii')"
Mean +- std dev: [/home/serhiy/py/cpython-release2/python] 210 ns +- 7 ns -> 
[/home/serhiy/py/cpython-release/python] 164 ns +- 6 ns: 1.28x faster (-22%)
$ ./python -m pyperf timeit -q --compare-to=../cpython-release2/python 
"str(b'abcdefgh', 'ascii', 'strict')"
Mean +- std dev: [/home/serhiy/py/cpython-release2/python] 222 ns +- 9 ns -> 
[/home/serhiy/py/cpython-release/python] 170 ns +- 6 ns: 1.30x faster (-23%)
$ ./python -m pyperf timeit -q --compare-to=../cpython-release2/python 
"str(b'abcdefgh', encoding='ascii', errors='strict')"
Mean +- std dev: [/home/serhiy/py/cpython-release2/python] 488 ns +- 20 ns -> 
[/home/serhiy/py/cpython-release/python] 306 ns +- 5 ns: 1.59x faster (-37%)

$ ./python -m pyperf timeit -q --compare-to=../cpython-release2/python "bytes()"
Mean +- std dev: [/home/serhiy/py/cpython-release2/python] 85.1 ns +- 2.2 ns -> 
[/home/serhiy/py/cpython-release/python] 60.2 ns +- 2.3 ns: 1.41x faster (-29%)
$ ./python -m pyperf timeit -q --compare-to=../cpython-release2/python 
"bytes(8)"
Mean +- std dev: [/home/serhiy/py/cpython-release2/python] 160 ns +- 5 ns -> 
[/home/serhiy/py/cpython-release/python] 115 ns +- 4 ns: 1.39x faster (-28%)
$ ./python -m pyperf timeit -q --compare-to=../cpython-release2/python 
"bytes(b'abcdefgh')"
Mean +- std dev: [/home/serhiy/py/cpython-release2/python] 131 ns +- 6 ns -> 
[/home/serhiy/py/cpython-release/python] 91.0 ns +- 2.8 ns: 1.43x faster (-30%)
$ ./python -m pyperf timeit -q --compare-to=../cpython-release2/python 
"bytes('abcdefgh', 'ascii')"
Mean +- std dev: [/home/serhiy/py/cpython-release2/python] 190 ns +- 6 ns -> 
[/home/serhiy/py/cpython-release/python] 144 ns +- 5 ns: 1.32x faster (-24%)
$ ./python -m pyperf timeit -q --compare-to=../cpython-release2/python 
"bytes('abcdefgh', 'ascii', 'strict')"
Mean +- std dev: [/home/serhiy/py/cpython-release2/python] 214 ns +- 5 ns -> 
[/home/serhiy/py/cpython-release/python] 156 ns +- 4 ns: 1.37x faster (-27%)
$ ./python -m pyperf timeit -q --compare-to=../cpython-release2/python 
"bytes('abcdefgh', encoding='ascii', errors='strict')"
Mean +- std dev: [/home/serhiy/py/cpython-release2/python] 442 ns +- 9 ns -> 
[/home/serhiy/py/cpython-release/python] 269 ns +- 8 ns: 1.64x faster (-39%)

$ ./python -m pyperf timeit -q --compare-to=../cpython-release2/python 
"bytearray()"
Mean +- std dev: [/home/serhiy/py/cpython-release2/python] 93.5 ns +- 2.1 ns -> 
[/home/serhiy/py/cpython-release/python] 73.1 ns +- 1.8 ns: 1.28x faster (-22%)
$ ./python -m pyperf timeit -q --compare-to=../cpython-release2/python 
"bytearray(8)"
Mean +- std dev: [/home/serhiy/py/cpython-release2/python] 154 ns +- 3 ns -> 
[/home/serhiy/py/cpython-release/python] 117 ns +- 3 ns: 1.32x faster (-24%)
$ ./python -m pyperf timeit -q --compare-to=../cpython-release2/python 
"bytearray(b'abcdefgh')"
Mean +- std dev: [/home/serhiy/py/cpython-release2/python] 164 ns +- 5 ns -> 
[/home/serhiy/py/cpython-release/python] 131 ns +- 2 ns: 1.25x faster (-20%)
$ ./python -m pyperf timeit -q --compare-to=../cpython-release2/python 
"bytearray('abcdefgh', 'ascii')"
Mean +- std dev: [/home/serhiy/py/cpython-release2/python] 239 ns +- 7 ns -> 
[/home/serhiy/py/cpython-release/python] 193 ns +- 4 ns: 1.24x faster (-19%)
$ ./python -m pyperf timeit -q --compare-to=../cpython-release2/python 
"bytearray('abcdefgh', 'ascii', 'strict')"
Mean +- std dev: [/home/serhiy/py/cpython-release2/python] 260 ns +- 5 ns -> 
[/home/serhiy/py/cpython-release/python] 207 ns +- 10 ns: 1.26x faster (-21%)
$ ./python -m pyperf timeit -q --compare-to=../cpython-release2/python 
"bytearray('abcdefgh', encoding='ascii', errors='strict')"
Mean +- std dev: [/home/serhiy/py/cpython-release2/python] 505 ns +- 11 ns -> 

[issue41333] Convert OrderedDict.pop() to Argument Clinic

2020-07-18 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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

___
Python tracker 

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



[issue41332] connect_accepted_socket() missing from AbstractEventLoop

2020-07-18 Thread Alex Grönholm

Change by Alex Grönholm :


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

___
Python tracker 

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



[issue41333] Convert OrderedDict.pop() to Argument Clinic

2020-07-18 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

The proposed PR converts OrderedDict.pop() to Argument Clinic. It makes it 2 
times faster.

$ ./python -m pyperf timeit -q --compare-to=../cpython-release2/python -s "from 
collections import OrderedDict; od = OrderedDict()" "od.pop('x', None)"
Mean +- std dev: [/home/serhiy/py/cpython-release2/python] 119 ns +- 2 ns -> 
[/home/serhiy/py/cpython-release/python] 56.3 ns +- 1.2 ns: 2.12x faster (-53%)

It was not converted before because Argument Clinic generated incorrect 
signature for it. It still is not able to generate correct signature, but at 
least it does not generate incorrect signature. And we now have other reason 
for using Argument Clinic -- performance.

--
components: Argument Clinic, Extension Modules
messages: 373905
nosy: larry, rhettinger, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Convert OrderedDict.pop() to Argument Clinic
type: performance
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



[issue41332] connect_accepted_socket() missing from AbstractEventLoop

2020-07-18 Thread Alex Grönholm

New submission from Alex Grönholm :

The connect_accepted_socket() method seems to be missing from the 
AbstractEventLoop ABC. I assume this was a simple mistake of omission. I will 
ready a PR to add it.

--
components: asyncio
messages: 373904
nosy: alex.gronholm, asvetlov, yselivanov
priority: normal
severity: normal
status: open
title: connect_accepted_socket() missing from AbstractEventLoop
type: behavior
versions: Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 3.9

___
Python tracker 

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



[issue39093] tkinter objects garbage collected from non-tkinter thread cause crash

2020-07-18 Thread E. Paine


Change by E. Paine :


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

___
Python tracker 

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



[issue39093] tkinter objects garbage collected from non-tkinter thread cause crash

2020-07-18 Thread E. Paine


Change by E. Paine :


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

___
Python tracker 

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



[issue39093] tkinter objects garbage collected from non-tkinter thread cause crash

2020-07-18 Thread E. Paine


Change by E. Paine :


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

___
Python tracker 

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



[issue41325] Document addition of `mock.call_args.args` and `mock.call_args.kwargs` in 3.8

2020-07-18 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

Thanks Jordan for the report and patch.

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



[issue41325] Document addition of `mock.call_args.args` and `mock.call_args.kwargs` in 3.8

2020-07-18 Thread miss-islington


miss-islington  added the comment:


New changeset f92544483fc724b7e9ac11b2ee86b38e069cc70f by Miss Islington (bot) 
in branch '3.9':
bpo-41325: Add version note for args and kwargs property in call object 
(GH-21525)
https://github.com/python/cpython/commit/f92544483fc724b7e9ac11b2ee86b38e069cc70f


--

___
Python tracker 

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



[issue41325] Document addition of `mock.call_args.args` and `mock.call_args.kwargs` in 3.8

2020-07-18 Thread miss-islington


miss-islington  added the comment:


New changeset 7734738d71c052779d3cb189e5ba0759beb8d620 by Miss Islington (bot) 
in branch '3.8':
bpo-41325: Add version note for args and kwargs property in call object 
(GH-21525)
https://github.com/python/cpython/commit/7734738d71c052779d3cb189e5ba0759beb8d620


--

___
Python tracker 

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



[issue40820] Mock Call attributes args and kwargs have no changeversion

2020-07-18 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

Thanks for the report. Closing this in favor of 
https://bugs.python.org/issue41325

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
superseder:  -> Document addition of `mock.call_args.args` and 
`mock.call_args.kwargs` in 3.8

___
Python tracker 

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



[issue41325] Document addition of `mock.call_args.args` and `mock.call_args.kwargs` in 3.8

2020-07-18 Thread miss-islington


Change by miss-islington :


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

___
Python tracker 

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



[issue41325] Document addition of `mock.call_args.args` and `mock.call_args.kwargs` in 3.8

2020-07-18 Thread miss-islington


Change by miss-islington :


--
pull_requests: +20667
pull_request: https://github.com/python/cpython/pull/21531

___
Python tracker 

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



[issue41325] Document addition of `mock.call_args.args` and `mock.call_args.kwargs` in 3.8

2020-07-18 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:


New changeset 9b01c598ca2576a1056816e85dd84bf5f9c74688 by Jordan Speicher in 
branch 'master':
bpo-41325: Add version note for args and kwargs property in call object 
(GH-21525)
https://github.com/python/cpython/commit/9b01c598ca2576a1056816e85dd84bf5f9c74688


--

___
Python tracker 

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



[issue41325] Document addition of `mock.call_args.args` and `mock.call_args.kwargs` in 3.8

2020-07-18 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

This is a duplicate of https://bugs.python.org/issue40820 . But this PR has cla 
signed so I am inclined towards merging this instead.

--
nosy: +xtreak

___
Python tracker 

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



[issue41295] CPython 3.8.4 regression on __setattr__ in multiinheritance with metaclasses

2020-07-18 Thread Stefan Behnel


Stefan Behnel  added the comment:

PR 21528 works for all four test cases that we now have (1x test_capi.py, 3x 
test_descr.py).

Any comments? We need to merge a fix before Monday to meet the deadline of the 
planned hotfix release.

@kam193, could you please also test that change with your real code?

--

___
Python tracker 

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



[issue38805] locale.getlocale() returns a non RFC1766 language code

2020-07-18 Thread Riccardo Polignieri

Riccardo Polignieri  added the comment:

> `locale.getlocale()` is now returning strange results

Not really "strange results" - fact is, now "getlocale()" returns the locale 
name *as if* it were already set from the beginnning (because it is, at least 
in part). 

Before: 

>>> import locale  # Python 3.7, new shell
>>> locale.getlocale()
(None, None)
>>> locale.setlocale(locale.LC_ALL, '') # say Hi from Italy
'Italian_Italy.1252'
>>> locale.getlocale()
('Italian_Italy', '1252')

now: 

>>> import locale  # Python 3.8, new shell
>>> locale.getlocale()
('Italian_Italy', '1252')

As for why returned locale names are "a little different" in Windows, I found 
no better explanation that Eryk Sun's essays in 
https://bugs.python.org/issue37945. Long story short, it's not even a bug 
anymore... it's a hot mess and it won't be solved anytime soon. 
But it's not the problem at hand, here. Returned locale names have not changed 
between 3.7 and 3.8. 



What *is* changed, though, is that now Python on Windows appears to set the 
locale, implicitly, right from the start. 
Except - maybe it does not, really: 

>>> import locale  # Python 3.8, new shell
>>> locale.getlocale()
('Italian_Italy', '1252')
>>> locale.localeconv()
{'int_curr_symbol': '', 'currency_symbol': '', 'mon_decimal_point': '', 
'mon_thousands_sep': '', 'mon_grouping': [], 'positive_sign': '', 
'negative_sign': '', 'int_frac_digits': 127, 'frac_digits': 127, 
'p_cs_precedes': 127, 'p_sep_by_space': 127, 'n_cs_precedes': 127, 
'n_sep_by_space': 127, 'p_sign_posn': 127, 'n_sign_posn': 127, 'decimal_point': 
'.', 'thousands_sep': '', 'grouping': []}

As you can see, we have an Italian locale only in the name: the conventions are 
still those of the default C locale. 
If we explicitly set the locale, on the other hand... 

>>> locale.setlocale(locale.LC_ALL, '')
'Italian_Italy.1252'
>>> locale.localeconv()
{'int_curr_symbol': 'EUR', 'currency_symbol': '€', ... ... }

... now we enjoy a real Italian locale - pizza, pasta, gelato and all. 



What happened? 
Unfortunately, this change of behaviour is NOT documented, except for a passing 
note here: https://docs.python.org/3/whatsnew/changelog.html#id144. It's buried 
*very* deep: 
"""
bpo-34485: On Windows, the LC_CTYPE is now set to the user preferred locale at 
startup. Previously, the LC_CTYPE locale was “C” at startup, but changed when 
calling setlocale(LC_CTYPE, “”) or setlocale(LC_ALL, “”).
"""
This explains... something. Python now pre-sets *only* the LC_CTYPE category, 
and that's why the other conventions remain unchanged. 
Unfortunately, setting *that* one category changes the result yielded by 
locale.getlocale(). But this is not a bug either, because it's the same 
behaviour you would have in Python 3.7: 

>>> locale.setlocale(locale.LC_CTYPE, '')  # Python 3.7
'Italian_Italy.1252'
>>> locale.getlocale()
('Italian_Italy', '1252')

...and that's because locale.getlocale() with no arguments default, wait for 
it, to getlocale(category=LC_CTYPE), as documented!



So, why Python 3.8 now pre-sets LC_CTYPE on Windows? Apparently, bpo-34485 is 
part of the ongoing shakespearian feud between Victor Stinner and the Python 
locale code. If you squint hard enough, you will see the answer here: 
https://vstinner.github.io/locale-bugfixes-python3.html but at this point, I 
don't know if anyone still keeps the score. 


To sum up: 
- there's nothing new about locale names - still the same mess; 
- if locale names as returned by locale.getlocale() bother you, you should 
follow Victor's advice here: https://bugs.python.org/issue37945#msg361806. Use 
locale.setlocale(category, None) instead; 
- if you relied on getlocale() with no arguments to test your locale, assuming 
that either a locale is unset or it is "fully set", then you should stop now. A 
locale can also be "partially set", and in fact it's just what happens now on 
Windows by default. You should test for a specific category instead; 
- changing the way the locale is set by default on Windows can be... rather 
surprising and can lead to misunderstandings. I would certainly add a note in 
the locale documentation to explain this new behaviour.

--
nosy: +ricpol

___
Python tracker 

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



[issue41262] Convert memoryview to Argument Clinic

2020-07-18 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

I do not have other benchmarks. memoryview was just one of few builtins which 
still use PyArg_ParseTupleAndKeywords() and I know how inefficient it is. Since 
Argument Clinic was already used for memoryview.hex() I did not see problems 
with converting the rest of memoryview methods to Argument Clinic.

Microbenchmarks:

$ ./python -m pyperf timeit -q --compare-to=../cpython-release/python -s "b = 
b'abcdefgh'" "memoryview(b)"
Mean +- std dev: [/home/serhiy/py/cpython-release/python] 187 ns +- 6 ns -> 
[/home/serhiy/py/cpython-release2/python] 144 ns +- 4 ns: 1.30x faster (-23%)

$ ./python -m pyperf timeit -q --compare-to=../cpython-release/python -s "b = 
b'abcdefgh'" "memoryview(object=b)"
Mean +- std dev: [/home/serhiy/py/cpython-release/python] 312 ns +- 7 ns -> 
[/home/serhiy/py/cpython-release2/python] 210 ns +- 6 ns: 1.49x faster (-33%)

$ ./python -m pyperf timeit -q --compare-to=../cpython-release/python -s "m = 
memoryview(b'abcdefgh')" "m.cast('I')"
Mean +- std dev: [/home/serhiy/py/cpython-release/python] 167 ns +- 4 ns -> 
[/home/serhiy/py/cpython-release2/python] 104 ns +- 2 ns: 1.60x faster (-38%)

$ ./python -m pyperf timeit -q --compare-to=../cpython-release/python -s "m = 
memoryview(b'abcdefgh')" "m.cast(format='I')"
Mean +- std dev: [/home/serhiy/py/cpython-release/python] 331 ns +- 6 ns -> 
[/home/serhiy/py/cpython-release2/python] 153 ns +- 7 ns: 2.16x faster (-54%)

$ ./python -m pyperf timeit -q --compare-to=../cpython-release/python -s "m = 
memoryview(b'abcdefgh')" "m.cast('B', (2, 2, 2))"
Mean +- std dev: [/home/serhiy/py/cpython-release/python] 229 ns +- 5 ns -> 
[/home/serhiy/py/cpython-release2/python] 154 ns +- 4 ns: 1.48x faster (-32%)

$ ./python -m pyperf timeit -q --compare-to=../cpython-release/python -s "m = 
memoryview(b'abcdefgh')" "m.cast(format='B', shape=(2, 2, 2))"
Mean +- std dev: [/home/serhiy/py/cpython-release/python] 494 ns +- 11 ns -> 
[/home/serhiy/py/cpython-release2/python] 198 ns +- 5 ns: 2.49x faster (-60%)

$ ./python -m pyperf timeit -q --compare-to=../cpython-release/python -s "m = 
memoryview(b'abcdefgh')" "m.tobytes()"
Mean +- std dev: [/home/serhiy/py/cpython-release/python] 90.3 ns +- 3.2 ns -> 
[/home/serhiy/py/cpython-release2/python] 65.8 ns +- 1.9 ns: 1.37x faster (-27%)

$ ./python -m pyperf timeit -q --compare-to=../cpython-release/python -s "m = 
memoryview(b'abcdefgh')" "m.tobytes('C')"
Mean +- std dev: [/home/serhiy/py/cpython-release/python] 183 ns +- 6 ns -> 
[/home/serhiy/py/cpython-release2/python] 129 ns +- 4 ns: 1.41x faster (-29%)

$ ./python -m pyperf timeit -q --compare-to=../cpython-release/python -s "m = 
memoryview(b'abcdefgh')" "m.tobytes(order='C')"
Mean +- std dev: [/home/serhiy/py/cpython-release/python] 340 ns +- 11 ns -> 
[/home/serhiy/py/cpython-release2/python] 174 ns +- 5 ns: 1.96x faster (-49%)

--

___
Python tracker 

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



[issue41311] Add a function to get a random sample from an iterable (reservoir sampling)

2020-07-18 Thread Oscar Benjamin


Oscar Benjamin  added the comment:

> Please don't get personal.

Sorry, that didn't come across with the intended tone :)

I agree that this could be out of scope for the random module but I wanted to 
make sure the reasons were considered.

Reading between the lines I get the impression that you'd both be happier with 
it if the algorithm was exact (rather than using fp). That would at least give 
the possibility for it to be used internally by e.g. sample/choice if there was 
a benefit for some cases.

--

___
Python tracker 

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



[issue41326] Build failure in blurb-it repo: "Failed building wheel for yarl"

2020-07-18 Thread Ned Deily


Ned Deily  added the comment:

blurb-it imports aiohttp which imports yarl. It might be a duplicate of 
https://github.com/aio-libs/yarl/issues/459

--
nosy: +asvetlov, ned.deily

___
Python tracker 

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



[issue41262] Convert memoryview to Argument Clinic

2020-07-18 Thread Stefan Krah


Stefan Krah  added the comment:

I cannot detect a speedup in test_buffer, which is a heavy user of memoryviews:

# before:
>>> a = [3.742, 3.589, 3.542, 3.495, 3.481, 3.620, 3.773, 3.755, 3.701, 3.661]
>>> sum(a) / 10
3.63589995

# after
>>> b = [3.63, 3.596, 3.475, 3.43, 3.792, 3.58, 3.810, 3.52, 3.55, 3.690]
>>> sum(b) / 10
3.60729995



A microbenchmark shows a speedup:

# before:
$ ./python -m timeit -s "b = b'1234567890'" "memoryview(b)"
200 loops, best of 5: 116 nsec per loop

# after:

./python -m timeit -s "b = b'1234567890'" "memoryview(b)"
500 loops, best of 5: 98 nsec per loop



As the original author, I'm not sure why I should put up with the
less readable code for such a gain.  For decimal I'm using the pi
benchmark, which, while small, is at least a real math function in
pure Python. 

Do you have other benchmarks?

--
status: closed -> open

___
Python tracker 

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



[issue41304] [CVE-2020-15801] python 38 embed ignore python38._pth file on windows

2020-07-18 Thread Ned Deily


Ned Deily  added the comment:


New changeset eb0d255ffe002412bb937e1bde61225e5431da5e by Miss Islington (bot) 
in branch '3.7':
bpo-41304: Update NEWS to include CVE-2020-15801 reference (GH-21521) (GH-21524)
https://github.com/python/cpython/commit/eb0d255ffe002412bb937e1bde61225e5431da5e


--

___
Python tracker 

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



[issue41330] Inefficient error-handle for CJK encodings

2020-07-18 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

In the Web application you need first to generate data (this may involve some 
network requests, IO operations, and some data transformations), then format 
the page, then encode it, and finally send it to client. I suppose that the 
encoding part is minor in comparison with others.

Also, as Inada-san noted, UTF-8 is more popular encoding in modern 
applications. It is also fast, so you may prefer UTF-8 if the performance of 
encoding is important to you.

--

___
Python tracker 

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



[issue41330] Inefficient error-handle for CJK encodings

2020-07-18 Thread Ma Lin


Ma Lin  added the comment:

> But how many new Python web application use CJK codec instead of UTF-8?

A CJK character usually takes 2-bytes in CJK encodings, but takes 3-bytes in 
UTF-8.

I tested a Chinese book:
in GBK: 853,025 bytes
in UTF-8: 1,267,523 bytes

For CJK content, UTF-8 is wasteful, maybe CJK encodings will not be eliminated.

--

___
Python tracker 

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



[issue41331] Sphinx can't find asdl.py when not started from the Doc/ directory

2020-07-18 Thread Julien Palard


Change by Julien Palard :


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

___
Python tracker 

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



[issue41331] Sphinx can't find asdl.py when not started from the Doc/ directory

2020-07-18 Thread Julien Palard


New submission from Julien Palard :

When running the following command from the Doc/ directory:

./venv/bin/sphinx-build -Q -b gettext -D gettext_compact=0 . ../pot/

everything goes right, but when running the following from cpython direcory:

./Doc/venv/bin/sphinx-build -Q -b gettext -D gettext_compact=0 Doc pot

we get:

Extension error:
Could not import extension asdl_highlight (exception: No module named 
'asdl')

This is because sys.path.append(os.path.abspath("../Parser/")) starts from the 
current directory, cpython/../Parser don't exists while Doc/../Parser exists.

It could be fixed by starting with a Path(__file__).resolve(), will PR it.

--
assignee: mdk
components: Documentation
messages: 373888
nosy: BTaskaya, mdk
priority: normal
severity: normal
status: open
title: Sphinx can't find asdl.py when not started from the Doc/ directory
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



[issue41262] Convert memoryview to Argument Clinic

2020-07-18 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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



[issue41262] Convert memoryview to Argument Clinic

2020-07-18 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 80a50368c0e4dc9d56af0ce748dea35c9d96d23f by Serhiy Storchaka in 
branch 'master':
bpo-41262: Convert memoryview to Argument Clinic. (GH-21421)
https://github.com/python/cpython/commit/80a50368c0e4dc9d56af0ce748dea35c9d96d23f


--

___
Python tracker 

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



[issue41288] Pickle crashes unpickling invalid NEWOBJ_EX opcode

2020-07-18 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset b4c98ed41e6c959e95b2a6f65c1b728e94039dfd by Serhiy Storchaka in 
branch 'master':
bpo-41288: Refactor of unpickling NEWOBJ and NEWOBJ_EX opcodes. (GH-21472)
https://github.com/python/cpython/commit/b4c98ed41e6c959e95b2a6f65c1b728e94039dfd


--

___
Python tracker 

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



[issue41330] Inefficient error-handle for CJK encodings

2020-07-18 Thread Inada Naoki


Inada Naoki  added the comment:

But how many new Python web application use CJK codec instead of UTF-8?

--
nosy: +inada.naoki

___
Python tracker 

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



[issue41271] Add support for io_uring to cpython

2020-07-18 Thread Ronald Oussoren


Ronald Oussoren  added the comment:

I'm closing this as "later" as the consensus is that this might be a useful 
binding to have, but io_uring is evolving too fast at the moment. 

It is better to develop these bindings on PyPI, which also makes it easier to 
iterate on the design.

--
resolution:  -> later
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



[issue41315] Add mathematical functions as wrappers to decimal.Decimal methods

2020-07-18 Thread Jean Abou Samra


Jean Abou Samra  added the comment:

Okay, understood, thanks for your detailed explanations.

--

___
Python tracker 

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



[issue39960] Using typename.__setattr__ in extension type with Py_TPFLAGS_HEAPTYPE is broken (hackcheck too eager?)

2020-07-18 Thread Stefan Behnel


Stefan Behnel  added the comment:

I pushed PR 21528 with a new proposal. See issue 41295.

--

___
Python tracker 

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



[issue41295] CPython 3.8.4 regression on __setattr__ in multiinheritance with metaclasses

2020-07-18 Thread Stefan Behnel


Change by Stefan Behnel :


--
pull_requests: +20664
pull_request: https://github.com/python/cpython/pull/21528

___
Python tracker 

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



[issue41330] Inefficient error-handle for CJK encodings

2020-07-18 Thread Ma Lin


Ma Lin  added the comment:

IMO "xmlcharrefreplace" is useful for Web application.

For example, the page's charset is "gbk", then this statement can generate the 
bytes content easily & safely:

s.encode('gbk', 'xmlcharrefreplace')

Maybe some HTML-related frameworks use this way to escape characters, such as 
Sphinx [1].


Attached file `error_handers_fast_paths.txt` summarized all current 
error-handler fast-paths.

[1] Sphinx use 'xmlcharrefreplace' to escape
https://github.com/sphinx-doc/sphinx/blob/e65021fb9b0286f373f01dc19a5777e5eed49576/sphinx/builders/html/__init__.py#L1029

--
Added file: https://bugs.python.org/file49324/error_handers_fast_paths.txt

___
Python tracker 

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



[issue41297] Remove doctest import from heapq

2020-07-18 Thread Ronald Oussoren


Ronald Oussoren  added the comment:

modulegraph already knows where the import is done, and users of the library 
can use that information to make decisions. 

There's no need to make changes to either heapq.py or modulegraph.

For py2app I've made the choice to no be smart about inclusions and just try to 
include everything that may be imported because disk space is cheap these days. 
 I just exclude optional dependencies (in py2app, not modulegraph) when I've 
manually checked that it is safe to do so and the dependency is large.

--

___
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

2020-07-18 Thread Va


Va  added the comment:

1.0.0-rc.1 is out by now: 
https://github.com/toml-lang/toml/blob/master/CHANGELOG.md

--
nosy: +VA
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



[issue41330] Inefficient error-handle for CJK encodings

2020-07-18 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

I am not even sure it was worth to add fast path for "xmlcharrefreplace". 
"surrogateescape" and "surrogatepass" are most likely used in performance 
critical cases. It is also easy to add support of "ignore" and "replace". 
"strict" raises an exception in any case, and "backslashreplace", 
"xmlcharrefreplace" and "namereplace" are too complex and used in cases when 
coding time is not dominant (error reporting, debugging, formatting complex 
documents).

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue39960] Using typename.__setattr__ in extension type with Py_TPFLAGS_HEAPTYPE is broken (hackcheck too eager?)

2020-07-18 Thread Stefan Behnel


Stefan Behnel  added the comment:

> intermediate base type "object" in the hierarchy

Sorry, I meant an intermediate base type "B", which inherits its setattr from 
"object".

--

___
Python tracker 

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



[issue41322] unittest: deprecate test methods returning non-None values

2020-07-18 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

It is also a good idea for linters to catch such kind of errors. It will help 
users of older Python versions.

We cannot raise error without deprecation period or add warnings in old 
versions because it potentially can break existing code, e.g.:

def test_ham(self, arg='ham'):
...

def test_spam(self):
res = test_ham('spam')
self.assertTrue(res)

--

___
Python tracker 

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



[issue39960] Using typename.__setattr__ in extension type with Py_TPFLAGS_HEAPTYPE is broken (hackcheck too eager?)

2020-07-18 Thread Stefan Behnel


Stefan Behnel  added the comment:

The problem in the test added in PR 21473 is that there is an intermediate base 
type "object" in the hierarchy:

class A(type):
def __setattr__(cls, key, value):
type.__setattr__(cls, key, value)

class B:
pass

class C(B, A):
pass

>>> [c for c in C.__mro__]
[, , , , ]

>>> [c.__setattr__ for c in C.__mro__]
[, , , , ]

I think the change to the algorithm there is too broad, it disables much of 
what the check was written for (or against).

Given Guido's second (negative) test case, I think it would also not be correct 
to add "object.__setattr__" to the list of allowed (intermediate) slot methods:

class A(type):
def __setattr__(cls, key, value):
object.__setattr__(cls, key, value)   # this should fail!

class B:
pass

class C(B, A):
pass

It's difficult to turn this into an algorithm. Is the MRO really the place to 
look? For "A", we're only really interested in the C-level bases, aren't we?

--

___
Python tracker 

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



[issue41322] unittest: deprecate test methods returning non-None values

2020-07-18 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

The current behavior is not a bug as it follows documented behavior.  In the 
absence of any use for returning values from test functions, I agree that we 
should do the simple thing and raise ValueError (I checked and did not find 
anything like a UnittestError.) That would add minimal time to testing.

--
nosy: +terry.reedy
title: unittest: Generator test methods will always be marked as passed -> 
unittest: deprecate test methods returning non-None values
type: behavior -> enhancement
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



[issue41315] Add mathematical functions as wrappers to decimal.Decimal methods

2020-07-18 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

Jean, I sympathize a bit with your wish, but decimal was designed for business, 
 not science.  Sqrt, exp, and 3 versions of log are the only math methods, and 
they happen to be the ones with some use in business calculations and 
statistics.  Extended math-science use needs a module that would wrap these 
methos and either include math module functions or decimal implementations 
thereof.  This might be candidate for pypi as well as someone's private 
collection.

--
nosy: +terry.reedy
resolution:  -> rejected
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