[issue44372] Can't install Python3.8, 3.9, 3.10 various errors including 0x80070643

2021-06-10 Thread Thomas Schweikle


New submission from Thomas Schweikle :

Python Setup for python-3.8.10-amd64.exe, python-3.9.5-amd64.exe, 
python10.0b2-amd64.exe fails after exausting "No Python 3.8 installation was 
detected.", then again "No Python 3.8 installation was detected." next it tells 
about "Error 0x80070643 while installing".

Non of the workarounds you'll able to find will work.

Looking into the registry you'll find various entries like:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Components\0255A3B1CB3E0445EBD928E5D9ABECFD]
"8400E080C358BF9469DE03ED7FBAE643"="C:\\Program 
Files\\Python\\38\\Lib\\lib2to3\\fixes\\fix_funcattrs.py"

I could find ~300 entries for Python 3.8, ~400 entries for Python 3.9 and ~1000 
entries for Python 3.10.

I've installed into a new windows 10, then removed Python 3.8 looked into the 
registry and found -- nothing. Tried the same, but this time installed Python 
3.8 and Python 3.9 in parallel before removing Python 3.8 and then Python 3.9. 
Again nothing. Next try: installed Python 3.8.9, then Python 3.9.0. Next 
upgraded Python 3.8.9 to 3.8.10. Then upgraded Python 3.9.0 to 3.9.5. Then 
removed Python 3.8.10 and Python 3.9.5. Voila! Lots of entries!

Conclusion: the installer does what it is expected to do, as long as you 
install and then remove the same version. As soon, as you upgraded in between, 
then remove it will leave various entries in the registry behind and 
reinstalling will fail with error 0x80070643.

Your installer has to do its work different: do not upgrade an existing 
installation "in line", but backup necessary parts, then remove the existing 
installation, clean up registry, then install the new version, restore what you 
backed up before.
Seems the installer looses track of these registry entries if upgrades are done 
inline and later on these existing entries make reinstalling/upgrading 
impossible.

--
components: Installation
messages: 395510
nosy: tps800
priority: normal
severity: normal
status: open
title: Can't install Python3.8, 3.9, 3.10 various errors including 0x80070643
type: crash
versions: Python 3.10, 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



[issue44373] make Event and Awaitable

2021-06-10 Thread Kaleb Barrett


New submission from Kaleb Barrett :

Following on from https://bugs.python.org/issue33544. I don't agree with the 
original suggestion to deprecate the wait() method on Events, but I do agree 
that Event should be made Awaitable. Doing so would make code more expressive, 
but more importantly improve the ability to use Events with generic code that 
can already handles the other Awaitable types in asyncio.

There were generally neutral takes on providing both __await__ and wait, 
besides Yury Selivanov who implied it was complex (???). I just tried the 
below, but maybe I'm missing something?


class AwaitableEvent(Awaitable[None], Event):

def __await__(self) -> None:
yield from self.wait().__await__()

__iter__ = __await__

--
components: asyncio
messages: 395511
nosy: asvetlov, ktbarrett, yselivanov
priority: normal
severity: normal
status: open
title: make Event and Awaitable
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



[issue44353] PEP 604 NewType

2021-06-10 Thread Dominic Davis-Foster


Dominic Davis-Foster  added the comment:

It is possible to implement NewType to return a class rather than a function as 
it does currently. However, the class version uses substantially more memory 
(1072 bytes vs 144 bytes with sys.getsizeof) and NewType is supposed to have 
almost no runtime overhead.

--
nosy: +domdfcoding

___
Python tracker 

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



[issue44337] Port LOAD_ATTR to adaptive interpreter

2021-06-10 Thread Mark Shannon


Mark Shannon  added the comment:


New changeset e117c0283705943189e6b1aef668a1f68f3f00a4 by Mark Shannon in 
branch 'main':
bpo-44337: Port LOAD_ATTR to PEP 659 adaptive interpreter (GH-26595)
https://github.com/python/cpython/commit/e117c0283705943189e6b1aef668a1f68f3f00a4


--

___
Python tracker 

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



[issue44348] test_exceptions.ExceptionTests.test_recursion_in_except_handler stack overflow on Windows debug builds

2021-06-10 Thread Mark Shannon


Mark Shannon  added the comment:


New changeset 54cb63863f19a7c64d9a3a5fd97bdfc0dd7ab374 by Mark Shannon in 
branch 'main':
bpo-44348: Move trace-info to thread-state (GH-26623)
https://github.com/python/cpython/commit/54cb63863f19a7c64d9a3a5fd97bdfc0dd7ab374


--

___
Python tracker 

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



[issue44363] Address sanitizer (gcc version) is generating false positives

2021-06-10 Thread Mark Shannon


Mark Shannon  added the comment:

It looks like I've been a bit unfair to the address sanitizer.

It does appear to produce incorrect locations sometimes, but that's not really 
a false positive and the reports are generally useful.

--

___
Python tracker 

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



[issue44372] Can't install Python3.8, 3.9, 3.10 various errors including 0x80070643

2021-06-10 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
components: +Windows
nosy: +paul.moore, steve.dower, 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



[issue44313] Generate LOAD_ATTR+CALL_FUNCTION instead of LOAD_METHOD+CALL_METHOD for imports

2021-06-10 Thread Mark Shannon


Mark Shannon  added the comment:

Yes. Simpler is good.


I think it will also be better for performance:

In general, we don't know what X is in `from Y import X`. It could be a module 
or anything else.

However, if we are accessing an attribute it is quite likely to be a module or 
class.
For `X` defined by `from Y import X`, `X` is likely to be a module, class, 
function, or some sort of constant like a string, int or Enum.

If it is a string, int or function then it is rare to call a method on it, so 
we can ignore that case.
Calling methods on an Enum constant is probably not very common either (I'm 
guessing here)

For a module, `LOAD_ATTR; CALL_FUNCTION` is clearly better than `LOAD_METHOD; 
CALL_METHOD`.

For a class, specializing `LOAD_ATTR` is no more complex than `LOAD_METHOD`, 
probably simpler.
So, for a class `LOAD_ATTR; CALL_FUNCTION` is no worse than `LOAD_METHOD; 
CALL_METHOD`, and might be better.


Overall, it looks like `X.foo()` when `X` is defiend by `from Y import X` is 
best as `LOAD_ATTR; CALL_FUNCTION` not `LOAD_METHOD; CALL_METHOD`.

--

___
Python tracker 

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



[issue44337] Port LOAD_ATTR to adaptive interpreter

2021-06-10 Thread Mark Shannon


Change by Mark Shannon :


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



[issue44338] Port LOAD_GLOBAL to adaptive interpreter

2021-06-10 Thread Mark Shannon


Change by Mark Shannon :


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

___
Python tracker 

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



[issue44313] Generate LOAD_ATTR+CALL_FUNCTION instead of LOAD_METHOD+CALL_METHOD for imports

2021-06-10 Thread Dong-hee Na


Change by Dong-hee Na :


--
nosy: +corona10

___
Python tracker 

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



[issue44370] Inconsistent results for min() and max() with math.nan as argument

2021-06-10 Thread Steven D'Aprano


Change by Steven D'Aprano :


--
nosy: +steven.daprano

___
Python tracker 

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



[issue44360] test_compile killed by SIGKILL on AMD64 Ubuntu 3.x (Linux OOM Killer)

2021-06-10 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
resolution:  -> not a bug
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



[issue44374] PyThreadState_IsCurrent bug under building Python with --with-experimental-isolated-subinterpreters

2021-06-10 Thread junyixie


New submission from junyixie :

under building Python with --with-experimental-isolated-subinterpreters
PyThreadState_IsCurrent use _PyRuntime.gilstate. is shared by multi sub 
interpreters.
Use interpreter `gil->last_holder == state` can fix it? 



```
static int
PyThreadState_IsCurrent(PyThreadState *tstate)
{
/* Must be the tstate for this thread */
struct _gilstate_runtime_state *gilstate = &_PyRuntime.gilstate;
assert(_PyGILState_GetThisThreadState(gilstate) == tstate);
return tstate == _PyRuntimeGILState_GetThreadState(gilstate);
}
```


```
static int
PyThreadState_IsCurrent(PyThreadState *tstate)
{
#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
PyInterpreterState *interp = tstate->interp;
struct _ceval_state *ceval2 = &interp->ceval;
struct _gil_runtime_state *gil = &ceval2->gil;
return tstate == (PyThreadState*)_Py_atomic_load_relaxed(&gil->last_holder);
#else
/* Must be the tstate for this thread */
struct _gilstate_runtime_state *gilstate = &_PyRuntime.gilstate;
assert(_PyGILState_GetThisThreadState(gilstate) == tstate);
return tstate == _PyRuntimeGILState_GetThreadState(gilstate);
#endif
}
```

--
components: Subinterpreters
messages: 395517
nosy: JunyiXie, vstinner
priority: normal
severity: normal
status: open
title: PyThreadState_IsCurrent bug under building Python with 
--with-experimental-isolated-subinterpreters
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



[issue44363] Address sanitizer (gcc version) is generating false positives

2021-06-10 Thread Mark Shannon


Change by Mark Shannon :


--
pull_requests: +25226
pull_request: https://github.com/python/cpython/pull/26639

___
Python tracker 

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



[issue44375] urllib.parse.urlparse is not parsing the url properly

2021-06-10 Thread Neethu


New submission from Neethu :

urllib.parse.urlparse is not parsing urls without scheme and with port number 
properly.

from urllib.parse import urlparse
print(urlparse("www.cwi.nl:80"))

ParseResult(scheme='www.cwi.nl', netloc='', path='80', params='', query='', 
fragment='')

Python version : 3.9.5

--
messages: 395518
nosy: neethun
priority: normal
severity: normal
status: open
title: urllib.parse.urlparse is not parsing the url properly
versions: Python 3.9

___
Python tracker 

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



[issue44353] PEP 604 NewType

2021-06-10 Thread Yurii Karabas


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

What about to return callable object instead of function from a 
`typing.NewType`?

It will look something like this:
```
class _NewType:
__slots__ = ('__name__', '__supertype__')

def __init__(self, name, supertype):
self.__name__ = name
self.__supertype__ = supertype

def __call__(self, val):
return val

def __or__(self, other):
return Union[self, other]

def __ror__(self, other):
return Union[other, self]



def NewType(name, tp):
"""NewType creates simple unique types with almost zero
runtime overhead. NewType(name, tp) is considered a subtype of tp
by static type checkers. At runtime, NewType(name, tp) returns
a dummy callable object that simply returns its argument. Usage::

UserId = NewType('UserId', int)

def name_by_id(user_id: UserId) -> str:
...

UserId('user')  # Fails type check

name_by_id(42)  # Fails type check
name_by_id(UserId(42))  # OK

num = UserId(5) + 1 # type: int
"""
return _NewType(name, tp)
``` 

With such implementation `__or__` will be available for a NewType and actually 
because of __slots__ size of object will be 48 bytes (with sys.getsizeof) which 
is less than current 144 bytes (if memory is important).

--
nosy: +uriyyo

___
Python tracker 

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



[issue44363] Address sanitizer (gcc version) is generating false positives

2021-06-10 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:


New changeset 31aa0dbff4c1d39c9d77c6c8f4a61d0e46c1268b by Mark Shannon in 
branch 'main':
bpo-44363: Get test_capi passing with address sanitizer (GH-26639)
https://github.com/python/cpython/commit/31aa0dbff4c1d39c9d77c6c8f4a61d0e46c1268b


--

___
Python tracker 

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



[issue44363] Address sanitizer (gcc version) is generating false positives

2021-06-10 Thread miss-islington


Change by miss-islington :


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

___
Python tracker 

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



[issue44363] Address sanitizer (gcc version) is generating false positives

2021-06-10 Thread miss-islington


Change by miss-islington :


--
pull_requests: +25228
pull_request: https://github.com/python/cpython/pull/26642

___
Python tracker 

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



[issue44370] Inconsistent results for min() and max() with math.nan as argument

2021-06-10 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

math.ieee754_total_order sounds good to me, but how would you get the minimum?

Wikipedia doesn't have much on the 2019 revision to IEEE-754 except to say that 
the min/max rules have been overhauled again, but without giving much detail.

https://en.wikipedia.org/wiki/IEEE_754

Also relevant:

https://grouper.ieee.org/groups/msc/ANSI_IEEE-Std-754-2019/background/minNum_maxNum_Removal_Demotion_v3.pdf

--

___
Python tracker 

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



[issue44375] urllib.parse.urlparse is not parsing the url properly

2021-06-10 Thread Gnanesh

Gnanesh  added the comment:

Hey neethu,

For empty schemes, it should have a prefix of "//" in the URL to parse it 
correctly.

Try:
> urlparse('//www.cwi.nl:80')

ParseResult(scheme='', netloc='www.cwi.nl:80', path='', params='', query='', 
fragment='')


Here's a comment from the docs 
(https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urlparse): 
> Following the syntax specifications in RFC 1808, urlparse recognizes a netloc 
> only if it is properly introduced by ‘//’. Otherwise the input is presumed to 
> be a relative URL and thus to start with a path component.

--
nosy: +Gnanesh

___
Python tracker 

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



[issue44363] Address sanitizer (gcc version) is generating false positives

2021-06-10 Thread miss-islington


miss-islington  added the comment:


New changeset 865269458fde83f58f056d02a777e4328c763880 by Miss Islington (bot) 
in branch '3.9':
bpo-44363: Get test_capi passing with address sanitizer (GH-26639)
https://github.com/python/cpython/commit/865269458fde83f58f056d02a777e4328c763880


--

___
Python tracker 

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



[issue44354] ssl deprecation warnings erganomics

2021-06-10 Thread Thomas Grainger


Thomas Grainger  added the comment:

it looks like OP_NO_SSLv2 and OP_NO_SSLv3 are not raising a DeprecationWarning


```
python310 -W error
Python 3.10.0b2 (default, Jun  2 2021, 00:22:18) [GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
>>> ssl.SSLContext(ssl.PROTOCOL_TLS)
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python3.10/ssl.py", line 501, in __new__
self = _SSLContext.__new__(cls, protocol)
DeprecationWarning: ssl module: PROTOCOL_TLS is deprecated
>>> ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)

>>> c = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
>>> c.options |= ssl.OP_NO_SSLv2  # no deprecation warning!?
>>> c.options |= ssl.OP_NO_SSLv3  # no deprecation warning!?
>>> c.options |= ssl.OP_NO_TLSv1
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python3.10/ssl.py", line 621, in options
super(SSLContext, SSLContext).options.__set__(self, value)
DeprecationWarning: ssl module: Setting OP_NO_SSL* or SSL_NO_TLS* options is 
deprecated is deprecated
```

--

___
Python tracker 

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



[issue44363] Address sanitizer (gcc version) is generating false positives

2021-06-10 Thread miss-islington


miss-islington  added the comment:


New changeset 0895e62c9b4f03b83120d44cb32587804084e0e2 by Miss Islington (bot) 
in branch '3.10':
bpo-44363: Get test_capi passing with address sanitizer (GH-26639)
https://github.com/python/cpython/commit/0895e62c9b4f03b83120d44cb32587804084e0e2


--

___
Python tracker 

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



[issue44354] ssl deprecation warnings erganomics

2021-06-10 Thread Christian Heimes


Christian Heimes  added the comment:

ctx.options |= ssl.OP_NO_SSLv2 and ctx.options |= ssl.OP_NO_SSLv3 are no-ops 
and don't modify the value of ctx.options. OP_NO_SSLv2 == 0 and OP_NO_SSLv3 is 
set by default:

>>> ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
>>> ctx.options
ssl.OP_NO_COMPRESSION|ssl.OP_ENABLE_MIDDLEBOX_COMPAT|ssl.OP_CIPHER_SERVER_PREFERENCE|ssl.OP_NO_SSLv3|0x8054
>>> int(ssl.OP_NO_SSLv2)
0

--

___
Python tracker 

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



[issue44376] Improve performance of integer exponentiation

2021-06-10 Thread Steven D'Aprano


New submission from Steven D'Aprano :

Naively, I assumed that `x**2` would be faster than `x*x` as there is only one 
name lookup in the first, and two in the second. But it is slower.

The performance of `x**2` relative to `x*x` has gradually deteriorated compared 
to `x*x` over many versions.

I have found the ratio of `x**2` to `x*x` using timeit:

pythonX.Y -m timeit -s "x=115" "x**2"
pythonX.Y -m timeit -s "x=115" "x*x"

for various X.Y:

2.4: 1.1  # ratio of time for x**2 / time for x*x
2.5: 1.5
2.6: 1.0
2.7: 1.6
3.2: 4.2
3.3: 4.2
3.5: 3.8
3.7: 5.9
3.9: 7.3


In the 2.x series, performance was quite close. In 3.x, the ratio has increased 
significantly. Either integer multiplication has gotten much faster, or 
exponentiation much slower, or both.

Shockingly (to me at least), an exponent of 1 is an order of magnitude slower 
than an multiplicand of 1:

2.7: 1.3  # ratio of time for x**1 / time for x*1
3.9: 10.2


Even an exponent of 10 is a little slower than repeated multiplication in 3.9:

`x*x*x*x*x*x*x*x*x*x` is slightly faster than `x**10`.


It would be nice if we could improve the performance of exponentiation.


(OS: Linux)

--
components: Interpreter Core
messages: 395527
nosy: steven.daprano
priority: normal
severity: normal
status: open
title: Improve performance of integer exponentiation
type: performance
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



[issue44354] ssl deprecation warnings erganomics

2021-06-10 Thread Thomas Grainger


Thomas Grainger  added the comment:

there should still be a deprecation warning so that 3.12 can raise 
AttributeError

--

___
Python tracker 

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



[issue44377] Truncated error message of original function while multiprocessing or multithreading

2021-06-10 Thread Prasanth Rajendran


New submission from Prasanth Rajendran :

Under multiprocessing package, in pool.py, when an error occurs on line 122:
result = (True, func(*args, **kwds))

The exception "e" has the error message due to execution of the function that 
is executed in parallel. 

However, the error message is lost when another error is occurred due to the 
execution of following line 128:
put((job, i, result))

The MaybeEncodingError masks or truncates the original error message, due to 
the following line at 130:
MaybeEncodingError(e, result[1])

where the repr function in the class truncates the message. 

The final error message has pickling error and the masked error of the actual 
execution.

--
components: Library (Lib)
messages: 395529
nosy: mrshanth
priority: normal
severity: normal
status: open
title: Truncated error message of original function while multiprocessing or 
multithreading
versions: Python 3.7

___
Python tracker 

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



[issue44347] Unclear documentation for shutil.copytree()

2021-06-10 Thread Jack DeVries


Change by Jack DeVries :


--
pull_requests: +25229
pull_request: https://github.com/python/cpython/pull/26643

___
Python tracker 

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



[issue43298] Windows build cannot detect missing Windows SDK

2021-06-10 Thread Jason R. Coombs


Jason R. Coombs  added the comment:

In issue44246, I've encountered this error while attempting to build CPython in 
a Docker image (built from 
https://github.com/jaraco/jaraco.windows/blob/d2edad2e2af9d469189d7ac6a14a4ba6f6270348/Dockerfile).
 Any suggestions on how to install the SDK to a viable version in a headless 
environment?

--
nosy: +jaraco

___
Python tracker 

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



[issue44246] 3.10 beta 1: breaking change in importlib.metadata entry points

2021-06-10 Thread Jason R. Coombs


Jason R. Coombs  added the comment:

The build error is tracked in issue43298.

--

___
Python tracker 

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



[issue44362] improve documentation of SSL deprecations

2021-06-10 Thread Jack DeVries


Jack DeVries  added the comment:

Would you like me to submit a PR for this simple patch?

https://github.com/jdevries3133/cpython/commit/42d9bd7f97f03b49d4fc89780616704998492ac1

--

___
Python tracker 

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



[issue44362] improve documentation of SSL deprecations

2021-06-10 Thread Thomas Grainger


Thomas Grainger  added the comment:

> Would you like me to submit a PR for this simple patch?
> 
> https://github.com/jdevries3133/cpython/commit/42d9bd7f97f03b49d4fc89780616704998492ac1


TLS_PROTOCOL_CLIENT and TLS_PROTOCOL_SERVER are defined in terms of the 
deprecated TLS_PROTOCOL, so now this makes the definition circular

--

___
Python tracker 

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



[issue44362] improve documentation of SSL deprecations

2021-06-10 Thread Christian Heimes


Change by Christian Heimes :


--
nosy:  -christian.heimes

___
Python tracker 

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



[issue44354] ssl deprecation warnings erganomics

2021-06-10 Thread Christian Heimes


Change by Christian Heimes :


--
nosy:  -christian.heimes

___
Python tracker 

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



[issue44378] Py_IS_TYPE(): cast discards ‘const’ qualifier from pointer target type

2021-06-10 Thread STINNER Victor

New submission from STINNER Victor :

The following change introduced a compiler warning:

commit c5cb077ab3c88394b7ac8ed4e746bd31b53e39f1
Author: Victor Stinner 
Date:   Tue Sep 22 12:42:28 2020 +0200

Py_IS_TYPE() macro uses Py_TYPE() (GH-22341)

Steps to Reproduce:

1. dnf install -y python3-devel pkgconf-pkg-config gcc
2. printf '#include ' > test.c
3. gcc -Wcast-qual -Werror -c test.c `pkg-config --cflags --libs python-3.10`

Actual results:
sh-5.1# gcc -Wcast-qual -Werror -c test.c `pkg-config --cflags --libs 
python-3.10`
In file included from /usr/include/python3.10/Python.h:78,
 from test.c:1:
/usr/include/python3.10/object.h: In function ‘_Py_IS_TYPE’:
/usr/include/python3.10/object.h:112:29: error: cast discards ‘const’ qualifier 
from pointer target type [-Werror=cast-qual]
  112 | #define _PyObject_CAST(op) ((PyObject*)(op))
  | ^
/usr/include/python3.10/object.h:137:34: note: in expansion of macro 
‘_PyObject_CAST’
  137 | #define Py_TYPE(ob) (_PyObject_CAST(ob)->ob_type)
  |  ^~
/usr/include/python3.10/object.h:144:12: note: in expansion of macro ‘Py_TYPE’
  144 | return Py_TYPE(ob) == type;
  |^~~
cc1: all warnings being treated as errors


Attached PR fix the compiler warning.


Issue reported on Fedora: https://bugzilla.redhat.com/show_bug.cgi?id=1969663

--
components: C API
messages: 395534
nosy: vstinner
priority: normal
severity: normal
status: open
title: Py_IS_TYPE(): cast discards ‘const’ qualifier from pointer target type
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



[issue44378] Py_IS_TYPE(): cast discards ‘const’ qualifier from pointer target type

2021-06-10 Thread STINNER Victor


Change by STINNER Victor :


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

___
Python tracker 

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



[issue44378] Py_IS_TYPE(): cast discards ‘const’ qualifier from pointer target type

2021-06-10 Thread STINNER Victor


STINNER Victor  added the comment:

Comment from my PR:

// bpo-44378: Don't use Py_TYPE() since Py_TYPE() requires a non-const
// object.

By the way, I wrote a change in Python 3.11 to convert Py_TYPE() macro into a 
static inline function which accepts a *const* PyObject pointer ("const 
PyObject*"):
https://github.com/python/cpython/commit/f3fa63ec75fdbb4a08a10957a5c631bf0c4a5970

But this change had to be reverted since it caused a buildbot regression 
(bpo-44348).

--

___
Python tracker 

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



[issue39573] [C API] Make PyObject an opaque structure in the limited C API

2021-06-10 Thread STINNER Victor

STINNER Victor  added the comment:

See also bpo-44378: "Py_IS_TYPE(): cast discards ‘const’ qualifier from pointer 
target type".

If Py_TYPE() is converted again to a static inline function which takes a 
"const PyObject*" type, Py_IS_TYPE() can be modified again at the same time to 
use Py_TYPE().

--

___
Python tracker 

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



[issue44365] Bad dataclass post-init example

2021-06-10 Thread Eric V. Smith


Eric V. Smith  added the comment:

The example was added in https://github.com/python/cpython/pull/25967

When reviewing it, I think I missed the fact that the base class is a 
dataclass. The example and text make more sense if Rectangle isn't a dataclass. 
Still, I don't like the example at all. I think deleting it might be the best 
thing to do. Or maybe come up with a case where the base class is some existing 
class in the stdlib that isn't a dataclass.

--

___
Python tracker 

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



[issue44353] PEP 604 NewType

2021-06-10 Thread Ken Jin


Change by Ken Jin :


--
nosy: +Jelle Zijlstra, gvanrossum, kj, levkivskyi
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



[issue44353] PEP 604 NewType

2021-06-10 Thread Jelle Zijlstra


Jelle Zijlstra  added the comment:

https://github.com/python/typing/issues/746 has some previous discussion of 
implementing NewType as a class (motivated by __repr__), including benchmarks.

--

___
Python tracker 

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



[issue44242] enum.IntFlag regression: missing values cause TypeError

2021-06-10 Thread Ethan Furman


Ethan Furman  added the comment:


New changeset 749648609de89f14581190ea34b9c0968787a701 by Ethan Furman in 
branch '3.10':
[3.10] bpo-44242: [Enum] remove missing bits test from Flag creation (GH-26586) 
(GH-26635)
https://github.com/python/cpython/commit/749648609de89f14581190ea34b9c0968787a701


--

___
Python tracker 

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



[issue43318] pdb does not output the prompt message when successfully clear breakpoints by "filename:lineno"

2021-06-10 Thread Irit Katriel


Irit Katriel  added the comment:

Your fix looks correct - the problem is that the list of breakpoints gets 
emptied by the clear_break call, and you copy the list so that it can be echoed 
later if clear_break does not err.

I made some polishing comments on the PR, and it also need to be rebased 
because there is not a merge conflict on test_pdb.

--
title: pdb can't output the prompt message when successfully clear breakpoints 
by "filename:lineno" -> pdb does not output the prompt message when 
successfully clear breakpoints by "filename:lineno"
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



[issue44365] Bad dataclass post-init example

2021-06-10 Thread Micael Jarniac


Micael Jarniac  added the comment:

I'm trying to think of an example, and what I've thought of so far is having a 
base dataclass that has a `__post_init__` method, and another dataclass that 
inherits from it and also has a `__post_init__` method.

In that case, the subclass might need to call `super().__post_init__()` inside 
its own `__post_init__` method, because otherwise, that wouldn't get called 
automatically.

Something along those lines:

>>> from dataclasses import dataclass, field
>>>
>>> @dataclass
... class A:
... x: int
... y: int
... xy: int = field(init=False)
...
... def __post_init__(self) -> None:
... self.xy = self.x * self.y
...
>>> @dataclass
... class B(A):
... m: int
... n: int
... mn: int = field(init=False)
...
... def __post_init__(self) -> None:
... super().__post_init__()
... self.mn = self.m * self.n
...
>>> b = B(x=2, y=4, m=3, n=6)
>>> b
B(x=2, y=4, xy=8, m=3, n=6, mn=18)

In this example, if not for the `super().__post_init__()` call inside B's 
`__post_init__`, we'd get an error `AttributeError: 'B' object has no attribute 
'xy'`.

I believe this could be an actual pattern that could be used when dealing with 
dataclasses.

--

___
Python tracker 

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



[issue37022] pdb: do_p and do_pp swallow exceptions from __repr__

2021-06-10 Thread Irit Katriel


Change by Irit Katriel :


--
versions: +Python 3.10, Python 3.11 -Python 3.7, Python 3.8

___
Python tracker 

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



[issue44376] Improve performance of integer exponentiation

2021-06-10 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +mark.dickinson

___
Python tracker 

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



[issue44379] Pickling recursion error, did not import pickle

2021-06-10 Thread Violet Godfrey


New submission from Violet Godfrey :

I accidentally created an infinite recursion. The error referenced pickling but 
I did not import pickle. 

To reproduce: 
def permute(inputList):
'''permute(inputList) -> list
returns list of all permutations of inputList
CURRENTLY DOESN'T ACTUALLLY WORK PROPERLY'''
for i in range(len(inputList)-1):
tempList = inputList[:-i-2]
tempList.append(inputList[-1])
for num in inputList[-i-2:-1]:
tempList.append(num)
print(tempList)
permute(tempList)  # runs infinitely (whoops)
print()

permute([1,2,3,4])

Error thrown: 
Traceback (most recent call last):
  File "C:\Users\Violet\Documents\Python Files\test.py", line 14, in 
permute([1,2,3,4])
  File "C:\Users\Violet\Documents\Python Files\test.py", line 11, in permute
permute(tempList)  # runs infinitely (whoops)
  File "C:\Users\Violet\Documents\Python Files\test.py", line 11, in permute
permute(tempList)  # runs infinitely (whoops)
  File "C:\Users\Violet\Documents\Python Files\test.py", line 11, in permute
permute(tempList)  # runs infinitely (whoops)
  [Previous line repeated 1009 more times]
  File "C:\Users\Violet\Documents\Python Files\test.py", line 10, in permute
print(tempList)
RecursionError: maximum recursion depth exceeded while pickling an object

--
assignee: terry.reedy
components: IDLE
messages: 395542
nosy: Octopi, terry.reedy
priority: normal
severity: normal
status: open
title: Pickling recursion error, did not import pickle
type: behavior
versions: Python 3.8

___
Python tracker 

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



[issue44356] Abstract enum mixins not allowed

2021-06-10 Thread Ethan Furman


Ethan Furman  added the comment:

Since I like puzzles, here is a working LenientStrEnum:

class LenientStrEnum(str, Enum):
#
def __init__(self, *args):
self._valid = True
#
@classmethod
def _missing_(cls, value):
logger.warning(
f"[{cls.__name__}] encountered an unknown value!\n"
f"Luckily I'm a LenientStrEnum, so I won't crash just yet.\n"
f"You might want to add a new case though.\n"
f"Value was: '{value}'"
)
unknown = cls._member_type_.__new__(cls, value)
unknown._valid = False
unknown._name_ = value.upper()
unknown._value_ = value
cls._member_map_[value] = unknown
return unknown
#
@property
def valid(self):
return self._valid

`_member_map_` is not guaranteed, but is unlikely to change.

--

___
Python tracker 

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



[issue43498] "dictionary changed size during iteration" error in _ExecutorManagerThread

2021-06-10 Thread Matt Whitlock


Matt Whitlock  added the comment:

Observed this same failure mode on a Raspberry Pi 1 while running 'make 
install' on Python 3.9.5 with 9 concurrent workers.

Exception in thread Thread-1:
Traceback (most recent call last):
  File 
"/var/tmp/portage/dev-lang/python-3.9.5_p2/image/usr/lib/python3.9/threading.py",
 line 954, in _bootstrap_inner
self.run()
  File 
"/var/tmp/portage/dev-lang/python-3.9.5_p2/image/usr/lib/python3.9/concurrent/futures/process.py",
 line 317, in run
result_item, is_broken, cause = self.wait_result_broken_or_wakeup()
  File 
"/var/tmp/portage/dev-lang/python-3.9.5_p2/image/usr/lib/python3.9/concurrent/futures/process.py",
 line 376, in wait_result_broken_or_wakeup
worker_sentinels = [p.sentinel for p in self.processes.values()]
  File 
"/var/tmp/portage/dev-lang/python-3.9.5_p2/image/usr/lib/python3.9/concurrent/futures/process.py",
 line 376, in 
worker_sentinels = [p.sentinel for p in self.processes.values()]
RuntimeError: dictionary changed size during iteration

--
nosy: +whitslack

___
Python tracker 

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



[issue44380] glob.glob handling of * (asterisk) wildcard is broken

2021-06-10 Thread Maxim Egorushkin


New submission from Maxim Egorushkin :

Problem:

`glob.glob` documentation states that "pathname ... can contain shell-style 
wildcards." 

However, it stops short of saying that shell-style wildcards are handled the 
same way as in a POSIX-compliant/friendly shell.

https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_13_02
 POSIX requires that "`*` (asterisk) is a pattern that shall match any string, 
including the null string."

However, `glob.glob` pattern `*` (asterisk) doesn't match an empty/null string. 

Reproduction:

$ ls *.bash_profile
.bash_profile
$ python3 -c 'import glob; print(glob.glob("*.bash_profile"))'
[]
$ python3 -c 'import glob; print(glob.glob(".bash_profile"))'
['.bash_profile']

--
components: Library (Lib)
messages: 395545
nosy: max0x7ba
priority: normal
severity: normal
status: open
title: glob.glob handling of * (asterisk) wildcard is broken
versions: Python 3.8

___
Python tracker 

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



[issue44380] glob.glob handling of * (asterisk) wildcard is broken

2021-06-10 Thread Maxim Egorushkin


Change by Maxim Egorushkin :


--
type:  -> behavior

___
Python tracker 

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



[issue44376] Improve performance of integer exponentiation

2021-06-10 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Is it because exponentiation becomes slower or because multiplication becomes 
faster? What are absolute numbers?

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue44380] glob.glob handling of * (asterisk) wildcard is broken

2021-06-10 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Only pattern beginning with a dot can match filename beginning with a dot.

>From https://docs.python.org/3/library/glob.html

   Note that unlike fnmatch.fnmatch(), glob treats filenames beginning with a 
dot (.) as special cases.

This phrase was added in issue16695 in attempt to improve documentation, but it 
is still not clear.

--
assignee:  -> docs@python
components: +Documentation -Library (Lib)
nosy: +docs@python, serhiy.storchaka
type: behavior -> enhancement
versions: +Python 3.10, Python 3.11, Python 3.9 -Python 3.8

___
Python tracker 

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



[issue44380] glob.glob handling of * (asterisk) wildcard is broken

2021-06-10 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
nosy: +nailor, petri.lehtinen

___
Python tracker 

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



[issue44380] glob.glob handling of * (asterisk) wildcard is broken

2021-06-10 Thread Maxim Egorushkin


Maxim Egorushkin  added the comment:

I may be naive, but why then:

$ python3 -c 'from pathlib import Path; 
print(list(Path(".").glob("*.bash_profile")))'

Outputs:

[PosixPath('.bash_profile')]


?

--

___
Python tracker 

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



[issue44364] Add non integral tests for `sqrt()`

2021-06-10 Thread Mark Dickinson


New submission from Mark Dickinson :


New changeset 90cd4330329a99e52f7141db5e0a469d30088e66 by Ajith Ramachandran in 
branch 'main':
bpo-44364:Add non integral tests for `sqrt()` (#26625)
https://github.com/python/cpython/commit/90cd4330329a99e52f7141db5e0a469d30088e66


--

___
Python tracker 

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



[issue44364] Add non integral tests for `sqrt()`

2021-06-10 Thread Mark Dickinson


Change by Mark Dickinson :


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



[issue44380] glob.glob handling of * (asterisk) wildcard is broken

2021-06-10 Thread Isaac Muse


Isaac Muse  added the comment:

Sadly, this because pathlib glob and glob.glob use different implementations. 
And glob.glob does not provide something equivalent to a DOTALL flag allowing a 
user to glob hidden files without explicitly defining the leading dot in the 
pattern.

--
nosy: +Isaac Muse

___
Python tracker 

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



[issue44380] glob.glob handling of * (asterisk) wildcard is broken

2021-06-10 Thread Maxim Egorushkin


Maxim Egorushkin  added the comment:

> glob.glob does not provide something equivalent to a DOTALL flag 

I see now, said a blind man.

--

___
Python tracker 

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



[issue44379] Pickling recursion error, did not import pickle

2021-06-10 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

It is because you run the code in IDLE.

print(tempList) converts argument to string and write it to sys.stdout. In IDLE 
sys.stdout is a proxy object which uses RPC to communicate with the IDLE 
process which should insert the written text in the console text widget. Pickle 
is used for encoding command and arguments. Here you get a recursion error in 
pickle because when print(tempList) is executed the recursion depth almost 
reached the limit.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue44357] Add math.cbrt() function: Cube Root

2021-06-10 Thread Mark Dickinson


Mark Dickinson  added the comment:


New changeset ac867f10b49322e25f34d2d8abd8e63c86834750 by Ajith Ramachandran in 
branch 'main':
bpo-44357:Add `math.cbrt()` function: Cube Root (GH-26622)
https://github.com/python/cpython/commit/ac867f10b49322e25f34d2d8abd8e63c86834750


--

___
Python tracker 

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



[issue44357] Add math.cbrt() function: Cube Root

2021-06-10 Thread Mark Dickinson


Mark Dickinson  added the comment:

All done; closing. Thank you for the contribution!

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



[issue44376] Improve performance of integer exponentiation

2021-06-10 Thread Mark Dickinson


Mark Dickinson  added the comment:

I can't reproduce this on my Mac laptop (using Python builds from MacPorts). 
Numbers for both x**2 and x*x are fairly stable across Python 3.2 to Python 
3.10. There's some variation, but nothing close to the same extent that Steven 
is seeing.

Here are my raw numbers:

lovelace:cpython mdickinson$ /opt/local/bin/python3.2 -m timeit -s "x=115" "x*x"
1000 loops, best of 3: 0.031 usec per loop
lovelace:cpython mdickinson$ /opt/local/bin/python3.3 -m timeit -s "x=115" "x*x"
1000 loops, best of 3: 0.0297 usec per loop
lovelace:cpython mdickinson$ /opt/local/bin/python3.4 -m timeit -s "x=115" "x*x"
1000 loops, best of 3: 0.0286 usec per loop
lovelace:cpython mdickinson$ /opt/local/bin/python3.5 -m timeit -s "x=115" "x*x"
1000 loops, best of 3: 0.03 usec per loop
lovelace:cpython mdickinson$ /opt/local/bin/python3.6 -m timeit -s "x=115" "x*x"
1000 loops, best of 3: 0.0312 usec per loop
lovelace:cpython mdickinson$ /opt/local/bin/python3.7 -m timeit -s "x=115" "x*x"
1000 loops, best of 5: 28.7 nsec per loop
lovelace:cpython mdickinson$ /opt/local/bin/python3.8 -m timeit -s "x=115" "x*x"
1000 loops, best of 5: 32 nsec per loop
lovelace:cpython mdickinson$ /opt/local/bin/python3.9 -m timeit -s "x=115" "x*x"
1000 loops, best of 5: 33.5 nsec per loop
lovelace:cpython mdickinson$ /opt/local/bin/python3.10 -m timeit -s "x=115" 
"x*x"
1000 loops, best of 5: 32.3 nsec per loop
lovelace:cpython mdickinson$ /opt/local/bin/python3.2 -m timeit -s "x=115" 
"x**2"
100 loops, best of 3: 0.249 usec per loop
lovelace:cpython mdickinson$ /opt/local/bin/python3.3 -m timeit -s "x=115" 
"x**2"
100 loops, best of 3: 0.224 usec per loop
lovelace:cpython mdickinson$ /opt/local/bin/python3.4 -m timeit -s "x=115" 
"x**2"
100 loops, best of 3: 0.221 usec per loop
lovelace:cpython mdickinson$ /opt/local/bin/python3.5 -m timeit -s "x=115" 
"x**2"
100 loops, best of 3: 0.213 usec per loop
lovelace:cpython mdickinson$ /opt/local/bin/python3.6 -m timeit -s "x=115" 
"x**2"
100 loops, best of 3: 0.235 usec per loop
lovelace:cpython mdickinson$ /opt/local/bin/python3.7 -m timeit -s "x=115" 
"x**2"
100 loops, best of 5: 204 nsec per loop
lovelace:cpython mdickinson$ /opt/local/bin/python3.8 -m timeit -s "x=115" 
"x**2"
100 loops, best of 5: 217 nsec per loop
lovelace:cpython mdickinson$ /opt/local/bin/python3.9 -m timeit -s "x=115" 
"x**2"
100 loops, best of 5: 245 nsec per loop
lovelace:cpython mdickinson$ /opt/local/bin/python3.10 -m timeit -s "x=115" 
"x**2"
100 loops, best of 5: 230 nsec per loop

--

___
Python tracker 

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



[issue44381] Allow enabling control flow guard in Windows build

2021-06-10 Thread Steve Dower


New submission from Steve Dower :

Currently we don't enable CFG (which is runtime protection against code 
injection into tables), because it likely has a performance impact and the kind 
of attack is outside our scope.

However, we should make it easier to build CPython with CFG enabled, so that 
third-parties who do want to include it in their scope can do so.

--
assignee: steve.dower
components: Build, Windows
messages: 395556
nosy: paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: Allow enabling control flow guard in Windows build
type: security
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



[issue44381] Allow enabling control flow guard in Windows build

2021-06-10 Thread Steve Dower


Change by Steve Dower :


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

___
Python tracker 

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



[issue44381] Allow enabling control flow guard in Windows build

2021-06-10 Thread Steve Dower


Steve Dower  added the comment:

FWIW, I don't actually know what the performance impact is. I'm not set up for 
running the perf benchmarks, and I don't know if anyone else is (on Windows), 
but if someone would like to then it'll be easier once the environment option 
to enable it is in there.

--

___
Python tracker 

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



[issue44382] Python 3.9+ on Windows 8.0

2021-06-10 Thread Hypo Turtle


New submission from Hypo Turtle :

As per https://docs.python.org/3/using/windows.html:
"This means that Python 3.9 supports Windows 8.1 and newer."

Isn't reflected on python.org main page which has:
"Note that Python 3.9+ cannot be used on Windows 7 or earlier."

Leaving 8.0 unaddressed.

--
assignee: docs@python
components: Documentation
messages: 395558
nosy: docs@python, hypoturtle
priority: normal
severity: normal
status: open
title: Python 3.9+ on Windows 8.0
type: enhancement
versions: Python 3.9

___
Python tracker 

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



[issue44383] argparse.BooleanOptionalAction interacts poorly with ArgumentDefaultsHelpFormatter

2021-06-10 Thread Julian Gilbey


New submission from Julian Gilbey :

With code like the following:



import argparse

parser = argparse.ArgumentParser(
description="Test program",
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)
parser.add_argument(
"--foo",
help="Use the foo component.",
action=argparse.BooleanOptionalAction,
default=True,
)

args = parser.parse_args()



a call "python prog.py --help" then gives:


usage: prog.py [-h] [--foo | --no-foo]

Test program

optional arguments:
  -h, --help   show this help message and exit
  --foo, --no-foo  Use the foo component. (default: True) (default: True)


Note the repeated "(default: True)", one produced by the BooleanOptionalAction 
class and the other by the ArgumentDefaultsHelpFormatter.  It would be good if 
they didn't both add this helpful information.

My suggestion would be that BooleanOptionalAction should not include this 
information; it is unique in doing so.

--
components: Library (Lib)
messages: 395559
nosy: juliangilbey
priority: normal
severity: normal
status: open
title: argparse.BooleanOptionalAction interacts poorly with 
ArgumentDefaultsHelpFormatter
type: behavior
versions: Python 3.9

___
Python tracker 

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



[issue44376] Improve performance of integer exponentiation

2021-06-10 Thread Tim Peters


Tim Peters  added the comment:

Under the released 3.9.5 for 64-bit Win10, raising to the power 2 is clearly 
much slower than multiplying directly:

C:\Windows\System32>py -3 -m timeit -s "x=151" "x*x"
1000 loops, best of 5: 30 nsec per loop

C:\Windows\System32>py -3 -m timeit -s "x=151" "x**2"
100 loops, best of 5: 194 nsec per loop

Since the multiplication itself is cheap, overheads must account for it. 
Offhand, looks to me like the `x**2` spelling is actually doing 31 
multiplications under the covers, although most of them are as cheap as 
Python-int multiplies get.

for (i = Py_SIZE(b) - 1; i >= 0; --i) {
digit bi = b->ob_digit[i];

for (j = (digit)1 << (PyLong_SHIFT-1); j != 0; j >>= 1) {
MULT(z, z, z);
if (bi & j)
MULT(z, a, z);
}
}

Python ints on a 64-bit box are stored internally in base 2**30 (PyLong_SHIFT 
is 30). z starts life at 1. The first 28 trips through the loop are chewing up 
the 28 leading zero bits in exponent 2, so MULT(z, z, z) multiplies 1 by 1 to 
get 1, 28 times. Then again on the 29th iteration, but now "bi & j" is finally 
true (we finally found the leading one bit in exponent 2), so z is replaced by 
1 times the base = the base. On the final, 30th, iteration, MULT(z, z, z) 
replaces z with its square, and we're done.

It would probably be worthwhile to add code special-casing the leading Python 
"digit" of the exponent, fast-forwarding without any multiplies to the leading 
one bit, and setting z directly to the base then.

--
nosy: +tim.peters

___
Python tracker 

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



[issue44370] Inconsistent results for min() and max() with math.nan as argument

2021-06-10 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

The idea of math.ieee754_total_order looks interesting, but how would it work 
with min/max?

In 
https://grouper.ieee.org/groups/msc/ANSI_IEEE-Std-754-2019/background/minNum_maxNum_Removal_Demotion_v3.pdf
 there is a comparison of several standards and implementations of symmetric 
and associative min/max. There are two options: propagate NaN and ignore it 
(treat it as missing data). It differs between different standards and 
implementations but in particular standard or implementation the same rule is 
used for min and max.

* If ieee754_total_order(NAN) < ieee754_total_order(1), then min(1, NAN) -> NAN 
("propagate") and max(1, NAN) -> 1 ("missing data").
* If ieee754_total_order(NAN) > ieee754_total_order(1), then min(1, NAN) -> 1 
("missing data") and max(1, NAN) -> NAN ("propagate").

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue44362] improve documentation of SSL deprecations

2021-06-10 Thread Christian Heimes


Change by Christian Heimes :


--
keywords: +patch
nosy: +christian.heimes
nosy_count: 6.0 -> 7.0
pull_requests: +25232
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/26646

___
Python tracker 

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



[issue33962] IDLE: use ttk.spinbox with configdialog

2021-06-10 Thread Terry J. Reedy


Terry J. Reedy  added the comment:


New changeset 42d5a4fc3b35e45cdd237d56a04e98894d0a31f5 by Mark Roseman in 
branch 'main':
bpo-33962: Use ttk spinbox for IDLE indent space config (GH-22954)
https://github.com/python/cpython/commit/42d5a4fc3b35e45cdd237d56a04e98894d0a31f5


--

___
Python tracker 

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



[issue33962] IDLE: use ttk.spinbox with configdialog

2021-06-10 Thread miss-islington


Change by miss-islington :


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

___
Python tracker 

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



[issue33962] IDLE: use ttk.spinbox with configdialog

2021-06-10 Thread miss-islington


Change by miss-islington :


--
pull_requests: +25234
pull_request: https://github.com/python/cpython/pull/26648

___
Python tracker 

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



[issue44364] Add non integral tests for `sqrt()`

2021-06-10 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

>>> math.sqrt(2.5) == 2.5**0.5
True
>>> math.sqrt(25.25) == 25.25**0.5
True

If we test the precision of math.sqrt(), would not be better to test it with 
data for which naive way of calculating the root returns different result? For 
example 2921 is the smallest integers for which math.sqrt(x) > x**0.5, and 3541 
is the smallest integers for which math.sqrt(x) < x**0.5.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue44356] Multiple enum mixins not allowed even when they have the same datatype

2021-06-10 Thread Ethan Furman


Change by Ethan Furman :


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

___
Python tracker 

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



[issue44356] Multiple enum mixins not allowed even when they have the same datatype

2021-06-10 Thread Ethan Furman


Change by Ethan Furman :


--
title: Abstract enum mixins not allowed -> Multiple enum mixins not allowed 
even when they have the same datatype

___
Python tracker 

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



[issue44364] Add non integral tests for `sqrt()`

2021-06-10 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

65733 and 262694 are integers in range 1..100 with largest relative errors 
of naive square root (with different signs).

33031 and 524557 are integers in range 1..100 with largest relative errors 
of naive cube root (with different signs).

--

___
Python tracker 

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



[issue44342] enum with inherited type won't pickle

2021-06-10 Thread Ethan Furman


Change by Ethan Furman :


--
priority: normal -> high
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



[issue33962] IDLE: use ttk.spinbox with configdialog

2021-06-10 Thread miss-islington


miss-islington  added the comment:


New changeset 9b889433c7bb3ed7e2b4655f024b49d97fe412fb by Miss Islington (bot) 
in branch '3.9':
bpo-33962: Use ttk spinbox for IDLE indent space config (GH-22954)
https://github.com/python/cpython/commit/9b889433c7bb3ed7e2b4655f024b49d97fe412fb


--

___
Python tracker 

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



[issue44364] Add non integral tests for `sqrt()`

2021-06-10 Thread Mark Dickinson


Mark Dickinson  added the comment:

> 2921 is the smallest integers for which math.sqrt(x) > x**0.5

This is platform-dependent. On my machine, for example, `math.sqrt(2921) == 
2921**0.5` returns `True`.

I don't see a lot of value in additional tests here; we're only wrapping the 
libm sqrt, so we only really need enough testing to catch possible 
implementation errors in that wrapping. But testing only integers with an exact 
square root doesn't seem enough.

--

___
Python tracker 

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



[issue44384] test_ttk_guionly: 2 tests fail once each on Pipelines Ubuntu

2021-06-10 Thread Terry J. Reedy


New submission from Terry J. Reedy :

3.10 Pipelines Ubuntu CI (like #42370) Each passed on 3.11 and 3.9 and all 
other CI tests and my machine.

FIRST RUN - FAIL: test_heading_callback 
(tkinter.test.test_ttk.test_widgets.TreeviewTest)
--
Traceback (most recent call last):
  File "/home/vsts/work/1/s/Lib/tkinter/test/test_ttk/test_widgets.py", line 
1548, in test_heading_callback
simulate_heading_click(5, 5)
  File "/home/vsts/work/1/s/Lib/tkinter/test/test_ttk/test_widgets.py", line 
1536, in simulate_heading_click
self.assertEqual(self.tv.identify_region(x, y), 'heading')
AssertionError: 'nothing' != 'heading'
- nothing
+ heading


RETEST RUN - FAIL: test_variable_change 
(tkinter.test.test_ttk.test_extensions.LabeledScaleTest)
--
Traceback (most recent call last):
  File "/home/vsts/work/1/s/Lib/tkinter/test/test_ttk/test_extensions.py", line 
144, in test_variable_change
self.assertGreater(x.scale.coords()[0], curr_xcoord)
AssertionError: 1 not greater than 1

--
components: Tests, Tkinter
messages: 395567
nosy: serhiy.storchaka, terry.reedy, vstinner
priority: normal
severity: normal
stage: needs patch
status: open
title: test_ttk_guionly: 2 tests fail once each on Pipelines Ubuntu
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



[issue33962] IDLE: use ttk.spinbox with configdialog

2021-06-10 Thread Terry J. Reedy


Terry J. Reedy  added the comment:


New changeset 540ebc4a8874f94152980be7778f3f793b65f111 by Miss Islington (bot) 
in branch '3.10':
bpo-33962: Use ttk spinbox for IDLE indent space config (GH-22954)
https://github.com/python/cpython/commit/540ebc4a8874f94152980be7778f3f793b65f111


--

___
Python tracker 

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



[issue33962] IDLE: use ttk.spinbox with configdialog

2021-06-10 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

Mark, I am not sure what last comment meant, but we generally only test IDLE 
with 3.x with the 8.6.y that comes with 3.x.  Ned Deily sometimes runs gui 
tests with various tcl/tk versions and builds to select one for the installer, 
but he knows about whatever you said ;-).

Thank you for the patch.

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

___
Python tracker 

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



[issue44356] Multiple enum mixins not allowed even when they have the same datatype

2021-06-10 Thread Ethan Furman


Ethan Furman  added the comment:


New changeset 8a4f0850d75747af8c96ca0e7eef1f5c1abfba25 by Ethan Furman in 
branch 'main':
bpo-44356: [Enum] allow multiple data-type mixins if they are all the same 
(GH-26649)
https://github.com/python/cpython/commit/8a4f0850d75747af8c96ca0e7eef1f5c1abfba25


--

___
Python tracker 

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



[issue37022] pdb: do_p and do_pp swallow exceptions from __repr__

2021-06-10 Thread miss-islington


Change by miss-islington :


--
pull_requests: +25237
pull_request: https://github.com/python/cpython/pull/26651

___
Python tracker 

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



[issue37022] pdb: do_p and do_pp swallow exceptions from __repr__

2021-06-10 Thread miss-islington


Change by miss-islington :


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

___
Python tracker 

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



[issue37022] pdb: do_p and do_pp swallow exceptions from __repr__

2021-06-10 Thread Irit Katriel


Irit Katriel  added the comment:


New changeset 6544b2532df82d137b71323445a07a6e29bcdec0 by Daniel Hahler in 
branch 'main':
bpo-37022: Fix bug where pdb's do_p/do_pp commands swallow exceptions from repr 
(GH-18180)
https://github.com/python/cpython/commit/6544b2532df82d137b71323445a07a6e29bcdec0


--
nosy: +iritkatriel

___
Python tracker 

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



[issue44356] Multiple enum mixins not allowed even when they have the same datatype

2021-06-10 Thread miss-islington


Change by miss-islington :


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

___
Python tracker 

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



[issue44356] Multiple enum mixins not allowed even when they have the same datatype

2021-06-10 Thread miss-islington


Change by miss-islington :


--
pull_requests: +25240
pull_request: https://github.com/python/cpython/pull/26654

___
Python tracker 

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



[issue44356] Multiple enum mixins not allowed even when they have the same datatype

2021-06-10 Thread miss-islington


Change by miss-islington :


--
pull_requests: +25239
pull_request: https://github.com/python/cpython/pull/26653

___
Python tracker 

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



[issue44242] enum.IntFlag regression: missing values cause TypeError

2021-06-10 Thread Ethan Furman


Ethan Furman  added the comment:

Thank you everyone for your help.

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



[issue44365] Bad dataclass post-init example

2021-06-10 Thread Eric V. Smith


Eric V. Smith  added the comment:

I'm not sure directly calling __post_init__ is a good pattern. Why would not 
calling __init__, like you would with any other class, not be the preferred 
thing to do?

--

___
Python tracker 

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



[issue37022] pdb: do_p and do_pp swallow exceptions from __repr__

2021-06-10 Thread Irit Katriel


Irit Katriel  added the comment:


New changeset e3bc32fc1ad5537b476b34062b07a040533c913a by Miss Islington (bot) 
in branch '3.10':
bpo-37022: Fix bug where pdb's do_p/do_pp commands swallow exceptions from repr 
(GH-18180) (GH-26650)
https://github.com/python/cpython/commit/e3bc32fc1ad5537b476b34062b07a040533c913a


--

___
Python tracker 

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



[issue37022] pdb: do_p and do_pp swallow exceptions from __repr__

2021-06-10 Thread Irit Katriel


Irit Katriel  added the comment:


New changeset 175ebc60d52f2e88cf5cba5224c15074d2623c10 by Miss Islington (bot) 
in branch '3.9':
bpo-37022: Fix bug where pdb's do_p/do_pp commands swallow exceptions from repr 
(GH-18180) (GH-26651)
https://github.com/python/cpython/commit/175ebc60d52f2e88cf5cba5224c15074d2623c10


--

___
Python tracker 

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



[issue37022] pdb: do_p and do_pp swallow exceptions from __repr__

2021-06-10 Thread Irit Katriel


Change by Irit Katriel :


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



[issue44370] Inconsistent results for min() and max() with math.nan as argument

2021-06-10 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

We should consider biting the bullet and revising the default NaN sort order.  
It has been a perpetual irritant.

1) Have NaNs always compare to less than any other float value.
2) When comparing two distinct NaNs, use the NaN payload
   and fall back to object id if necessary.
3) When comparing two identical NaNs, always return False.

That preserves the IEEE-754 guarantee that NaNs never compare equal to one 
another -- which is one of the few properties that people rely on.

IEEE-754 doesn't concern itself at all with the notion of object identity, so 
giving two NaNs a deterministic but unequal ordering isn't at odds with the 
standard.

IMHO, making min(), max(), and sorted() both deterministic and commutative is a 
big enough win to warrant foregoing one of the less important properties of 
NaN.  User care about determinism and commutativity more than they care that 
float('NaN') > 10 and float('NaN') < 10 both return False.

“Logic clearly dictates that the needs of the many outweigh the needs of the 
few.” -- Spock, The Wrath of Khan ;-)

Python is practical language, so we should consider making a choice based on 
pragmatism rather than strict standard compliance.  Bug reports like this are 
the tip of the iceberg.  Given the prevalence of NaNs being used as a 
placeholder for missing data, it is likely that people struggle with this every 
day.

The original design of NaNs was to let invalid intermediate results flow 
through a calculation and not require error testing at every step.  But in 
practice, NaNs are not commonly used this way.  Mainly, they are used as the 
float equivalent of None in an array of floats.  We should support this 
reality.  IMO it is a small disaster that NaNs completely wreck sorting and do 
so silently.  From user POV, an arcane property of NaNs is an inadequate 
justification for the misbehavior.

--
nosy: +rhettinger

___
Python tracker 

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



[issue44385] Some target-related rules are unreachable in the grammar

2021-06-10 Thread Lysandros Nikolaou


New submission from Lysandros Nikolaou :

Three rules (targets, target and t_atom) in the grammar are unreachable. We 
were using them at some point in the past, but we never removed them when we 
replaced them with other rules.

--
assignee: lys.nikolaou
components: Parser
messages: 395577
nosy: gvanrossum, lys.nikolaou, pablogsal
priority: normal
severity: normal
status: open
title: Some target-related rules are unreachable in the grammar
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



  1   2   >