[issue41316] tarfile: Do not write full path in FNAME field

2020-07-16 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +ethan.furman

___
Python tracker 

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



[issue41134] distutils.dir_util.copy_tree FileExistsError when updating symlinks

2020-07-16 Thread Tom Hale


Change by Tom Hale :


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

___
Python tracker 

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



[issue41319] IDLE 3.8 can not save and run this file

2020-07-16 Thread 宋嘉腾

New submission from 宋嘉腾 :

If I delete the chinese in this py file, it can run.
I use notepad and edit it, and it can run derectly in cmd.

--
assignee: terry.reedy
components: IDLE
files: tempconvert.py
messages: 373797
nosy: terry.reedy, 宋嘉腾
priority: normal
severity: normal
status: open
title: IDLE 3.8 can not save and run this file
type: compile error
versions: Python 3.8
Added file: https://bugs.python.org/file49320/tempconvert.py

___
Python tracker 

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



[issue41318] Better error message of "Cannot recover from stack overflow."

2020-07-16 Thread Heyi Tang


New submission from Heyi Tang :

Is it possible to add more detailed message for the error "Cannot recover from 
stack overflow"?
Something like "Cannot recover from stack overflow, it may be caused by 
catching a RecursionError but reaching the limit again before properly handling 
it."
Maybe the detailed design in 
https://github.com/python/cpython/blob/master/Include/ceval.h#L48 could also be 
shown to the developer?

It is hard to understand what happened only with the message "Cannot recover 
from stack overflow".

I hit the error because I write the code as following:
@some_logger
def f():
return f()
try:
  f()
except RecursionError:
  print("Recursion Error is raised!")

And it took me a lot of time to figure out why RecursionError is not raised but 
the "Fatal Python error" is shown.
Finally I realized that the problem is that the following code piece in 
"some_logger" (Which is an internal library provided by others) caught the 
exception and make tstate->overflowed=1.

def some_logger(func):
@functools.wraps(func)
def new_func(*args, **kwargs):
try:
# Unfortunately this code hit RecursionError and catched it
logger.info(some_message)
except Exception as e:
pass # Avoid affecting user function
return func(*args, **kwargs)
return new_func

So I think it might be better to provide more information to the developer that 
"Cannot recover" means that "RecursionError is caught and stack overflow 
again." and hint user to know the design of _Py_EnterRecursiveCall.

--
components: Interpreter Core
messages: 373796
nosy: th
priority: normal
severity: normal
status: open
title: Better error message of "Cannot recover from stack overflow."
type: enhancement
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



[issue38656] mimetypes for python 3.7.5 fails to detect matroska video

2020-07-16 Thread Michael Lazar

Michael Lazar  added the comment:

Greetings,

I just encountered this issue [0] and I agree with the sentiment that the 
documentation is currently misleading.

Particularly,

> By default, it provides access to the same database as the rest of this 
> module. The initial database is a copy of that provided by the module, and 
> may be extended by loading additional mime.types-style files into the 
> database using the read() or readfp() methods. The mapping dictionaries may 
> also be cleared before loading additional data if the default data is not 
> desired.

“as the rest of the module” implies to me that it should behave the same way as 
mimetypes.guess_type() does. The documentation only has one other reference to 
this built-in list of mimetypes, and the default values are hidden behind 
underscored variable names. I would re-word this as

"By default, it provides access to a database of well-known values defined 
internally by the python module. Unlike the other mimetypes convenience 
functions, it does not include definitions from the list of 
mimetypes.knownfiles. The initial database may be extended by loading 
additional mime.types-style files into the database using the read() or 
readfp() methods. The mapping dictionaries may also be cleared before loading 
additional data if the default data is not desired."

I would be happy to submit a PR if others agree.

[0] https://github.com/michael-lazar/jetforce/issues/38

--
nosy: +michael-lazar

___
Python tracker 

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



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

2020-07-16 Thread Tim Peters


Tim Peters  added the comment:

Thanks! That explanation really helps explain where "geometric distribution" 
comes from. Although why it keeps taking k'th roots remains a mystery to me ;-)

Speaking of which, the two instances of

exp(log(random())/k)

are numerically suspect. Better written as

random()**(1/k)

The underlying `pow()` implementation will, in effect, compute log(random()) 
with extra bits of precision for internal use. Doing log(random()) forces it to 
use a 53-bit approximation. Not to mention that it's more _obvious_ to write a 
k'th root as a k'th root.  Note: then the 1/k can be computed once outside the 
loop.

Perhaps worse is

log(1-W)

which should be written

log1p(-W)

instead.  W is between 0 and 1, and the closer it is to 0 the more its trailing 
bits are entirely lost in computing 1-W. It's the purpose of log1p to combat 
this very problem.

--

___
Python tracker 

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



[issue41312] add !p to pprint.pformat() in str.format() an f-strings

2020-07-16 Thread Eric V. Smith


Eric V. Smith  added the comment:

I suggest you discuss this on python-ideas, since we'll need to reach consensus 
there, first.

--
components: +Interpreter Core -IO, Library (Lib)

___
Python tracker 

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



[issue41312] add !p to pprint.pformat() in str.format() an f-strings

2020-07-16 Thread Charles Machalow


Charles Machalow  added the comment:

In terms of multiple parameters, I propose adding a method to control the 
defaults used by !p.

Though the defaults would work more than well enough for basic log and print 
usage.

--

___
Python tracker 

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



[issue40456] Complete adding silent mode for py_compile

2020-07-16 Thread Cameron Simpson


Cameron Simpson  added the comment:

Since bad input causes py_compile.py to issue an error like this:

  File 
"/usr/local/Cellar/python@3.8/3.8.3/Frameworks/Python.framework/Versions/3.8/lib/python3.8/py_compile.py",
 line 213, in main
if quiet < 2:
NameError: name 'quiet' is not defined

I suggest, to save long review of a larger PR elsewhere, can we please just 
initially apply a patch like this:

[~/src/cpython(git:py_compile-quiet-not-initialised)]fleet2*> diff
+ exec git diff
diff --git a/Lib/py_compile.py b/Lib/py_compile.py
index 21736896af..cea851274d 100644
--- a/Lib/py_compile.py
+++ b/Lib/py_compile.py
@@ -186,6 +186,7 @@ def main(args=None):
 """
 if args is None:
 args = sys.argv[1:]
+quiet = 0
 rv = 0
 if args == ['-']:
 while True:

Then the runtime issue goes away, and adding the feature fully can be addressed 
in a more leisurely fashion.

--
nosy: +cameron

___
Python tracker 

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



[issue41316] tarfile: Do not write full path in FNAME field

2020-07-16 Thread Emmanuel Arias


Emmanuel Arias  added the comment:

Hi,

If I understand correctly, the name that you are using into the tar
is the basename of the file. I didn't test it yet, but this PR will
remove the possibility to create a file into the tar using the
source tree folder?

Maybe we can think about implement a parameter seems like arcname
on Zipfile?

What about that?

Cheers!

--
nosy: +eamanu

___
Python tracker 

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



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

2020-07-16 Thread Larry Hastings


Larry Hastings  added the comment:

I must have taken my stupid pills today.  Why is this considered a "security" 
"release blocker"?  If you can put files in the root of the hard drive where 
Windows was installed, surely you have other, easier attack vectors.

--

___
Python tracker 

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



[issue41312] add !p to pprint.pformat() in str.format() an f-strings

2020-07-16 Thread Eric V. Smith


Eric V. Smith  added the comment:

I agree with Raymond that it's unlikely that this will work, as a practical 
matter. In addition to the other problems mentioned, there's the issue of the 
many parameters to control pprint.

And I agree with pprint, or a replacement, needing a redesign. I think it 
should use singledispatch.

--

___
Python tracker 

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



[issue41312] add !p to pprint.pformat() in str.format() an f-strings

2020-07-16 Thread Charles Machalow


Charles Machalow  added the comment:

One of the key things for ppformat here is to format long spanning dicts/lists 
to multiple lines, that look easy to read in a log. I feel as though that 
feature/usefulness outweigh potential indentation weirdness.

A lot of the usage would probably be towards the end of an fstring.

--

___
Python tracker 

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



[issue41312] add !p to pprint.pformat() in str.format() an f-strings

2020-07-16 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

If the python-ideas discussion is fruitful, go ahead and re-open this tracker 
item.

Personally, I don't see how this would work.  The pretty printing routines rely 
on knowing their current level of indentation.  Also, much of the "prettiness" 
comes from making the output span multiple lines, so this wouldn't fit well in 
the middle of an f-string.  Lastly, the pprint module leaves a lot to be 
desired and likely needs a rewrite from scratch, so it wouldn't be wise to tie 
it directly to a core language feature.

--
nosy: +rhettinger
resolution:  -> later
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



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

2020-07-16 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

I concur with Stefan.  This would mostly be a waste.

Also, the APIs aren't completely harmonious because the Decimal methods accept 
an optional context object.

--

___
Python tracker 

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



[issue41300] IDLE: add missing import io in iomenu.py

2020-07-16 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

Łukasz, Please cherry-pick the 3.8 backport,  ffeb920, as it has a 3.8-specific 
fixup to idlelib/NEWS.txt.

I verified the bug and fix on Windows.  I am leaving this open to add automated 
tests.

--
keywords:  -patch
stage: patch review -> test needed

___
Python tracker 

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



[issue41300] IDLE: add missing import io in iomenu.py

2020-07-16 Thread Terry J. Reedy


Terry J. Reedy  added the comment:


New changeset ffeb9202540c07d384f82ff3ab86c37c1433283a by Miss Islington (bot) 
in branch '3.8':
[3.8] bpo-41300: IDLE - save files with non-ascii chars  (GH-21512)
https://github.com/python/cpython/commit/ffeb9202540c07d384f82ff3ab86c37c1433283a


--

___
Python tracker 

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



[issue41300] IDLE: add missing import io in iomenu.py

2020-07-16 Thread miss-islington


miss-islington  added the comment:


New changeset 5a7aa280457423b97512810d6d9baac37f99fbf4 by Miss Islington (bot) 
in branch '3.9':
bpo-41300: IDLE - save files with non-ascii chars  (GH-21512)
https://github.com/python/cpython/commit/5a7aa280457423b97512810d6d9baac37f99fbf4


--

___
Python tracker 

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



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

2020-07-16 Thread Oscar Benjamin


Oscar Benjamin  added the comment:

To be clear I suggest that this could be a separate function from the existing 
sample rather than a replacement or a routine used internally.

The intended use-cases for the separate function are:

1. Select from something where you really do not want to build a list and just 
want/need to use a single pass. For example in selecting a random line from a 
text file it is necessary to read the entire file in any case just to know how 
many lines there are. The method here would mean that you could make the 
selection in a single pass in O(k) memory. The same can apply to many 
situations involving generators etc.

2. Convenient, possibly faster selection from a most-likely small dict/set 
(this was the original context from python-ideas).

The algorithm naturally gives something in between the original order or a 
randomised order. There are two possibilities for changing that:

a. Call random.shuffle or equivalent either to get the original k items in a 
random order or at the end before returning.

b. Preserve the original ordering from the iterable: append all new items and 
use a sentinel for removed items (remove sentinels at the end).

Since randomised order does not come naturally and requires explicit shuffling 
my preference would be to preserve the original order (b.) because there is no 
other way to recover the information lost by shuffling (assuming that only a 
single pass is possible). The user can call shuffle if they want.

To explain what "geometrically distributed" means I need to refer to the 
precursor algorithm from which this is derived. A simple Python version could 
be:


def sample_iter_old(iterable, k=1):
uvals_vals = []
# Associate a uniform (0, 1) with each element:
for uval, val in zip(iter(random, None), iterable):
uvals_vals.append((uval, val))
uvals_vals.sort()
uvals_vals = uvals_vals[:k]   # keep the k items with smallest uval
return [val for uval, val in uvals_vals]


In sample_iter_old each element val of the iterable is associated with a 
uniform (0, 1) variate uval. At each step we keep the k elements having the 
smallest uval variates. This is relatively inefficient because we need to 
generate a uniform variate for each element val of the iterable. Most of the 
time during the algorithm the new val is simply discarded so sample_iter tries 
instead to calculate how many items to discard.

The quantity W in sample_iter is the max of the uvals from sample_iter_old:

W := max(uval, for uval, val in uvals_vals)

A new item from the iterable will be swapped in if its uval is less than W. The 
number of items skipped before finding a uval < W is geometrically distributed 
with parameter W.

--

___
Python tracker 

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



[issue41306] test_tk test_widgets.ScaleTest fails with Tk 8.6.10

2020-07-16 Thread Ned Deily


Ned Deily  added the comment:

I can reproduce that test failure with Tk 8.6.10 on macOS, along with a few 
others. I believe various small things have changed in Tk somewhere between 
8.6.8 and 8.6.10 in ways that affect some of the Python Tk gui tests, like 
test_tk and test_ttk_guionly. Some of our tests are pretty brittle with regard 
to Tk behavior; they captured how a particular version of Tk worked without 
necessarily a guarantee on the Tk side that the observed behavior wouldn't 
change. Someone needs to go through and make the tests work with all recent 
versions of Tk 8.6.x and someone should also get at least some buildbots 
running with 8.6.10 and really running the gui tests.

--
nosy: +gpolo, serhiy.storchaka
stage:  -> needs patch
title: test_tk failure on Arch Linux -> test_tk test_widgets.ScaleTest fails 
with Tk 8.6.10

___
Python tracker 

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



[issue41300] IDLE: add missing import io in iomenu.py

2020-07-16 Thread miss-islington


Change by miss-islington :


--
pull_requests: +20649
pull_request: https://github.com/python/cpython/pull/21514

___
Python tracker 

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



[issue41300] IDLE: add missing import io in iomenu.py

2020-07-16 Thread miss-islington


Change by miss-islington :


--
keywords: +patch
nosy: +miss-islington
nosy_count: 3.0 -> 4.0
pull_requests: +20648
stage: test needed -> patch review
pull_request: https://github.com/python/cpython/pull/21513

___
Python tracker 

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



[issue41300] IDLE: add missing import io in iomenu.py

2020-07-16 Thread Terry J. Reedy


Terry J. Reedy  added the comment:


New changeset 38d3864efe914fda64553e2ec75c9ec15574483f by Terry Jan Reedy in 
branch 'master':
 bpo-41300: IDLE - save files with non-ascii chars  (GH-21512)
https://github.com/python/cpython/commit/38d3864efe914fda64553e2ec75c9ec15574483f


--

___
Python tracker 

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



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

2020-07-16 Thread Stefan Krah


Stefan Krah  added the comment:

The top level decimal.py that dispatches to either _decimal or
_pydecimal is pure Python.  So perhaps these applications could
add these methods themselves:


>>> import decimal
>>> def exp(x):
... return x.exp()
... 
>>> decimal.exp = exp
>>> 
>>> from decimal import *
>>> exp(Decimal(2))
Decimal('7.389056098930650227230427461')


As you see, it is no big deal, but it feels a bit odd to have
some methods like exp() and sqrt() exposed in the top level.


We already have:

  Decimal.exp()

And:

  >>> c = getcontext()
  >>> c.exp(Decimal(2))
  Decimal('7.389056098930650227230427461')

--

___
Python tracker 

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



[issue41317] sock_accept() does not remove server socket reader on cancellation

2020-07-16 Thread Alex Grönholm

New submission from Alex Grönholm :

Unlike with all the other sock_* functions, sock_accept() only removes the 
reader on the server socket when the socket becomes available for reading (ie. 
when there's an incoming connection). If the operation is cancelled instead, 
the reader is not removed.

If then the server socket is closed and a new socket is created which has the 
same file number and it is used for a socket operation, it will cause a 
FileNotFoundError because the event loop thinks it has this fd registered but 
the epoll object does not agree since all closed sockets are automatically 
removed from it.

The attached script reproduces the problem on Fedora Linux 32 (all relevant 
Python versions), but not on Windows (on any tested Python versions from 3.6 to 
3.8).

--
components: asyncio
files: bug.py
messages: 373777
nosy: alex.gronholm, asvetlov, yselivanov
priority: normal
severity: normal
status: open
title: sock_accept() does not remove server socket reader on cancellation
type: behavior
versions: Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 3.9
Added file: https://bugs.python.org/file49319/bug.py

___
Python tracker 

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



[issue41300] IDLE: add missing import io in iomenu.py

2020-07-16 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

Łukasz, please pull this simple fix to a 3.9.0b4 and 3.8.4 regression into 
3.8.5.  It disabled saving files with non-ascii chars.

--
keywords: +3.8regression -patch
nosy: +lukasz.langa
priority: normal -> release blocker
stage: patch review -> test needed
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



[issue41310] micro-optimization: increase our float parsing speed by Nx

2020-07-16 Thread Eric V. Smith


Eric V. Smith  added the comment:

I don't think we'd want to fall back to strtod, but rather to the code we 
already use (Gay's). So this would increase our maintenance burden.

I'm also not convinced that we actually spend a lot of time in this code, but 
of course profiling would be needed to make sure.

--

___
Python tracker 

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



[issue41313] sys.setrecursionlimit: OverflowError still raised when int limited in sys.maxsize

2020-07-16 Thread Stefan Krah


Stefan Krah  added the comment:

Mark has already mentioned that setting the recursion limit to a
value higher than 2000-1 makes no sense.

Apart from that, sys.maxsize is actually documented like this:

   maxsize -- the largest supported length of containers.


So it applies to Py_ssize_t (signed version of size_t), but not to
any C integer in general.

--
nosy: +skrah
stage:  -> resolved
status: pending -> closed

___
Python tracker 

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



[issue41300] IDLE: add missing import io in iomenu.py

2020-07-16 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
keywords: +patch
pull_requests: +20647
stage: test needed -> patch review
pull_request: https://github.com/python/cpython/pull/21512

___
Python tracker 

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



[issue41305] Add StreamReader.readinto()

2020-07-16 Thread Yury Selivanov


Yury Selivanov  added the comment:

> By the way if we will eventually combine StreamReader and StreamWriter won't 
> this function (readinto) be useful then?

Yes.  But StreamReader and StreamWriter will stay for the foreseeable future 
for backwards compatibility pretty much frozen in time.

So I'd like to start treating them as legacy APIs now.

--

___
Python tracker 

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



[issue41305] Add StreamReader.readinto()

2020-07-16 Thread Tony


Tony  added the comment:

By the way if we will eventually combine StreamReader and StreamWriter won't 
this function (readinto) be useful then?

Maybe we should consider adding it right now.

Tell me your thoughts on this.

--

___
Python tracker 

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



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

2020-07-16 Thread Tim Peters


Tim Peters  added the comment:

Pro: focus on the "iterable" part of the title. If you want to, e.g., select 3 
lines "at random" out of a multi-million-line text file, this kind of reservoir 
sampling allows to do that holding no more than one line in memory 
simultaneously. Materializing an iterable in a sequence is sometimes 
impossible. Yup, it takes O(number of elements) time, but so does anything else 
that has to look at every element of an iterable (including materializing an 
iterable in a sequence!).

So this would make most sense as a different function.

Con: over the years we've worked diligently to purge these algorithms of minor 
biases, leaving them as unbiased as the core generator. Introducing 
floating-point vagaries goes against that, and results may vary at times due to 
tiny differences in platform exp() and log() implementations.

Worse, I'm not sure that the _approach_ is beyond reproach: the claim that 
skips "follow a geometric distribution" is baffling to me. If the reservoir has 
size K, then when we're looking at the N'th element it should be skipped with 
probability 1-K/N. But when looking at the N+1'th, that changes to 1-K/(N+1). 
Then 1-K/(N+2), and so on. These probabilities are all different. In an actual 
geometric distribution, the skip probability is a constant.

Now 1-K/(N+i) is approximately equal to 1-K/(N+j) for i and j sufficiently 
close, and for K sufficiently smaller than N, so the skips may be well 
_approximated_ by a geometric distribution. But that's quite different than 
saying they _do_ follow a geometric distribution, and I see no reason to trust 
that the difference can't matter.

The simple algorithm on the Wikipedia page suffers none of these potential 
problems (it implements an obviously-sound approach, & our `randrange()` is 
unbiased and platform-independent).  But, for selecting 3 out of a 
million-element iterable, would invoke the core generator hundreds of thousands 
of times more often.

--
nosy: +mark.dickinson, tim.peters

___
Python tracker 

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



[issue41305] Add StreamReader.readinto()

2020-07-16 Thread Tony


Tony  added the comment:

> Which brings me to the most important point: what we need it not coding it 
> (yet), but rather drafting the actual proposal and posting it to 
> https://discuss.python.org/c/async-sig/20.  Once a formal proposal is there 
> we can proceed with the implementation.

Posted: https://discuss.python.org/t/discussion-on-a-new-api-for-asyncio/4725

By the way I know it's unrelated but I want a CR on 
https://github.com/python/cpython/pull/21446 I think it's also very important.

--

___
Python tracker 

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



[issue41310] micro-optimization: increase our float parsing speed by Nx

2020-07-16 Thread Tim Peters


Tim Peters  added the comment:

Gregory, care to take their code and time it against Python?

I'm not inclined to: reading the comments in the code, they're trying "fast 
paths" already described in papers by Clinger and - later - by Gay.  When those 
fast paths don't apply, they fall back on the system `strtod`. But Python's 
current implementation builds on Gay's fastest code (and never falls back to 
the system).

It's possible they "improved" on Gay by building relatively giant tables of 
static data.

--

___
Python tracker 

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



[issue41306] test_tk failure on Arch Linux

2020-07-16 Thread Felix Yan


Felix Yan  added the comment:

tkinter.TCL_VERSION: 8.6
tkinter.TK_VERSION: 8.6
tkinter.info_patchlevel: 8.6.10

It's always reproducible in either a real desktop or Xvfb with arbitrary 
resolution etc as far as I have tested.

--

___
Python tracker 

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



[issue41306] test_tk failure on Arch Linux

2020-07-16 Thread Ned Deily


Ned Deily  added the comment:

What version of Tk is being used?  It's in the output from:
  python3 -m test.pythoninfo
or however you invoke python.

--
nosy: +ned.deily

___
Python tracker 

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



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

2020-07-16 Thread Matthias Klose


Matthias Klose  added the comment:

David, which issue number is this?

--
nosy: +doko

___
Python tracker 

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



[issue39017] Infinite loop in the tarfile module

2020-07-16 Thread Larry Hastings


Change by Larry Hastings :


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



[issue41305] Add StreamReader.readinto()

2020-07-16 Thread Yury Selivanov


Yury Selivanov  added the comment:

> Is it simply combining stream reader and stream writer into a single object 
> and changing the write() function to always wait the write (thus deprecating 
> drain) and that's it?

Pretty much. We might also rename a few APIs here and there, like "close()" 
should become an "async def aclose()"

We also will likely want to define a few ABCs.

Which brings me to the most important point: what we need it not coding it 
(yet), but rather drafting the actual proposal and posting it to 
https://discuss.python.org/c/async-sig/20.  Once a formal proposal is there we 
can proceed with the implementation.

It's a bit of a process to follow, but we have to do it this way.

--
nosy: +aeros, njs

___
Python tracker 

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



[issue39017] Infinite loop in the tarfile module

2020-07-16 Thread Larry Hastings


Larry Hastings  added the comment:


New changeset cac9ca8ed99bd98f4c0dcd1913a146192bf5ee84 by Petr Viktorin in 
branch '3.5':
[3.5] bpo-39017: Avoid infinite loop in the tarfile module (GH-21454) (#21489)
https://github.com/python/cpython/commit/cac9ca8ed99bd98f4c0dcd1913a146192bf5ee84


--

___
Python tracker 

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



[issue41286] Built-in platform module does not offer to check for processor instructions

2020-07-16 Thread Ammar Askar

Ammar Askar  added the comment:

Thanks for your understanding Boštjan, closing this as requested.

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

___
Python tracker 

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



[issue41286] Built-in platform module does not offer to check for processor instructions

2020-07-16 Thread Boštjan Mejak

Boštjan Mejak  added the comment:

Thanks for letting me know about py-cpuinfo. It is a very good tool. It solves 
my problem. This Python issue can now be closed as "Won't fix".

--

___
Python tracker 

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



[issue41313] sys.setrecursionlimit: OverflowError still raised when int limited in sys.maxsize

2020-07-16 Thread Mark Dickinson


Mark Dickinson  added the comment:

Setting to pending; I don't see any bug here, and I suspect the original report 
was based on a misunderstanding of what sys.setrecursionlimit is for.

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

___
Python tracker 

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



[issue41310] micro-optimization: increase our float parsing speed by Nx

2020-07-16 Thread Mark Dickinson


Mark Dickinson  added the comment:

Is there a description of the algorithms or ideas used anywhere? The blog post 
you link to has no details, and I don't see any useful descriptions in the 
GitHub README or the source; trawling through the source to figure out what the 
key ideas are is not ideal. I don't find the tests particularly convincing, 
either.

I think this is too immature to consider for CPython, right now. Maybe it would 
make sense to revisit some day in the future if/when the library is more mature.

--

___
Python tracker 

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



[issue41316] tarfile: Do not write full path in FNAME field

2020-07-16 Thread Artem Bulgakov


Change by Artem Bulgakov :


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

___
Python tracker 

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



[issue41316] tarfile: Do not write full path in FNAME field

2020-07-16 Thread Artem Bulgakov


New submission from Artem Bulgakov :

tarfile sets FNAME field to the path given by user: Lib/tarfile.py:424

It writes full path instead of just basename if user specified absolute path. 
Some archive viewer apps like 7-Zip may process file incorrectly. Also it 
creates security issue because anyone can know structure of directories on 
system and know username or other personal information.

You can reproduce this by running below lines in Python interpreter. Tested on 
Windows and Linux.

Python 3.8.2 (default, Apr 27 2020, 15:53:34)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> import tarfile
>>> open("somefile.txt", "w").write("sometext")
8
>>> tar = tarfile.open("/home/bulgakovas/file.tar.gz", "w|gz")
>>> tar.add("somefile.txt")
>>> tar.close()
>>> open("file.tar.gz", "rb").read()[:50]
b'\x1f\x8b\x08\x08cE\x10_\x02\xff/home/bulgakovas/file.tar\x00\xed\xd3M\n\xc20\x10\x86\xe1\xac=EO\x90'

You can see full path to file.tar (/home/bulgakovas/file.tar) as FNAME field. 
If you will write just tarfile.open("file.tar.gz", "w|gz"), FNAME will be equal 
to file.tar.

RFC1952 says about FNAME:
This is the original name of the file being compressed, with any directory 
components removed.

So tarfile must remove directory names from FNAME and write only basename of 
file.

--
components: Library (Lib)
messages: 373759
nosy: ArtemSBulgakov, lars.gustaebel
priority: normal
severity: normal
status: open
title: tarfile: Do not write full path in FNAME field
type: behavior
versions: Python 3.10, 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



[issue41249] TypedDict inheritance doesn't work with get_type_hints and postponed evaluation of annotations across modules

2020-07-16 Thread Keith Blaha


Keith Blaha  added the comment:

> TBH this is not very elegant, but I think you can go ahead with this (at 
> least as a quick fix) since I don't see a better solution yet.

Agreed, given that the current workaround of implementing them in the same 
module works I think I will stick with that while this is brainstormed further.

--

___
Python tracker 

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



[issue38856] asyncio ProactorEventLoop: wait_closed() can raise ConnectionResetError

2020-07-16 Thread Chris Meyer


Change by Chris Meyer :


--
nosy: +cmeyer

___
Python tracker 

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



[issue41304] python 38 embed ignore python38._pth file on windows

2020-07-16 Thread Steve Dower


Steve Dower  added the comment:

For clarity, this was caused by the fix for issue29778, and was only released 
in 3.8.4 and 3.9.0b4. No other versions had a release before the fix was merged.

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



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

2020-07-16 Thread Steve Dower


Steve Dower  added the comment:

FYI, issue41304 fixed a regression in this patch in 3.7 and later. The 
regression shipped in 3.8.4 and 3.9.0b4, but will be fixed in the subsequent 
releases.

--

___
Python tracker 

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



[issue41045] f-string's "debug" feature is undocumented

2020-07-16 Thread Ama Aje My Fren


Change by Ama Aje My Fren :


--
nosy: +amaajemyfren
nosy_count: 5.0 -> 6.0
pull_requests: +20645
pull_request: https://github.com/python/cpython/pull/21509

___
Python tracker 

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



[issue38856] asyncio ProactorEventLoop: wait_closed() can raise ConnectionResetError

2020-07-16 Thread Bas Nijholt


Bas Nijholt  added the comment:

I have noticed the following on Linux too:
```
Traceback (most recent call last):
  File "/config/custom_components/kef_custom/aiokef.py", line 327, in 
_disconnect
await self._writer.wait_closed()
  File "/usr/local/lib/python3.7/asyncio/streams.py", line 323, in wait_closed
await self._protocol._closed
  File "/config/custom_components/kef_custom/aiokef.py", line 299, in 
_send_message
await self._writer.drain()
  File "/usr/local/lib/python3.7/asyncio/streams.py", line 339, in drain
raise exc
  File "/usr/local/lib/python3.7/asyncio/selector_events.py", line 814, in 
_read_ready__data_received
data = self._sock.recv(self.max_size)
ConnectionResetError: [Errno 104] Connection reset by peer
```
after which every invocation of `await asyncio.open_connection` fails with 
`ConnectionRefusedError` until I restart the entire Python process.

IIUC, just ignoring the exception will not be enough.

This issue is about the `ProactorEventLoop` for Windows specifically, however, 
my process uses the default event loop on Linux.

--
nosy: +basnijholt

___
Python tracker 

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



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

2020-07-16 Thread Jean Abou Samra


Change by Jean Abou Samra :


--
title: Add mathematical functions as wrapper to decimal.Decimal methods -> Add 
mathematical functions as wrappers to decimal.Decimal methods

___
Python tracker 

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



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

2020-07-16 Thread Jean Abou Samra


New submission from Jean Abou Samra :

Common mathematical functions such as sqrt(), exp(), etc. are available for 
decimal numbers as methods of decimal.Decimal instances (like 
https://docs.python.org/3/library/decimal.html#decimal.Decimal.exp). This does 
not pair well with the math and cmath modules as well as NumPy and SymPy which 
all define these as functions. It also makes it harder to switch to decimals 
instead of floats when you realize that your program lacks arithmetic precision.

It would be nice to have functions in the decimal module that called the 
corresponding methods. This would unify the interface with other modules while 
keeping backwards compatibility and preserving the possibility to subclass 
Decimal.

--
components: Library (Lib)
messages: 373754
nosy: Jean Abou Samra, facundobatista, mark.dickinson, rhettinger, skrah
priority: normal
severity: normal
status: open
title: Add mathematical functions as wrapper to decimal.Decimal methods
type: enhancement
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



[issue41314] __future__ doc and PEP 563 conflict

2020-07-16 Thread wyz23x2


Change by wyz23x2 :


--
assignee:  -> docs@python
components: +Documentation
nosy: +docs@python
versions: +Python 3.10, Python 3.7

___
Python tracker 

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



[issue41314] __future__ doc and PEP 563 conflict

2020-07-16 Thread wyz23x2


New submission from wyz23x2 :

In https://docs.python.org/3/library/__future__.html:
annotations | 3.7.0b1 | *4.0* | PEP 563: Postponed evaluation of annotations

In PEP 563:
Starting with Python 3.7, a __future__ import is required to use the described 
functionality. No warnings are raised.

In Python *3.10* this will become the default behavior. Use of annotations 
incompatible with this PEP is no longer supported.

Python 4.0 or 3.10? Not clear.

--
messages: 373753
nosy: wyz23x2
priority: normal
severity: normal
status: open
title: __future__ doc and PEP 563 conflict

___
Python tracker 

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



[issue41249] TypedDict inheritance doesn't work with get_type_hints and postponed evaluation of annotations across modules

2020-07-16 Thread Ivan Levkivskyi


Ivan Levkivskyi  added the comment:

> I was thinking that similarly to __required_keys__ and __optional_keys__, the 
> TypedDict could preserve its original bases in a new dunder attribute, and 
> get_type_hints could work off of that instead of MRO when it is dealing with 
> a TypedDict. I would be willing to contribute the PRs to implement this if 
> the design is acceptable

TBH this is not very elegant, but I think you can go ahead with this (at least 
as a quick fix) since I don't see a better solution yet.

--

___
Python tracker 

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



[issue40477] Python Launcher app on macOS 10.15 Catalina fails to run scripts

2020-07-16 Thread wyz23x2


Change by wyz23x2 :


--
type:  -> crash

___
Python tracker 

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



[issue41313] sys.setrecursionlimit: OverflowError still raised when int limited in sys.maxsize

2020-07-16 Thread Eric V. Smith


Change by Eric V. Smith :


--
title: OverflowError still raised when int limited in sys.maxsize -> 
sys.setrecursionlimit: OverflowError still raised when int limited in 
sys.maxsize

___
Python tracker 

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



[issue41313] OverflowError still raised when int limited in sys.maxsize

2020-07-16 Thread Mark Dickinson


Mark Dickinson  added the comment:

The recursion depth and recursion limit are stored internally as C ints, so 
yes, 2**31 - 1 = 2147483647 is the maximum value that you can pass to 
`sys.setrecursionlimit` that won't fail immediately.

But it's unclear why you'd ever want to set the recursion limit that high. 
What's your goal here? Are you looking for a way to effectively disable that 
recursion limit altogether? If so, can you explain the use-case?

Note that the recursion limit is there to prevent your code from exhausting the 
C stack and segfaulting as a result: simply setting that limit to a huge value 
won't (by itself) allow you to run arbitrarily deeply nested recursions. On my 
machine, without the protection of the recursion limit, a simple recursive call 
segfaults at around a depth of 30800.

--
nosy: +mark.dickinson

___
Python tracker 

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



[issue41305] Add StreamReader.readinto()

2020-07-16 Thread Tony


Tony  added the comment:

Ok actually that sounds really important, I am interested.

But to begin doing something like this I need to know what's the general design.

Is it simply combining stream reader and stream writer into a single object and 
changing the write() function to always wait the write (thus deprecating drain) 
and that's it?

If there is not more to it I can probably do this pretty quickly, I mean it 
seems easy on the surface.

If there is more to it then I would like a more thorough explanation. Maybe we 
should chat about this.

--

___
Python tracker 

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



[issue41313] OverflowError still raised when int limited in sys.maxsize

2020-07-16 Thread wyz23x2


wyz23x2  added the comment:

Tested. 2**31-31 is the max, which is 2147483617, compared to sys.maxsize's 
9223372036854775807!

--
type:  -> behavior

___
Python tracker 

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



[issue41313] OverflowError still raised when int limited in sys.maxsize

2020-07-16 Thread wyz23x2


wyz23x2  added the comment:

Needs to add 10 zeros (sys.maxsize//100) to get it work. //200 
doesn't work.
Python version: 3.8.4
Platform: Windows 10 2004

--

___
Python tracker 

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



[issue41313] OverflowError still raised when int limited in sys.maxsize

2020-07-16 Thread wyz23x2


New submission from wyz23x2 :

Consider this code:
import sys
sys.setrecursionlimit(sys.maxsize)
Causes this:
OverflowError: Python int too large to convert to C int
So what is the limit? It should be sys.maxsize.
These 2 also don't work:
sys.setrecursionlimit(sys.maxsize-1)
sys.setrecursionlimit(sys.maxsize//2)
That is a big difference with at least 50%.

--
components: C API, Library (Lib)
messages: 373747
nosy: wyz23x2
priority: normal
severity: normal
status: open
title: OverflowError still raised when int limited in sys.maxsize
versions: Python 3.10, 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