[issue40279] Documentation example of module init function lacks error handling

2020-04-24 Thread Stefan Behnel


Stefan Behnel  added the comment:


New changeset 882a7f44da08c6fb210bd9a17f80903cbca84034 by Miss Islington (bot) 
in branch '3.8':
bpo-40279: Add some error-handling to the module initialisation docs example 
(GH-19705) (GH-19710)
https://github.com/python/cpython/commit/882a7f44da08c6fb210bd9a17f80903cbca84034


--

___
Python tracker 

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



[issue40279] Documentation example of module init function lacks error handling

2020-04-24 Thread Stefan Behnel


Stefan Behnel  added the comment:

Hi Cajetan, thank you for your contribution! That's a nice documentation 
improvement.

--
nosy:  -miss-islington
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



[issue40279] Documentation example of module init function lacks error handling

2020-04-24 Thread miss-islington


Change by miss-islington :


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

___
Python tracker 

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



[issue40279] Documentation example of module init function lacks error handling

2020-04-24 Thread Stefan Behnel


Stefan Behnel  added the comment:


New changeset d4f3923d5901ef1ccdbe6ad6c5a753af90832a0f by Cajetan Rodrigues in 
branch 'master':
bpo-40279: Add some error-handling to the module initialisation docs example 
(GH-19705)
https://github.com/python/cpython/commit/d4f3923d5901ef1ccdbe6ad6c5a753af90832a0f


--

___
Python tracker 

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



[issue40386] Strange behavior during invalid import of modules without if __name__ == "__main__"

2020-04-24 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Trying using "import this" instead of "import this.main".

The latter does an "import this" and then attempts to load a "main" package 
that doesn't exist.  You're observed the expected behavior.  See 
https://docs.python.org/3/tutorial/modules.html#packages for more details.

Hope that clears-up your understanding of what is happening.

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



[issue40385] Tools/checkpyc.py has been broken since PEP 552

2020-04-24 Thread Benjamin Peterson


Benjamin Peterson  added the comment:


New changeset f82807746d26b4c047f7f3115065f20bb63fb5ff by Ammar Askar in branch 
'master':
closes bpo-40385: Remove Tools/scripts/checkpyc.py (GH-19709)
https://github.com/python/cpython/commit/f82807746d26b4c047f7f3115065f20bb63fb5ff


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



[issue40385] Tools/checkpyc.py has been broken since PEP 552

2020-04-24 Thread Ammar Askar


Change by Ammar Askar :


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

___
Python tracker 

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



[issue40386] Strange behavior during invalid import of modules without if __name__ == "__main__"

2020-04-24 Thread wyz23x2


Change by wyz23x2 :


--
type:  -> behavior

___
Python tracker 

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



[issue40386] Strange behavior during invalid import of modules without if __name__ == "__main__"

2020-04-24 Thread wyz23x2


wyz23x2  added the comment:

Sorry, it's "of 'this' is run", not "un".

--

___
Python tracker 

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



[issue40386] Strange behavior during invalid import of modules without if __name__ == "__main__"

2020-04-24 Thread wyz23x2


Change by wyz23x2 :


--
components: +Library (Lib)
versions: +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



[issue40386] Strange behavior during invalid import of modules without if __name__ == "__main__"

2020-04-24 Thread wyz23x2


New submission from wyz23x2 :

This behavior:

Python 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 23:03:10) [MSC v.1916 64 bit 
(AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> import this.main
The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
Traceback (most recent call last):
  File "", line 1, in 
import this.main
ModuleNotFoundError: No module named 'this.main'; 'this' is not a package
>>> import this.main
Traceback (most recent call last):
  File "", line 1, in 
import this.main
ModuleNotFoundError: No module named 'this.main'; 'this' is not a package
>>> del this
Traceback (most recent call last):
  File "", line 1, in 
del this
NameError: name 'this' is not defined
>>> import this
>>>

This confuses users because the code of "this" is un the 1st time, but not the 
times after it. And "this" isn't actually imported after that; stranger is when 
you perform the correct import, it doesn't run.

Is this right?

--
messages: 367253
nosy: wyz23x2
priority: normal
severity: normal
status: open
title: Strange behavior during invalid import of modules without if __name__ == 
"__main__"

___
Python tracker 

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



[issue34990] year 2038 problem in compileall.py

2020-04-24 Thread Ammar Askar


Change by Ammar Askar :


--
pull_requests: +19029
pull_request: https://github.com/python/cpython/pull/19708

___
Python tracker 

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



[issue40385] Tools/checkpyc.py has been broken since PEP 552

2020-04-24 Thread Benjamin Peterson


Benjamin Peterson  added the comment:

I'd vote for axing it.

--
nosy: +benjamin.peterson

___
Python tracker 

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



[issue40383] weakref class name are hardcoded in reprs

2020-04-24 Thread OhBonsai


Change by OhBonsai :


--
assignee:  -> docs@python
components: +Documentation -Extension Modules
nosy: +docs@python
title: some class name are hardcoded in reprs -> weakref class name are 
hardcoded in reprs

___
Python tracker 

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



[issue13645] import machinery vulnerable to timestamp collisions

2020-04-24 Thread Ammar Askar


Change by Ammar Askar :


--
pull_requests:  -19023

___
Python tracker 

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



[issue40384] IDLE: Undesired highlight

2020-04-24 Thread Alex


Alex <2423067...@qq.com> added the comment:

The sharp is at line 2, not line 3. I made a mistake.

--

___
Python tracker 

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



[issue40385] Tools/checkpyc.py has been broken since PEP 552

2020-04-24 Thread Ammar Askar


New submission from Ammar Askar :

Looks like checkpyc.py has been broken since PEP 552 was implemented 
https://github.com/python/cpython/blob/0e80b561d442769631d66f1cc8813ac30f97378e/Tools/scripts/checkpyc.py#L44-L46

It fails to read the 4 bytes for the `flags` field nor does it handle hash 
based files. 

Considering it's been broken since 2017 and no one has complained, it might be 
safe to remove this particular script.

--
components: Demos and Tools
messages: 367250
nosy: ammar2
priority: normal
severity: normal
status: open
title: Tools/checkpyc.py has been broken since PEP 552
type: behavior
versions: 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



[issue40384] IDLE: Undesired highlight

2020-04-24 Thread Alex


New submission from Alex <2423067...@qq.com>:

In this code:

def a():
#
def
def b():

When I delete the # at line 3, the keyword 'def' become blue.

--
assignee: terry.reedy
components: IDLE
messages: 367249
nosy: Alex-Python-Programmer, terry.reedy
priority: normal
severity: normal
status: open
title: IDLE: Undesired highlight
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



[issue40383] some class name are hardcoded in reprs

2020-04-24 Thread OhBonsai


Change by OhBonsai :


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

___
Python tracker 

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



[issue40383] some class name are hardcoded in reprs

2020-04-24 Thread OhBonsai


New submission from OhBonsai :

Same with #21861 #27541

hard-coding in 
https://github.com/python/cpython/blob/master/Objects/weakrefobject.c#L162  
__repr__ 

- Reproducing
>>> import weakref
>>> class ExtendRef(weakref.ref): pass
... 
>>> class Obj(): pass
... 
>>> eref = ExtendRef(Obj())
>>> eref


- Expect the subclass name
>>> eref


--
components: Extension Modules
messages: 367248
nosy: OhBonsai, corona10, taleinat
priority: normal
severity: normal
status: open
title: some class name are hardcoded in reprs
type: enhancement
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



[issue27620] IDLE: Add keyboard equivalents for mouse actions.

2020-04-24 Thread Zackery Spytz


Change by Zackery Spytz :


--
keywords: +patch
nosy: +ZackerySpytz
nosy_count: 3.0 -> 4.0
pull_requests: +19026
stage: test needed -> patch review
pull_request: https://github.com/python/cpython/pull/19706

___
Python tracker 

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



[issue40346] Add random.BaseRandom to ease implementation of subclasses

2020-04-24 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

SystemRandom is a weird special case.  Otherwise, almost every PRNG is going to 
need seed(), getstate(), and setstate().  A base class should each offer some 
reusable code to minimize the burden on the subclass:

* The existing seed method allows multiple input types to be collapsed to a 
long integer.  A subclass can extend this as needed or can override it 
completely.  This is useful and will tend to give a more consistent API across 
multiple RNGs.

* The getstate/setstate methods take care of the gauss_next value and allow the 
seeding to be versioned.  This is also useful and helps us insulate users from 
state related implementation details such as gauss_next.

Please don't lose the above functionality by default.

Also, please make sure that code written to the existing spec continues to 
work.¹

+1 on offering a PCG generator; however, it should an additional alternative to 
MT and SystemRandom rather than a replacement.  Also, it needs to work well on 
32-bit builds.  Notes should be added that its state space is *much* smaller 
than MT, so shuffle() becomes state space limited at much smaller population 
sizes -- meaning that a large number of possible permutations become 
unreachable by shuffle() -- for example, to cover all possible shuffles for a 
deck of 52 playing cards requires 226 bits.²  Also, I expect that PCG won't 
offer us the same performance advantage as it does for numpy because the MT 
code itself is only a fraction of the time in a call to random(); the rest of 
the time is in the function call overhead, converting the bytes to a C double, 
and creating a new Python float object.

I would still like to see a PEP for this. 


¹ https://code.activestate.com/recipes/576707/
² factorial(52).bit_length()

--

___
Python tracker 

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



[issue40334] PEP 617: new PEG-based parser

2020-04-24 Thread Guido van Rossum


Guido van Rossum  added the comment:

@Anthony: Presumably some of these will be unavoidable. I see you have 
PYPY-specific checks in your code already.

You could also help by sending us the test programs and the different output 
produced by the old and the new parser. You could either create a Gist and link 
it here, or open bug reports here: 
https://github.com/we-like-parsers/cpython/issues . I opened one already for 
you: https://github.com/we-like-parsers/cpython/issues/121

--

___
Python tracker 

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



[issue37551] IDLE: Quitting with a new, unsaved editor window causes an exception

2020-04-24 Thread Cajetan Rodrigues


Cajetan Rodrigues  added the comment:

Cannot reproduce on Ubuntu 19.10 with idle3.9 
(Python 3.9.0a5+ (heads/master:a25a04fea5, Apr 20 2020, 22:35:10))

--
nosy: +cajetan.rodrigues

___
Python tracker 

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



[issue39481] Implement PEP 585 (Type Hinting Generics In Standard Collections)

2020-04-24 Thread Guido van Rossum


Guido van Rossum  added the comment:

In commit 0e80b561d442769631d66f1cc8813ac30f97378e a What's New section was 
added.

--

___
Python tracker 

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



[issue30491] Add a lightweight mechanism for detecting un-awaited coroutine objects

2020-04-24 Thread Nikolay Bryskin


Change by Nikolay Bryskin :


--
nosy: +nikicat

___
Python tracker 

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



[issue40334] PEP 617: new PEG-based parser

2020-04-24 Thread Guido van Rossum


Guido van Rossum  added the comment:


New changeset 0e80b561d442769631d66f1cc8813ac30f97378e by Guido van Rossum in 
branch 'master':
bpo-40334: Add What's New sections for PEP 617 and PEP 585 (GH-19704)
https://github.com/python/cpython/commit/0e80b561d442769631d66f1cc8813ac30f97378e


--

___
Python tracker 

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



[issue34028] Python 3.7.0 wont compile with SSL Support 1.1.0 > alledged missing X509_VERIFY_PARAM_set1_host() support

2020-04-24 Thread Christian Heimes


Christian Heimes  added the comment:

That's a very dangerous trick and I advise against it. You are modifying the 
global linker path and inject custom OpenSSL libraries into it. This may affect 
and disrupt other programs or OS core tools.

Instead compile the _ssl and _hashlib module with rpath, e.g. LD_RUN_PATH. You 
also don't have to modify CFLAGS or LDFLAGS. --with-openssl does that for you.

$ export LD_RUN_PATH=/home/heimes/dev/python/multissl/openssl/1.1.1f/lib
$ ./configure --with-openssl=/home/heimes/dev/python/multissl/openssl/1.1.1f -C
$ make
$ unset LD_RUN_PATH
$ ldd build/lib.linux-x86_64-3.9/_ssl.cpython-39-x86_64-linux-gnu.so
linux-vdso.so.1 (0x7ffc124eb000)
libssl.so.1.1 => 
/home/heimes/dev/python/multissl/openssl/1.1.1f/lib/libssl.so.1.1 
(0x7fd3d7cab000)
libcrypto.so.1.1 => 
/home/heimes/dev/python/multissl/openssl/1.1.1f/lib/libcrypto.so.1.1 
(0x7fd3d7974000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x7fd3d791c000)
libc.so.6 => /lib64/libc.so.6 (0x7fd3d7753000)
libdl.so.2 => /lib64/libdl.so.2 (0x7fd3d774c000)
/lib64/ld-linux-x86-64.so.2 (0x7fd3d7d8e000)

--

___
Python tracker 

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



[issue40378] ast.parse fails to trigger SyntaxWarning that normal execution does

2020-04-24 Thread Batuhan Taskaya


Batuhan Taskaya  added the comment:

> This does seem like a bug and prematurely closed, I'm a bit disappointed in 
> the current resolution

I would love to see it moved as a new step in the execution pipeline that we 
cane extend easily and use externally (like PyAST_Validate). But I'm not sure 
if the burden worths the gain. Though, for the current version it would be very 
simple to implement such checks (3-4) with a simple NodeVisitor. Just an 
example (should be pretty close to output, not exact): 
https://github.com/isidentical/astvalidate/blob/master/astvalidate/validators/syntatical.py

--

___
Python tracker 

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



[issue40279] Documentation example of module init function lacks error handling

2020-04-24 Thread Cajetan Rodrigues


Change by Cajetan Rodrigues :


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

___
Python tracker 

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



[issue40340] Programming FAQ about "How do I convert a string to a number?" contains a typo

2020-04-24 Thread Kyle Stanley


Kyle Stanley  added the comment:


New changeset 5aafa548794d23b6d4cafb4fd88289cd0ba2a2a8 by Cajetan Rodrigues in 
branch 'master':
bpo-40340: Separate examples more clearly in the programming FAQ (GH-19688)
https://github.com/python/cpython/commit/5aafa548794d23b6d4cafb4fd88289cd0ba2a2a8


--
nosy: +aeros

___
Python tracker 

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



[issue40335] Regression in multiline SyntaxError offsets

2020-04-24 Thread Anthony Sottile


Anthony Sottile  added the comment:

cool, reported there as well!

--

___
Python tracker 

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



[issue40334] PEP 617: new PEG-based parser

2020-04-24 Thread Anthony Sottile


Anthony Sottile  added the comment:

:waves: -- seeing a lot of failures in pyflakes' testsuite around SyntaxErrors 
https://github.com/PyCQA/pyflakes/pull/532

(you can reproduce with `path/to/python -m unittest discover pyflakes` without 
needing any dependencies installed)

--
nosy: +Anthony Sottile

___
Python tracker 

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



[issue40335] Regression in multiline SyntaxError offsets

2020-04-24 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

> pyflakes's testsuite has many failures under the new parser

Can you report this also on the PEP 617 issue?

--

___
Python tracker 

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



[issue40360] Deprecate lib2to3 (and 2to3) for future removal

2020-04-24 Thread Gregory P. Smith


Gregory P. Smith  added the comment:

I think what we're doing with the documentation update is fine.  We can add a 
warning on stderr to the tool in 3.11.  But I don't expect people will be using 
the tool _from_ the latest CPython 3.x by then.

2to3 is already included with Python 2.7 and the only real use for it is for 
people who still have code they maintain on 2.7 so they've got a copy already.  
There is no value in running a 2to3 shipped with Python 3 vs the latest 2.7.  
Meaningful updates to it were already back ported to 2.7 over time as it was 
intentionally exempt from feature freeze.

We should have sorted out a PyPI home for lib2to3 by 3.11 time and can also 
create a PyPI package for the 2to3 tool itself at that point.

I _think_ there is support for running 2to3 on sources at package install time 
from setup.py?  But I don't expect anything actually maintained and widely used 
to require that by the time this deprecation lands.  If it does, that becomes a 
plumbing issue within package tools to know that requiring 2to3 at either build 
or install time adds an implicit tool dependency on the new pypi package to get 
it.

Maybe I'm just in a good mood about all of this, but none of this seems 
worrisome.

--

___
Python tracker 

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



[issue40279] Documentation example of module init function lacks error handling

2020-04-24 Thread Cajetan Rodrigues


Cajetan Rodrigues  added the comment:

At the risk of sounding like a jerk, I'd very much want to say that 
copy-pasters should get what they deserve :) But then I remember I was once a 
copy-paster too!

Hello again, Stefan :)

Thanks for watching out for the community - I'll be happy to fix this!

--
nosy: +cajetan.rodrigues

___
Python tracker 

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



[issue40335] Regression in multiline SyntaxError offsets

2020-04-24 Thread Anthony Sottile


Anthony Sottile  added the comment:

pyflakes's testsuite has many failures under the new parser -- is the 
expectation that those will be fixed by 3.9 final?

--

___
Python tracker 

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



[issue40378] ast.parse fails to trigger SyntaxWarning that normal execution does

2020-04-24 Thread Anthony Sottile


Anthony Sottile  added the comment:

I would really like to be able to trigger all warnings consistently and 
statically without executing the code.

This is useful (for instance) for this simple script which validates the ast: 
https://github.com/pre-commit/pre-commit-hooks/blob/master/pre_commit_hooks/check_ast.py

when run with PYTHONWARNINGS=error I get nice error reports for things such as 
invalid escape sequence, but I do not get them for string-call which I would 
like to

This does seem like a bug and prematurely closed, I'm a bit disappointed in the 
current resolution

--

___
Python tracker 

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



[issue40378] ast.parse fails to trigger SyntaxWarning that normal execution does

2020-04-24 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

It is not a bug. Execution includes more stages than ast.parse().

--
nosy: +serhiy.storchaka
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



[issue40381] plistlib doesn't handle poorly-formatted plists

2020-04-24 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
nosy: +ned.deily, ronaldoussoren

___
Python tracker 

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



[issue40378] ast.parse fails to trigger SyntaxWarning that normal execution does

2020-04-24 Thread Batuhan Taskaya


Batuhan Taskaya  added the comment:

This is probably because that these warnings raised during code generation, 
rather then AST Validation / generation.

--
nosy: +BTaskaya

___
Python tracker 

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



[issue40360] Deprecate lib2to3 (and 2to3) for future removal

2020-04-24 Thread Carl Meyer


Carl Meyer  added the comment:

@gregory.p.smith

What do you think about the question I raised above about how to make this 
deprecation visible to users of the 2to3 CLI tool, assuming the plan is to 
remove both?

--

___
Python tracker 

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



[issue40335] Regression in multiline SyntaxError offsets

2020-04-24 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

And the regression happens because we are ignoring that test currently due to 
the new parser not currently reporting the same offsets:

https://github.com/python/cpython/blob/master/Lib/test/test_exceptions.py#L181

--

___
Python tracker 

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



[issue40335] Regression in multiline SyntaxError offsets

2020-04-24 Thread Pablo Galindo Salgado

Pablo Galindo Salgado  added the comment:

With the old parser it works:

~/github/python/master master*
❯ ./python -X oldparser t.py
3.9.0a5+ (heads/master:503de7149d, Apr 24 2020, 22:02:28)
[GCC 9.3.0]

SyntaxError:
- line: 8
- offset: 8
- text: "'''\n\ndef bar():\npass\n\ndef baz():\n'''quux'''\n"


~/github/python/master master*
❯ ./python  t.py
3.9.0a5+ (heads/master:503de7149d, Apr 24 2020, 22:02:28)
[GCC 9.3.0]

SyntaxError:
- line: 8
- offset: 52
- text: "'''"

--

___
Python tracker 

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



[issue40335] Regression in multiline SyntaxError offsets

2020-04-24 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

Yeah, I can confirm after bisecting that the commit that introduced the 
regression is the new parser:

c5fc15685202cda73f7c3f5c6f299b0945f58508 is the first bad commit
commit c5fc15685202cda73f7c3f5c6f299b0945f58508
Author: Pablo Galindo 
Date:   Wed Apr 22 23:29:27 2020 +0100

bpo-40334: PEP 617 implementation: New PEG parser for CPython (GH-19503)

Co-authored-by: Guido van Rossum 
Co-authored-by: Lysandros Nikolaou 

--

___
Python tracker 

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



[issue40335] Regression in multiline SyntaxError offsets

2020-04-24 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


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

___
Python tracker 

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



[issue40335] Regression in multiline SyntaxError offsets

2020-04-24 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

Hu.actually, no. This is something else...

--

___
Python tracker 

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



[issue40367] ImportError: libffi.so.6

2020-04-24 Thread Éric Araujo

Éric Araujo  added the comment:

How did you get the Python installed in /opt/python/3.8.1?

Maybe it was compiled against libffi 6, then you updated the system to libffi 
7, so that Python would need a rebuild.

--
nosy: +eric.araujo

___
Python tracker 

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



[issue40335] Regression in multiline SyntaxError offsets

2020-04-24 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

This is likely due to the new parser (see PEP 617). Do you get the same problem 
running with -X oldparser ?

--

___
Python tracker 

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



[issue39089] Update IDLE's credits

2020-04-24 Thread Tal Einat


Tal Einat  added the comment:

Looks pretty good to me. I've been working on IDLE since... 2003/2004, 
beginning with a private fork of IDLE-fork. I began actually contributing to 
the main CPython version of IDLE in 2005.

--

___
Python tracker 

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



[issue40031] Python Configure IDLE 'Ok' and 'Apply' buttons do not seem to work.

2020-04-24 Thread Tal Einat


Tal Einat  added the comment:

Saaheer, could you please run IDLE by opening a command window (Run -> cmd.exe) 
or PowerShell, then running `python -m idlelib`? Then when this happens, please 
check the command / PowerShell window to see whether an error message and/or 
traceback has appeared there, and if so please copy it here. That would greatly 
help us to diagnose the issue.

--

___
Python tracker 

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



[issue40335] Regression in multiline SyntaxError offsets

2020-04-24 Thread Anthony Sottile


Anthony Sottile  added the comment:

This seems to have regressed again

$ ./python --version --version
Python 3.9.0a5+ (heads/master:503de7149d, Apr 24 2020, 13:34:49) 
[GCC 7.5.0]
$ ./python t.py
  File "/home/asottile/workspace/cpython/t.py", line 8

^
SyntaxError: invalid string prefix

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

___
Python tracker 

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



[issue40382] Make 'rt' the default for open in docs

2020-04-24 Thread Facundo Batista


New submission from Facundo Batista :

This is mostly a confusion about 'r' being a synonym of 'rt', while it's more 
explicit if we consider 'r' as one default, and 't' as other (as other parts of 
the documentation do).

Doing `help(open)` we get:

mode is an optional string that specifies the mode in which the file
is opened. It defaults to 'r' which means open for reading in text
mode. 

Later in the same text it's stated:

The default mode is 'rt' (open for reading text).

Which reflects the wording I want to have, but is confusing that initially it 
said a different thing.

If we get the html docs, it says "The default mode is 'r' (open for reading 
text, synonym of 'rt')."

Why not just stating that the default mode is 'rt'?

--
assignee: docs@python
components: Documentation
messages: 367219
nosy: docs@python, facundobatista
priority: normal
severity: normal
stage: needs patch
status: open
title: Make 'rt' the default for open in docs
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



[issue40381] plistlib doesn't handle poorly-formatted plists

2020-04-24 Thread Clay Caviness

Clay Caviness  added the comment:

I expect the answer here to be "plistlib is correct, that's a poorly formatted 
plist", but since plistlib is "for reading and writing the “property list” 
files used mainly by Mac OS X and supports both binary and XML plist files", 
and Apple's own tooling handles these poorly-formatted files without error it 
was worth raising the issue.

--

___
Python tracker 

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



[issue40381] plistlib doesn't handle poorly-formatted plists

2020-04-24 Thread Clay Caviness


New submission from Clay Caviness :

Some Info.plist files are poorly formatted. I am using plistlib to read 
Info.plist file from various .app bundles. On some, plistlib.load raises a 
ValueError when trying to parse.

Examining one of these Info.plist files, it turns out *it* is poorly formatted, 
but while python's plistlib is unhappy, it passes "plutil -lint" just fine and 
"Foundation.NSDictionary.dictionaryWithContentsOfFile_" is happy to read it.

Here's a minimal sample plist file:
"""

http://www.apple.com/DTDs/PropertyList-1.0.dtd;>


  An array
  
a string
A wild key appears!
it has a string
another string
  


"""

plistlib (correctly, I think) says that's no good. Apple's tooling just ... 
changes the key to another string in the array and carries on.

I've attached an actual problematic Info.plist as well.

--
components: Library (Lib)
files: Info.plist
messages: 367217
nosy: Clay Caviness
priority: normal
severity: normal
status: open
title: plistlib doesn't handle poorly-formatted plists
versions: Python 3.7
Added file: https://bugs.python.org/file49091/Info.plist

___
Python tracker 

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



[issue40377] APPDATA location in Microsoft Store version

2020-04-24 Thread Steve Dower


Steve Dower  added the comment:

You're welcome! We're all involved - apart from a little bit of startup code, 
it's exactly the same as the regular install.

Right now, I'd say you have a case that needs the regular installer, in order 
to avoid the appdata redirection.

As for changing it, it seems that thing have been updated again in last year's 
1903 update to make AppData redirection even more transparent (ref: 
https://docs.microsoft.com/en-us/windows/msix/desktop/desktop-to-uwp-behind-the-scenes#file-system
 ). So the intent is really clear that these file locations are not supposed to 
be shared (e.g. by printing out the directory backing the app-local 
modifications).

What's the best option here? Probably for Jupyter to move the files elsewhere, 
or provide a way to output the relevant contents of the file on the console 
rather than just printing the path. Either of those would work fine on Python 
3.8 and earlier as well.

I'm not even sure that those UWP APIs are guaranteed to give a path to the 
redirected folder - that would break reading of unredirected files, as the docs 
are clear that User\Name\AppData is redirected, not the other way around. So I 
don't know that it's an option. I'm also not aware of any way to disable the 
redirection within the app, like there is for WOW64 redirections.

Having thought some more, I really do think the best option is for Jupyter to 
be able to print out the required information. That means its stored files can 
be safely backed up/restored (or transferred, if put in Roaming) and other 
applications can "python -m jupyter kernelspec " to get all 
of the info they need. Even if we added a new API here, they'd still have to 
make a change, so making a change that works well for all runtime versions is 
probably preferable for them as well.

--
components: +Windows
nosy: +paul.moore, tim.golden, zach.ware
type: behavior -> enhancement
versions: +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



[issue40380] Errors during make test python 3.8.2

2020-04-24 Thread Steven Fleck


New submission from Steven Fleck :

I'm having some issues with installing python 3.8.2. I'm installing it in my 
personal workspace on my university's computing resources (linux). I've 
installed many programs here, but python is giving me some issues. 

Ultimately, I'm failing 5 tests:
test_multiprocessing_forkserver 
test_pathlib
test_resource
test_socket 
test_zipfie

Any help into what I can do to fix these errors would be greatly appreciated. 
I've attached a file that has the outputs of each command listed below. I hope 
it helps

line 0001: ./configure
line 0754: make
line 1238: make test
line 3539: make test TESTOPTS="-v test_multiprocessing_forkserver test_pathlib 
test_resource test_socket test_zipfie"

--
components: Installation
files: python_3.8.2_installation.txt
messages: 367215
nosy: Steven Fleck
priority: normal
severity: normal
status: open
title: Errors during make test python 3.8.2
type: compile error
versions: Python 3.8
Added file: https://bugs.python.org/file49090/python_3.8.2_installation.txt

___
Python tracker 

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



[issue34028] Python 3.7.0 wont compile with SSL Support 1.1.0 > alledged missing X509_VERIFY_PARAM_set1_host() support

2020-04-24 Thread Jan Wilmans


Jan Wilmans  added the comment:

I couldn't get this to work at all, python 3.7 compiled fine, but at the end it 
reports:

'''
*** WARNING: renaming "_ssl" since importing it failed: libssl.so.1.1: cannot 
open shared object file: No such file or directory
*** WARNING: renaming "_hashlib" since importing it failed: libssl.so.1.1: 
cannot open shared object file: No such file or directory

Python build finished successfully!

Following modules built successfully but were removed because they could not be 
imported:
_hashlib  _ssl 


Could not build the ssl module!
Python requires an OpenSSL 1.0.2 or 1.1 compatible libssl with 
X509_VERIFY_PARAM_set1_host().
LibreSSL 2.6.4 and earlier do not provide the necessary APIs, 
https://github.com/libressl-portable/portable/issues/381
'''

But in the end I got it to work like this:

- install_python3.7.sh  
#!/bin/bash
set -euo pipefail

mkdir /tmp/openssl
cd /tmp/openssl
wget https://www.openssl.org/source/openssl-1.1.1a.tar.gz
tar -xvf openssl-1.1.1a.tar.gz
cd openssl-1.1.1a
./config --prefix=/usr/local/openssl1.1.1 --openssldir=/usr/local/openssl1.1.1
make
make install
rm -rf /tmp/opensll

echo /usr/local/openssl1.1.1/lib > /etc/ld.so.conf.d/openssl1.1.1.conf
ldconfig 

mkdir /tmp/python37
wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tgz
tar xfz Python-3.7.3.tgz
cd Python-3.7.3
./configure --with-ensurepip=yes --with-openssl=/usr/local/openssl1.1.1 
CFLAGS="-I/usr/local/openssl1.1.1/include" 
LDFLAGS="-L/usr/local/openssl1.1.1/lib" CXX=/usr/bin/g++
make
make install
rm -rf /tmp/python37

ldconfig 


This important pieces are:

echo /usr/local/openssl1.1.1/lib > /etc/ld.so.conf.d/openssl1.1.1.conf
ldconfig 

to make it find the .so to load it at runtime and 

./configure --with-ensurepip=yes --with-openssl=/usr/local/openssl1.1.1 
CFLAGS="-I/usr/local/openssl1.1.1/include" 
LDFLAGS="-L/usr/local/openssl1.1.1/lib" CXX=/usr/bin/g++

specifying the non-standard openssl-version specifically.

--
nosy: +Jan Wilmans

___
Python tracker 

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



[issue13645] import machinery vulnerable to timestamp collisions

2020-04-24 Thread Ammar Askar


Change by Ammar Askar :


--
nosy: +ammar2
nosy_count: 8.0 -> 9.0
pull_requests: +19023
pull_request: https://github.com/python/cpython/pull/19651

___
Python tracker 

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



[issue40348] Programming FAQ about "What is delegation?": Fix typos

2020-04-24 Thread Éric Araujo

Éric Araujo  added the comment:

Thanks!  Would you like to make the changes yourself?

--
nosy: +eric.araujo

___
Python tracker 

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



[issue40379] multiprocessing's default start method of fork()-without-exec() is broken

2020-04-24 Thread Itamar Turner-Trauring


Itamar Turner-Trauring  added the comment:

Looks like as of 3.8 this only impacts Linux/non-macOS-POSIX, so I'll amend the 
above to say this will also make it consistent with macOS.

--

___
Python tracker 

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



[issue40346] Add random.BaseRandom to ease implementation of subclasses

2020-04-24 Thread Tim Peters


Tim Peters  added the comment:

To be serious about numpy ;-) , people consuming a great many random outputs 
will eventually move to numpy out of necessity (speed).  So for that reason 
alone it's good to mimic what they do. But more fundamentally, they have more 
people with relevant deep knowledge contributing to the project than Python 
has. When, e.g., they were considering a Twister alternative, PCG's inventor 
contributed extensively to their discussion, and even created a new member of 
the PCG family to address concerns raised by numpy contributors' testing - sll 
_before_ it was released.

Apart from Mark chiming in, the Python project just doesn't get that level of 
help in these areas.

--

___
Python tracker 

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



[issue40334] PEP 617: new PEG-based parser

2020-04-24 Thread Guido van Rossum


Change by Guido van Rossum :


--
pull_requests: +19022
pull_request: https://github.com/python/cpython/pull/19704

___
Python tracker 

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



[issue40360] Deprecate lib2to3 (and 2to3) for future removal

2020-04-24 Thread Gregory P. Smith


Gregory P. Smith  added the comment:


New changeset 503de7149d03bdcc671dcbbb5b64f761bb192b4d by Carl Meyer in branch 
'master':
bpo-40360: Deprecate lib2to3 module in light of PEP 617 (GH-19663)
https://github.com/python/cpython/commit/503de7149d03bdcc671dcbbb5b64f761bb192b4d


--

___
Python tracker 

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



[issue40379] multiprocessing's default start method of fork()-without-exec() is broken

2020-04-24 Thread Itamar Turner-Trauring


New submission from Itamar Turner-Trauring :

By default, multiprocessing uses fork() without exec() on POSIX. For a variety 
of reasons this can lead to inconsistent state in subprocesses: module-level 
globals are copied, which can mess up logging, threads don't survive fork(), 
etc..

The end results vary, but quite often are silent lockups.

In real world usage, this results in users getting mysterious hangs they do not 
have the knowledge to debug.

The fix for these people is to use "spawn" by default, which is the default on 
Windows.

Just a small sample:

1. Today I talked to a scientist who spent two weeks stuck, until she found my 
article on the subject 
(https://codewithoutrules.com/2018/09/04/python-multiprocessing/). Basically 
multiprocessing locked up, doing nothing forever. Switching to "spawn" fixed it.
2. https://github.com/dask/dask/issues/3759#issuecomment-476743555 is someone 
who had issues fixed by "spawn".
3. https://github.com/numpy/numpy/issues/15973 is a NumPy issue which 
apparently impacted scikit-learn.


I suggest changing the default on POSIX to match Windows.

--
messages: 367210
nosy: itamarst
priority: normal
severity: normal
status: open
title: multiprocessing's default start method of fork()-without-exec() is broken
type: behavior
versions: Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 3.9

___
Python tracker 

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



[issue40360] Deprecate lib2to3 (and 2to3) for future removal

2020-04-24 Thread Gregory P. Smith


Gregory P. Smith  added the comment:

Okay,the pending deprecation is in.  Keeping open as a reminder to turn that 
into a real DeprecationWarning in 3.10 after the 3.9 branch is cut.

We'll then want to track reminding us to remove it in 3.12.

--

___
Python tracker 

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



[issue40378] ast.parse fails to trigger SyntaxWarning that normal execution does

2020-04-24 Thread Anthony Sottile


New submission from Anthony Sottile :

compare the following:

```
if False: 'foo'(1)
```


$ python3.9
Python 3.9.0a5 (default, Mar 23 2020, 23:11:30) 
[GCC 7.5.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ast
>>> ast.parse(b"if False: 'foo'(1)")

>>> if False: 'foo'(1)
... 
:1: SyntaxWarning: 'str' object is not callable; perhaps you missed a 
comma?


even with `PYTHONWARNINGS=error` no warning / error is raised

--
messages: 367207
nosy: Anthony Sottile
priority: normal
severity: normal
status: open
title: ast.parse fails to trigger SyntaxWarning that normal execution does
type: behavior
versions: 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



[issue40374] collections.abc docs table: Mapping missing __reversed__

2020-04-24 Thread Raymond Hettinger


Change by Raymond Hettinger :


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



[issue40374] collections.abc docs table: Mapping missing __reversed__

2020-04-24 Thread Thor Whalen


Thor Whalen  added the comment:

Dennis,

Thanks for the (very complete) explanation. I induced to err because of the
following confusing facts:
```
from collections.abc import Mapping, Sequence
import sys
if sys.version_info <= (2, 7):
assert '__reversed__' not in dir(Mapping)
elif sys.version_info >= (3, 7):
assert not isinstance(Mapping, Sequence)
assert '__reversed__' in dir(Mapping)
assert list(reversed(dict.fromkeys('abc'))) == ['c', 'b', 'a']
# + no mention of Mapping.__reversed__ in the docs
```
Indeed, I didn't look at the code. Thanks for that.

On Thu, Apr 23, 2020 at 5:28 PM Dennis Sweeney 
wrote:

>
> Dennis Sweeney  added the comment:
>
> > `Mapping.__reversed__` exists
>
> While ``'__reversed__' in dir(Mapping)`` is true, that unfortunately does
> not mean that it is a real callable method:
>
>
> from collections.abc import Mapping
> class Map(Mapping):
> def __getitem__(self, x):
> if x == 42:
> return 17
> raise KeyError
> def __len__(self, x):
> return 1
> def __iter__(self):
> yield 42
>
> >>> m = Map()
> >>> reversed(m)
> Traceback (most recent call last):
> ...
> TypeError: 'Map' object is not reversible
>
> In the code for Mapping, ``__reversed__`` is explicitly defined as None
> [1] so that calling ``reversed(custom_mapping)`` doesn't accidentally fall
> back on the sequence protocol, which would mean starting at
> len(custom_mapping)-1 and calling __getitem__ on each index [2], which is
> certainly not desirable for arbitrary mappings.
>
> I don't think there is a reasonable way, given arbitrary implementations
> of __len__, __iter__, and __getitem__, to have a mixin reversed iterator.
> If someone wants their mapping to have a __reversed__ method, they should
> define it themselves.
>
> [1]
> https://github.com/python/cpython/blob/master/Lib/_collections_abc.py#L707
> [2]
> https://docs.python.org/3/reference/datamodel.html?highlight=__reversed__#object.__reversed__
>
> --
> nosy: +Dennis Sweeney
>
> ___
> Python tracker 
> 
> ___
>

--
nosy: +Thor Whalen

___
Python tracker 

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



[issue40346] Add random.BaseRandom to ease implementation of subclasses

2020-04-24 Thread STINNER Victor


STINNER Victor  added the comment:

Fun fact. When I wrote my "class NumpyRandom(random.BaseRandom):" example, I 
found a quite serious bug in numpy:

"default_rng.integers(2**32) always return 0"
https://github.com/numpy/numpy/issues/16066

Even numpy is not perfect yet :-)

--

___
Python tracker 

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



[issue40346] Add random.BaseRandom to ease implementation of subclasses

2020-04-24 Thread Mark Dickinson


Mark Dickinson  added the comment:

[Tim]

> Mark, you don't count ;-)

Yes, I was suspecting I'd fail the "real world" test. Fair enough. :-)

--

___
Python tracker 

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



[issue40346] Add random.BaseRandom to ease implementation of subclasses

2020-04-24 Thread Tim Peters


Tim Peters  added the comment:

Mark, you don't count ;-)  Neither do I.  Of course I've subclassed Random too, 
to experiment with other base generators (including PCG variants).  But they're 
throwaways, and I don't care that it can require staring at the code to make as 
many changes as needed.  Developers _of_ Python don't need things to be trivial 
to make quick progress.

So I remain where I was:  +0, provided there are no notable runtime 
regressions.  Nice to have (hence "+"), but don't really care if it never 
happens (hence "0").

As to what numpy does, I'm always in favor of following their lead when 
possible and Pythonic.

--

___
Python tracker 

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



[issue40346] Add random.BaseRandom to ease implementation of subclasses

2020-04-24 Thread STINNER Victor


STINNER Victor  added the comment:

I see 3 options to fix randbytes() in subclasses:

(A) Remove the randbytes() optimization (C implementation): always implement it 
with getrandbits().

(B) Add BaseRandom base class: PR 19631.

(C) Modify __init_subclass__() to implement randbytes() with getrandbits() in 
subclasses: PR 19700

--

Option (A) is the simplest, but it makes randbytes() 5x slower.

Option (B) is my favorite: it keeps all random.Random optimization, it reduces 
SystemRandom footprint by 2 KB, it eases writing new subclasses (a single 
method must be defined).

Option (C) seems to be complicated to implement. I'm not sure that it does 
satisfy Raymond's requirements.

--

Option (A) and (C) don't solve my initial concern of this issue: it's not easy 
to subclass random.Random, it is still required to *override* 5 methods.

The main drawback of option (B) is that Random subclasses now inherit 
Random.randbytes() and so should override it which is new requirement. But 
technically, if Random.randbytes() is inherited: it respects its contract, it 
generates random bytes... it's just that it may not be the behavior expected by 
the developer.

My PR 19631 solves this drawback by *documenting* the new requirement in the 
Porting guide of What's New in Python 3.9. I'm not sure if it should be 
qualified as backward incompatible, but if yes, I propose to make it on purpose 
(other options have other drawbacks).

--

Honestly, so far, I'm confused. It's now unclear to me if subclassing the 
random.Random class is a supported feature and/or if we want to support it. 
It's also unclear to me if the performance matters in the random module. On one 
side, gauss() has an optimization which makes it not thread-safe, on the other 
side option (A) would make randbytes() 5x slower.

It's also possible to combine some options like (B)+(C) which solves the main 
(B) drawback.

Obviously, the last choice is to revert the randbytes() features (decide that 
it's no longer possible to add such new method to the random.Random because of 
drawbacks described in this issue).

--

Well, I proposed various options. Now I let you to decide ;-)

--

___
Python tracker 

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



[issue40346] Add random.BaseRandom to ease implementation of subclasses

2020-04-24 Thread Mark Dickinson


Mark Dickinson  added the comment:

[Victor]

> Honestly, if you consider that BaseRandom base class is not worth it, I will 
> just abandon this idea.

It's not that I think it's not worth it (I'm not currently convinced either 
way). It's more that if we're going to make a change, then it's not clear to me 
that the particular choice in the BaseRandom PR is necessarily the only or best 
way to do it. There are a good few technical choices to be made, and I think 
there's value in having a wider discussion.

--

___
Python tracker 

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



[issue40346] Add random.BaseRandom to ease implementation of subclasses

2020-04-24 Thread STINNER Victor


STINNER Victor  added the comment:

Raymond Hettinger: "It is not okay to flat out ignore the opposing comments 
from the module maintainers.  Being on the steering committee isn't a license 
to do whatever you want, ignoring published APIs, breaking user code, and 
ignoring other contributors.  If you want to go forward with this, there should 
be a PEP (and you should be recused from adjudicating it)."

That's a personal attack, would you mind to stay at the technical level, 
please? Thanks.

--

___
Python tracker 

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



[issue40346] Add random.BaseRandom to ease implementation of subclasses

2020-04-24 Thread STINNER Victor


STINNER Victor  added the comment:

Mark:
> With the various competing options and the lack of agreement on what (if 
> anything) should be done, this feels like PEP territory.

Honestly, if you consider that BaseRandom base class is not worth it, I will 
just abandon this idea. I'm not interested to write a whole PEP just for that. 
(Maybe someone else is more motivated than me ;-))

--

___
Python tracker 

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



[issue40346] Add random.BaseRandom to ease implementation of subclasses

2020-04-24 Thread STINNER Victor


STINNER Victor  added the comment:

Antoine:
> However, if we want to think about a new subclassing API, it may be worth 
> looking at the recent Numpy changes. Numpy added a new random generator API 
> recently, with a design based on composition rather than inheritance (and 
> also they switched from Mersenne Twister to another underlying PRNG!):
> https://numpy.org/doc/stable/reference/random/index.html

Yeah, sometimes composition is simpler. My BaseRandom base class (PR 19631) can 
be used with composition indirectly, since all you need is to implemented 
getrandbits(). Example:

---
from numpy.random import default_rng
import random

class NumpyRandom(random.BaseRandom):
def __init__(self):
self._rng = default_rng()

def getrandbits(self, n):
# FIXME: support n larger than 64 ;-)
return int(self._rng.integers(2 ** n))

gen = NumpyRandom()
print(gen.randint(1, 6))
print(gen.random())
print(gen.randbytes(3))
---

--

___
Python tracker 

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



[issue40375] Add the UNSELECT command to imaplib

2020-04-24 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



[issue9216] FIPS support for hashlib

2020-04-24 Thread STINNER Victor


STINNER Victor  added the comment:

Christian Heimes: "Instead if doing a FIPS test, users and applications should 
perform a feature test and handle the error. The approach is future-proof and 
can also cover crypto policies restriction like minimum key sizes."

Alright, I see. Thanks for your explanation ;-)

--

___
Python tracker 

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



[issue40334] PEP 617: new PEG-based parser

2020-04-24 Thread STINNER Victor


STINNER Victor  added the comment:

Lysandros:
> This is now fixed.

Thanks, that was quick ;-)

--

___
Python tracker 

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



[issue9216] FIPS support for hashlib

2020-04-24 Thread Christian Heimes


Christian Heimes  added the comment:

I'm against exposing the function as hashlib.get_fips_mode() because it is an 
internal implementation detail. I don't want to confuse users or make users 
think that "if hashlib.get_fips_mode()" is sufficient for feature tests. For 
starters there are multiple levels and versions of the FIPS standard like 
FIPS-140-2 and FIPS-140-3.

Instead if doing a FIPS test, users and applications should perform a feature 
test and handle the error. The approach is future-proof and can also cover 
crypto policies restriction like minimum key sizes.

--

___
Python tracker 

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



[issue9216] FIPS support for hashlib

2020-04-24 Thread STINNER Victor


STINNER Victor  added the comment:

Petr Viktorin and Christian Heimes convinced me that it's a bad idea to expose 
OpenSSL FIPS_mode() as a public hashlib.get_fips_mode() function. It is too 
specific to OpenSSL. For example, FIPS_mode() result is a number which is 
specific to OpenSSL. Other crypto libraries are likely to use different values.

Moreover, as I wrote in my previous message, other crypto libraries expose the 
FIPS mode differently. It may not just be a global FIPS mode.

Finally, there are different FIPS modes. For example, Gcrypt has an "Enforced 
FIPS" mode.

So I modified PR 19703 to only expose FIPS_mode() as a private 
_hashlib.get_fips_mode() function. Well, as done in RHEL in fact ;-)

--

___
Python tracker 

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



[issue9216] FIPS support for hashlib

2020-04-24 Thread STINNER Victor


STINNER Victor  added the comment:

I'm trying to understand how "portable" is it to expose OpenSSL FIPS_mode() as 
hashlib.get_fips_mode() which would return a boolean (True or False).

It seems like FIPS is more complex than that. Other crypto libraries which 
implement FIPS have a different way to expose FIPS mode to the consumer of the 
API:

* NSS seems to have a different API for functions in FIPS mode: 
https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS/Reference/NSS_cryptographic_module/FIPS_mode_of_operation
* GnuTLS provides gnutls_fips140_mode_enabled() which returns an unsigned 
integer: "return non-zero if true or zero if false"
* Gcrypt doesn't seem to expose a function to know if FIPS is enabled or not. 
It also has an "Enforced FIPS" mode:

  * https://www.gnupg.org/documentation/manuals/gcrypt/Enabling-FIPS-mode.html
  * https://www.gnupg.org/documentation/manuals/gcrypt/Enabling-FIPS-mode.html

* Bouncy Castle has a "FIPS provider": an object should be requested in FIPS 
mode

See also RHEL 8 Security Hardening documentation, "Chapter 3. Using system-wide 
cryptographic policies":
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/security_hardening/using-the-system-wide-cryptographic-policies_security-hardening

For my needs (skip tests which are not relevant in FIPS mode), it seems like 
keeping the function private in _hashlib.get_fips_mode() is enough.

My plan is to use it in as test.support.get_fips_mode() function which would 
return False if _hashlib.get_fips_mode() is missing.

--

___
Python tracker 

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



[issue40370] AIX: ld_so_aix not found during test of test_peg_generator

2020-04-24 Thread Michael Felt


Michael Felt  added the comment:

Thanks for the quick response. I see both bots are good.

--

___
Python tracker 

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



[issue40334] PEP 617: new PEG-based parser

2020-04-24 Thread Lysandros Nikolaou


Lysandros Nikolaou  added the comment:

> test_peg_generator leaks references.

This is now fixed.

--

___
Python tracker 

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



[issue40334] PEP 617: new PEG-based parser

2020-04-24 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:


New changeset 24ffe705c30e36c82940d75fd1454256634d0b3c by Lysandros Nikolaou in 
branch 'master':
bpo-40334: Rewrite test_c_parser to avoid memory leaks (GH-19694)
https://github.com/python/cpython/commit/24ffe705c30e36c82940d75fd1454256634d0b3c


--

___
Python tracker 

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



[issue9216] FIPS support for hashlib

2020-04-24 Thread STINNER Victor


STINNER Victor  added the comment:

> I'm fine with a used_for_security flag and functions to get/set FIPS state. 
> Something like hashlib.get_fips_mode() is useful for testing.

I proposed PR 19703 to expose OpenSSL FIPS_mode() as hashlib.get_fips_mode().

FIPS support was introduced in version 0.9.7 of OpenSSL and so is available in 
the minimum OpenSSL required to build Python 3.9.

LibreSSL doesn't have FIPS_mode() on purpose. Ted Unangst wrote: "I figured I 
should mention our current libressl policy wrt FIPS mode.  It's gone and it's 
not coming back."
https://marc.info/?l=openbsd-misc=139819485423701=2

My plan is to use hashlib.get_fips_mode() to skip a few tests if the FIPS mode 
is enabled. Simple example: test_crypt.test_methods() checks that 
self.assertEqual(crypt.methods[-1], crypt.METHOD_CRYPT). Except that in FIPS 
mode, METHOD_CRYPT is not available since it's too weak (3DES if I recall 
correctly). I would like to skip this test in FIPS mode.

My colleague Chalampos also plans to add a FIPS enabled buildbot running RHEL8 
to ensure that the Python test suite pass in FIPS mode, and detect regressions 
in FIPS mode.

--

___
Python tracker 

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



[issue9216] FIPS support for hashlib

2020-04-24 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +19021
pull_request: https://github.com/python/cpython/pull/19703

___
Python tracker 

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



[issue40377] APPDATA location in Microsoft Store version

2020-04-24 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +steve.dower

___
Python tracker 

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



[issue40377] APPDATA location in Microsoft Store version

2020-04-24 Thread Stephan Troyer


New submission from Stephan Troyer :

In Microsoft Store apps, access to %APPDATA% and %LOCALAPPDATA% gets 
transparently redirected to an app specific location (such as 
%LOCALAPPDATA%\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\).
 This is perfect for saving settings etc. of Python scripts and packages, 
however that doesn't work, when the unredirected paths are returned by a 
sandboxed Python script and consumed by a 3rd party tool.
One example for the issue created by that is Jupyter, which saves its kernel 
settings to %appdata% and returns that path when using the command `jupyter 
kernelspec list`. However other applications which rely on that output can't 
access the resulting paths (since their file access doesn't get redirected).
Would it make sense to add some API for accessing the UWP APIs 
ApplicationData.Current.LocalFolder and ApplicationData.Current.RoamingFolder, 
which provide a folder path, which doesn't get redirected?

Besides, I want to thank everyone involved in the Microsoft Store version of 
Python!

--
components: IO
messages: 367188
nosy: stephtr
priority: normal
severity: normal
status: open
title: APPDATA location in Microsoft Store version
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



[issue40376] documentation for os.getgrouplist potentially misleading

2020-04-24 Thread Jens Holzkämper

Change by Jens Holzkämper :


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

___
Python tracker 

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



[issue40376] documentation for os.getgrouplist potentially misleading

2020-04-24 Thread Jens Holzkämper

New submission from Jens Holzkämper :

https://docs.python.org/3/library/os.html#os.getgrouplist states „Return list 
of group ids that user belongs to. If group is not in the list, it is included; 
typically, group is specified as the group ID field from the password record 
for user.“, but the function is at least on Linux a wrapper for getgrouplist 
from the C standard library, which lists only the membership in groups in the 
group-database. Users can be members of groups without it being declared in the 
group database, this is often the case with the default group of the user which 
is only declared in the passwd database.

e.g. 
/etc/passwd: woodfighter:x:1000:1000:,,,:/home/woodfighter:/bin/bash
/etc/group: woodfighter:x:1000:

os.getgrouplist("woodfighter",65534) then doesn't contain group id 1000.

The documentation tries to steer a developer in the right direction with the 
second sentence but fails to state, that the list will be possibly incomplete 
otherwise. I would add something like „, because that group ID will otherwise 
be potentially omitted.“ before the last period.

--
assignee: docs@python
components: Documentation
messages: 367187
nosy: docs@python, woodfighter
priority: normal
severity: normal
status: open
title: documentation for os.getgrouplist potentially misleading
type: enhancement

___
Python tracker 

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



[issue38061] FreeBSD: Optimize subprocess.Popen(close_fds=True) using closefrom()

2020-04-24 Thread STINNER Victor


STINNER Victor  added the comment:

Thanks Ed Maste, Conrad Meyer, Kyle Evans and Kubilay Kocak!

I ran a benchmark:

vstinner@freebsd$ env/bin/python -m pyperf command -v -- ./python -c 'import 
subprocess, sys; args=[sys.executable, "-sS", "-c", "pass"]; 
subprocess.run(args)'

The optimization made subprocess almost 4x faster on FreeBSD!

vstinner@freebsd$ env/bin/python -m pyperf compare_to ref.json closefrom.json 
Mean +- std dev: [ref] 176 ms +- 1 ms -> [closefrom] 46.6 ms +- 1.2 ms: 3.77x 
faster (-74%)

129 ms were wasted in calling 229 284 times close(fd)!

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



[issue37790] subprocess.Popen() is extremely slow (with close_fds=True which is the default) on Illumos

2020-04-24 Thread STINNER Victor


STINNER Victor  added the comment:

I merged FreeBSD changes:

New changeset 162c567d164b5742c0d1f3f8bd8c8bab9c117cd0 by Victor Stinner in 
branch 'master':
bpo-38061: os.closerange() uses closefrom() on FreeBSD (GH-19696)
https://github.com/python/cpython/commit/162c567d164b5742c0d1f3f8bd8c8bab9c117cd0

New changeset e6f8abd500751a834b6fff4f107ecbd29f2184fe by Victor Stinner in 
branch 'master':
bpo-38061: subprocess uses closefrom() on FreeBSD (GH-19697)
https://github.com/python/cpython/commit/e6f8abd500751a834b6fff4f107ecbd29f2184fe

Free feel to propose a more generic way to detect when closefrom() function is 
available ;-) Or just a patch to add "|| defined(sun)".

--

___
Python tracker 

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



[issue38061] FreeBSD: Optimize subprocess.Popen(close_fds=True) using closefrom()

2020-04-24 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset e6f8abd500751a834b6fff4f107ecbd29f2184fe by Victor Stinner in 
branch 'master':
bpo-38061: subprocess uses closefrom() on FreeBSD (GH-19697)
https://github.com/python/cpython/commit/e6f8abd500751a834b6fff4f107ecbd29f2184fe


--

___
Python tracker 

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



[issue38061] FreeBSD: Optimize subprocess.Popen(close_fds=True) using closefrom()

2020-04-24 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 162c567d164b5742c0d1f3f8bd8c8bab9c117cd0 by Victor Stinner in 
branch 'master':
bpo-38061: os.closerange() uses closefrom() on FreeBSD (GH-19696)
https://github.com/python/cpython/commit/162c567d164b5742c0d1f3f8bd8c8bab9c117cd0


--

___
Python tracker 

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



[issue37790] subprocess.Popen() is extremely slow (with close_fds=True which is the default) on Illumos

2020-04-24 Thread Antoine Pitrou


Antoine Pitrou  added the comment:

I think we would accept a PR since it would probably be trivial, but someone 
has to submit it :-)

--

___
Python tracker 

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



[issue37790] subprocess.Popen() is extremely slow (with close_fds=True which is the default) on Illumos

2020-04-24 Thread John Levon


John Levon  added the comment:

closefrom() is on both Solaris and illumos too - and might even have originated 
there as an API -  so if that's the issue, it should be trivially fixable

--

___
Python tracker 

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



[issue40286] Add randbytes() method to random.Random

2020-04-24 Thread STINNER Victor


STINNER Victor  added the comment:

Raymond:
> The randbytes() method needs to depend on genrandbits().

I created PR 19700 which allows to keep the optimization (C implementation in 
_randommodule.c) and Random subclasses implement randbytes() with getrandbits().

--

___
Python tracker 

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



[issue40346] Add random.BaseRandom to ease implementation of subclasses

2020-04-24 Thread STINNER Victor


STINNER Victor  added the comment:

I created this issue to address Raymond's comment:
"The randbytes() method needs to depend on genrandbits()."
https://bugs.python.org/issue40286#msg366860

I wrote PR 19700 to address that and only that.

With PR 19700, Random subclasses get a randbytes() implementation which uses 
getrandbits().

*Maybe* we could do the same in Random subclasses for the random() method, so 
let's start with the simplest PR :-)

Let's fix the randbytes() issue first.

--

___
Python tracker 

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



  1   2   >