[issue40350] modulefinder chokes on numpy - dereferencing None in spec.loader

2020-04-21 Thread Greg Whiteley


New submission from Greg Whiteley :

Issue:

Running ModuleFinder.run_script() on numpy versions 1.16.1 to 1.18.3 (maybe 
more) fails with backtrace.  See steps to reproduce below.

I do not see this problem on earlier versions of python than 3.8 (tested 3.4, 
3.5, 3.6 on ubuntu LTSs), but the code has changed around 3.8.

The failure comes to this line of modulefinder.py

https://github.com/python/cpython/blame/master/Lib/modulefinder.py#L79

if spec.loader.is_package(name):
return None, os.path.dirname(file_path), ("", "", _PKG_DIRECTORY)

I can work around it by changing that to check for None

if spec.loader is not None and spec.loader.is_package(name):
return None, os.path.dirname(file_path), ("", "", _PKG_DIRECTORY)


Environment:

Ubuntu 20.04 with default python3, python3-pip

Steps to reproduce:

# note any nump version I've tried 1.16.1 and greater fails - I included 1.18.3 
to be precise for reproduciton
$ pip3 install "numpy==1.18.3"
$ cat test.py
import numpy

$ python3
>>> from modulefinder import ModuleFinder
>>> finder = ModuleFinder()
>>> finder.run_script("test.py")
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python3.8/modulefinder.py", line 165, in run_script
self.load_module('__main__', fp, pathname, stuff)
...

300 lines of stack elided - see attached fulllog.txt

...
  File "/usr/lib/python3.8/modulefinder.py", line 433, in scan_code
self._safe_import_hook(name, m, fromlist, level=0)
  File "/usr/lib/python3.8/modulefinder.py", line 378, in _safe_import_hook
self.import_hook(name, caller, level=level)
  File "/usr/lib/python3.8/modulefinder.py", line 177, in import_hook
q, tail = self.find_head_package(parent, name)
  File "/usr/lib/python3.8/modulefinder.py", line 233, in find_head_package
q = self.import_module(head, qname, parent)
  File "/usr/lib/python3.8/modulefinder.py", line 320, in import_module
fp, pathname, stuff = self.find_module(partname,
  File "/usr/lib/python3.8/modulefinder.py", line 511, in find_module
return _find_module(name, path)
  File "/usr/lib/python3.8/modulefinder.py", line 78, in _find_module
if spec.loader.is_package(name):
AttributeError: 'NoneType' object has no attribute 'is_package'
>>> 


Obviously I can't tell if numpy or modulefinder is the real culprit.

Let me know if I can give any more information.

--
components: Library (Lib)
files: fulllog.txt
messages: 366912
nosy: Greg Whiteley
priority: normal
severity: normal
status: open
title: modulefinder chokes on numpy - dereferencing None in spec.loader
type: behavior
versions: Python 3.8
Added file: https://bugs.python.org/file49079/fulllog.txt

___
Python tracker 

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



[issue40337] builtins.RuntimeError: Caught RuntimeError in pin memory thread for device 0.

2020-04-21 Thread Eric V. Smith


Eric V. Smith  added the comment:

Unless the original poster can provide more information (and preferably a way 
to reproduce this), I'm going to close this.

--
status: open -> pending

___
Python tracker 

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



[issue29847] Path takes and ignores **kwargs

2020-04-21 Thread Yurii Karabas


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


--
nosy: +uriyyo
nosy_count: 6.0 -> 7.0
pull_requests: +18959
pull_request: https://github.com/python/cpython/pull/19632

___
Python tracker 

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



[issue40351] How to edit "python --help"?

2020-04-21 Thread Nino


New submission from Nino :

Can someone tell how can I edit the "python --help". Is it possible and if yes, 
how? I build python 3.7 on my PC from source code.

--
assignee: docs@python
components: Documentation
messages: 366914
nosy: Nino-95, docs@python
priority: normal
severity: normal
status: open
title: How to edit "python --help"?
type: resource usage
versions: Python 3.7

___
Python tracker 

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



[issue40351] How to edit "python --help"?

2020-04-21 Thread Rémi Lapeyre

Rémi Lapeyre  added the comment:

Hi Nino, the text for `python --help` is here : 
https://github.com/python/cpython/blob/master/Python/initconfig.c#L28-L130

--
nosy: +remi.lapeyre

___
Python tracker 

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



[issue38977] python3.8 and namedlist1.7 is Incompatible

2020-04-21 Thread raina


raina  added the comment:

Traceback (most recent call last):
  File "c:\users\raina\appdata\local\programs\python\python38\lib\runpy.py", 
line 193, in _run_module_as_main
return _run_code(code, main_globals, None,
..  
code = compile(module_node, '', 'exec')
TypeError: required field "posonlyargs" missing from arguments

--
nosy: +raina

___
Python tracker 

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



[issue40351] How to edit "python --help"?

2020-04-21 Thread Eric V. Smith

Eric V. Smith  added the comment:

Thanks, Rémi.

Nino: Please don't ask help questions on the bug tracker, only report bugs 
here. For general questions you can try the python-list mailing list or Stack 
Overflow.

--
nosy: +eric.smith
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



[issue40346] Redesign random.Random class inheritance

2020-04-21 Thread STINNER Victor


STINNER Victor  added the comment:

Example with Python 3.8:
---
import random

class MyRandom(random.Random):
def getrandbits(self, n):
return 0

my = MyRandom()
print([my.randint(1, 6) for _ in range(3)])
print([my.random() for _ in range(3)])
---

Output:
---
[1, 1, 1]
[0.5654641798814677, 0.610057019404943, 0.7526620665660224]
---

[1, 1, 1] is what I expect, but what are these random [0.5654641798814677, 
0.610057019404943, 0.7526620665660224] numbers?

This behavior is surprising me. I would expect the base class to be "empty", 
not to inherit Mersenne Twister. If I don't implement all required abstract 
methods: I would either expect an error when the class is created, or at least 
when the method is called.


Raymond:
> Am not sure I'm comfortable with you defining random() in pure python 
> dividing by BPF -- that seems like a C level decision.

My PR 19631 doesn't change random.Random.random() (still implemented in C) nor 
random.SystemRandom.random() (same Python implementation): they should produce 
exactly the same random floating point numbers.

--

___
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-21 Thread STINNER Victor


STINNER Victor  added the comment:

Raymond:
> Also, I don't want randbytes() in the C extension.  We're tried to keep as 
> much of the code as possible in pure Python and only have the MersenneTwister 
> specific code in the C module.  The improves maintainability and makes the 
> code more accessible to a broader audience.

I don't see how 30 lines makes Python so harder to maintain. These lines make 
the function 4x to 5x faster. We are not talking about 5% or 10% faster. I 
think that such optimization is worth it. When did we decide to stop optimizing 
Python?


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

I created bpo-40346: "Redesign random.Random class inheritance" for a more 
generic fix, not just randbytes().


Raymond:
> Also, please don't change the name of the genrand_int32() function.  It was a 
> goal to change as little as possible from the official, standard version of 
> the C code at 
> http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/emt19937ar.html .

This code was already modified to replace "unsigned long" with "uint32_t" for 
example. I don't think that renaming genrand_int32() to genrand_uint32() makes 
the code impossible to maintain. Moreover, it seems like 
http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/emt19937ar.html was not 
updated for 13 years.

--

___
Python tracker 

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



[issue40352] SocketHandler silently drops log messages on re-connect

2020-04-21 Thread Oleg Nykolyn


New submission from Oleg Nykolyn :

Hi,

I've faced this issue when using logging.handlers.SocketHandler AWS TCP 
balancer. AWS balancer uses 60 second time-out by default (max 4000s), thus 
resulting in lots of closed sockets during inactive periods.
SocketHandler.send() drops current message on any socket errors, so only next 
message gets logged.
I've tried to reproduce this using Lib unit tests, but didn't find any easy way 
to close() socket on test server side.
 
Sample client/server scripts attached, server output:

Got connection from:  ('127.0.0.1', 58044)
Got message:  b'Message #1\n'
Got message:  b'Message #2\n'
Got connection from:  ('127.0.0.1', 58045)
Got message:  b'Message #5\n'

Server closes incoming connection is 2 seconds, client looses messages #3 and 
#4.

--
components: Library (Lib)
files: Archive.zip
messages: 366920
nosy: Oleg Nykolyn
priority: normal
severity: normal
status: open
title: SocketHandler silently drops log messages on re-connect
type: behavior
versions: Python 3.8
Added file: https://bugs.python.org/file49080/Archive.zip

___
Python tracker 

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



[issue40352] SocketHandler silently drops log messages on re-connect

2020-04-21 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
nosy: +vinay.sajip

___
Python tracker 

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



[issue40237] Test code coverage (C) job of Travis CI fails on test_distutils which creates _configtest.gcno file

2020-04-21 Thread hai shi


hai shi  added the comment:

> The historical background is code coverage of C code seemed like a good idea, 
> so we set it up. :) Not much else to it.

Hm, code coverage of C code including two parts:
1) coverage of inner c code;
2) extension modules built by distutils;

If I understand correct, we force on 1) is good enough, no?

--

___
Python tracker 

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



[issue40346] Redesign random.Random class inheritance

2020-04-21 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

It may be time to start emitting a warning if a Random subclass overrides 
random() but not getrandbits() or vice versa.

If you only override random(), methods which rely on generating random integers 
will use worse algorithm (slightly less uniform). If you only override 
getrandbits(), -- it is even worse, methods which rely on generating random 
floating point number will be not affected.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue40346] Redesign random.Random class inheritance

2020-04-21 Thread STINNER Victor


STINNER Victor  added the comment:

> It may be time to start emitting a warning if a Random subclass overrides 
> random() but not getrandbits() or vice versa.

Does someone know if there are users outside the stdlib of random subclass 
which only implements random()? I guess that a deprecation warning should help 
us to know :-)

There is also an implementation detail: technically, it's also sems to possible 
to only implement _randbelow(): see __init_subclass__(). But I'm not sure what 
happens in Python 3.8 if you implement _randbelow() but not random() not 
getrandbits().

In my experience, all RNG either generates random bits or random bytes, but not 
directly random floats. Usually, floats are computed from the other operations: 
that's what I'm proposing in BaseRandom. random() is now computed from 
getrandbits(). But it remains possible to override random(), as done in 
random.Random.

--

___
Python tracker 

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



[issue40237] Test code coverage (C) job of Travis CI fails on test_distutils which creates _configtest.gcno file

2020-04-21 Thread STINNER Victor


STINNER Victor  added the comment:

Brett:
> The historical background is code coverage of C code seemed like a good idea, 
> so we set it up. :) Not much else to it.

If there is no user of code coverage *on pull requests*, maybe the simplest fix 
is to remove this job.

There is also Codecov service running somehow on Python branches through GitHub 
integration.

--

___
Python tracker 

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



[issue40352] SocketHandler silently drops log messages on re-connect

2020-04-21 Thread Rémi Lapeyre

Rémi Lapeyre  added the comment:

On one hand it's bad messages get lost, one the other retrying to send the 
message would take a lot of time and make `SocketHandler` very slow.

Maybe we could had the record to a very short queue so we can retry to send it 
with the next message?

--
nosy: +remi.lapeyre

___
Python tracker 

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



[issue40353] Add an optional "strict" check to zip

2020-04-21 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

It would be better to implement it as a separate function.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue40353] Add an optional "strict" check to zip

2020-04-21 Thread Brandt Bucher


New submission from Brandt Bucher :

As discussed on Python-ideas:

https://mail.python.org/archives/list/python-id...@python.org/thread/6GFUADSQ5JTF7W7OGWF7XF2NH2XUTUQM/

When a keyword-only argument "strict=True" is passed to zip's constructor, a 
ValueError will be raised in the case where one iterator is exhausted before 
the others. Otherwise, no side-effects (such as iterator consumption) will be 
changed.

I do wonder if we can use a better keyword than "strict" here.

I'm currently working on an implementation, and @cool-RR is working on tests 
and docs.

--
assignee: brandtbucher
components: Interpreter Core
messages: 366926
nosy: brandtbucher, cool-RR
priority: normal
severity: normal
status: open
title: Add an optional "strict" check to zip
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



[issue40353] Add an optional "strict" check to zip

2020-04-21 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Also you can just get a ready implementation from more-tertools.

--

___
Python tracker 

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



[issue40352] SocketHandler silently drops log messages on re-connect

2020-04-21 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

If sending log messages is not guaranteed, we could use UDP. But when we use 
TCP it is expected that log messages will not be lost.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue40353] Add an optional "strict" check to zip

2020-04-21 Thread Ram Rachum


Ram Rachum  added the comment:

Here are the tests I made: 
https://github.com/cool-RR/cpython/commit/766409748a107f290997b0cfab5aa19d0c2888e5

--

___
Python tracker 

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



[issue40353] Add an optional "strict" check to zip

2020-04-21 Thread STINNER Victor


Change by STINNER Victor :


--
nosy: +vstinner

___
Python tracker 

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



[issue40354] problem when using yield

2020-04-21 Thread xie

New submission from xie :

--version1:--
def func1():
a=0 
b=10
for i in range(4):
result = yield a+100 if b>100 else (yield a)
print(result)

f1 = func1()
print("value:%s" % next(f1))
print("--")
print("value:%s" % next(f1))
print("--")

--version2--

def func1():
a=0 
b=10
for i in range(4):
result = (yield a+100) if b>100 else (yield a)
print(result)

f1 = func1()
print("value:%s" % next(f1))
print("--")
print("value:%s" % next(f1))
print("--")


--problem
I think two version should behave same,but it did not.Do this will be treated 
as a bug ?

--
messages: 366931
nosy: xsmyqf
priority: normal
severity: normal
status: open
title: problem when using yield
type: behavior
versions: Python 3.7

___
Python tracker 

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



[issue40164] Upgrade Windows and macOS installer builds to OpenSSL 1.1.1g

2020-04-21 Thread Ned Deily


Ned Deily  added the comment:

And today (2020-04-21) 1.1.1g is released with a high severity fix.

--
title: Upgrade Windows and macOS installer builds to OpenSSL 1.1.1f -> Upgrade 
Windows and macOS installer builds to OpenSSL 1.1.1g

___
Python tracker 

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



[issue40354] problem when using yield

2020-04-21 Thread Mark Dickinson


Mark Dickinson  added the comment:

Which part of the behaviour do you think is a bug?

In version1, you want to think of the yield expression as though it were 
bracketed like this:

result = yield (a+100 if b>100 else (yield a))

With the particular values of a and b that you have, that statement is 
equivalent to this:

result = yield (yield 0)

This yields two values to the consumer: a `0` from the inner yield, followed by 
a None (or whatever was "sent" into the generator, if applicable) for the out 
yield.

In version 2, the corresponding line simplifies to just

result = yield 0

So no, I don't think these two versions of the code should behave the same, and 
I don't think there's any bug here.

--
nosy: +mark.dickinson

___
Python tracker 

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



[issue39148] DatagramProtocol + IPv6 does not work with ProactorEventLoop

2020-04-21 Thread Kjell Braden


Kjell Braden  added the comment:

Please let me know if there is anything else I can do to get this going.

--

___
Python tracker 

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



[issue33065] IDLE debugger: failure stepping through module loading

2020-04-21 Thread Timothy Geiser


Timothy Geiser  added the comment:

I wish I could be more helpful than to just pipe up with a "this bug affects 
me, too," note, but wanted to poke this bug report since it's been dormant for 
14 months.
With Python 3.8.2 I tried using the pgpdump module (version 1.5, installed from 
pip) on Windows 10 and wanted to step through how it worked. As soon as I 
enabled the debugger in IDLE it stopped working, throwing a very similar stack 
trace. Here's the MWE:

>>> import pgpdump
>>> 
[DEBUG ON]
>>> pgpdump.BinaryData(b'')


Traceback (most recent call last):
  File "", line 1, in 
pgpdump.BinaryData(b'')
  File "C:\Python38\lib\site-packages\pgpdump\data.py", line 13, in __init__
if not data:
  File "C:\Python38\lib\site-packages\pgpdump\data.py", line 13, in __init__
if not data:
  File "C:\Python38\lib\bdb.py", line 88, in trace_dispatch
return self.dispatch_line(frame)
  File "C:\Python38\lib\bdb.py", line 112, in dispatch_line
self.user_line(frame)
  File "C:\Python38\lib\idlelib\debugger.py", line 24, in user_line
self.gui.interaction(message, frame)
AttributeError: 'BinaryData' object has no attribute 'length'

This error only occurs when the Locals checkbox in the debugging window is 
checked - it runs as expected as long as Locals is unchecked (this minimum 
[not]working example throws a "pgpdump.utils.PgpdumpException: no data to 
parse" error, as it should). A longer example with actual data will run for 
several steps while Locals is unchecked, but fails with the first Step once 
Locals is checked. A side note is that the specific error here is that the 
class BinaryData is being asked about it's 'length', rather than the OP's error 
of _ModuleLock not having a 'name'
Is there anything else I can do to help fix this, given that I'm not familiar 
with programming bdb or the IDLE debugger GUI?

--
nosy: +geitda

___
Python tracker 

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



[issue34037] asyncio: BaseEventLoop.close() shutdowns the executor without waiting causing leak of dangling threads

2020-04-21 Thread Kyle Stanley


Kyle Stanley  added the comment:

> Kyle: Can you please add a short sentence there to document the new 
> requirement?

Yep, I'll open a PR soon. I'm glad this is coming up now rather than 
post-release, thanks for bringing attention to it.

--

___
Python tracker 

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



[issue40235] confusing documentation for IOBase.__exit__

2020-04-21 Thread Daniel Holth


Daniel Holth  added the comment:

Possibly the best io module example I've found 
https://github.com/python/cpython/blob/master/Lib/_compression.py

--

___
Python tracker 

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



[issue40355] The ast module fails to reject certain malformed nodes

2020-04-21 Thread Brandt Bucher


New submission from Brandt Bucher :

There are several places in the ast module where the use of zip is allowing 
malformed nodes to have unpaired children silently thrown away. A couple of 
short examples:

>>> from ast import Constant, Dict, literal_eval, unparse
>>> nasty_dict = Dict(keys=[Constant("I don't have a value!")], values=[])
>>> unparse(nasty_dict)
'{}'
>>> literal_eval(nasty_dict)
{}

I'm currently working on a patch to raise errors instead.

--
assignee: brandtbucher
components: Library (Lib)
messages: 366938
nosy: brandtbucher
priority: normal
severity: normal
status: open
title: The ast module fails to reject certain malformed nodes
type: behavior
versions: Python 3.9

___
Python tracker 

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



[issue34037] asyncio: BaseEventLoop.close() shutdowns the executor without waiting causing leak of dangling threads

2020-04-21 Thread Kyle Stanley


Change by Kyle Stanley :


--
pull_requests: +18960
stage: resolved -> patch review
pull_request: https://github.com/python/cpython/pull/19634

___
Python tracker 

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



[issue40355] The ast module fails to reject certain malformed nodes

2020-04-21 Thread Rémi Lapeyre

Change by Rémi Lapeyre :


--
nosy: +remi.lapeyre

___
Python tracker 

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



[issue34037] asyncio: BaseEventLoop.close() shutdowns the executor without waiting causing leak of dangling threads

2020-04-21 Thread Kyle Stanley


Kyle Stanley  added the comment:


New changeset 9c82ea7868a1c5ecf88891c627b5c399357eb05e by Kyle Stanley in 
branch 'master':
bpo-34037: Add Python API whatsnew for loop.shutdown_default_executor() (#19634)
https://github.com/python/cpython/commit/9c82ea7868a1c5ecf88891c627b5c399357eb05e


--

___
Python tracker 

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



[issue40164] Upgrade Windows and macOS installer builds to OpenSSL 1.1.1g

2020-04-21 Thread Steve Dower


Steve Dower  added the comment:

That'll teach me for being so quick on this...

Are we even impacted by the issue though? I don't see any calls to 
SSL_check_chain() in our code or the SSL sources.

Advisory: https://www.openssl.org/news/secadv/20200421.txt
Full diff: 
https://github.com/openssl/openssl/compare/OpenSSL_1_1_1f...OpenSSL_1_1_1g

--
nosy: +christian.heimes

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



[issue40355] The ast module fails to reject certain malformed nodes

2020-04-21 Thread Batuhan Taskaya


Batuhan Taskaya  added the comment:

See https://bugs.python.org/msg360767 for ast.unparse's point of view regarding 
malformed nodes.

--
nosy: +BTaskaya, pablogsal

___
Python tracker 

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



[issue39943] Meta: Clean up various issues in C internals

2020-04-21 Thread STINNER Victor


STINNER Victor  added the comment:

> Yes, it is a consequence of PR 19345. But it looks like a compiler bug. It 
> complains about implicit conversion from `const void **` to `void *` in 
> memcpy() and PyMem_Del().

Is it possible to add an explicit cast to make the compiler warnings quiet?

--

___
Python tracker 

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



[issue34037] asyncio: BaseEventLoop.close() shutdowns the executor without waiting causing leak of dangling threads

2020-04-21 Thread Kyle Stanley


Kyle Stanley  added the comment:

PR-19634 should address the primary issue of documenting in the 3.9 whatsnew 
that alternative event loops should implement loop.shutdown_default_executor().

For reference, here's the implementation in BaseEventLoop: 
https://github.com/python/cpython/blob/9c82ea7868a1c5ecf88891c627b5c399357eb05e/Lib/asyncio/base_events.py#L556-L574.
 I believe it could be used in alternative event loops without too much 
modification.

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



[issue40356] OverflowError: mktime argument out of range

2020-04-21 Thread darkman66


New submission from darkman66 :

example test

import time, pickle

d=pickle.loads(b'\x80\x03ctime\nstruct_time\nq\x00(M\xe4\x07K\x04K\x10K\x13K\x0cK#K\x03KkK\x01tq\x01}q\x02(X\x07\x00\x00\x00tm_zoneq\x03NX\t\x00\x00\x00tm_gmtoffq\x04Nu\x86q\x05Rq\x06.')
time.mktime(d)

on macox python compiled via brew 
Python 3.7.3 (default, Mar  6 2020, 22:34:30)
Type "copyright", "credits" or "license" for more information.

IPython 5.3.0 -- An enhanced Interactive Python.

all good, result -> Out[3]: 1587064355.0

in docker installed out of official deb (ubuntu 9.10)

Python 3.7.5 (default, Nov 20 2019, 09:21:52)
Type "copyright", "credits" or "license" for more information.
IPython 5.3.0 -- An enhanced Interactive Python.


In [5]: time.mktime(d)
---
OverflowError Traceback (most recent call last)
 in ()
> 1 time.mktime(d)

OverflowError: mktime argument out of range

--
components: C API
messages: 366944
nosy: darkman66
priority: normal
severity: normal
status: open
title: OverflowError: mktime argument out of range
type: crash
versions: Python 3.7

___
Python tracker 

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



[issue40357] asyncio: will shutdown_default_executor work in single step (stop, run_forever) mode?

2020-04-21 Thread Chris Meyer


New submission from Chris Meyer :

Is the new asyncio.loop.shutdown_default_executor() suitable for event loops 
that are run in single-step mode?

event_loop.create_task(event_loop.shutdown_default_executor())
event_loop.stop()
event_loop.run_forever()

I don't see how it will work since shutdown_default_executor() may not be 
finished during a single 'stopped' run_forever() call. 

Also, what happens to pending executor futures? Previously reported bug #28464.

Here is my currently working code for shutting down the event loop.

# give event loop one chance to finish up
event_loop.stop()
event_loop.run_forever()
# wait for everything to finish, including tasks running in executors
# this assumes that all outstanding tasks finish in a reasonable time (i.e. no 
infinite loops).
all_tasks_fn = getattr(asyncio, "all_tasks", None)
if not all_tasks_fn:
all_tasks_fn = asyncio.Task.all_tasks
tasks = all_tasks_fn(loop=event_loop)
if tasks:
gather_future = asyncio.gather(*tasks, return_exceptions=True)
else:
# work around fact that gather always uses global event loop in Python 3.8
gather_future = event_loop.create_future()
gather_future.set_result([])
event_loop.run_until_complete(gather_future)
# due to a seeming bug in Python libraries, the default executor needs to be 
shutdown explicitly before the event loop
# see http://bugs.python.org/issue28464 .
_default_executor = getattr(event_loop, "_default_executor", None)
if _default_executor:
_default_executor.shutdown()
event_loop.close()

--
messages: 366945
nosy: cmeyer, vstinner
priority: normal
severity: normal
status: open
title: asyncio: will shutdown_default_executor work in single step (stop, 
run_forever) mode?
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



[issue40353] Add an optional "strict" check to zip

2020-04-21 Thread Brandt Bucher


Brandt Bucher  added the comment:

Slight edit: if the shortest iterator is "first", one additional item will have 
to be drawn from the next non-exhausted iterator. I missed that, initially.

> It would be better to implement it as a separate function.

I disagree. It's not intrusive here; I think the handful of new lines this 
needs to fit into the existing zip implementation (which already handles most 
of this logic) is more maintainable than a whole new object/function living 
somewhere else.

> Also you can just get a ready implementation from more-tertools.

I've found that there are several places where our own standard library could 
immediately benefit from this change.

--

___
Python tracker 

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



[issue33065] IDLE debugger: failure stepping through module loading

2020-04-21 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

Timothy, this is already more helpful than a simple 'me too'.  Can you reduce 
pgdata.dump to a truly minimal file that exhibits the bug?  and then upload it? 
 Installing any package into my local copy of the master CPython repository is 
problemmatical.  What I need is a file that I can download elsewhere, load into 
IDLE, run from a branch for this issue, and edit and rerun.  From the 
traceback, it appears that it might be as simple as 

class BinaryData:
def __init__(self, bd):


BinaryData(b'')

--

___
Python tracker 

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



[issue38870] Expose ast.unparse in the ast module

2020-04-21 Thread Batuhan Taskaya


Change by Batuhan Taskaya :


--
pull_requests: +18961
pull_request: https://github.com/python/cpython/pull/19636

___
Python tracker 

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



[issue40138] Windows implementation of os.waitpid() truncates the exit status (status << 8)

2020-04-21 Thread STINNER Victor


Change by STINNER Victor :


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

___
Python tracker 

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



[issue40357] asyncio: will shutdown_default_executor work in single step (stop, run_forever) mode?

2020-04-21 Thread STINNER Victor


Change by STINNER Victor :


--
nosy: +aeros

___
Python tracker 

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



[issue40357] asyncio: will shutdown_default_executor work in single step (stop, run_forever) mode?

2020-04-21 Thread STINNER Victor


Change by STINNER Victor :


--
nosy:  -vstinner

___
Python tracker 

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



[issue40353] Add an optional "strict" check to zip

2020-04-21 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

I don't think this is needed in the builtin zip at all. I think that there is 
no consensus on Python-Ideas that this is needed or desirable.

I especially don't think the API should be a keyword flag on zip. Flag 
arguments which change the behaviour of functions are at best a code-smell and 
at worst an outright anti-pattern.

It is not always practical to avoid them, but in this case it certainly is: if 
we need this (I'm not sure we do) then a separate zip_strict() function in 
itertools next to zip_longest() is better than a flag on the builtin zip.

(That's not to say that the zip_strict iterator must be an independent class to 
the builtin zip and itertools.zip_longest, they can share a common backend. It 
is the public API I am referring to.)

I've already posted an implementation on the mailing list, it is about half a 
dozen or so lines of Python. Another independent implementation is available 
from the current development branch of more-itertools, more or less the same 
only with a less informative error message.

Personally, the fact that this has only just hit more-itertools counts as a 
point against this function to me: more-itertools is the "everything including 
the kitchen sink" grab-bag of iterator tools, and even they didn't think they 
needed "zip_equal" until version literally a few days ago. It's so new it isn't 
even documented yet:

https://pypi.org/project/more-itertools/

--
nosy: +steven.daprano

___
Python tracker 

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



[issue40353] Add an optional "strict" check to zip

2020-04-21 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

> independent class

Oops, sorry I mean independent implementation.

--

___
Python tracker 

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



[issue27635] pickle documentation says that unpickling may not call __new__

2020-04-21 Thread Furkan Onder


Furkan Onder  added the comment:

The problem is fixed, issue can be closed.

--

___
Python tracker 

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



[issue32912] Raise non-silent warning for invalid escape sequences

2020-04-21 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +xtreak

___
Python tracker 

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



[issue38770] Pickle handle self references in classes

2020-04-21 Thread Furkan Onder


Furkan Onder  added the comment:

I ran your script and didn't get RecursionError. The issue seems to be fixed.

Python 3.8.2 (default, Apr  8 2020, 14:31:25) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from __future__ import print_function
>>> 
>>> import pickle, sys
>>> 
>>> class Foo:
... __name__ = __qualname__ = "Foo.ref"
... pass
... 
>>> Foo.ref = Foo
>>> 
>>> print(sys.version_info)
sys.version_info(major=3, minor=8, micro=2, releaselevel='final', serial=0)
>>> for proto in range(0, pickle.HIGHEST_PROTOCOL + 1):
... print("{}:".format(proto), end=" ")
... try:
... pkl = pickle.dumps(Foo, proto)
... print("Dump OK,", end=" ")
... assert(pickle.loads(pkl) is Foo)
... print("Load OK,")
... except Exception as err:
... print(repr(err))
... 
0: PicklingError("Can't pickle : import of module 
'__main__' failed")
1: PicklingError("Can't pickle : import of module 
'__main__' failed")
2: PicklingError("Can't pickle : import of module 
'__main__' failed")
3: PicklingError("Can't pickle : import of module 
'__main__' failed")
4: Dump OK, Load OK,
5: Dump OK, Load OK,
>>>

--
nosy: +furkanonder

___
Python tracker 

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



[issue34204] Bump the default pickle protocol in shelve

2020-04-21 Thread Zackery Spytz


Change by Zackery Spytz :


--
keywords: +patch
nosy: +ZackerySpytz
nosy_count: 4.0 -> 5.0
pull_requests: +18963
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/19639

___
Python tracker 

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



[issue40327] list(sys.modules.items()) can throw RuntimeError: dictionary changed size during iteration

2020-04-21 Thread Raymond Hettinger


Raymond Hettinger  added the comment:


New changeset 75bedbe2ed4119ff18a2ea86c544b3cf08a92e75 by Raymond Hettinger in 
branch 'master':
bpo-40327: Improve atomicity, speed, and memory efficiency of the items() loop 
(GH-19628)
https://github.com/python/cpython/commit/75bedbe2ed4119ff18a2ea86c544b3cf08a92e75


--

___
Python tracker 

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



[issue40327] list(sys.modules.items()) can throw RuntimeError: dictionary changed size during iteration

2020-04-21 Thread miss-islington


Change by miss-islington :


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

___
Python tracker 

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



[issue39817] CRITICAL: TypeError: cannot pickle 'generator'

2020-04-21 Thread Furkan Onder


Furkan Onder  added the comment:

Can you send your code?

--
nosy: +furkanonder

___
Python tracker 

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



[issue40356] OverflowError: mktime argument out of range

2020-04-21 Thread Eric V. Smith


Eric V. Smith  added the comment:

FWIW, that time.struct_time value is:

>>> d
time.struct_time(tm_year=2020, tm_mon=4, tm_mday=16, tm_hour=19, tm_min=12, 
tm_sec=35, tm_wday=3, tm_yday=107, tm_isdst=1)


I don't get an error on 3.7.4 from Cygwin or 3.7.6 from stock Fedora.

--
components: +Interpreter Core -C API
nosy: +eric.smith
type: crash -> behavior

___
Python tracker 

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



[issue40164] Upgrade Windows and macOS installer builds to OpenSSL 1.1.1g

2020-04-21 Thread Ned Deily


Ned Deily  added the comment:

> Are we even impacted by the issue though?

Certainly we use a check_chain function at least indirectly but, whether that 
path is vulnerable, dunno.

But, in any case, we will no doubt be pinged about it so best to be ahead of 
the curve, I think.

--

___
Python tracker 

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



[issue38770] Pickle handle self references in classes

2020-04-21 Thread Furkan Onder


Furkan Onder  added the comment:

Ahh. I misunderstood the problem. Pickle behaves differently when it is a 
circular reference. If you have a solution, I am waiting with curiosity.

--

___
Python tracker 

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



[issue40358] pathlib's relative_to should behave like os.path.relpath

2020-04-21 Thread Domenico Ragusa


New submission from Domenico Ragusa :

Can we improve pathlib.relative_to(other) so that it handles the case of a path 
not being a direct child of other, like os.path.relpath?

For example:
Path('/some/thing').relative_to('/foo') -> Path('../some/thing')

At the moment it just raises an exception.

--
components: Library (Lib)
files: pathlib.diff
keywords: patch
messages: 366958
nosy: Domenico Ragusa
priority: normal
severity: normal
status: open
title: pathlib's relative_to should behave like os.path.relpath
type: enhancement
versions: Python 3.9
Added file: https://bugs.python.org/file49081/pathlib.diff

___
Python tracker 

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



[issue39423] Process finished with exit code -1073741819 (0xC0000005) when trying to access data from a pickled file

2020-04-21 Thread Furkan Onder


Furkan Onder  added the comment:

Hi,
Can you share the program codes to better understand the problem?

--
nosy: +furkanonder

___
Python tracker 

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



[issue33065] IDLE debugger: failure stepping through module loading

2020-04-21 Thread Timothy Geiser


Timothy Geiser  added the comment:

It looks like the IDLE debugger seems to call repr on objects to present in the 
Locals list, even before they've been properly initialized. If __repr__ needs 
to refer to variables that don't exist until __init__ is done (and I don't 
think it's unreasonable for __repr__ to assume that __init__ is indeed 
finished), the debugger either needs wait until __init__ has completed on any 
given instance before trying to repr it, or otherwise needs to catch a 
potentially very wide range of exceptions that might be raised from calling 
__repr__ so early. I prefer the latter solution, since any buggy code that 
(effectively) crashes on it's __repr__ (for whatever reason) will probably 
bring the debugger to it's knees.
I played around with pdb directly and can sort of get the same thing if I ask 
for __repr__ too early:

 1 Python 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 23:03:10) [MSC v.1916 64 bit 
(AMD64)] on win32
 2 Type "help", "copyright", "credits" or "license" for more information.
 3 >>> import data
 4 >>> import pdb
 5 >>> pdb.run("data.BinaryData(b'some data')")
 6 > (1)()
 7 (Pdb) step
 8 --Call--
 9 > c:\users\geitd\documents\python\data.py(4)__init__()
10 -> def __init__(self, data):
11 (Pdb) p self
12 (Pdb) p BinaryData.__repr__(self)
13 *** AttributeError: 'BinaryData' object has no attribute 'length'
14 (Pdb) step
15 > c:\users\geitd\documents\python\data.py(5)__init__()
16 -> if not data:
17 (Pdb) step
18 > c:\users\geitd\documents\python\data.py(7)__init__()
19 -> if len(data) <= 1:
20 (Pdb) step
21 > c:\users\geitd\documents\python\data.py(10)__init__()
22 -> self.data = data
23 (Pdb) step
24 > c:\users\geitd\documents\python\data.py(11)__init__()
25 -> self.length = len(data)
26 (Pdb) p self
27 (Pdb) p BinaryData.__repr__(self)
28 *** AttributeError: 'BinaryData' object has no attribute 'length'
29 (Pdb) step
30 --Return--
31 > c:\users\geitd\documents\python\data.py(11)__init__()->None
32 -> self.length = len(data)
33 (Pdb) p self
34 
35 (Pdb) p BinaryData.__repr__(self)
36 ''

Note that line 11 didn't return anything, but didn't have any bad results, 
whereas the way I phrased line 12 gave the exact same error the IDLE debugger 
threw.
Lines 26 and 27 towards the end of __init__ came out the same, but after the 
--Return-- on 30, either phrasing gives what you'd expect.
I suppose the TL;DR is to take the mechanism that gives the correct behavior of 
'p self' in pdb and copy it over to the IDLE debugger (or whatever other 
mechanism is necessary).

Is this enough for you to work from?

--
Added file: https://bugs.python.org/file49082/data.py

___
Python tracker 

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



[issue39939] PEP 616: Add str methods to remove prefix or suffix

2020-04-21 Thread Dennis Sweeney


Dennis Sweeney  added the comment:

I'm personally -0 for underscores -- they might slightly improve readability of 
the function name in isolation but may also add confusion about which methods 
have underscores.  Only one out of the 45 non-dunder str methods has an 
underscore right now:

>>> meths = [x for x in dir(str) if not x.startswith('__')]
>>> [x for x in meths if '_' in x]
['format_map']
>>> [x for x in meths if '_' not in x]
['capitalize', 'casefold', 'center', 'count', 'encode', 'endswith', 
'expandtabs', 'find', 'format', 'index', 'isalnum', 'isalpha', 'isascii', 
'isdecimal', 'isdigit', 'isidentifier', 'islower', 'isnumeric', 'isprintable', 
'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 
'maketrans', 'partition', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', 
'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 
'title', 'translate', 'upper', 'zfill']

Maybe I'm wrong, but it seemed to me that most of the discussions to date had 
arrived at leaving out underscores.  Is there a process or appropriate channel 
to continue this discussion now that the PEP is accepted?

--

___
Python tracker 

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



[issue40354] problem when using yield

2020-04-21 Thread xie


xie  added the comment:

Okay,I agree with you.I did not get the priority.

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



[issue40346] Redesign random.Random class inheritance

2020-04-21 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

-1   I am opposed to this redesign.  There is no problem being solved that 
warrants changing a long standing public API.  It is irresponsible to just 
guess at whether anyone is using the API.  To add randbytes() could have just 
been a simple two line addition.  None of what is being proposed is necessary 
-- there are no known user problems being solved.  At best, this is unnecessary 
code churn.  At worse, it will be a breaking change.

--

___
Python tracker 

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



[issue40359] email.parse part.get_filename() fails to unwrap long attachment file names

2020-04-21 Thread Matthew Davis


New submission from Matthew Davis :

# Summary

When parsing emails with long attachment file names, part.get_filename() often 
returns \n or \r\n.
It should strip those characters out.

# Steps to reproduce

I have attached a minimal working example.

The relevant part of the raw email is:

--_004_D6CEDE1EBD6645898F5643C0C6878005examplecom_
Content-Type: text/plain;
name="an attachment with a very very very long super long file name 
which has
 many words and just keeps on going and going.txt"

# Expected output:

attachments = ["an attachment with a very very very long super long file name 
which has many words and just keeps on going and going.txt"]

Maybe I'm reading the email RFC spec wrong. My interpretation is that the 
parser should do something like:

raw = raw.replace('\r\n ', ' ').replace('\n ', ' ')

# Actual output

attachments = ["an attachment with a very very very long super long file name 
which\n has many words and just keeps on going and going.txt"]

Note that I have seen other examples where the output includes \r\n not just \n

# Impact

I'm trying to write an email bot which saves attachments to a database, and 
also forwards on the emails.
My both thinks that the filename includes a line break. This inevitably causes 
failures in my subsequent code.

# Relevant links:

The RFC for email spec is here: 
https://tools.ietf.org/html/rfc2822.html#section-2.2.3

This Stack Overflow answer seems relevant: 
https://stackoverflow.com/questions/3050298/parsing-email-with-python/3050374#3050374

Issue 3601 may be relevant, but doesn't seem exactly the same. It seems to be 
the reverse, *constructing* emails with long headers. My issue is *parsing* 
emails with long headers.

--
components: email
files: mwe.py
messages: 366963
nosy: barry, matt-davis, r.david.murray
priority: normal
severity: normal
status: open
title: email.parse part.get_filename() fails to unwrap long attachment file 
names
versions: Python 3.6
Added file: https://bugs.python.org/file49083/mwe.py

___
Python tracker 

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



[issue39939] PEP 616: Add str methods to remove prefix or suffix

2020-04-21 Thread Dennis Sweeney


Dennis Sweeney  added the comment:

Oops -- I now see the message on Python-Dev.

--

___
Python tracker 

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



[issue40359] email.parse part.get_filename() fails to unwrap long attachment file names

2020-04-21 Thread Matthew Davis


Matthew Davis  added the comment:

Ah woops, I mistyped the relevant ticket.

It's issue 36401

https://bugs.python.org/issue36041

--

___
Python tracker 

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



[issue40359] email.parse part.get_filename() fails to unwrap long attachment file names

2020-04-21 Thread Matthew Davis


Matthew Davis  added the comment:

36041

--

___
Python tracker 

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



[issue40260] modulefinder traceback regression starting on Windows

2020-04-21 Thread Anthony Sottile


Anthony Sottile  added the comment:

This is still failing, but now in a different way:


Traceback (most recent call last):
  File "../debian/pymindeps.py", line 185, in 
main(sys.argv[1:])
  File "../debian/pymindeps.py", line 178, in main
mf.run_script(arg)
  File "/tmp/code/Lib/modulefinder.py", line 163, in run_script
self.load_module('__main__', fp, pathname, stuff)
  File "../debian/pymindeps.py", line 92, in load_module
m = modulefinder.ModuleFinder.load_module(self, fqname,
  File "/tmp/code/Lib/modulefinder.py", line 359, in load_module
self.scan_code(co, m)
  File "/tmp/code/Lib/modulefinder.py", line 432, in scan_code
self._safe_import_hook(name, m, fromlist, level=0)
  File "/tmp/code/Lib/modulefinder.py", line 377, in _safe_import_hook
self.import_hook(name, caller, level=level)
  File "../debian/pymindeps.py", line 42, in import_hook
return modulefinder.ModuleFinder.import_hook(self, name, caller,
  File "/tmp/code/Lib/modulefinder.py", line 175, in import_hook
q, tail = self.find_head_package(parent, name)
  File "/tmp/code/Lib/modulefinder.py", line 231, in find_head_package
q = self.import_module(head, qname, parent)
  File "../debian/pymindeps.py", line 48, in import_module
m = modulefinder.ModuleFinder.import_module(self,
  File "/tmp/code/Lib/modulefinder.py", line 325, in import_module
m = self.load_module(fqname, fp, pathname, stuff)
  File "../debian/pymindeps.py", line 92, in load_module
m = modulefinder.ModuleFinder.load_module(self, fqname,
  File "/tmp/code/Lib/modulefinder.py", line 342, in load_module
co = compile(fp.read()+b'\n', pathname, 'exec')
TypeError: can only concatenate str (not "bytes") to str

--

___
Python tracker 

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



[issue40260] modulefinder traceback regression starting on Windows

2020-04-21 Thread Anthony Sottile


Anthony Sottile  added the comment:

The failure above is `fp` is now a text file but before it was a binary file.  
this causes `fp.read()` + `b'\n'` to fail

I can send a patch -- I don't think the `b'\n'` is necessary any more (as far 
as I can tell it used to be there for an old version of python where 
`compile(...)` errored if the file did not end in a newline, that's now handled 
in the parser internally though)

--

___
Python tracker 

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



[issue40260] modulefinder traceback regression starting on Windows

2020-04-21 Thread Anthony Sottile


Change by Anthony Sottile :


--
pull_requests: +18965
pull_request: https://github.com/python/cpython/pull/19641

___
Python tracker 

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



[issue40260] modulefinder traceback regression starting on Windows

2020-04-21 Thread Anthony Sottile


Anthony Sottile  added the comment:

actually I said that backwards in the previous message -- it was a text file 
and now it's a binary file

--

___
Python tracker 

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



[issue40164] Upgrade Windows and macOS installer builds to OpenSSL 1.1.1g

2020-04-21 Thread Ned Deily


Change by Ned Deily :


--
pull_requests: +18966
pull_request: https://github.com/python/cpython/pull/19642

___
Python tracker 

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



[issue40164] Upgrade Windows and macOS installer builds to OpenSSL 1.1.1g

2020-04-21 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 7.0 -> 8.0
pull_requests: +18967
pull_request: https://github.com/python/cpython/pull/19643

___
Python tracker 

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



[issue40164] Upgrade Windows and macOS installer builds to OpenSSL 1.1.1g

2020-04-21 Thread miss-islington


Change by miss-islington :


--
pull_requests: +18968
pull_request: https://github.com/python/cpython/pull/19644

___
Python tracker 

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



[issue40164] Upgrade Windows and macOS installer builds to OpenSSL 1.1.1g

2020-04-21 Thread Ned Deily


Ned Deily  added the comment:


New changeset 783a673f23c5e9ffafe12fe172e119dc0fa2abda by Ned Deily in branch 
'master':
bpo-40164: Update macOS installer builds to use OpenSSL 1.1.1g. (GH-19642)
https://github.com/python/cpython/commit/783a673f23c5e9ffafe12fe172e119dc0fa2abda


--

___
Python tracker 

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



[issue40358] pathlib's relative_to should behave like os.path.relpath

2020-04-21 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +pitrou

___
Python tracker 

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



[issue40164] Upgrade Windows and macOS installer builds to OpenSSL 1.1.1g

2020-04-21 Thread miss-islington


miss-islington  added the comment:


New changeset 9e51aab37e9af6fa0fe406fd56184a0aded28e11 by Miss Islington (bot) 
in branch '3.8':
bpo-40164: Update macOS installer builds to use OpenSSL 1.1.1g. (GH-19642)
https://github.com/python/cpython/commit/9e51aab37e9af6fa0fe406fd56184a0aded28e11


--

___
Python tracker 

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



[issue40164] Upgrade Windows and macOS installer builds to OpenSSL 1.1.1g

2020-04-21 Thread Ned Deily


Ned Deily  added the comment:


New changeset 7ad3adda9bff8a9055eaf0b66489e8204f1e7cc6 by Miss Islington (bot) 
in branch '3.7':
bpo-40164: Update macOS installer builds to use OpenSSL 1.1.1g. (GH-19642) 
(GH-19644)
https://github.com/python/cpython/commit/7ad3adda9bff8a9055eaf0b66489e8204f1e7cc6


--

___
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-21 Thread Gregory P. Smith


New submission from Gregory P. Smith :

Based on the PEP 617 acceptance thread on python-dev, lib2to3 is eventually 
going to run into trouble parsing modern syntax a few releases from now.

It would be better off maintained outside of the standard library.  It gets 
used by a lot of things and is generally useful, but would make a lot more 
sense as a PyPI project than as something only quasi-maintained within the 
stdlib (it only gained the ability to parse a couple modern syntax features in 
via bugfix contributions to the stdlib the past month or two...  meaning a lot 
of versions of it out there cannot)

Black has already forked it.

goal:  PendingDeprecationWarning and documentation as such in 3.9.  Move to 
DeprecationWarning in 3.10 or 3.11 and remove it by ~3.12.  Subject to our 
existing deprecation process guidelines.

--
assignee: gregory.p.smith
messages: 366973
nosy: gregory.p.smith
priority: normal
severity: normal
status: open
title: Deprecate lib2to3 (and 2to3) for future removal
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



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

2020-04-21 Thread Gregory P. Smith


Change by Gregory P. Smith :


--
components: +2to3 (2.x to 3.x conversion tool)
stage:  -> needs patch

___
Python tracker 

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



[issue40314] python code order of magnitude faster than equivalent CPython code for simple import statement

2020-04-21 Thread deekay


deekay  added the comment:

The times are correct. It's very noticeable even without using a stopwatch. The 
C version actually takes 23 seconds to execute.

--

___
Python tracker 

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



[issue40346] Redesign random.Random class inheritance

2020-04-21 Thread Tim Peters


Tim Peters  added the comment:

This wasn't written with subclassing in mind to begin with.  A class was just 
an obvious way to allow advanced users to construct instances with their own 
states (e.g., so they could build pseudo-independent generators for parallel 
programming).

When SystemRandom got added, I believe that did about as little as possible 
just so that it "would work".

Making it easy to create subclasses was never a goal regardless.

I don't mind if that _becomes_ a goal, but with some disclaimers:

- If that makes any method currently in use slower, it's not worth it.

- Saving bytes in a SystemRandom instance is of no practical value.

So I think I'm agreeing with Raymond that reworking this doesn't solve any 
actual problem.  But I'm not opposed to making changes for aesthetic reasons, 
provided such changes don't impose costs beyond the always-present risk of 
breaking things with any change.

--

___
Python tracker 

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



[issue40222] "Zero cost" exception handling

2020-04-21 Thread Shantanu


Change by Shantanu :


--
nosy: +hauntsaninja

___
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-21 Thread Gregory P. Smith


Change by Gregory P. Smith :


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

___
Python tracker 

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



[issue40358] pathlib's relative_to should behave like os.path.relpath

2020-04-21 Thread Bowie Chen


Change by Bowie Chen :


--
nosy: +bowiechen

___
Python tracker 

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



[issue40222] "Zero cost" exception handling

2020-04-21 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

This is an exciting prospect.  Am looking forward to it :-)

--
nosy: +rhettinger

___
Python tracker 

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



[issue32966] Python 3.7.2 - 0x80070643 - Fatal Error during installation

2020-04-21 Thread Jacob Melendrez


Jacob Melendrez  added the comment:

I am trying to uninstall python 3.7.2 because I think it is preventing me from 
correctly using python 3.8.2. When I go to my program list on windows 10 and 
try to uninstall it, it gets approximately 10% in and then gives me the message 
that No python 3.7 installation was detected. I hit Ok and then it continues 
loading for another 1% and then I receive the error message "0x80070643 Fatal 
Error during installation " How do I resolve this?

--
nosy: +Cybernetic
title: Python 3.6.4 - 0x80070643 - Fatal Error during installation -> Python 
3.7.2 - 0x80070643 - Fatal Error during installation
versions: +Python 3.7 -Python 3.6

___
Python tracker 

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



[issue38946] IDLE on macOS 10.15 Catalina does not open double-clicked files if app already launched

2020-04-21 Thread AndrewGYork


AndrewGYork  added the comment:

We have a 10.15.3 Mac with python 3.8.2, IDLE version 3.8.2, and we see similar 
behavior.

Summary:
The *second* 'bad' .py file you double-click won't open in IDLE. This seems 
unrelated to permissions, but a 'bad' file (saved by IDLE) can be converted to 
a 'good' file by emailing the file to myself.

Details:
Open IDLE, save a 5-byte file 'fails.py' (contents: pass) to an empty folder. 
Permissions are rw-r--r--.

Close IDLE. Double-click 'fails.py', which opens in the IDLE editor; a shell 
also opens. Double-click 'fails.py' again, or drag it onto the IDLE icon in the 
Dock, and it does not open in a second instance of the IDLE editor. Typing 
`idle3 fails.py` in the terminal does open in a second instance of the IDLE 
editor (same version as first instance).

Email 'fails.py' to myself, via Gmail. Download 'fails.py' from Gmail, and 
rename it to 'works.py'. Permissions are still rw-r--r--.

Close IDLE. Double-click 'works.py', which opens in the IDLE editor; a shell 
also opens. Double-click 'works.py' again, or drag it onto the IDLE icon in the 
Dock, and it *does* open in a second instance of the IDLE editor. Any number of 
instances can be simultaneously opened this way.

Close IDLE. Double-click 'works.py' several times to open it in several 
different instances of the IDLE editor. Double-click 'fails.py' once, which 
successfully opens in one more instance of the IDLE editor. Finally, 
double-click 'fails.py' a second time; it does *not* open a second instance of 
'fails.py' in the IDLE editor.

IDLE's File->Open menu option does not open two instances of `fails.py` OR 
`works.py`; attempts to open the second instance simply raise focus of the 
first instance. However, if you open 'fails.py' via the menu, you can then open 
a second instance of 'fails.py' via double-clicking, but not a third.

--
nosy: +AndrewGYork

___
Python tracker 

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



[issue40342] Programming FAQ about "How do I apply a method to a sequence of objects?" should include the option of an explicit for-loop

2020-04-21 Thread Mark Dickinson


Mark Dickinson  added the comment:

This is an antipattern I've seen on multiple occasions in real code. A common 
offender is:

[worker.join() for worker in workers]

Similarly, things like:

[plugin.start() for plugin in plugins]

I do think it would be worth updating the FAQ text.

--
nosy: +mark.dickinson

___
Python tracker 

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



[issue40342] Programming FAQ about "How do I apply a method to a sequence of objects?" should include the option of an explicit for-loop

2020-04-21 Thread Mark Dickinson


Mark Dickinson  added the comment:

However, the list comprehension pattern is not as bad as lines like this one 
[#1]:

map(lambda plugin: self.start_plugin(plugin), self._plugins)

... which of course stopped working as soon as we transitioned to Python 3. :-(


[#1] 
https://github.com/enthought/envisage/blob/b7adb8793336dd3859623cb89bcc7bdfefe91b29/enthought/envisage/plugin_manager.py#L105

--

___
Python tracker 

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



[issue33065] IDLE debugger: failure stepping through module loading

2020-04-21 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

I believe I found the bug.  For IDLE's original single process mode, still 
available with the -n startup option, debugger.py contains the entire debugger. 
 The values displayed for global and local names are obtained with 
reprlib.Repr.repr.  That in turn calls .repr1, and that calls .repr_xxx, where 
xxx is one of the 'common' builtin classes or 'instance'.

The latter is used for all user classes.  It calls __builtins__.repr, but 
guarded by 'try...except Exception' since user classes may cause exceptions.  
The except clause returns an alternative type and id string, like 
object.__repr__.  (That alternative could also raise, but much less often.  Any 
of the examples above should run if IDLE were started from a command line with 
'python -m idlelib -n'.

When user code is run in a separate process, the code that interacts with user 
object must also run in the separate process.  debugger.Idb is moved and the 
code in debugger_r is added, some in each process.  Of concern here is that the 
GUI code that displays global or local values is passed a dict proxy instead of 
an actual namespace dict.  The proxy __getitem__ for d[key] makes an rpc call 
to through the socket connection to code in the user process.  That returns not 
the object itself but a string representation.  It does so with an unguarded 
repr call.

IDLE intentionally removes traceback lines added by IDLE (and pdb, if used), so 
that tracebacks look mostly the same as in standard CPython.  But that is a 
handicap when there is a bug in IDLE.  A traceback ending with 
  File .../idlelib/debugger_r, line 173, in dict_item
value = repr(value)
AttributeError: ...

would have been a big help here.  I am thinking about how to selectively 
disable traceback cleanup.

In any case, I believe the solution is to import reprlib in debugger_r also and 
add 'reprlib.Repr' before 'repr' in the line above.

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