[issue45382] platform() is not able to detect windows 11

2021-10-08 Thread Marc-Andre Lemburg


Marc-Andre Lemburg  added the comment:

On 08.10.2021 02:15, Eryk Sun wrote:
> 
>> use the build number as reference instead of the major.minor
> 
> It could check the (major, minor, build) tuple, which allows reporting 10.1+ 
> as "post11" and minimizes hard coding of build numbers. For example, given 
> win32_ver() iterates by (major, minor, build) thresholds:

Great idea.

Could you prepare a PR for this ?

--

___
Python tracker 

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



[issue45351] List all sockets in TCP echo server using streams

2021-10-08 Thread Olaf van der Spek


Olaf van der Spek  added the comment:

> server = await asyncio.start_server(handle_echo, '127.0.0.1', )

If 127.0.0.1 is replaced by localhost, the server might listen on ::1 and 
127.0.0.1 but only one address will be printed, which is confusing (and wrong 
IMO).

So the output of the example isn't wrong if you don't change it, but the 
example code itself could be better.

--

___
Python tracker 

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



[issue20692] Tutorial and FAQ: how to call a method on an int

2021-10-08 Thread za


Change by za :


--
nosy: +za3
nosy_count: 10.0 -> 11.0
pull_requests: +27136
pull_request: https://github.com/python/cpython/pull/28818

___
Python tracker 

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



[issue45406] inspect.getouterframes() tracebacks when $CWD does not exists

2021-10-08 Thread Raúl Cumplido

Raúl Cumplido  added the comment:

I have reproduced on python3.10 and validated this is also happening for other 
python versions:

# PYTHON 3.9
$ mkdir /tmp/bar
$ cd /tmp/bar
$ rmdir /tmp/bar
$ python3.9
Python 3.9.5 (default, May 19 2021, 11:32:47) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import inspect
>>> inspect.getouterframes(inspect.currentframe())
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python3.9/inspect.py", line 1529, in getouterframes
frameinfo = (frame,) + getframeinfo(frame, context)
  File "/usr/lib/python3.9/inspect.py", line 1499, in getframeinfo
filename = getsourcefile(frame) or getfile(frame)
  File "/usr/lib/python3.9/inspect.py", line 709, in getsourcefile
if getattr(getmodule(object, filename), '__loader__', None) is not None:
  File "/usr/lib/python3.9/inspect.py", line 738, in getmodule
file = getabsfile(object, _filename)
  File "/usr/lib/python3.9/inspect.py", line 722, in getabsfile
return os.path.normcase(os.path.abspath(_filename))
  File "/usr/lib/python3.9/posixpath.py", line 379, in abspath
cwd = os.getcwd()
FileNotFoundError: [Errno 2] No such file or directory

# PYTHON 3.8
$ mkdir /tmp/bar
$ cd /tmp/bar
$ rmdir /tmp/bar
$ python3.8
Python 3.8.10 (default, Sep 28 2021, 16:10:42) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import inspect
>>> inspect.getouterframes(inspect.currentframe())
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python3.8/inspect.py", line 1503, in getouterframes
frameinfo = (frame,) + getframeinfo(frame, context)
  File "/usr/lib/python3.8/inspect.py", line 1473, in getframeinfo
filename = getsourcefile(frame) or getfile(frame)
  File "/usr/lib/python3.8/inspect.py", line 708, in getsourcefile
if getattr(getmodule(object, filename), '__loader__', None) is not None:
  File "/usr/lib/python3.8/inspect.py", line 737, in getmodule
file = getabsfile(object, _filename)
  File "/usr/lib/python3.8/inspect.py", line 721, in getabsfile
return os.path.normcase(os.path.abspath(_filename))
  File "/usr/lib/python3.8/posixpath.py", line 379, in abspath
cwd = os.getcwd()
FileNotFoundError: [Errno 2] No such file or directory
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 76, in 
apport_excepthook
binary = os.path.realpath(os.path.join(os.getcwd(), sys.argv[0]))
FileNotFoundError: [Errno 2] No such file or directory

Original exception was:
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python3.8/inspect.py", line 1503, in getouterframes
frameinfo = (frame,) + getframeinfo(frame, context)
  File "/usr/lib/python3.8/inspect.py", line 1473, in getframeinfo
filename = getsourcefile(frame) or getfile(frame)
  File "/usr/lib/python3.8/inspect.py", line 708, in getsourcefile
if getattr(getmodule(object, filename), '__loader__', None) is not None:
  File "/usr/lib/python3.8/inspect.py", line 737, in getmodule
file = getabsfile(object, _filename)
  File "/usr/lib/python3.8/inspect.py", line 721, in getabsfile
return os.path.normcase(os.path.abspath(_filename))
  File "/usr/lib/python3.8/posixpath.py", line 379, in abspath
cwd = os.getcwd()
FileNotFoundError: [Errno 2] No such file or directory
>>>

--
nosy: +raulcd

___
Python tracker 

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



[issue45262] crash if asyncio is used before and after re-initialization if using python embedded in an application

2021-10-08 Thread STINNER Victor


STINNER Victor  added the comment:

Is Matthias Reichl's fix enough to use asyncio in a subinterpreter?

--

___
Python tracker 

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



[issue45262] crash if asyncio is used before and after re-initialization if using python embedded in an application

2021-10-08 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 6846d6712a0894f8e1a91716c11dd79f42864216 by Miss Islington (bot) 
in branch '3.10':
bpo-45262, asyncio: Fix cache of the running loop holder (GH-28796) (GH-28816)
https://github.com/python/cpython/commit/6846d6712a0894f8e1a91716c11dd79f42864216


--

___
Python tracker 

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



[issue45401] logging TimedRotatingFileHandler must not rename devices like /dev/null

2021-10-08 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
nosy: +serhiy.storchaka

___
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-10-08 Thread Ma Lin


Ma Lin  added the comment:

Today I tested with msvc2022-preview, `__forceinline` attribute will not hang 
the build.

64-bit PGO builds:

28d28e0~1,vc2022   : baseline
28d28e0~1+F,vc2022 : 1.02x slower  <1>
28d28e0,vc2022 : 1.03x slower  <2>
28d28e0+F,vc2022   : 1.03x slower
3.10 final,vc2022  : 1.03x slower
3.10 final+F,vc2022: 1.03x slower
28d28e0~1,vc2019   : 1.00x slower  <3>

28d28e0~1 is the last fast commit, 28d28e0 is the first slow commit.
`+F` means add `__forceinline` attribute to all inline functions in object.h
vc2019 and vc2022 are the latest version.

<1> Forcing inline is slower.
<2> 28d28e0 is still slow, but not that much.
<3> Normally, msvc2019 and msvc2022 have the same performance.

Is it possible to write a PGO profile for 28d28e0? 
https://github.com/python/cpython/commit/28d28e053db6b69d91c2dfd579207cd8ccbc39e7

msvc2022 will be released in November this year, and maybe subsequent versions 
can be built with msvc2022.

--

___
Python tracker 

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



[issue45103] IDLE: make configdialog font page survive font failures

2021-10-08 Thread E. Paine


E. Paine  added the comment:

> Did the FiraCode font work for you or merely not work without crashing?

It worked fine (other than a few missing features such as context-aware 
punctuation).

The steps I did to test were:

- Load IDLE
- Enter config dialog
- Set IDLE to use Fira Code font
- Use 'OK' button to exit config dialog
- Close IDLE
- Reload IDLE
- Enter config dialog
- Revert font

--

___
Python tracker 

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



[issue44359] test_ftplib fails as "env changes" if a socket operation times out in a thread: TimeoutError is not catched

2021-10-08 Thread STINNER Victor


STINNER Victor  added the comment:

Another error on AMD64 Fedora Rawhide LTO + PGO 3.x:
https://buildbot.python.org/all/#/builders/79/builds/870

0:01:10 load avg: 4.48 [236/427/1] test_ftplib failed (env changed) -- running: 
(...)
Warning -- Uncaught thread exception: Exception
Exception in thread Thread-67:
Traceback (most recent call last):
  File 
"/home/buildbot/buildarea/3.x.cstratak-fedora-rawhide-x86_64.lto-pgo/build/Lib/asyncore.py",
 line 90, in read
obj.handle_read_event()
^^^
  File 
"/home/buildbot/buildarea/3.x.cstratak-fedora-rawhide-x86_64.lto-pgo/build/Lib/test/test_ftplib.py",
 line 384, in handle_read_event
self._do_ssl_handshake()

  File 
"/home/buildbot/buildarea/3.x.cstratak-fedora-rawhide-x86_64.lto-pgo/build/Lib/test/test_ftplib.py",
 line 345, in _do_ssl_handshake
self.socket.do_handshake()
^^
  File 
"/home/buildbot/buildarea/3.x.cstratak-fedora-rawhide-x86_64.lto-pgo/build/Lib/ssl.py",
 line 1346, in do_handshake
self._sslobj.do_handshake()
^^^
ssl.SSLZeroReturnError: TLS/SSL connection has been closed (EOF) (_ssl.c:998)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File 
"/home/buildbot/buildarea/3.x.cstratak-fedora-rawhide-x86_64.lto-pgo/build/Lib/threading.py",
 line 1031, in _bootstrap_inner
self.run()
^^
  File 
"/home/buildbot/buildarea/3.x.cstratak-fedora-rawhide-x86_64.lto-pgo/build/Lib/test/test_ftplib.py",
 line 298, in run
asyncore.loop(timeout=0.1, count=1)
^^^
  File 
"/home/buildbot/buildarea/3.x.cstratak-fedora-rawhide-x86_64.lto-pgo/build/Lib/asyncore.py",
 line 214, in loop
poll_fun(timeout, map)
^^
  File 
"/home/buildbot/buildarea/3.x.cstratak-fedora-rawhide-x86_64.lto-pgo/build/Lib/asyncore.py",
 line 157, in poll
read(obj)
^
  File 
"/home/buildbot/buildarea/3.x.cstratak-fedora-rawhide-x86_64.lto-pgo/build/Lib/asyncore.py",
 line 94, in read
obj.handle_error()
^^
  File 
"/home/buildbot/buildarea/3.x.cstratak-fedora-rawhide-x86_64.lto-pgo/build/Lib/test/test_ftplib.py",
 line 421, in handle_error
raise Exception
^^^
Exception

--

___
Python tracker 

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



[issue45410] python -m test -jN: write stderr in stdout to get messages in order

2021-10-08 Thread STINNER Victor


New submission from STINNER Victor :

In buildbot logs, when a worker process is run, two pipes are created for 
stdout and stderr. The problem is that using two pipes produce an output which 
is hard to read.

Pseudo output:
---
stdout time 1
stdout time 2
stdout time 3
stderr time 1
stderr time 2
---

I would prefer:
---
stdout time 1
stderr time 1
stdout time 2
stderr time 2
stdout time 3
---

Real logs:
https://buildbot.python.org/all/#/builders/79/builds/870
---
0:01:10 load avg: 4.48 [236/427/1] test_ftplib failed (env changed) -- (...)
Warning -- Uncaught thread exception: Exception
Exception in thread Thread-67:
Traceback (most recent call last):
  (...)
Exception
test__all__ (test.test_ftplib.MiscTestCase) ... ok
test_abort (test.test_ftplib.TestFTPClass) ... ok
test_acct (test.test_ftplib.TestFTPClass) ... ok
test_all_errors (test.test_ftplib.TestFTPClass) ... ok
(...)
Ran 94 tests in 2.326s
---

The Warning is logged at the beginning, it's not possible to know which test 
emitted this warning.

I propose to write stdout and stderr of a worker process into a single pipe to 
keep messages order.

In the past, I saw buildbot logging stderr messages in a different color. But 
it no longer seems to be the case.

I'm working on a PR.

--
components: Tests
messages: 403467
nosy: vstinner
priority: normal
severity: normal
status: open
title: python -m test -jN: write stderr in stdout to get messages in order
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



[issue45411] Add Mimetypes for Subtitle Files

2021-10-08 Thread Josephine Stolle


New submission from Josephine Stolle :

Since Python is used for webdevelopment, it would be very beneficial for 
developers to have subtitle files as default mimetypes.

--
components: Library (Lib)
messages: 403468
nosy: Josephine-Marie
priority: normal
pull_requests: 27137
severity: normal
status: open
title: Add Mimetypes for Subtitle Files
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



[issue45411] Add Mimetypes for Subtitle Files

2021-10-08 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

What standard specifies these MIME types?

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue45411] Add Mimetypes for Subtitle Files

2021-10-08 Thread Josephine Stolle


Josephine Stolle  added the comment:

text/vtt is has IANA registration 
https://www.iana.org/assignments/media-types/text/vtt 
and .srt is plain/text 
https://www.matroska.org/technical/subtitles.html#srt-subtitles

--

___
Python tracker 

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



[issue45410] python -m test -jN: write stderr in stdout to get messages in order

2021-10-08 Thread STINNER Victor


Change by STINNER Victor :


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

___
Python tracker 

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



[issue45382] platform() is not able to detect windows 11

2021-10-08 Thread STINNER Victor


STINNER Victor  added the comment:

macOS has a similar issue in the platform module. Previously, platform gave the 
darwin kernel version, whereas most users only know macOS versions. See 
bpo-35344.

Even if Microsoft decided to internally stay at 10.x, IMO users really expect 
"Windows 11" when requesting the Windows version, especially in 
platform.platform().

--
nosy: +vstinner

___
Python tracker 

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



[issue45351] asyncio doc: List all sockets in TCP echo server using streams

2021-10-08 Thread STINNER Victor


STINNER Victor  added the comment:

I agree that all socket addresses must be listed. But I would prefer to write a 
single line. Maybe something like:

addresses = ', '.join(sock.getsockname() for sock in server.sockets)
print('Serving on {addresses}')

Do you want to propose a PR to enhance the example?

--
nosy: +vstinner
title: List all sockets in TCP echo server using streams -> asyncio doc: List 
all sockets in TCP echo server using streams
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



[issue45412] [C API] Remove Py_OVERFLOWED(), Py_SET_ERRNO_ON_MATH_ERROR(), Py_ADJUST_ERANGE1()

2021-10-08 Thread STINNER Victor


New submission from STINNER Victor :

I propose to remove the following macros from the Python C API:

* Py_OVERFLOWED()
* _Py_SET_EDOM_FOR_NAN()
* Py_SET_ERRNO_ON_MATH_ERROR()
* Py_SET_ERANGE_IF_OVERFLOW()
* Py_ADJUST_ERANGE1()
* Py_ADJUST_ERANGE2()

Only Py_ADJUST_ERANGE1() and Py_ADJUST_ERANGE2() are still used by Python 
itself, other macros are no longer used since Python 2.7:

* Py_OVERFLOWED(): no longer used since Python 2.7
* _Py_SET_EDOM_FOR_NAN(): used by Py_SET_ERRNO_ON_MATH_ERROR() which is no 
longer used
* Py_SET_ERRNO_ON_MATH_ERROR(): no longer used since Python 2.6
* Py_SET_ERANGE_IF_OVERFLOW(): no longer used since Python 2.4
* Py_ADJUST_ERANGE1(): used by Objects/floatobject.c
* Py_ADJUST_ERANGE2(): used by Objects/complexobject.c

I searched for these macros in the PyPI top 5000 modules: none of these macros 
are used. There is a single match: frozendict-2.0.6 which contains a 
Include/pyport.h copy, but it doesn't use these macros.

--

Py_OVERFLOWED() was used by long_true_divide() and PyLong_AsDouble() in Python 
2.6, but Python 2.7 no longer used them.


(1) Py_OVERFLOWED() call in long_true_divide() was removed in Python 2.7 by 
bpo-1811:

commit 465728364749e903fb4293b2f7a266b58de6bde4
Author: Mark Dickinson 
Date:   Sun Dec 27 14:55:57 2009 +

Issue #1811:  Improve accuracy and consistency of true division for 
integers.


(2) Py_OVERFLOWED() call in PyLong_AsDouble() was removed in Python 2.7 by 
bpo-3166:

commit 6736cf8d20b67b74e8e959622132963285156242
Author: Mark Dickinson 
Date:   Mon Apr 20 21:13:33 2009 +

Issue #3166: Make long -> float (and int -> float) conversions
correctly rounded, using round-half-to-even.  This ensures that the
value of float(n) doesn't depend on whether we're using 15-bit digits
or 30-bit digits for Python longs.

--

Py_SET_ERRNO_ON_MATH_ERROR() and Py_SET_ERANGE_IF_OVERFLOW() were used in 
Objects/mathmodule.c in Python 2.5.


(1) The last call to Py_SET_ERRNO_ON_MATH_ERROR() was removed by in Python 2.6 
by:

commit 6f34109384f3a78d5f4f8bdd418a89caca19631e
Author: Christian Heimes 
Date:   Fri Apr 18 23:13:07 2008 +

I finally got the time to update and merge Mark's and my trunk-math branch. 
The patch is collaborated work of Mark Dickinson and me. It was mostly done a 
few months ago. The patch fixes a lot of loose ends and edge cases related to 
operations with NaN, INF, very small values and complex math.

The patch also adds acosh, asinh, atanh, log1p and copysign to all 
platforms. Finally it fixes differences between platforms like different 
results or exceptions for edge cases. Have fun :)


(2) The last call to Py_SET_ERANGE_IF_OVERFLOW() was removed in Python 2.4 by:

commit 77d9a3effa21b8987ceac26d67ad676e1c5afb49
Author: Hye-Shik Chang 
Date:   Mon Mar 22 08:43:55 2004 +

Patch #871657: Set EDOM for `nan' return values on FreeBSD and OpenBSD.
This fixes a problem that math.sqrt(-1) doesn't raise math.error.

--
components: C API
messages: 403473
nosy: vstinner
priority: normal
severity: normal
status: open
title: [C API] Remove Py_OVERFLOWED(), Py_SET_ERRNO_ON_MATH_ERROR(), 
Py_ADJUST_ERANGE1()
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



[issue45412] [C API] Remove Py_OVERFLOWED(), Py_SET_ERRNO_ON_MATH_ERROR(), Py_ADJUST_ERANGE1()

2021-10-08 Thread STINNER Victor


Change by STINNER Victor :


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

___
Python tracker 

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



[issue45412] [C API] Remove Py_OVERFLOWED(), Py_SET_ERRNO_ON_MATH_ERROR(), Py_ADJUST_ERANGE1()

2021-10-08 Thread STINNER Victor


Change by STINNER Victor :


--
nosy: +mark.dickinson

___
Python tracker 

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



[issue45412] [C API] Remove Py_OVERFLOWED(), Py_SET_ERRNO_ON_MATH_ERROR(), Py_ADJUST_ERANGE1()

2021-10-08 Thread STINNER Victor


STINNER Victor  added the comment:

Py_OVERFLOWED() documentation says that the function is not reliable since C99. 
Python is using C99 since Python 3.6.

/* Py_OVERFLOWED(X)
 * Return 1 iff a libm function overflowed.  Set errno to 0 before calling
 * a libm function, and invoke this macro after, passing the function
 * result.
 * Caution:
 *This isn't reliable.  C99 no longer requires libm to set errno under
 *any exceptional condition, but does require +- HUGE_VAL return
 *values on overflow.  A 754 box *probably* maps HUGE_VAL to a
 *double infinity, and we're cool if that's so, unless the input
 *was an infinity and an infinity is the expected result.  A C89
 *system sets errno to ERANGE, so we check for that too.  We're
 *out of luck if a C99 754 box doesn't map HUGE_VAL to +Inf, or
 *if the returned result is a NaN, or if a C89 box returns HUGE_VAL
 *in non-overflow cases.
 *X is evaluated more than once.
 * Some platforms have better way to spell this, so expect some #ifdef'ery.
 *
 * OpenBSD uses 'isinf()' because a compiler bug on that platform causes
 * the longer macro version to be mis-compiled. This isn't optimal, and
 * should be removed once a newer compiler is available on that platform.
 * The system that had the failure was running OpenBSD 3.2 on Intel, with
 * gcc 2.95.3.
 *
 * According to Tim's checkin, the FreeBSD systems use isinf() to work
 * around a FPE bug on that platform.
 */

--

___
Python tracker 

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



[issue45412] [C API] Remove Py_OVERFLOWED(), Py_SET_ERRNO_ON_MATH_ERROR(), Py_ADJUST_ERANGE1()

2021-10-08 Thread STINNER Victor


STINNER Victor  added the comment:

Py_SET_ERRNO_ON_MATH_ERROR() documentation also says that it is not reliable:

/* Py_SET_ERRNO_ON_MATH_ERROR(x)
 * If a libm function did not set errno, but it looks like the result
 * overflowed or not-a-number, set errno to ERANGE or EDOM.  Set errno
 * to 0 before calling a libm function, and invoke this macro after,
 * passing the function result.
 * Caution:
 *This isn't reliable.  See Py_OVERFLOWED comments.
 *X is evaluated more than once.
 */

--

___
Python tracker 

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



[issue45412] [C API] Remove Py_OVERFLOWED(), Py_SET_ERRNO_ON_MATH_ERROR(), Py_ADJUST_ERANGE1()

2021-10-08 Thread STINNER Victor


STINNER Victor  added the comment:

Py_ADJUST_ERANGE1() is used by float ** float.

Py_ADJUST_ERANGE2() is used by complex ** complex.

--

___
Python tracker 

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



[issue45412] [C API] Remove Py_OVERFLOWED(), Py_SET_ERRNO_ON_MATH_ERROR(), Py_ADJUST_ERANGE1()

2021-10-08 Thread STINNER Victor


STINNER Victor  added the comment:

I add Mark Dickinson and Tim Peters who were involved in changes removing usage 
of these macros.

--
nosy: +tim.peters

___
Python tracker 

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



[issue45411] Add Mimetypes for Subtitle Files

2021-10-08 Thread Julien Palard


Julien Palard  added the comment:

Those two looks legit to me.

--
nosy: +mdk

___
Python tracker 

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



[issue45404] Undefined I_* macros of stropts.h when building Python 3.10 on Ubuntu: fail to build the fcntl module

2021-10-08 Thread STINNER Victor


Change by STINNER Victor :


--
title: Undefined I_* macros when building 3.10 on Ubuntu? -> Undefined I_* 
macros of stropts.h when building Python 3.10 on Ubuntu: fail to build the 
fcntl module

___
Python tracker 

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



[issue45404] Undefined I_* macros when building 3.10 on Ubuntu?

2021-10-08 Thread STINNER Victor


STINNER Victor  added the comment:

On my Fedora 34, the HAVE_STROPTS_H macro is not defined in pyconfig.h:

/* Define to 1 if you have the  header file. */
/* #undef HAVE_STROPTS_H */

I confirm that I cannot find this file:

$ find /usr/include/ -name stropts.h
$ find /usr/lib/gcc/x86_64-redhat-linux/11/ -name stropts.h

--
nosy: +vstinner

___
Python tracker 

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



[issue45410] python -m test -jN: write stderr in stdout to get messages in order

2021-10-08 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset b108db63e02797a795840152b82cab9792fd3ed2 by Victor Stinner in 
branch 'main':
bpo-45410: libregrtest -jN writes stderr into stdout (GH-28819)
https://github.com/python/cpython/commit/b108db63e02797a795840152b82cab9792fd3ed2


--

___
Python tracker 

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



[issue14757] INCA: Inline Caching meets Quickening in Python 3.3

2021-10-08 Thread Guido van Rossum


Guido van Rossum  added the comment:

See GitHub.com/faster-cpython/ideas/issues/93 for a belated follow-up.

--
nosy: +gvanrossum

___
Python tracker 

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



[issue14757] INCA: Inline Caching meets Quickening in Python 3.3

2021-10-08 Thread Guido van Rossum


Guido van Rossum  added the comment:

Followup: https://github.com/faster-cpython/ideas/issues/93

New paper: https://arxiv.org/abs/2109.02958

--

___
Python tracker 

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



[issue14757] INCA: Inline Caching meets Quickening in Python 3.3

2021-10-08 Thread Guido van Rossum


Change by Guido van Rossum :


--
Removed message: https://bugs.python.org/msg403481

___
Python tracker 

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



[issue45357] Idle does not check user config for extention configuration

2021-10-08 Thread CoolCat467


CoolCat467  added the comment:

Yes, changing settings on ZzDummy works correctly, but this is because an entry 
for it exists in the default config file. The problem is when if you attempt to 
add a new extension through the user config file. When IDLE is looking for 
extensions to load, it only checks the default config file, not the user config 
file. So if I add a new extension entry to my ~/.idlerc/config-extensions.cfg 
file, "[lintcheck]\nenable = True", and have a module installed on my system 
called "lintcheck", with a class named "lintcheck". Because IDLE is only 
looking in the default config file for extensions to load, it never finds 
lintcheck and therefore it is never loaded. On the contrary, if it were in the 
system default config file, IDLE would find it and "lintcheck" would be loaded.

--

___
Python tracker 

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



[issue45404] Undefined I_* macros of stropts.h when building Python 3.10 on Ubuntu: fail to build the fcntl module

2021-10-08 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

It is not defined on my Ubuntu 20.04 either. But stropts.h could be installed 
by some Ubuntu package not installed on my computer, or came from some 
non-standard source.

On my computer:

$ dlocate stropts.h
manpages-posix-dev: /usr/share/man/man7/stropts.h.7posix.gz
python3-pycparser: /usr/share/python3-pycparser/fake_libc_include/stropts.h
python-pycparser: /usr/share/python-pycparser/fake_libc_include/stropts.h

$ locate stropts.h
/usr/share/man/man7/stropts.h.7posix.gz
/usr/share/python-pycparser/fake_libc_include/stropts.h
/usr/share/python3-pycparser/fake_libc_include/stropts.h

--

___
Python tracker 

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



[issue45401] logging TimedRotatingFileHandler must not rename devices like /dev/null

2021-10-08 Thread Vinay Sajip


Change by Vinay Sajip :


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

___
Python tracker 

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



[issue45413] Add install scheme for virtual environments

2021-10-08 Thread Filipe Laíns

Change by Filipe Laíns :


--
title: Add install scheme for virtual environment -> Add install scheme for 
virtual environments

___
Python tracker 

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



[issue45413] Add install scheme for virtual environment

2021-10-08 Thread Filipe Laíns

New submission from Filipe Laíns :

Python 3.10 introduced sysconfig._get_preferred_schemes[1], a mechanism to 
allow downstream distributors to overwrite the default install scheme.
This is done to support downstream modifications where distributors change the 
installation layout (eg. different site-packages directory). So, distributors 
will change the default scheme to one that correctly represents their layout.

This presents an issue for projects/people that need to bootstrap virtual 
environments, like virtualenv (see [2]). As distributors might now be 
customizing the default install scheme, there is no guarantee that the 
information returned by sysconfig.get_default_scheme/get_paths is correct for 
the virtual environment, the only guarantee we have is that it correct for the 
*current* environment. When bootstrapping a virtual environment, we need to 
know its layout, so that we can place the files in the correct locations.

The usual solution in situations like this would be to invoke the interpreter 
we are targeting to get the correct information (eg. path/to/python -m 
sysconfig), but that is not possible here as the environment does not exist yet 
-- we are the ones trying to create it.

To solve this issue, I propose the addition of a "virtual" or "venv" install 
scheme, for virtual environments. The idea is that virtual environments 
(defined by the presence of pyvenv.cfg, see [3][4]) will always use this 
scheme, they will use the paths specified by this scheme and 
sysconfig.get_default_scheme will always return it (_get_preferred_schemes 
would have no effect here!).
This makes it possible to know the virtual environment layout for another 
interpreter, via sysconfig.get_paths(scheme='virtual').

I am not cure if this should be adopted in 3.10 or 3.11, as it effectively 
makes it impossible to reliably construct virtual environments, and requires 
workarounds such as [5], that pretty much implements this proposal with 
non-standardized downstream patches.

[1] 
https://docs.python.org/3/library/sysconfig.html#sysconfig._get_preferred_schemes
[2] https://github.com/pypa/virtualenv/issues/2208
[3] https://docs.python.org/3/library/site.html?highlight=pyvenv.cfg
[4] https://docs.python.org/3/library/venv.html?highlight=pyvenv.cfg
[5] https://github.com/pypa/virtualenv/pull/2209

--
assignee: FFY00
messages: 403485
nosy: FFY00, gaborjbernat, hroncok, jaraco
priority: normal
severity: normal
status: open
title: Add install scheme for virtual environment
type: enhancement
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



[issue45413] Add install scheme for virtual environments

2021-10-08 Thread Miro Hrončok

Miro Hrončok  added the comment:

The existing install schemes contain values for all different kinds of OSes, 
somehow named according to them.

If we introduce a single "virtual"/"venv" scheme, it would need to have 
different contents on different OSes (e.g. Windows vs POSIX). I don't think 
that would cause any actual trouble, but it would be somewhat different than 
all the other schemes.

If we introduce multiple ones (e.g. "posix_venv" and "nt_venv") we would need 
an additional layer to get the one appropriate for the current platform.

Hence, I think having a single one is more pragmatic.

--

___
Python tracker 

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



[issue45357] Idle does not check user config for extention configuration

2021-10-08 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

The current configuration design is that user .idlerc config-x.cfg files 
contain changes from the idlelib config-x.def files.  A proposal to change this 
is an enhancement request rather than a bugfix request.  It will make the logic 
more complex, increase maintenance burden, and likely make changes to the 
configuration system harder.

If Python is installed for one user, any changes to config-extensions.def only 
apply to that one user, just as with additions to site-packages.  If Python is 
installed for all users, why shouldn't extensions be available to all, just as 
with additions to site-packages?  Assuming that extensions are by default not 
enabled, users will have to explicitly enable them, just as they have to 
explicitly import added packages.

On a system with non-admin users, such as in a classroom, I can imagine that 
the admin user(s) might not want non-admin users to be able to modify IDLE 
behavior.  I am reluctant to open this can of worms and would not do so by 
myself.

--
stage: patch review -> test needed
type: behavior -> enhancement
versions: +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



[issue45414] pathlib.Path.parents negative indexing is wrong for absolute paths

2021-10-08 Thread Josh Rosenberg


New submission from Josh Rosenberg :

At least on PosixPath (not currently able to try on Windows to check 
WindowsPath, but from a quick code check I think it'll behave the same way), 
the negative indexing added in #21041 is implemented incorrectly for absolute 
paths. Passing either -1 or -2 will return a path representing the root, '/' 
for PosixPath (which should only be returned for -1), and passing an index of 
-3 or beyond returns the value expected for that index + 1, e.g. -3 gets the 
result expected for -2, -4 gets the result for -3, etc. And for the negative 
index that should be equivalent to index 0, you end up with an IndexError.

The underlying problem appears to be that absolute paths (at least, those 
created from a string) are represented in self._parts with the root '/' 
included (redundantly, since self._root has it too), so all the actual 
components of the path are offset by one.

This does not affect slicing (slicing is implemented using range and 
slice.indices to perform normalization from negative to positive indices, so it 
never indexes with a negative index).

Example:

>>> from pathlib import Path
>>> p = Path('/1/2/3')
>>> p._parts
['/', '1', '2', '3']
>>> p.parents[:]
(PosixPath('/1/2'), PosixPath('/1'), PosixPath('/'))
>>> p.parents[-1]
PosixPath('/')
>>> p.parents[-1]._parts  # Still behaves normally as self._root is still '/'
[]
>>> p.parents[-2]
PosixPath('/')
>>> p.parents[-2]._parts
['/']
>>> p.parents[-3]
PosixPath('/1')
>>> p.parents[-4]
Traceback (most recent call last):
...
IndexError: -4

It looks like the underlying problem is that the negative indexing code doesn't 
account for the possibility of '/' being in _parts and behaving as a component 
separate from the directory/files in the path. Frankly, it's a little odd that 
_parts includes '/' at all (Path has a ._root/.root attribute that stores it 
too, and even when '/' isn't in the ._parts/.parts, the generated complete path 
includes it because of ._root), but it looks like the docs guaranteed that 
behavior in their examples.

It looks like one of two options must be chosen:

1. Fix the negative indexing code to account for absolute paths, and ensure 
absolute paths store '/' in ._parts consistently (it should not be possible to 
get two identical Paths, one of which includes '/' in _parts, one of which does 
not, which is possible with the current negative indexing bug; not sure if 
there are any documented code paths that might produce this warped sort of 
object outside of the buggy .parents), or

2. Make no changes to the negative indexing code, but make absolute paths 
*never* store the root as the first element of _parts (.parts can prepend 
self._drive/self._root on demand to match documentation). This probably 
involves more changes (lots of places assume _parts includes the root, e.g. the 
_PathParents class's own __len__ method raises a ValueError when called on the 
warped object returned by p.parents[-1], because it adjusts for the root, and 
the lack of one means it returns a length of -1).

I think #1 is probably the way to go. I believe all that would require is to 
add:

if idx < 0:
return self.__getitem__(len(self) + idx)

just before:

return self._pathcls._from_parsed_parts(self._drv, self._root, 
self._parts[:-idx - 1])

so it never tries to use a negative idx directly (it has to occur after the 
check for valid index in [-len(self), len(self) so very negative indices don't 
recurse until they become positive).

This takes advantage of _PathParents's already adjusting the reported length 
for the presence of drive/root, keeping the code simple; the alternative I came 
up with that doesn't recurse changes the original return line:

return self._pathcls._from_parsed_parts(self._drv, self._root, 
self._parts[:-idx - 1])

to:

adjust = idx >= 0 or not (self._drv or self._root)
return self._pathcls._from_parsed_parts(self._drv, self._root, 
self._parts[:-idx - adjust])

which is frankly terrible, even if it's a little faster.

--
components: Library (Lib)
messages: 403488
nosy: josh.r
priority: normal
severity: normal
status: open
title: pathlib.Path.parents negative indexing is wrong for absolute paths
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



[issue21041] pathlib.PurePath.parents rejects negative indexes

2021-10-08 Thread Josh Rosenberg


Josh Rosenberg  added the comment:

Negative indexing is broken for absolute paths, see #45414.

--
nosy: +josh.r

___
Python tracker 

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



[issue45412] [C API] Remove Py_OVERFLOWED(), Py_SET_ERRNO_ON_MATH_ERROR(), Py_ADJUST_ERANGE1()

2021-10-08 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

And I have doubts about Py_ADJUST_ERANGE2(). I think that it is used 
incorrectly. See issue44970.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue10716] Modernize pydoc to use better HTML and separate CSS

2021-10-08 Thread Víctor Terrón

Change by Víctor Terrón :


--
nosy:  -vterron

___
Python tracker 

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



[issue45414] pathlib.Path.parents negative indexing is wrong for absolute paths

2021-10-08 Thread Paul Ganssle


Change by Paul Ganssle :


--
nosy: +p-ganssle

___
Python tracker 

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



[issue45406] inspect.getouterframes() tracebacks when $CWD does not exists

2021-10-08 Thread Irit Katriel


Irit Katriel  added the comment:

Thanks for the report, crash typically refers to segfaults rather than 
exceptions being raised. Updated versions.

--
nosy: +iritkatriel
type: crash -> behavior
versions: +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



[issue45406] inspect.getouterframes() tracebacks when $CWD does not exists

2021-10-08 Thread Irit Katriel


Change by Irit Katriel :


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

___
Python tracker 

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



[issue45340] Lazily create dictionaries for plain Python objects

2021-10-08 Thread Josh Rosenberg


Josh Rosenberg  added the comment:

Hmm... Key-sharing dictionaries were accepted largely without question because 
they didn't harm code that broke them (said code gained nothing, but lost 
nothing either), and provided a significant benefit. Specifically:

1. They imposed no penalty on code that violated the code-style recommendation 
to initialize all variables consistently in __init__ (code that always ended up 
using a non-sharing dict). Such classes don't benefit, but neither do they get 
penalized (just a minor CPU cost to unshare when it realized sharing wouldn't 
work). 

2. It imposes no penalty for using vars(object)/object.__dict__ when you don't 
modify the set of keys (so reading or changing values of existing attributes 
caused no problems).

The initial version of this worsens case #2; you'd have to convert to 
key-sharing dicts, and possibly to unshared dicts a moment later, if the set of 
attributes is changed. And when it happens, you'd be paying the cost of the now 
defunct values pointer storage for the life of each instance (admittedly a 
small cost).

But the final proposal compounds this, because the penalty for lazy attribute 
creation (directly, or dynamically by modifying via vars()/__dict__) is now a 
per-instance cost of n pointers (one for each value).

The CPython codebase rarely uses lazy attribute creation, but AFAIK there is no 
official recommendation to avoid it (not in PEP 8, not in the official 
tutorial, not even in PEP 412 which introduced Key-Sharing Dictionaries). 
Imposing a fairly significant penalty on people who aren't even violating 
language recommendations, let alone language rules, seems harsh.

I'm not against this initial version (one pointer wasted isn't so bad), but the 
additional waste in the final version worries me greatly.

Beyond the waste, I'm worried how you'd handle the creation of the first 
instance of such a class; you'd need to allocate and initialize an instance 
before you know how many values to tack on to the object. Would the first 
instance use a real dict during the first __init__ call that it would use to 
realloc the instance (and size all future instances) at the end of __init__? Or 
would it be realloc-ing for each and every attribute creation? In either case, 
threading issues seem like a problem.

Seems like:

1. Even in the ideal case, this only slightly improves memory locality, and 
only provides a fixed reduction in memory usage per-instance (the dict header 
and a little allocator round-off waste), not one that scales with number of 
attributes.

2. Classes that would benefit from this would typically do better to use 
__slots__ (now that dataclasses.dataclass supports slots=True, encouraging that 
as a default use case adds little work for class writers to use them)

If the gains are really impressive, might still be worth it. But I'm just 
worried that we'll make the language penalize people who don't know to avoid 
lazy attribute creation. And the complexity of this layered:

1. Not-a-dict
2. Key-sharing-dict
3. Regular dict

approach makes me worry it will allow subtle bugs in key-sharing dicts to go 
unnoticed (because so little code would still use them).

--
nosy: +josh.r

___
Python tracker 

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



[issue45414] pathlib.Path.parents negative indexing is wrong for absolute paths

2021-10-08 Thread Paul Ganssle

Paul Ganssle  added the comment:

This is a great bug report, but for anyone else who gets a bit lost in the 
details, here's the core of the issue:

>>> p = Path("/1/2")
>>> q = Path("1/2")

>>> p.parents[-1]  # This is correct
PosixPath('/')
>>> q.parents[-1]
PosixPath('.')

>>> p.parents[-2]  # Should be PosixPath('/1')
PosixPath('/')
>>> q.parents[-2]
PosixPath('1')

>>> p.parents[-3]  # Should be PosixPath('/1/2')
PosixPath('/1')
>>> q.parents[-3]
PosixPath('1/2')

I think a refactoring where '/' doesn't appear in ._parts would be a good idea 
if we can get past Chesterton's Fence and determine that this was indeed not a 
deliberate design decision (or at least one whose concerns no longer apply), 
but at least in the short term, I agree that transforming negative indexes into 
positive indices is the right, expedient thing to do.

We'll definitely want to make sure that we're careful about bad indices (and 
add relevant tests), though, since it would be easy to get weird behavior where 
too-large negative indexes start "wrapping around" (e.g. p.parents[-4] with 
len(p._parents) == 3 → p.parents[-1]).

--
type:  -> behavior

___
Python tracker 

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



[issue45340] Lazily create dictionaries for plain Python objects

2021-10-08 Thread Josh Rosenberg


Josh Rosenberg  added the comment:

Hmm... And there's one other issue (that wouldn't affect people until they 
actually start worrying about memory overhead). Right now, if you want to 
determine the overhead of an instance, the options are:

1. Has __dict__: sys.getsizeof(obj) + sys.getsizeof(obj.__dict__)
2. Lacks __dict__ (built-ins, slotted classes): sys.getsizeof(obj)

This change would mean even checking if something using this setup has a 
__dict__ creates one. Without additional introspection support, there's no way 
to tell the real memory usage of the instance without changing the memory usage 
(for the worse).

--

___
Python tracker 

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



[issue45415] Assert oparg < INSTR_OFFSET()

2021-10-08 Thread Steve Dower


New submission from Steve Dower :

encodings.search_function is triggering this assertion at Python/ceval.c#L4055:

   TARGET(JUMP_ABSOLUTE) {
PREDICTED(JUMP_ABSOLUTE);
assert(oparg < INSTR_OFFSET());<<<

It seems to be saying that absolute jumps should only go backwards?

The assertion is triggering reliably in a Windows debug build (including as 
part of the build process, which means we can't release right now). I don't see 
anything Windows-specific here though, so I assume it's core and may just be a 
codepath in encodings that Linux doesn't use?

--
components: Interpreter Core
messages: 403495
nosy: steve.dower
priority: release blocker
severity: normal
stage: test needed
status: open
title: Assert oparg < INSTR_OFFSET()
type: compile error
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



[issue45415] Assert oparg < INSTR_OFFSET()

2021-10-08 Thread Steve Dower


Steve Dower  added the comment:

+Pablo because of blocker.

+Mark because it seems like f6eafe18c004 is probably the cause

--
nosy: +Mark.Shannon, pablogsal

___
Python tracker 

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



[issue45414] pathlib.Path.parents negative indexing is wrong for absolute paths

2021-10-08 Thread Josh Rosenberg

Josh Rosenberg  added the comment:

"We'll definitely want to make sure that we're careful about bad indices ... 
since it would be easy to get weird behavior where too-large negative indexes 
start 'wrapping around'"

When I noticed the problem, I originally thought "Hey, the test for a negative 
index can come *before* the range check and save some work for negative 
indices". Then I realized, while composing this bug report, that that would 
make p.parents[-4] with len(p.parents) == 3 → p.parents[-1] as you said, and 
die with a RecursionError for p.parents[-3000] or so. I'm going to ignore the 
possibility I'm sleep-deprived and/or sloppy, and assume a lot of good 
programmers would think to make that "optimization" and accidentally introduce 
new bugs. :-) So yeah, all the tests.

--

___
Python tracker 

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



[issue45415] Assert oparg < INSTR_OFFSET()

2021-10-08 Thread Steve Dower


Steve Dower  added the comment:

Also +Victor, because I think we should switch back to debug builds in CI in 
order to catch failed assertions before they get merged.

Since you're the most strongly against this, I wanted to give you a chance to 
argue against it (or suggest a better approach than just switching to the debug 
build).

--
nosy: +vstinner

___
Python tracker 

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



[issue45415] Assert oparg < INSTR_OFFSET()

2021-10-08 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

I bet you can trigger this on Linux compiling with '--without-computed-gotos'.

Maybe we need a buildbot in that mode

--

___
Python tracker 

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



[issue45416] "loop argument must agree with lock" instantiating asyncio.Condition

2021-10-08 Thread Simon Willison


New submission from Simon Willison :

In Python 3.10 it is not possible to instantiate an asyncio.Condition that 
wraps an asyncio.Lock without raising a "loop argument must agree with lock" 
exception.

This code raises that exception:

asyncio.Condition(asyncio.Lock())

This worked in previous Python versions.

Note that the error only occurs if an event loop is running. Here's a simple 
script that replicates the problem:

import asyncio

# This runs without an exception:
print(asyncio.Condition(asyncio.Lock()))

# This does not work:
async def example():
print(asyncio.Condition(asyncio.Lock()))

# This raises "ValueError: loop argument must agree with lock":
asyncio.run(example())

--
components: asyncio
messages: 403500
nosy: asvetlov, simonw, yselivanov
priority: normal
severity: normal
status: open
title: "loop argument must agree with lock" instantiating asyncio.Condition
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



[issue45416] "loop argument must agree with lock" instantiating asyncio.Condition

2021-10-08 Thread Simon Willison


Simon Willison  added the comment:

I ran across this issue while trying to use the https://pypi.org/project/janus/ 
locking library with Python 3.10 - see my issue on their tracker here: 
https://github.com/aio-libs/janus/issues/358

--

___
Python tracker 

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



[issue45352] Move documentation for typed generic forms of standard collections to collections.abc

2021-10-08 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
stage:  -> needs patch
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



[issue45416] "loop argument must agree with lock" instantiating asyncio.Condition

2021-10-08 Thread Simon Willison


Simon Willison  added the comment:

It looks like the relevant test is here: 
https://github.com/python/cpython/blob/a1092f62492a3fcd6195bea94eccf8d5a300acb1/Lib/test/test_asyncio/test_locks.py#L722-L727

def test_explicit_lock(self):
lock = asyncio.Lock()
cond = asyncio.Condition(lock)

self.assertIs(cond._lock, lock)
self.assertIs(cond._loop, lock._loop)

But... that test doesn't appear to run inside an event loop, so it's not 
covering the behaviour described in this issue.

--

___
Python tracker 

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



[issue45353] sys.modules: dictionary changed size during iteration

2021-10-08 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

Do you have an example for which "for m in sys.modules: print(m, end=' ')" 
fails?  In particular, is there code in the stdlib that fails iterating over 
sys.modules?  If not the latter, this should be closed as 'Not a bug'.

Note that questions about using Python should go elsewhere, such as python-list 
or stackoverflow.

--
nosy: +terry.reedy
stage:  -> test needed
type:  -> behavior
versions: +Python 3.11 -Python 3.8

___
Python tracker 

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



[issue45356] Calling `help` executes @classmethod @property decorated methods

2021-10-08 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

Randolf, what specific behaviors do you consider to be bugs that should be 
fixed.  What would a test of the the changed behavior look like?

This should perhaps be closed as a duplicate of #44904.  Randolf, please check 
and say what you thing.

--
nosy: +terry.reedy
stage:  -> test needed

___
Python tracker 

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



[issue45356] Calling `help` executes @classmethod @property decorated methods

2021-10-08 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

On current 3.9, 3.10, 3.11, on Windows running in IDLE, I see
computing class property ..
computing class property ..
computing class property ..
computing class property ..
computing class property ..
Help ...

--
versions: +Python 3.11 -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



[issue45416] "loop argument must agree with lock" instantiating asyncio.Condition

2021-10-08 Thread Łukasz Langa

Łukasz Langa  added the comment:

Issue confirmed. The problem is that `Condition.__init__` compares its own loop 
with Lock's internal `_loop` attribute. That attribute is set to None unless 
the lock waited to be acquired.

uriyyo, Andrew, Yury, since it's pretty likely that Lock objects will now have 
`_loop` set to None, I think the check for "loop agreement" in Condition is 
kind of useless. So I propose to simply remove it. It's the only such check in 
all of asyncio.

If you insist on keeping the loop check, it should special-case `_loop is None`.

Simon, thanks for your detailed report! As a backwards-compatible workaround 
till we get a fix in, your user code can do the following:

>>> l = asyncio.Lock()
>>> getattr(l, '_get_loop', lambda: None)()
<_UnixSelectorEventLoop running=True closed=False debug=False>

You can use such lock without issues now:

>>> asyncio.Condition(l)


Alternatively, if the above disgusts you and you only want to trigger public 
APIs, you can do this dance:

>>> l = asyncio.Lock()
>>> await l.acquire()  # first acquire will just work
True
>>> try:
...   # second acquire will block so we time it out
...   await asyncio.wait_for(l.acquire(), 0.1)
... except asyncio.TimeoutError:
...   pass
...
>>> l.release()

Now the lock is fully initialized and we can use it:

>>> c = asyncio.Condition(l)

Both workarounds should be compatible with Python 3.7+ asyncio.

--
nosy: +lukasz.langa, uriyyo

___
Python tracker 

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



[issue45414] pathlib.Path.parents negative indexing is wrong for absolute paths

2021-10-08 Thread Josh Rosenberg


Josh Rosenberg  added the comment:

On the subject of sleep-deprived and/or sloppy, just realized:

return self.__getitem__(len(self) + idx)

should really just be:

idx += len(self)

no need to recurse.

--

___
Python tracker 

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



[issue45365] Make concurrent.futures.Future usable outside of executors

2021-10-08 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
stage:  -> test needed
title: concurrent.futures.Future should be suitable for use outside of 
executors -> Make concurrent.futures.Future usable outside of executors
versions: +Python 3.11 -Python 3.10

___
Python tracker 

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



[issue45415] Assert oparg < INSTR_OFFSET()

2021-10-08 Thread Steve Dower


Steve Dower  added the comment:

I can't get it to go with that option (with or without -DDEBUG, which I *think* 
is needed to get assert to work?), and I also don't see anything obvious in the 
changeset I linked. So I guess there's some other assumption that isn't holding?

--

___
Python tracker 

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



[issue45378] Can't find "map" with search on docs.python.org

2021-10-08 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

The iterator classes are not identified as such because being a class instead 
of a function, such as a generator function, is a CPython implementation 
detail, not a language requirement.

Searching for filter seems as bad -- builtin filter is about the 60th hit.  
Builtins should be listed first instead.

--
nosy: +terry.reedy

___
Python tracker 

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



[issue45415] Assert oparg < INSTR_OFFSET()

2021-10-08 Thread Mark Shannon


Mark Shannon  added the comment:

Nothing to do with it being Windows, or computed gotos.
I forgot to bump magic number again :(

--
assignee:  -> Mark.Shannon

___
Python tracker 

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



[issue45415] Assert oparg < INSTR_OFFSET()

2021-10-08 Thread Steve Dower


Steve Dower  added the comment:

*facepalm* on myself, for not even thinking of that. Indeed, clearing all my 
.pyc files fixes it.

I think I got distracted by the error coming from one of the newly frozen 
modules, except because we're in tree it shouldn't be using the frozen one, so 
it is picking up the cached file instead.

--

___
Python tracker 

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



[issue45417] Enum creation non-linear in the number of values

2021-10-08 Thread Oliver Margetts


New submission from Oliver Margetts :

Creating large enums takes a significant amount of time. Moreover this appears 
to be nonlinear in the number of entries in the enum. Locally, importing a 
single python file and taking this to the extreme:

 1000 entries - 0.058s
1 entries - 4.327s

This is partially addressed by https://bugs.python.org/issue38659 and I can 
confirm that using `@_simple_enum` does not have this problem. But it seems 
like that API is only intended for internal use and the 'happy path' for 
user-defined enums is still not good.

Note that it is not simply parsing the file / creating the instances, it is to 
do with the cardinality. Creating 100 enums with 100 entries each is far faster 
than a single 1 entry enum.

--
files: huge.py
messages: 403512
nosy: olliemath
priority: normal
severity: normal
status: open
title: Enum creation non-linear in the number of values
type: performance
versions: Python 3.10, Python 3.11, Python 3.7
Added file: https://bugs.python.org/file50332/huge.py

___
Python tracker 

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



[issue45413] Add install scheme for virtual environments

2021-10-08 Thread Filipe Laíns

Filipe Laíns  added the comment:

Yes, we could have several schemes, but I think having only one is more 
sensible.

The implementation would be fairly easy. We would just copy the "nt" scheme if 
on Windows, otherwise "posix_prefix".

--

___
Python tracker 

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



[issue45399] Remove hostflags from PySSLContext

2021-10-08 Thread komugi


komugi  added the comment:

Hi, I would like to work on it. I'll send the PR tomorrow.

--
nosy: +komugi

___
Python tracker 

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



[issue45405] configure fails on macOS with non-Apple clang version 13 which implements --print-multiarch

2021-10-08 Thread Ned Deily


Ned Deily  added the comment:

OK, I've had a chance to look at this issue and I now understand what you were 
describing. So, yes, it would be good to fix the test in configure so that it 
does work with a newer clang that does implement the --print-multiarch command 
line option. FTR, this is not an issue with clang from any Apple tools chains 
(Xcode or Command Line Tools) released to this point. A PR against configure.ac 
in main would be welcome, we can auto-backport to other active branches as 
necessary. We currently use autoconf 2.69 but, if that is not available, a core 
developer can regenerate configure prior to merging.

--
stage:  -> needs patch
title: Python does not configure on darwin using public llvm / clang version 
13.0.0 -> configure fails on macOS with non-Apple clang version 13 which 
implements --print-multiarch
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



[issue45415] Assert oparg < INSTR_OFFSET()

2021-10-08 Thread Ken Jin


Ken Jin  added the comment:

> I think we should switch back to debug builds in CI in order to catch failed 
> assertions before they get merged.

I'm not Victor, but +1. I've been bitten by release builds not catching things, 
see issue44348 for example where I advocated for switching back to debug builds 
for Windows.

FWIW, the macOS and Ubuntu CI use debug builds too. So I don't see why Windows 
is special.

--
nosy: +kj

___
Python tracker 

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



[issue45260] Implement superinstruction UNPACK_SEQUENCE_ST

2021-10-08 Thread zcpara


Change by zcpara :


--
nosy: +Mark.Shannon

___
Python tracker 

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



[issue38659] enum classes cause slow startup time

2021-10-08 Thread Armin Rigo


Armin Rigo  added the comment:

Nobody seemed to mention it so I might as well: defining a regular Enum class 
takes an amount of time that is clearly quadratic in the number of attributes.  
That means that the problem is not Python-versus-C or small speed-ups or adding 
secret APIs to do the simple case faster.  The problem is in the algorithm 
which needs to be fixed somewhere.  My timings:

number of attributes time
1500 0.24s
3000 0.94s
6000 3.74s
1200015.57s

--
nosy: +arigo

___
Python tracker 

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



[issue45399] Remove hostflags from PySSLContext

2021-10-08 Thread ramikg


ramikg  added the comment:

In addition to https://github.com/python/cpython/pull/28602?
What would the PR include?

--

___
Python tracker 

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