[issue45181] Rewrite loading sqlite3 tests

2021-09-13 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

The proposed PR rewrites the loading of sqlite3 tests. Instead of explicitly 
enumerating test modules and test classes in every module, and manually 
creating test suites, it uses unittest discover ability. Every new test files 
and test classes will be automatically added to tests.

As a side effect, unittest filtering by pattern works now.

$ ./python -m test.test_sqlite -vk long
test_sqlite: testing with version '2.6.0', sqlite_version '3.31.1'
test_func_return_long_long (sqlite3.test.test_userfunctions.FunctionTests) ... 
ok
test_param_long_long (sqlite3.test.test_userfunctions.FunctionTests) ... ok

--
Ran 2 tests in 0.001s

OK

--
components: Tests
messages: 401687
nosy: erlendaasland, ghaering, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Rewrite loading sqlite3 tests
type: enhancement
versions: Python 3.11

___
Python tracker 

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



[issue45181] Rewrite loading sqlite3 tests

2021-09-13 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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

___
Python tracker 

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



[issue45177] Use shared test loader when possible when running test suite

2021-09-13 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

See issue45181. Most of this code is gone.

Also, TestLoader has mutable attribute "errors". I am not sure that it is good 
idea to share it between unrelated tests.

--

___
Python tracker 

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



[issue45177] Use shared test loader when possible when running test suite

2021-09-13 Thread Erlend E. Aasland


Erlend E. Aasland  added the comment:

> Also, TestLoader has mutable attribute "errors". I am not sure that it is 
> good idea to share it between unrelated tests.

Noted. I'm closing this.

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



[issue45182] Incorrect use of requires_zlib in test_bdist_rpm

2021-09-13 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

requires_zlib is a decorator factory which returns a decorator, not a 
decorator. It should always be followed by parenthesis. In 
Lib/distutils/tests/test_bdist_rpm.py it is used improperly, so the 
corresponding tests were never ran.

--
components: Tests
messages: 401690
nosy: dstufft, eric.araujo, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Incorrect use of requires_zlib in test_bdist_rpm
type: behavior
versions: Python 3.10, Python 3.11, Python 3.9

___
Python tracker 

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



[issue45182] Incorrect use of requires_zlib in test_bdist_rpm

2021-09-13 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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

___
Python tracker 

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



[issue5846] Deprecate obsolete functions in unittest

2021-09-13 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 851811f5772c43f72f445e2ce1ac3ea9da951ae3 by Serhiy Storchaka in 
branch 'main':
bpo-5846: Do not use obsolete unittest functions. (GH-28303)
https://github.com/python/cpython/commit/851811f5772c43f72f445e2ce1ac3ea9da951ae3


--

___
Python tracker 

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



[issue45167] deepcopy of GenericAlias with __deepcopy__ method is broken

2021-09-13 Thread Yurii Karabas


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


--
keywords: +patch
nosy: +uriyyo
nosy_count: 1.0 -> 2.0
pull_requests: +26720
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/28306

___
Python tracker 

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



[issue45167] deepcopy of GenericAlias with __deepcopy__ method is broken

2021-09-13 Thread Yurii Karabas


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


--
versions: +Python 3.10, Python 3.11

___
Python tracker 

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



[issue45167] deepcopy of GenericAlias with __deepcopy__ method is broken

2021-09-13 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

I think it is better to narrow the __getattr__. It can break protocols using 
other special methods.

--
nosy: +gvanrossum, serhiy.storchaka

___
Python tracker 

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



[issue45155] Add default arguments for int.to_bytes()

2021-09-13 Thread Petr Viktorin

Petr Viktorin  added the comment:

> I’m not convinced.  I’m more concerned with the obscurity of the API.  If I 
> saw its use in some code I was reviewing, I’d look it up, and then I’d know 
> exactly what it was doing.

I know you would. But there are many others who just try things until they work.

Also, if this does become *the* way to create bytes, it won't be obscure any 
more -- but you'd still need to remember to always specify byteorder for length 
> 1. That is, unless you *want* platform-specific behavior, which I don't think 
is all that often. Even in this case, you want to think about the issue, and 
omitting the argument is a bad way to encode that you thought about it.


---

Hm, what happened to the idea of only requiring byteorder for `length > 1`? I 
recall it being discussed

--

___
Python tracker 

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



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

2021-09-13 Thread Erlend E. Aasland


Change by Erlend E. Aasland :


--
nosy: +erlendaasland

___
Python tracker 

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



[issue45116] Performance regression 3.10b1 and later on Windows: Py_DECREF() not inlined in PGO build

2021-09-13 Thread STINNER Victor


Change by STINNER Victor :


--
title: Performance regression 3.10b1 and later on Windows -> Performance 
regression 3.10b1 and later on Windows: Py_DECREF() not inlined in PGO build

___
Python tracker 

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



[issue45156] mock.seal has infinite recursion with int class attributes

2021-09-13 Thread Nikita Sobolev


Nikita Sobolev  added the comment:

I've proposed a solution, based on the assumption that we don't need to recurse 
into `_SpecState` props:

```
if isinstance(m._mock_children.get(attr), _SpecState):
   continue
```

It seems like a simple and reasonable thing to do.
Link: https://github.com/python/cpython/pull/28300

--

___
Python tracker 

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



[issue45182] Incorrect use of requires_zlib in test_bdist_rpm

2021-09-13 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 9260e6739865c966c3ec6c5c289e0b96f848403e by Serhiy Storchaka in 
branch 'main':
bpo-45182: Fix incorrect use of requires_zlib in test_bdist_rpm (GH-28305)
https://github.com/python/cpython/commit/9260e6739865c966c3ec6c5c289e0b96f848403e


--

___
Python tracker 

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



[issue45182] Incorrect use of requires_zlib in test_bdist_rpm

2021-09-13 Thread miss-islington


Change by miss-islington :


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

___
Python tracker 

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



[issue45182] Incorrect use of requires_zlib in test_bdist_rpm

2021-09-13 Thread miss-islington


Change by miss-islington :


--
pull_requests: +26722
pull_request: https://github.com/python/cpython/pull/28309

___
Python tracker 

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



[issue45022] Update libffi to 3.4.2

2021-09-13 Thread Ghostkeeper


Ghostkeeper  added the comment:

It seems this just broke our Windows build process of Python 3.8, since the 
cpython-bin-deps repository now contains only a libffi-8.lib while the the 
Python 3.8 branch still refers to libffi-7.lib in libffi.props: 
https://github.com/python/cpython/blob/5a42a49477cd601d67d81483f9589258dccb14b1/PCbuild/libffi.props#L13

--
nosy: +Ghostkeeper

___
Python tracker 

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



[issue45181] Rewrite loading sqlite3 tests

2021-09-13 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 3e19409d6443c66a6a7d62f58b2bb4e8330e56c4 by Serhiy Storchaka in 
branch 'main':
bpo-45181: Simplify loading sqlite3 tests (GH-28304)
https://github.com/python/cpython/commit/3e19409d6443c66a6a7d62f58b2bb4e8330e56c4


--

___
Python tracker 

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



[issue45181] Rewrite loading sqlite3 tests

2021-09-13 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



[issue45183] Unexpected exception with zip importer

2021-09-13 Thread Ronald Oussoren


New submission from Ronald Oussoren :

The attached file demonstrates the problem:

If importlib.invalidate_caches() is called while the zipfile used by the zip 
importer is not available the import system breaks entirely. I found this in a 
testsuite that accedently did this (it should have updated sys.path). 

I get the following exception:

$ python3.10 t.py
Traceback (most recent call last):
  File "/Users/ronald/Projects/modulegraph2/t.py", line 27, in 
import uu
  File "", line 1027, in _find_and_load
  File "", line 1002, in _find_and_load_unlocked
  File "", line 945, in _find_spec
  File "", line 1430, in find_spec
  File "", line 1402, in _get_spec
  File "", line 168, in find_spec
  File "", line 375, in _get_module_info
TypeError: argument of type 'NoneType' is not iterable


This exception is not very friendly

This particular exception is caused by setting self._files to None in the 
importer's invalidate_caches method, while not checking for None in 
_get_modules_info. 

I'm not sure what the best fix would be, setting self._files to an empty list 
would likely be the easiest fix.

Note that the script runs without errors in Python 3.9.

--
files: repro.py
keywords: 3.10regression
messages: 401698
nosy: ronaldoussoren
priority: normal
severity: normal
status: open
title: Unexpected exception with zip importer
versions: Python 3.10, Python 3.11
Added file: https://bugs.python.org/file50279/repro.py

___
Python tracker 

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



[issue45183] Unexpected exception with zip importer

2021-09-13 Thread Ronald Oussoren


Change by Ronald Oussoren :


--
nosy: +pablogsal, twouters

___
Python tracker 

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



[issue45182] Incorrect use of requires_zlib in test_bdist_rpm

2021-09-13 Thread miss-islington


miss-islington  added the comment:


New changeset 2f1d9bca144f3bbb4199111f4763ef05daea8526 by Miss Islington (bot) 
in branch '3.10':
bpo-45182: Fix incorrect use of requires_zlib in test_bdist_rpm (GH-28305)
https://github.com/python/cpython/commit/2f1d9bca144f3bbb4199111f4763ef05daea8526


--

___
Python tracker 

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



[issue45183] Unexpected exception with zip importer

2021-09-13 Thread Ronald Oussoren


Change by Ronald Oussoren :


--
type:  -> behavior

___
Python tracker 

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



[issue40080] Stripping annotations out as a new optimization mode

2021-09-13 Thread Filipe Laíns

Change by Filipe Laíns :


--
nosy: +FFY00

___
Python tracker 

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



[issue20524] format error messages should provide context information

2021-09-13 Thread Nikita Sobolev


Change by Nikita Sobolev :


--
keywords: +patch
nosy: +sobolevn
nosy_count: 4.0 -> 5.0
pull_requests: +26723
stage: test needed -> patch review
pull_request: https://github.com/python/cpython/pull/28310

___
Python tracker 

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



[issue20524] format error messages should provide context information

2021-09-13 Thread Nikita Sobolev


Nikita Sobolev  added the comment:

> I think that would require some major surgery to the code, but would be worth 
> it.

I've decided to take an easy path: https://github.com/python/cpython/pull/28310

```
PyErr_Format(PyExc_ValueError,
 "Invalid format specifier: '%s' for object of type '%s'",
 PyUnicode_AsUTF8AndSize(format_spec, NULL),
 Py_TYPE(obj)->tp_name);
```

This worked for me as the starting point. It covered: int, float, complex, and 
str types.

> Note that in your original example, you want the error to contain 
> "{length:%HH:%MM}". By the time the error is detected, the only thing the 
> code knows is the format specifier "%HH:%MM". It doesn't know the "length" 
> part. 

I guess it has changed since the 2014.

I would love to hear any feedback on my proposal and improve it to the level 
when it can be merged :)

--

___
Python tracker 

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



[issue21302] time.sleep (floatsleep()) should use clock_nanosleep() on Linux

2021-09-13 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 85a4748118c3793be7047ecbcbfc79dd07cb2a75 by Livius in branch 
'main':
bpo-21302: Add clock_nanosleep() implementation for time.sleep() (GH-28111)
https://github.com/python/cpython/commit/85a4748118c3793be7047ecbcbfc79dd07cb2a75


--

___
Python tracker 

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



[issue21302] time.sleep (floatsleep()) should use clock_nanosleep() on Linux

2021-09-13 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +26724
pull_request: https://github.com/python/cpython/pull/28311

___
Python tracker 

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



[issue42135] [importlib] Deprecate find_module() & find_loader() mplementations

2021-09-13 Thread Hugo van Kemenade


Change by Hugo van Kemenade :


--
nosy: +hugovk
nosy_count: 1.0 -> 2.0
pull_requests: +26725
pull_request: https://github.com/python/cpython/pull/28312

___
Python tracker 

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



[issue45182] Incorrect use of requires_zlib in test_bdist_rpm

2021-09-13 Thread Éric Araujo

Éric Araujo  added the comment:

At this point, it seems that there would be more value in reporting this to 
setuptools than on bpo.

--

___
Python tracker 

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



[issue45168] dis output for LOAD_CONST is confusing

2021-09-13 Thread Irit Katriel


Change by Irit Katriel :


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

___
Python tracker 

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



[issue45184] Add `pop` function to remove context manager from (Async)ExitStack

2021-09-13 Thread Andreas H.


New submission from Andreas H. :

Currently it is not possible to remove context managers from an ExitStack (or 
AsyncExitStack). 


Workarounds are difficult and generally do accesses implementation details of 
(Async)ExitStack.
See e.g. https://stackoverflow.com/a/37607405. It could be done as follows:


class AsyncExitStackWithPop(contextlib.AsyncExitStack):
"""Same as AsyncExitStack but with pop, i.e. removal functionality"""
async def pop(self, cm):
callbacks = self._exit_callbacks
self._exit_callbacks = collections.deque()
found = None
while callbacks:
cb = callbacks.popleft()
if cb[1].__self__ == cm:
found = cb
else:
self._exit_callbacks.append(cb)
if not found:
raise KeyError("context manager not found")
if found[0]:
return found[1](None,None,None)
else:
return await found[1](None, None, None)

The alternative is re-implementation of ExitStack with pop functionality, but 
that is also very difficult to get right (especially with exceptions). Which is 
probably the reason why there is ExitStack in the library at all.


So I propose to augment (Async)ExitStack with a `pop` method like above or 
similar to the above.


Use-Cases:

An example is a component that manages several connections to network services. 
During run-time the network services might need to change (i.e. some be 
disconnected and some be connected according to business logic), or handle 
re-connection events (ie. graceful response to network errors).
It is not too hard to imagine more use cases.
Essentially every case where dynamic resource management is needed and where 
single resources are managable with python context managers.

--
components: Library (Lib)
messages: 401703
nosy: andreash, ncoghlan, yselivanov
priority: normal
severity: normal
status: open
title: Add `pop` function to remove context manager from (Async)ExitStack
type: enhancement
versions: Python 3.10, Python 3.11, 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



[issue45022] Update libffi to 3.4.2

2021-09-13 Thread Zachary Ware


Zachary Ware  added the comment:

The 3.8 branch has been updated to point to the `libffi-3.3.0` tag; you can 
either update to the latest revision of 3.8 or pull in just 
8c3a10e58b12608c3759fee684e7aa399facae2a

--

___
Python tracker 

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



[issue4492] httplib code thinks it closes connection, but does not

2021-09-13 Thread Irit Katriel


Irit Katriel  added the comment:

The code has changed quite a lot since this was created and it no longer 
matches the description in this issue.

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



[issue41710] acquire(timeout) of threading.Lock and threading.Condition is affected by jumps in system time: Python should use sem_clockwait(CLOCK_MONOTONIC)

2021-09-13 Thread STINNER Victor


Change by STINNER Victor :


--
title: Timeout is affected by jumps in system time -> acquire(timeout) of 
threading.Lock and threading.Condition is affected by jumps in system time: 
Python should use sem_clockwait(CLOCK_MONOTONIC)

___
Python tracker 

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



[issue21302] time.sleep (floatsleep()) should use clock_nanosleep() on Linux

2021-09-13 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 85dc53a463967659075744ad911d08a32aa70dd5 by Victor Stinner in 
branch 'main':
bpo-21302: Update time.sleep() doc for clock_nanosleep() (GH-28311)
https://github.com/python/cpython/commit/85dc53a463967659075744ad911d08a32aa70dd5


--

___
Python tracker 

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



[issue45119] test_signal.test_itimer_virtual() failed on AMD64 Fedora Rawhide: Linux kernel 5.15 regression

2021-09-13 Thread STINNER Victor


STINNER Victor  added the comment:

Update: Frederic Weisbecker proposed a kernel fix:
https://lkml.org/lkml/2021/9/13/1647

--

___
Python tracker 

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



[issue45184] Add `pop` function to remove context manager from (Async)ExitStack

2021-09-13 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

If you can remove context managers in arbitrary order it is no longer a stack.

I think that it is just a wrong tool for your problem. Just maintain a 
collection of opened connections. Set or dict can be better that list or deque.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue45155] Add default arguments for int.to_bytes()

2021-09-13 Thread Barry A. Warsaw

Barry A. Warsaw  added the comment:

That’s okay, Brandt’s improved sys.byteorder is fastest .

% ./python.exe -m timeit -r11 -s 'x=3452452454524' 'x.to_bytes(10, "little")'
200 loops, best of 11: 94.6 nsec per loop
% ./python.exe -m timeit -r11 -s 'x=3452452454524' 'x.to_bytes(10, "big")'
200 loops, best of 11: 97.8 nsec per loop
% ./python.exe -m timeit -r11 -s 'x=3452452454524' 'x.to_bytes(10)'
500 loops, best of 11: 79.1 nsec per loop

On Sep 12, 2021, at 04:20, Raymond Hettinger  wrote:
> 
> Raymond Hettinger  added the comment:
> 
> Interestingly, "little" is faster than "big".
> 
> $ python3.10 -m timeit -r11 -s 'x=3452452454524' 'x.to_bytes(10, "little")'
> 500 loops, best of 11: 82.7 nsec per loop
> $ python3.10 -m timeit -r11 -s 'x=3452452454524' 'x.to_bytes(10, "big")'
> 500 loops, best of 11: 90.6 nsec per loop
> 
> --
> 
> ___
> Python tracker 
> 
> ___

--

___
Python tracker 

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



[issue38222] pathlib Path objects should support __format__

2021-09-13 Thread Richard


Richard  added the comment:

I would like for this to be reconsidered. Yes, you can use str(), but 
converting back and forth becomes really clunky:

log_dir = 'logs/{date}'
log_file = Path(str(path).format(time.strftime('%Y-%m-%d')) / 'log.txt'

--
nosy: +nyuszika7h

___
Python tracker 

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



[issue38222] pathlib Path objects should support __format__

2021-09-13 Thread Richard


Richard  added the comment:

Sorry, that should have been:

log_dir = Path('logs/{date}')

--

___
Python tracker 

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



[issue38222] pathlib Path objects should support __format__

2021-09-13 Thread Eric V. Smith


Eric V. Smith  added the comment:

> log_dir = Path('logs/{date}')
> log_file = Path(str(path).format(time.strftime('%Y-%m-%d')) / 'log.txt'

(I think you're missing "date=" in the call to .format().)

Could you show what you think this would look like if Path.__format__ existed? 
I don't think anyone's suggesting that path.format() would be added by this 
issue, but maybe that would be a reasonable proposal as a different issue.

--

___
Python tracker 

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



[issue45155] Add default arguments for int.to_bytes()

2021-09-13 Thread Barry A. Warsaw


Barry A. Warsaw  added the comment:

I created a Discourse poll: 
https://discuss.python.org/t/what-should-be-the-default-value-for-int-to-bytes-byteorder/10616

--

___
Python tracker 

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



[issue45182] Incorrect use of requires_zlib in test_bdist_rpm

2021-09-13 Thread miss-islington


miss-islington  added the comment:


New changeset 218fe2cb798df32a722f61b95db280f6685ec3e6 by Miss Islington (bot) 
in branch '3.9':
bpo-45182: Fix incorrect use of requires_zlib in test_bdist_rpm (GH-28305)
https://github.com/python/cpython/commit/218fe2cb798df32a722f61b95db280f6685ec3e6


--

___
Python tracker 

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



[issue45173] Remove configparser deprecations

2021-09-13 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset 1fc41ae8709e20d741bd86c2345173688a5e84b0 by Hugo van Kemenade in 
branch 'main':
bpo-45173 Remove configparser deprecations (GH-28292)
https://github.com/python/cpython/commit/1fc41ae8709e20d741bd86c2345173688a5e84b0


--
nosy: +lukasz.langa

___
Python tracker 

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



[issue45167] deepcopy of GenericAlias with __deepcopy__ method is broken

2021-09-13 Thread Łukasz Langa

Łukasz Langa  added the comment:

Serhiy, can you elaborate how GH-28306 can break protocols using other special 
methods? I can't come up with an example.

--
nosy: +lukasz.langa

___
Python tracker 

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



[issue35474] mimetypes.guess_all_extensions potentially mutates list

2021-09-13 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset 9cd8fb8d6356c17dafa1be727cab3d438f6df53f by Miss Islington (bot) 
in branch '3.9':
bpo-35474: Fix mimetypes.guess_all_extensions() potentially mutating list 
(GH-28286) (GH-28290)
https://github.com/python/cpython/commit/9cd8fb8d6356c17dafa1be727cab3d438f6df53f


--
nosy: +lukasz.langa

___
Python tracker 

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



[issue35474] mimetypes.guess_all_extensions potentially mutates list

2021-09-13 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset 06c26f4d2909eae196ac81c9ed9b41e747e42685 by Miss Islington (bot) 
in branch '3.10':
bpo-35474: Fix mimetypes.guess_all_extensions() potentially mutating list 
(GH-28286) (GH-28289)
https://github.com/python/cpython/commit/06c26f4d2909eae196ac81c9ed9b41e747e42685


--

___
Python tracker 

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



[issue35474] mimetypes.guess_all_extensions potentially mutates list

2021-09-13 Thread Łukasz Langa

Łukasz Langa  added the comment:

Thanks, Serhiy! ✨ 🍰 ✨

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



[issue45155] Add default arguments for int.to_bytes()

2021-09-13 Thread Matthew Barnett


Matthew Barnett  added the comment:

I'd probably say "In the face of ambiguity, refuse the temptation to guess".

As there's disagreement about the 'correct' default, make it None and require 
either "big" or "little" if length > 1 (the default).

--
nosy: +mrabarnett

___
Python tracker 

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



[issue38222] pathlib Path objects should support __format__

2021-09-13 Thread Antoine Pitrou


Antoine Pitrou  added the comment:

I would be in favour of adding Path.__format__, even though I'm not terribly 
convinced by the use case presented.

--

___
Python tracker 

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



[issue45184] Add `pop` function to remove context manager from (Async)ExitStack

2021-09-13 Thread Andreas H.


Andreas H.  added the comment:

I see your point. But even with `pop` or `remove` it is still a stack or 
stack-like. In the normal case the context managers are still released in 
reverse order as they were added. Order cannot be changed arbitrarily.

There is just the additional function of removing a single context manager 
prematurely(e.g. for graceful error recovery and such). 

I would perhaps say that a stack is the "wrong" solution to the problem of 
"programmatically combining context managers" [this is from the official 
documentaion] in the first place. I write wrong in quotes because it is of 
course not really wrong, as one wants the reverse exit order. But to adequately 
address the dynamic case one needs in my opinion the ability to prematurely 
remove context managers. Otherwise the use is limited.

Reimplemeting the desired functionality with dicts or lists does not seem 
appealing to me as the code will be 90% the same to ExitStack. It will then 
also make ExitStack obsolete. So why not integrate it there?

The unsymmetry of being able to add context managers but not being able to 
remove them also seems odd to me.

--

___
Python tracker 

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



[issue45185] test.test_ssl.TestEnumerations is not run

2021-09-13 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

test.test_ssl.TestEnumerations is not run when run ssl tests. If add it to the 
list of test classes it fails:

==
ERROR: test_options (test.test_ssl.TestEnumerations)
--
Traceback (most recent call last):
  File "/home/serhiy/py/cpython/Lib/test/test_ssl.py", line 4981, in 
test_options
enum._test_simple_enum(CheckedOptions, ssl.Options)
^^^
  File "/home/serhiy/py/cpython/Lib/enum.py", line 1803, in _test_simple_enum
raise TypeError('enum mismatch:\n   %s' % '\n   '.join(failed))
^^^
TypeError: enum mismatch:
   '_use_args_':
 checked -> False
 simple  -> True
   '__format__':  checked ->  
simple -> 
   '__getnewargs__':  checked -> Nonesimple -> 

==
ERROR: test_sslerrornumber (test.test_ssl.TestEnumerations)
--
Traceback (most recent call last):
  File "/home/serhiy/py/cpython/Lib/test/test_ssl.py", line 4998, in 
test_sslerrornumber
enum._test_simple_enum(Checked_SSLMethod, ssl._SSLMethod)
^
  File "/home/serhiy/py/cpython/Lib/enum.py", line 1803, in _test_simple_enum
raise TypeError('enum mismatch:\n   %s' % '\n   '.join(failed))
^^^
TypeError: enum mismatch:
   extra key:   'PROTOCOL_SSLv23'

==
ERROR: test_sslmethod (test.test_ssl.TestEnumerations)
--
Traceback (most recent call last):
  File "/home/serhiy/py/cpython/Lib/test/test_ssl.py", line 4973, in 
test_sslmethod
enum._test_simple_enum(Checked_SSLMethod, ssl._SSLMethod)
^
  File "/home/serhiy/py/cpython/Lib/enum.py", line 1803, in _test_simple_enum
raise TypeError('enum mismatch:\n   %s' % '\n   '.join(failed))
^^^
TypeError: enum mismatch:
   extra key:   'PROTOCOL_SSLv23'

==
ERROR: test_verifyflags (test.test_ssl.TestEnumerations)
--
Traceback (most recent call last):
  File "/home/serhiy/py/cpython/Lib/test/test_ssl.py", line 5002, in 
test_verifyflags
enum.FlagEnum, 'VerifyFlags', 'ssl',
^
AttributeError: module 'enum' has no attribute 'FlagEnum'

--

--
components: Tests
messages: 401723
nosy: christian.heimes, serhiy.storchaka
priority: normal
severity: normal
status: open
title: test.test_ssl.TestEnumerations is not run
type: behavior
versions: Python 3.10, Python 3.11, Python 3.9

___
Python tracker 

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



[issue45185] test.test_ssl.TestEnumerations is not run

2021-09-13 Thread Ethan Furman


Change by Ethan Furman :


--
nosy: +ethan.furman

___
Python tracker 

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



[issue45186] Marshal output isn't completely deterministic.

2021-09-13 Thread Eric Snow


New submission from Eric Snow :

(See: https://github.com/python/cpython/pull/28107#issuecomment-915627148)

The output from marshal (e.g. PyMarshal_WriteObjectToString(), marshal.dump()) 
may be different depending on if it is a debug or non-debug build.  I found 
this while working on freezing stdlib modules.

--
components: Interpreter Core
messages: 401724
nosy: eric.snow
priority: normal
severity: normal
stage: needs patch
status: open
title: Marshal output isn't completely deterministic.
type: behavior
versions: Python 3.11

___
Python tracker 

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



[issue45186] Marshal output isn't completely deterministic.

2021-09-13 Thread Eric Snow


Eric Snow  added the comment:

FYI, I came up with a fix (for frozen modules, at least) in  
https://github.com/python/cpython/pull/28107.

--

___
Python tracker 

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



[issue45187] Some tests in test_socket are not run

2021-09-13 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

Test classes ISOTPTest, J1939Test, BasicUDPLITETest, UDPLITETimeoutTest in 
test_socket are not included in the list of test classes and are not run by 
regrtest.

--
components: Tests
messages: 401725
nosy: serhiy.storchaka
priority: normal
severity: normal
status: open
title: Some tests in test_socket are not run
type: behavior
versions: Python 3.10, Python 3.11, Python 3.9

___
Python tracker 

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



[issue45186] Marshal output isn't completely deterministic.

2021-09-13 Thread Eric Snow


Eric Snow  added the comment:

One consequence of this is that frozen module .h files can be different for 
debug vs. non-debug, which causes CI (and Windows builds) to fail.

--

___
Python tracker 

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



[issue45155] Add default arguments for int.to_bytes()

2021-09-13 Thread STINNER Victor


STINNER Victor  added the comment:

>>> (65).to_bytes()
b'A'

It seems like your proposal is mostly guided by: convert an int to a byte 
(bytes string of length 1). IMO this case is special enough to justify the 
usage of a different function.

What if people expect int.to_bytes() always return a single byte, but then get 
two bytes by mistake?

ch = 256
byte = ch.to_bytes()
assert len(byte) == 2  # oops

A function dedicated to create a single byte is expected to raise a ValueError 
for values outside the range [0; 255]. Like:

>>> struct.pack('B', 255)
b'\xff'
>>> struct.pack('B', 256)
struct.error: ubyte format requires 0 <= number <= 255

--

___
Python tracker 

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



[issue45187] Some tests in test_socket are not run

2021-09-13 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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

___
Python tracker 

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



[issue45155] Add default arguments for int.to_bytes()

2021-09-13 Thread STINNER Victor


STINNER Victor  added the comment:

> In the PEP 467 discussion, I proposed (...)

Since this PEP is controversial, and this issue seems to be controversial as 
well, maybe this idea should be part of the PEP.

--

___
Python tracker 

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



[issue45155] Add default arguments for int.to_bytes()

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

Vedran Čačić  added the comment:

The poll is invalid, since the option that most people want is deliberately not 
offered.

--

___
Python tracker 

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



[issue45188] De-couple the Windows builds from freezing modules.

2021-09-13 Thread Eric Snow


New submission from Eric Snow :

Currently for Windows builds, generating the frozen modules depends on first 
building python.exe.  One consequence of this is that we must keep all frozen 
module .h files in the repo (which we'd like to avoid for various reasons).

We should be able to freeze modules before building python.exe, like we already 
do via our Makefile.  From what I understand, this will require that a subset 
of the runtime be separately buildable so we can use it in _freeze_module.c and 
use that before actually building python.exe.

@Steve, please correct any details I got wrong here. :)

--
components: Build
messages: 401731
nosy: eric.snow, steve.dower
priority: normal
severity: normal
stage: needs patch
status: open
title: De-couple the Windows builds from freezing modules.
type: behavior
versions: Python 3.11

___
Python tracker 

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



[issue45187] Some tests in test_socket are not run

2021-09-13 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

PR 28317 makes test classes in test_socket be autocollected instead of 
explicitly enumerated. This will save as from similar errors in future.

--

___
Python tracker 

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



[issue45020] Freeze all modules imported during startup.

2021-09-13 Thread Eric Snow


Change by Eric Snow :


--
dependencies: +De-couple the Windows builds from freezing modules., Marshal 
output isn't completely deterministic.

___
Python tracker 

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



[issue45157] DTrace on RHEL7, generated Include/pydtrace_probes.h fails to build: error: impossible constraint in ‘asm’

2021-09-13 Thread STINNER Victor


STINNER Victor  added the comment:

Issue worked around by disabling LTO on RHEL7 buildbots:
https://github.com/python/buildmaster-config/commit/b8e56c0a545b8f5176c6984dd38a4e2630f21306

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

___
Python tracker 

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



[issue45020] Freeze all modules imported during startup.

2021-09-13 Thread Guido van Rossum


Guido van Rossum  added the comment:

If you reduce the number of modules being frozen you could probably manage
to land this (or most of it) before tackling those other issues.

--

___
Python tracker 

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



[issue45188] De-couple the Windows builds from freezing modules.

2021-09-13 Thread Steve Dower


Steve Dower  added the comment:

Only thing I'd add is that you should just be able to list the required .c 
files in _freeze_module.vcxproj (formerly known as freeze_importlib.vcxproj) 
rather than depending on pythoncore.vcxproj.

That will generate twice as many .obj files for those modules (which is fine, 
just takes a little more time at build), and will force everything to be 
regenerated if you modify them, but that's an expected part of having part of 
the interpreter depend upon itself.

--
components: +Windows
nosy: +paul.moore, tim.golden, zach.ware

___
Python tracker 

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



[issue45167] deepcopy of GenericAlias with __deepcopy__ method is broken

2021-09-13 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

I meant that the current __getattr__ breaks deepcopy(). It can break also other 
protocols. It already has a list of exceptions, we need to add "__copy__" and 
"__deepcopy__" in this list. Or maybe exclude all dunder names by default and 
use a white list?

--

___
Python tracker 

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



[issue45182] Incorrect use of requires_zlib in test_bdist_rpm

2021-09-13 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



[issue45019] Freezing modules has manual steps but could be automated.

2021-09-13 Thread Eric Snow


Change by Eric Snow :


--
pull_requests: +26728
pull_request: https://github.com/python/cpython/pull/28319

___
Python tracker 

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



[issue45155] Add default arguments for int.to_bytes()

2021-09-13 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Just reread the thread. AFAICT not a single use case was presented for having 
system byte ordering as the default.  However, multiple respondents have 
pointed out that a default to system byte ordering is a bug waiting to happen, 
almost ensuring that some users will encounter unexpected behaviors when 
crossing platforms.  We've seen issues like that before and should avoid them.

We don't really need a poll.  What is needed is for the system byte ordering 
proponents to present valid reasons why it would useful and to address the 
concerns that it is actually harmful.

If the proposal goes through despite the concerns, we should ask folks writing 
lint tools to flag every use of the default as a potential bug and advise 
people to never use the default unless they know for sure that it is encoding 
only a single byte.  Personally, I would never let system byte ordering pass a 
code review.

--

___
Python tracker 

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



[issue45019] Freezing modules has manual steps but could be automated.

2021-09-13 Thread Eric Snow


Eric Snow  added the comment:


New changeset a2d8c4b81b8e68e2ffe10945f7ca69174c14e52a by Eric Snow in branch 
'main':
bpo-45019: Do some cleanup related to frozen modules. (gh-28319)
https://github.com/python/cpython/commit/a2d8c4b81b8e68e2ffe10945f7ca69174c14e52a


--

___
Python tracker 

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



[issue45020] Freeze all modules imported during startup.

2021-09-13 Thread Eric Snow


Change by Eric Snow :


--
pull_requests: +26729
pull_request: https://github.com/python/cpython/pull/28320

___
Python tracker 

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



[issue42135] [importlib] Deprecate find_module() & find_loader() mplementations

2021-09-13 Thread Brett Cannon


Brett Cannon  added the comment:


New changeset 9f93018b69d72cb48d3444554261ae3b0ea00c93 by Hugo van Kemenade in 
branch 'main':
bpo-42135 Correct version slated for importlib.find_loader removal (GH-28312)
https://github.com/python/cpython/commit/9f93018b69d72cb48d3444554261ae3b0ea00c93


--

___
Python tracker 

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



[issue42135] [importlib] Deprecate find_module() & find_loader() mplementations

2021-09-13 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 2.0 -> 3.0
pull_requests: +26730
pull_request: https://github.com/python/cpython/pull/28321

___
Python tracker 

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



[issue45020] Freeze all modules imported during startup.

2021-09-13 Thread Eric Snow


Eric Snow  added the comment:

On Mon, Sep 13, 2021 at 2:59 PM Guido van Rossum  wrote:
> If you reduce the number of modules being frozen you could probably manage
> to land this (or most of it) before tackling those other issues.

Yeah, that's what I'm doing. :)

--

___
Python tracker 

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



[issue45189] Drop the "list_frozen" command from _test_embed.

2021-09-13 Thread Eric Snow


New submission from Eric Snow :

In Programs/_test_embed.c the "list_frozen" command prints out the name of each 
frozen module (defined in Python/frozen.c).  The only place this is used is in 
Tools/scripts/generate_stdlib_module_names.py (in list_frozen()).  That script 
can be updated to call imp._get_frozen_module_names(), which was added in PR 
GH-28319 for bpo-45019.  Then _test_embed can go back to being used strictly 
for tests.

(FWIW, the script could also read from Python/frozen_modules/MANIFEST after 
running "make regen-frozen".  That file was added in GH-27980).

--
components: Demos and Tools
messages: 401741
nosy: eric.snow, vstinner
priority: normal
severity: normal
stage: needs patch
status: open
title: Drop the "list_frozen" command from _test_embed.
versions: Python 3.11

___
Python tracker 

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



[issue42135] [importlib] Deprecate find_module() & find_loader() mplementations

2021-09-13 Thread Brett Cannon


Brett Cannon  added the comment:


New changeset a390bb6d66027517498e75b6b91a91be5f136d28 by Miss Islington (bot) 
in branch '3.10':
bpo-42135 Correct version slated for importlib.find_loader removal (GH-28312) 
(GH-28321)
https://github.com/python/cpython/commit/a390bb6d66027517498e75b6b91a91be5f136d28


--

___
Python tracker 

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



[issue45116] Performance regression 3.10b1 and later on Windows: Py_DECREF() not inlined in PGO build

2021-09-13 Thread neonene


neonene  added the comment:

With msvc 16.10.3 and 16.11.2 (latest),
PR25244 told me the amount of code in _PyEval_EvalFrameDefault() is over the 
limit of PGO.
In the old version of _PyEval_EvalFrameDefault (b98eba5), the same issue can be 
caused adding any-code anywhere with more than 20 expressions/statements. For 
example, at the top/middle/end of the function, repeating "if (0) {}" 10times, 
or "if (0) {19 statements}". As for python3.9.7, more than 800 
expressions/statements.

Here is just a workaround for 3.10rc2 on windows.
==
--- Python/ceval.c
+++ Python/ceval.c
@@ -1306,9 +1306 @@
-#define DISPATCH() \
-{ \
-if (trace_info.cframe.use_tracing OR_DTRACE_LINE OR_LLTRACE) { \
-goto tracing_dispatch; \
-} \
-f->f_lasti = INSTR_OFFSET(); \
-NEXTOPARG(); \
-DISPATCH_GOTO(); \
-}
+#define DISPATCH() goto tracing_dispatch
@@ -1782,4 +1774,9 @@
 tracing_dispatch:
 {
+if (!(trace_info.cframe.use_tracing OR_DTRACE_LINE OR_LLTRACE)) {
+f->f_lasti = INSTR_OFFSET();
+NEXTOPARG();
+DISPATCH_GOTO();
+}
 int instr_prev = f->f_lasti;
 f->f_lasti = INSTR_OFFSET();
==

This patch becomes ineffective just adding one expression to DISPATCH macro as 
below

   #define DISPATCH() {if (1) goto tracing_dispatch;}

And this approach is not sufficient for 3.11 with bigger eval-func.
I don't know a cl/link option to lift such restriction of function size.


3.10rc2 x86 pgo : 1.00
patched : 1.09x faster (slower  5, faster 48, not significant 5)

3.10rc2 x64 pgo : 1.00 (roughly the same speed as official bin)
patched : 1.07x faster (slower  5, faster 47, not significant 6)
  patched(/Ob3) : 1.07x faster (slower  7, faster 45, not significant 6)

x64 results are posted.

Fixing inlining rejection also made __forceinline buildable with normal 
processing time and memory usage.

--
Added file: https://bugs.python.org/file50280/310rc2_benchmarks.txt

___
Python tracker 

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



[issue45188] De-couple the Windows builds from freezing modules.

2021-09-13 Thread Steve Dower


Change by Steve Dower :


--
keywords: +patch
pull_requests: +26731
stage: needs patch -> patch review
pull_request: https://github.com/python/cpython/pull/28322

___
Python tracker 

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



[issue40128] IDLE Show completions pop-up not working on macOS

2021-09-13 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

Pablo (and Ned) 

PR_26672 (and backports) added one line to idlelib/autocomplete_w.py, 206 or 
209.
  acw.update_idletasks() # Need for tk8.6.8 on macOS: #40128.
NEWs item included "The added update_idletask call should be harmless and 
possibly helpful otherwise. "

This is consistent with https://www.tcl.tk/man/tcl8.6/TclCmd/update.html

At the end of the PR, Tal Einat reports
"this broke completions for me with Tcl/Tk 8.6.11 on Ubuntu 20.04.
Apparently also with Tcl/Tk 8.6.10, which is the current default.
Also broken in my latest install of Python 3.9.7 (not built from source)."

Tal, did you verify that #ing the line fixes your issues?  Can you be more 
specific as to what you see?

I rechecked on my Macbook and the line is definitely needed for 3.9.7 with tk 
8.6.8.  It makes no difference for 3.10.0rc2 with 8.6.11.  (So the bug of 
requiring update_idletasks call to ever see the dropdown box was fixed.)

Assume Tal's report is verified on another machine, we could, before 3.10.0,
1. Remove the line.
2. Disable the line.
3. Make it conditional on macOS and 8.6.8.

It is obviously too late for 3.9.7.

--
nosy: +lukasz.langa, pablogsal
priority: normal -> release blocker

___
Python tracker 

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



[issue40128] IDLE Show completions pop-up not working on macOS

2021-09-13 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

https://www.tcl.tk/man/tcl8.6/TclCmd/update.html

--

___
Python tracker 

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



[issue45155] Add default arguments for int.to_bytes()

2021-09-13 Thread Matthew Barnett


Matthew Barnett  added the comment:

I wonder whether there should be a couple of other endianness values, namely, 
"native" and "network", for those cases where you want to be explicit about it. 
If you use "big" it's not clear whether that's because you want network 
endianness or because the platform is big-endian.

--

___
Python tracker 

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



[issue45190] unicode 14.0 upgrade

2021-09-13 Thread Benjamin Peterson


New submission from Benjamin Peterson :

Unicode 14.0 is expected on September 14. We'll need to do the usual table 
regenerations.

--
assignee: benjamin.peterson
components: Unicode
messages: 401747
nosy: benjamin.peterson, ezio.melotti, vstinner
priority: normal
severity: normal
status: open
title: unicode 14.0 upgrade

___
Python tracker 

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



[issue45191] Error.__traceback__.tb_lineno is wrong

2021-09-13 Thread nahco314


New submission from nahco314 :

I think that the emphasis of the errors caused by some of these equivalent 
expressions is wrong or inconsistent.
expr1: 1 .bit_length("aaa")
expr2: 1 \
.bit_length("aaa")
expr3: 1 \
.bit_length(*["aaa"])

Below is the __traceback__.tb_lineno of the error given when running each 
version of the expression. (kubuntu20.0.4, CPython (pyenv))
The line number and location shown in the error message also correspond to this.

in 3.6.14, 3,7,11
expr1: 0
expr2: 1
expr3: 1

in 3.8.11, 3.9.6
expr1: 0
expr2: 0
expr3: 0

in 3.10.0rc1, 3.11-dev(3.11.0a0)
expr1: 0
expr2: 1
expr3: 0

I think the results in 3.6.14 and 3.7.11 are correct.

--
components: Interpreter Core
messages: 401748
nosy: nahco314
priority: normal
severity: normal
status: open
title: Error.__traceback__.tb_lineno is wrong
type: behavior
versions: Python 3.10, Python 3.11, Python 3.8, Python 3.9

___
Python tracker 

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



[issue45155] Add default arguments for int.to_bytes()

2021-09-13 Thread Barry A. Warsaw

Barry A. Warsaw  added the comment:

> I'd probably say "In the face of ambiguity, refuse the temptation to guess".
> 
> As there's disagreement about the 'correct' default, make it None and require 
> either "big" or "little" if length > 1 (the default).

Jelle suggested that over in Discourse, and I’m not opposed, but it does mean 
that there’s no natural default for byteorder in int.from_bytes().

--

___
Python tracker 

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



[issue45155] Add default arguments for int.to_bytes()

2021-09-13 Thread Barry A. Warsaw

Barry A. Warsaw  added the comment:

On Sep 13, 2021, at 13:38, STINNER Victor  wrote:
> It seems like your proposal is mostly guided by: convert an int to a byte 
> (bytes string of length 1). IMO this case is special enough to justify the 
> usage of a different function.

Like bchr() ? 

> What if people expect int.to_bytes() always return a single byte, but then 
> get two bytes by mistake?
> 
> ch = 256
> byte = ch.to_bytes()

The OverflowError you’ll get seems reasonable.

--

___
Python tracker 

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



[issue45155] Add default arguments for int.to_bytes()

2021-09-13 Thread Barry A. Warsaw

Barry A. Warsaw  added the comment:

On Sep 13, 2021, at 13:39, Vedran Čačić  wrote:
> 
> The poll is invalid, since the option that most people want is deliberately 
> not offered.

*Is* there an option that most people want?

--

___
Python tracker 

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



[issue45155] Add default arguments for int.to_bytes()

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

Vedran Čačić  added the comment:

I'd say yes. Of course, one way to ascertain that would be to conduct a valid 
pool. ;-)

--

___
Python tracker 

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



[issue45155] Add default arguments for int.to_bytes()

2021-09-13 Thread Barry A. Warsaw

Barry A. Warsaw  added the comment:

On Sep 13, 2021, at 22:12, Vedran Čačić  wrote:
> 
> 
> Vedran Čačić  added the comment:
> 
> I'd say yes. Of course, one way to ascertain that would be to conduct a valid 
> pool. ;-)

People can always comment otherwise in the Discourse thread.

--

___
Python tracker 

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



[issue45192] The tempfile._infer_return_type function cannot infer the type of os.PathLike objects.

2021-09-13 Thread Kyungmin Lee


New submission from Kyungmin Lee :

The tempfile module has been updated to accept an object implementing 
os.PathLike protocol for path-related parameters as of Python 3.6 (e.g. dir 
parameter). An os.PathLike object represents a filesystem path as a str or 
bytes object (i.e. def __fspath__(self) -> Union[str, bytes]:). However, if an 
object implementing os.PathLike[bytes] is passed as a dir argument, a TypeError 
is raised. This bug occurs because the tempfile._infer_return_type function 
considers all objects other than bytes as str type.

--
components: Library (Lib)
messages: 401754
nosy: rekyungmin
priority: normal
severity: normal
status: open
title: The tempfile._infer_return_type function cannot infer the type of 
os.PathLike objects.
type: behavior
versions: Python 3.10, 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



[issue45192] The tempfile._infer_return_type function cannot infer the type of os.PathLike objects.

2021-09-13 Thread Kyungmin Lee


Kyungmin Lee  added the comment:

for example:

```
from typing import Union


class FakePath:
def __init__(self, path):
self.path = path

def __fspath__(self) -> Union[str, bytes]:
return self.path


if __name__ == "__main__":
from tempfile import TemporaryDirectory

# You need to create `existing_path` directory

with TemporaryDirectory(dir=FakePath("existing_path")) as str_path:
print(str_path)  # 'existing_path/...'

with TemporaryDirectory(dir=FakePath(b"existing_path")) as byte_path:
print(byte_path)  # expected b'existing_path/...' but raised TypeError

```

--

___
Python tracker 

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



[issue45192] The tempfile._infer_return_type function cannot infer the type of os.PathLike objects.

2021-09-13 Thread Kyungmin Lee


Change by Kyungmin Lee :


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

___
Python tracker 

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



[issue40128] IDLE Show completions pop-up not working on macOS

2021-09-13 Thread Tal Einat


Tal Einat  added the comment:

Confirmed with python 3.9.7 installed via the "deadsnakes" apt repo on another 
Ubuntu 20.04 machine.

"Confirmed" meaning specifically that the completion window never appears, and 
commenting out that single line resolves the issue.

--

___
Python tracker 

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



[issue40128] IDLE Show completions pop-up not working on macOS

2021-09-13 Thread Tal Einat


Tal Einat  added the comment:

Note that _tkinter.TK_VERSION and _tkinter.TK_VERSION are simply "8.6", not 
enough to differentiate between patch versions. The best way to get this info 
appears to be tk.call("info", "patchlevel").

Specifically I suggest:

TK_VERSION = tuple(map(int, tk.call("info", "patchlevel").split(".")))

...

if (8, 6, 8) <= TK_VERSION < (8, 6, 10):
...

--

___
Python tracker 

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



[issue45167] deepcopy of GenericAlias with __deepcopy__ method is broken

2021-09-13 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
pull_requests: +26734
pull_request: https://github.com/python/cpython/pull/28324

___
Python tracker 

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



[issue45193] IDLE Show completions pop-up not working on Ubuntu Linux

2021-09-13 Thread Tal Einat


New submission from Tal Einat :

The completion window never appears with Python version 3.9.7 and with the 
current main branch.

Ubuntu 20.04 (reproduced on two separate machines)
Tested with Tcl/Tk versions 8.6.10 and 8.6.11.

This is directly caused by the fix for issue #40128. Commenting out that line 
resolves this issue entirely.

(See also the PR for that fix, PR GH-26672.)

--
assignee: terry.reedy
components: IDLE
messages: 401758
nosy: taleinat, terry.reedy
priority: normal
severity: normal
stage: needs patch
status: open
title: IDLE Show completions pop-up not working on Ubuntu Linux
type: behavior
versions: Python 3.10, Python 3.11, Python 3.9

___
Python tracker 

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



[issue40128] IDLE Show completions pop-up not working on macOS

2021-09-13 Thread Tal Einat


Tal Einat  added the comment:

I've created a separate issue for the completion window not appearing on Linux, 
issue #45193. Let's move the discussion there.

--

___
Python tracker 

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



  1   2   >