[issue1635741] Py_Finalize() doesn't clear all Python objects at exit

2020-03-15 Thread hai shi


Change by hai shi :


--
pull_requests: +18359
pull_request: https://github.com/python/cpython/pull/19012

___
Python tracker 

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



[issue39966] mock 3.9 bug: Wrapped objects without __bool__ raise exception

2020-03-15 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

Thanks for the report. There should be a check to ensure that the attribute is 
present to handle the attribute error while attaching the wrapped object's 
value. Something like below could be done so that we check for wrapped value or 
fallback to the old behaviour. This needs a test too where the report can be 
added as a unittest. The news entry can also ensure that the wrapped value will 
be used when present or falls back to the default value. Marking it as a 3.9 
regression.

diff --git Lib/unittest/mock.py Lib/unittest/mock.py
index 20daf724c1..86e832cc51 100644
--- Lib/unittest/mock.py
+++ Lib/unittest/mock.py
@@ -2036,7 +2036,7 @@ _side_effect_methods = {
 def _set_return_value(mock, method, name):
 # If _mock_wraps is present then attach it so that wrapped object
 # is used for return value is used when called.
-if mock._mock_wraps is not None:
+if mock._mock_wraps is not None and hasattr(mock._mock_wraps, name):
 method._mock_wraps = getattr(mock._mock_wraps, name)
 return

--
keywords: +3.9regression

___
Python tracker 

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



[issue39967] bdb calls linecache.checkcache, resulting in source being different from code

2020-03-15 Thread daniel hahler


New submission from daniel hahler :

`Bdb.reset` calls `linecache.checkcache`, which will clear the cache for any 
updated source files.

This however might result in displayed source code being different from the 
actual code, in case you are editing the file being currently debugged.

I think it is better to keep the initially cached version (which might still 
get invalidated/checked via inspect itself), but that is another issue.

The code is very old already, merged in b6775db241:

  commit b6775db241
  Author: Guido van Rossum 
  Date:   Mon Aug 1 11:34:53 1994 +

  Merge alpha100 branch back to main trunk

I will try a PR that removes it to see if it causes any test failures.

Code ref: 
https://github.com/python/cpython/blob/598d29c51c7b5a77f71eed0f615eb0b3865a4085/Lib/bdb.py#L56-L57

--
components: Library (Lib)
messages: 364224
nosy: blueyed
priority: normal
severity: normal
status: open
title: bdb calls linecache.checkcache, resulting in source being different from 
code
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



[issue39967] bdb calls linecache.checkcache, resulting in source being different from code

2020-03-15 Thread daniel hahler


Change by daniel hahler :


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

___
Python tracker 

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



[issue39360] python3.8 regression - ThreadPool join via __del__ hangs forever

2020-03-15 Thread Arkadiusz Miśkiewicz

Arkadiusz Miśkiewicz  added the comment:

I've applied pull request patch (which looks a bit weird to me, removes 
something then adds the same thing back etc 
https://patch-diff.githubusercontent.com/raw/python/cpython/pull/19009.patch). 
Essentially the change is:

diff --git a/Lib/multiprocessing/pool.py b/Lib/multiprocessing/pool.py
index b223d6aa72..8bd9608b0e 100644
--- a/Lib/multiprocessing/pool.py
+++ b/Lib/multiprocessing/pool.py
@@ -682,7 +682,15 @@ class Pool(object):
 # this is guaranteed to only be called once
 util.debug('finalizing pool')

-worker_handler._state = TERMINATE
+# Explicitly do the cleanup here if it didn't come from terminate()
+# (required for if the queue will block, if it is already closed)
+if worker_handler._state != TERMINATE:
+# Notify that the worker_handler state has been changed so the
+# _handle_workers loop can be unblocked (and exited) in order to
+# send the finalization sentinel all the workers.
+worker_handler._state = TERMINATE
+change_notifier.put(None)
+
 task_handler._state = TERMINATE

 util.debug('helping task handler/workers to finish')


Unfortunately test case from first message in this bug report still hangs for 
me with this applied.

--

___
Python tracker 

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



[issue39360] python3.8 regression - ThreadPool join via __del__ hangs forever

2020-03-15 Thread Arkadiusz Miśkiewicz

Arkadiusz Miśkiewicz  added the comment:

(note, testing on 3.8 branch + pull request patch)

--

___
Python tracker 

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



[issue30082] hide command prompt when using subprocess.Popen with shell=False on Windows

2020-03-15 Thread swgmma


swgmma  added the comment:

> Try running that script with pythonw.exe instead.

That did the trick. Confirmed that the changes are working as intended.

Running the test script posted earlier and adding the new `force_hide` kwarg to 
the subprocess call:

With `force_hide=False`, a command prompt window pops up.
With `force_hide=True`, no command prompt window pops up.

--

___
Python tracker 

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



[issue30082] hide command prompt when using subprocess.Popen with shell=False on Windows

2020-03-15 Thread swgmma


Change by swgmma :


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

___
Python tracker 

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



[issue30082] hide command prompt when using subprocess.Popen with shell=False on Windows

2020-03-15 Thread swgmma


Change by swgmma :


--
pull_requests: +18362
pull_request: https://github.com/python/cpython/pull/18719

___
Python tracker 

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



[issue30082] hide command prompt when using subprocess.Popen with shell=False on Windows

2020-03-15 Thread swgmma


Change by swgmma :


--
pull_requests:  -18362

___
Python tracker 

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



[issue1635741] Py_Finalize() doesn't clear all Python objects at exit

2020-03-15 Thread Dong-hee Na


Change by Dong-hee Na :


--
nosy: +corona10
nosy_count: 13.0 -> 14.0
pull_requests: +18363
pull_request: https://github.com/python/cpython/pull/19015

___
Python tracker 

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



[issue39879] Update language reference to specify that dict is insertion-ordered.

2020-03-15 Thread Lahfa Samy


Lahfa Samy  added the comment:

Following the guide, I've send a patch with the fix, I'm waiting for a review. 
Once the patch will be reviewed and accepted. My patch will need to be 
backported from 3.9 to 3.7.

--

___
Python tracker 

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



[issue39507] http library missing HTTP status code 418 "I'm a teapot"

2020-03-15 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 61ac612e78e4f2625977406fb6f366e0a644673a by Ross in branch 
'master':
bpo-39507: Add HTTP status 418 "I'm a Teapot" (GH-18291)
https://github.com/python/cpython/commit/61ac612e78e4f2625977406fb6f366e0a644673a


--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue39507] http library missing HTTP status code 418 "I'm a teapot"

2020-03-15 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
components: +Library (Lib)
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
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



[issue38870] Expose ast.unparse in the ast module

2020-03-15 Thread Batuhan Taskaya


Change by Batuhan Taskaya :


--
pull_requests: +18365
pull_request: https://github.com/python/cpython/pull/19016

___
Python tracker 

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



[issue39968] move extension modules' macros of `get_xx_state()` to inline function.

2020-03-15 Thread hai shi

New submission from hai shi :

as victor and petr said in PR18613:inline function is more better than macros, 
so I plan move all extension modules' macros of `get_xx_state()` to inline 
function.

Note: some inline get_xx_state() can not be used directly in 
`tp_traverse`、`tp_free` and `tp_clear`(issue39824).

--
components: Extension Modules
messages: 364231
nosy: petr.viktorin, shihai1991, vstinner
priority: normal
severity: normal
status: open
title: move extension modules' macros of `get_xx_state()` to inline function.
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



[issue39968] move extension modules' macros of `get_xx_state()` to inline function.

2020-03-15 Thread hai shi


Change by hai shi :


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

___
Python tracker 

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



[issue10572] Move test sub-packages to Lib/test

2020-03-15 Thread Ido Michael


Ido Michael  added the comment:

Before I put more time into that, here's the strategy here:

1. Module by module migration.
2. By this order
 tkinter/test
  distutils/tests
  ctypes/tests
  lib2to3/tests
  unittest/test

*  sqlite3/test - excluded because needs more work.

Please let me know if there is a different order or more exclusions?

--

___
Python tracker 

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



[issue10572] Move test sub-packages to Lib/test

2020-03-15 Thread Ido Michael


Ido Michael  added the comment:

+ Distutils is last priority

--

___
Python tracker 

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



[issue39968] move extension modules' macros of `get_module_state()` to inline function.

2020-03-15 Thread hai shi


Change by hai shi :


--
title: move extension modules' macros of `get_xx_state()` to inline function. 
-> move extension modules' macros of `get_module_state()` to inline function.

___
Python tracker 

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



[issue39968] port extension modules' macros of `get_module_state()` to inline function.

2020-03-15 Thread hai shi


Change by hai shi :


--
title: move extension modules' macros of `get_module_state()` to inline 
function. -> port extension modules' macros of `get_module_state()` to inline 
function.

___
Python tracker 

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



[issue1635741] Py_Finalize() doesn't clear all Python objects at exit

2020-03-15 Thread hai shi


hai shi  added the comment:

hundreds of encoding names can not be released in Py_Finalize().
for example: 
```
0x7ff482f589e0 [1] 'iso_8859_1_1987'
0x7ff482f58970 [1] 'iso_8859_1'
```
-->
```
0x7ff482f589e0 [2] 'iso_8859_1_1987'
0x7ff482f58970 [2] 'iso_8859_1'
```

--

___
Python tracker 

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



[issue1635741] Py_Finalize() doesn't clear all Python objects at exit

2020-03-15 Thread hai shi


Change by hai shi :


--
pull_requests: +18367
pull_request: https://github.com/python/cpython/pull/19018

___
Python tracker 

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



[issue37207] Use PEP 590 vectorcall to speed up calls to range(), list() and dict()

2020-03-15 Thread Dong-hee Na


Change by Dong-hee Na :


--
pull_requests: +18368
pull_request: https://github.com/python/cpython/pull/19019

___
Python tracker 

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



[issue33689] Blank lines in .pth file cause a duplicate sys.path entry

2020-03-15 Thread Ido Michael


Ido Michael  added the comment:

I can take this and have a PR

--
nosy: +Ido Michael

___
Python tracker 

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



[issue39107] Upgrade tcl/tk to 8.6.10 (Windows and maxOS)

2020-03-15 Thread Ido Michael


Ido Michael  added the comment:

I can take this for Mac V 10.14.6 if there was a decision?

--
nosy: +Ido Michael

___
Python tracker 

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



[issue39380] ftplib uses latin-1 as default encoding

2020-03-15 Thread Sebastian G Pedersen


Sebastian G Pedersen  added the comment:

Thanks again for the engagement.
I am also in favor of adding the encoding to the constructor. However, 
following Giampaolo's comment, that utf-8 is standard and has been for a long 
time (and the RFC dating back to year 1999), I am also in favor of changing the 
default encoding in the same PR. As mentioned in the previous comments, most 
users use ASCII and will not be affected by this anyway - which is probably 
also why this issue hasn't been raised before.
Please let me know 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



[issue39969] Remove Param expression context from AST

2020-03-15 Thread Batuhan Taskaya


New submission from Batuhan Taskaya :

Param is an expression context that is no longer in use, we can simply remove 
it. This node predates the arguments node, and if I am not misguessing used 
inside of function signatures.

--
components: Library (Lib)
messages: 364238
nosy: BTaskaya
priority: normal
severity: normal
status: open
title: Remove Param expression context from AST
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



[issue39955] argparse print_help breaks when help is blank space

2020-03-15 Thread Ido Michael


Ido Michael  added the comment:

Looks like both the original and this are still issues.
Can I take this?

--
nosy: +Ido Michael

___
Python tracker 

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



[issue39969] Remove Param expression context from AST

2020-03-15 Thread Batuhan Taskaya


Change by Batuhan Taskaya :


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

___
Python tracker 

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



[issue39970] Combined behavior of datetime.datetime.timestamp() and datetime.datetime.utcnow() on non-UTC timezoned machines

2020-03-15 Thread Yi Luan


New submission from Yi Luan :

Hello,

Apologies if this was a duplicate issue.

I guess the most concise way of saying this is that when doing:

>>> datetime.datetime.utcnow().timestamp()

on a machine whose local time isn't the UTC time, the above code will not 
return the correct timestamp.

Because datetime.datetime.timestamp() and datetime.datetime.fromtimestamp() 
will intrinsically convert the timestamp based on the local time of the running 
machine, when fed with data that are already converted to UTC, these functions 
will double convert them hence will return incorrect result.

For example:
On a machine that is in CST time:
>>> dt = datetime.datetime.utcnow()
>>> dt
datetime.datetime(2020, 3, 15, 14, 33, 10, 213664)
>>> datetime.datetime.fromtimestamp(dt.timestamp(), datetime.timezone.utc)
datetime.datetime(2020, 3, 15, 6, 33, 10, 213664)

Meanwhile, on a machine that is in UTC time:
>>> dt = datetime.datetime.utcnow()
>>> dt
datetime.datetime(2020, 3, 15, 14, 41, 2, 203275)
>>> datetime.datetime.fromtimestamp(dt.timestamp(), datetime.timezone.utc)
datetime.datetime(2020, 3, 15, 14, 41, 2, 203275)

I understand that one should probably use datetime.datetime.fromtimestamp() to 
construct time, but the output of the above code is inconsistent on machines 
that are set to different timezones. The above code explicitly asked to get the 
UTC time now and get the timestamp, then convert from a UTC timestamp to a 
datetime object. The result should be the same on the first machine but it 
didn't.

>From my point of view, timestamp() functions should not shift any datetime 
>objects since it returns an object that is naive about the tzinfo anyway. 
>Timestamp data generated by Python should be correct and code should do what 
>the programmer asked the code to do. In the above example, 
>datetime.datetime.utcnow().timestamp() should return the timestamp of now in 
>UTC time but in fact on a machine in CST time it would return the timestamp 8 
>hours before the UTC timestamp of now.

The intrinsic behavior of timestamp() functions will cause ambiguity in code, 
therefore I suggest that timestamp() functions, unless used on tz aware 
objects, should not shift any date time based on the running machine's local 
time.

--
components: Library (Lib)
messages: 364240
nosy: Yi Luan
priority: normal
severity: normal
status: open
title: Combined behavior of datetime.datetime.timestamp() and 
datetime.datetime.utcnow() on non-UTC timezoned machines
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



[issue39970] Combined behavior of datetime.datetime.timestamp() and datetime.datetime.utcnow() on non-UTC timezoned machines

2020-03-15 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +belopolsky, p-ganssle

___
Python tracker 

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



[issue39725] unrelated `from None` exceptions lose prior exception information

2020-03-15 Thread Ido Michael


Ido Michael  added the comment:

Can I take this change into a PR?
Or is it still in the process?

--
nosy: +Ido Michael

___
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-03-15 Thread Ido Michael


Ido Michael  added the comment:

Is this open for a PR?

--
nosy: +Ido Michael

___
Python tracker 

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



[issue39970] Combined behavior of datetime.datetime.timestamp() and datetime.datetime.utcnow() on non-UTC timezoned machines

2020-03-15 Thread Paul Ganssle


Paul Ganssle  added the comment:

This is the intended behavior of these functions, and there is actually now a 
warning on both the utcnow and utcfromtimestamp functionsto reflect this:

https://docs.python.org/3/library/datetime.html#datetime.datetime.utcnow

I would say that the correct answer here is to stop using utcnow and 
utcfromtimestamp (except possibly in very limited circumstance), I have written 
about it here:

https://blog.ganssle.io/articles/2019/11/utcnow.html

The preferred way to do this is `datetime.now(tzinfo=datetime.timezone.utc)` or 
`datetime.fromtimestamp(ts, tzinfo=datetime.timezone.utc)`.

The main thing to internalize is that the result of `.timestamp()` always has a 
time zone, because it is an epoch time, meaning that it is the number of 
seconds in UTC since 1970-01-01T00:00:00Z.

In Python 2, any operations on naive datetimes that required them to represent 
absolute times were an error, but in Python 3 that was changed and they were 
treated as local times. Perhaps leaving that behavior as is and having a 
dedicated "local time" object would have been a good idea, but there are 
actually some serious problems with doing it that way because it's difficult to 
define "local time" in such a way that it may not change over the course of an 
interpreter lifetime, which would cause major issues for an aware datetime 
(guaranteed not to change over the course of the interpreter lifetime). 
Treating naive times as local for operations that require localization (without 
changing their equality and comparison semantics, which is what would cause the 
problems) is a neat solution to that.

Sorry this causes confusion, perhaps in the future we can look into removing 
the `.utcnow()` and `.utcfromtimestamp()` functions, or renaming them to 
something else.

I'm going to set the status of this as wontfix because this is an intended 
behavior, but feel free to continue to use the ticket for discussion.

Thank you for taking the time to file an issue!

--
resolution:  -> wont fix
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



[issue39970] Combined behavior of datetime.datetime.timestamp() and datetime.datetime.utcnow() on non-UTC timezoned machines

2020-03-15 Thread Alexander Belopolsky

Alexander Belopolsky  added the comment:

I am sure this has been reported before – I will try to find the relevant 
issue.  This behavior is correct and documented.  The only improvement that we 
can consider is to make it more explicit that utcnow is deprecated and the 
correct way to obtain the UTC timestamp is

datetime.now(timezone.utc).timestamp()

--

___
Python tracker 

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



[issue39970] Combined behavior of datetime.datetime.timestamp() and datetime.datetime.utcnow() on non-UTC timezoned machines

2020-03-15 Thread Alexander Belopolsky


Alexander Belopolsky  added the comment:

This is a duplicate of issue 33293.

--
superseder:  -> Using datetime.datetime.utcnow().timestamp() in Python3.6.0 
can't get correct UTC timestamp.

___
Python tracker 

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



[issue39970] Combined behavior of datetime.datetime.timestamp() and datetime.datetime.utcnow() on non-UTC timezoned machines

2020-03-15 Thread Alexander Belopolsky


Change by Alexander Belopolsky :


--
resolution: wont fix -> duplicate

___
Python tracker 

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



[issue39971] Error on documentation - Quick fix.

2020-03-15 Thread Diogo Flores


New submission from Diogo Flores :

Hello,

A code example from the 'functional programming how-to' raises an error.

The simplest fix would be to remove the Ellipsis object from the 'line_list'.

Thank you,
Diogo

Please check below for the commands issued:

# 
https://docs.python.org/3/howto/functional.html#generator-expressions-and-list-comprehensions

>>> line_list = ['  line 1\n', 'line 2  \n', ...]
>>> 
>>> # Generator expression -- returns iterator
>>> stripped_iter = (line.strip() for line in line_list)
>>> 
>>> # List comprehension -- returns list
>>> stripped_list = [line.strip() for line in line_list]
Traceback (most recent call last):
  File "", line 1, in 
  File "", line 1, in 
AttributeError: 'ellipsis' object has no attribute 'strip'

--
assignee: docs@python
components: Documentation
messages: 364247
nosy: docs@python, dxflores
priority: normal
severity: normal
status: open
title: Error on documentation  -  Quick fix.
versions: Python 3.8

___
Python tracker 

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



[issue39845] Argparse on Python 3.7.1 (Windows) appends double quotes to string if it ends with backward slash

2020-03-15 Thread Eryk Sun


Eryk Sun  added the comment:

PowerShell translates single quotes to double quotes when they're used to 
delimit a string in the command line, which complies with VC++ command-line 
parsing and CommandLineToArgvW [1]. But PowerShell 5 has a bug here. It 
translates 'C:\unu doi\' into "C:\unu doi\". A double quote preceded by a 
backslash is parsed as a literal double quote. It should escape the trailing 
backslash as two backslashes, i.e. "C:\unu doi\\". PowerShell 6 (pwsh) 
implements it correctly.

[1]: 
https://docs.microsoft.com/en-us/cpp/c-language/parsing-c-command-line-arguments?view=vs-2019

--
nosy: +eryksun
resolution:  -> third party
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



[issue10572] Move test sub-packages to Lib/test

2020-03-15 Thread Éric Araujo

Éric Araujo  added the comment:

I would advise against this for two reasons:

- git does not track renames, contrart to Mercurial, so every log/diff command 
needs to analyse files to determine if something was moved rather than deleted 
+ created; the matching can change depending on a command-line param, and git 
log needs a --follow option.

- github does not apply --follow, so history for moved files is not useful: 
https://github.com/idomic/cpython/commits/bpo-10572-testlibs/Lib/test/tkinter_test/test_tkinter/test_widgets.py
 (for some reason, annotate works: 
https://github.com/idomic/cpython/blame/bpo-10572-testlibs/Lib/test/tkinter_test/test_tkinter/test_widgets.py
 )

--

___
Python tracker 

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



[issue39969] Remove Param expression context from AST

2020-03-15 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


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



[issue39969] Remove Param expression context from AST

2020-03-15 Thread Pablo Galindo Salgado

Pablo Galindo Salgado  added the comment:


New changeset 8689209e0338943dba9b7ff5566b8a420374764c by Batuhan Taşkaya in 
branch 'master':
bpo-39969: Remove ast.Param node class as is no longer used (GH-19020)
https://github.com/python/cpython/commit/8689209e0338943dba9b7ff5566b8a420374764c


--
nosy: +pablogsal

___
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-03-15 Thread Kyle Stanley


Kyle Stanley  added the comment:

> Is this open for a PR?

I opened a PR for this issue a bit ago (applies Yury's suggestion of 
suppressing the exception), just waiting on review from Andrew when he finds 
the time to do so.

--

___
Python tracker 

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



[issue1635741] Py_Finalize() doesn't clear all Python objects at exit

2020-03-15 Thread miss-islington


Change by miss-islington :


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

___
Python tracker 

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



[issue1635741] Py_Finalize() doesn't clear all Python objects at exit

2020-03-15 Thread miss-islington


Change by miss-islington :


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

___
Python tracker 

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



[issue39360] python3.8 regression - ThreadPool join via __del__ hangs forever

2020-03-15 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

> which looks a bit weird to me

Is explained in the message in https://bugs.python.org/msg364211:

What happens is that is moving that code so is executed in both code paths: 
explicit termination and multiprocessing finalization.

> Unfortunately test case from first message in this bug report still hangs for 
> me with this applied.

Hummm, the test case from this bug is precisely the test case in PR 19009 so it 
should not hang.

--

___
Python tracker 

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



[issue39360] python3.8 regression - ThreadPool join via __del__ hangs forever

2020-03-15 Thread Pablo Galindo Salgado

Pablo Galindo Salgado  added the comment:


New changeset ac10e0c93218627d1a639db0b7b41714c5f6a883 by Batuhan Taşkaya in 
branch 'master':
bpo-39360: Ensure all workers exit when finalizing a multiprocessing Pool 
(GH-19009)
https://github.com/python/cpython/commit/ac10e0c93218627d1a639db0b7b41714c5f6a883


--

___
Python tracker 

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



[issue39360] python3.8 regression - ThreadPool join via __del__ hangs forever

2020-03-15 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 5.0 -> 6.0
pull_requests: +18372
pull_request: https://github.com/python/cpython/pull/19023

___
Python tracker 

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



[issue39360] python3.8 regression - ThreadPool join via __del__ hangs forever

2020-03-15 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

> Hummm, the test case from this bug is precisely the test case in PR 19009 so 
> it should not hang.

Oh, actually I am wrong as this is a different issue I had in mind. PR 19009 
should fix the case reported in https://bugs.python.org/issue38744 and this 
equivalent:

  from multiprocessing import Pool
class A:
def __init__(self):
self.pool = Pool(processes=1)
def test():
problem = A()
problem.pool.map(float, tuple(range(10)))
if __name__ == "__main__":
test()

Notice that in this code there is no __del__ call.

--
nosy:  -miss-islington

___
Python tracker 

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



[issue39360] python3.8 regression - ThreadPool join via __del__ hangs forever

2020-03-15 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

I tried and I cannot reproduce the hang with the code provided in the first 
message here after PR 19009. (Tested on Linux, Windows and MacOS)

--

___
Python tracker 

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



[issue39961] warning: this use of "defined" may not be portable (Mac OS)

2020-03-15 Thread Ronald Oussoren


Ronald Oussoren  added the comment:

What version of macOS are you on? And which compiler do you use?

--

___
Python tracker 

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



[issue38744] python 3.8 hang in multiprocessing.Pool() locking on FreeBSD / Linux

2020-03-15 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


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



[issue38744] python 3.8 hang in multiprocessing.Pool() locking on FreeBSD / Linux

2020-03-15 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

Closed via PR 19009

--
resolution:  -> fixed
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



[issue38870] Expose ast.unparse in the ast module

2020-03-15 Thread Pablo Galindo Salgado

Pablo Galindo Salgado  added the comment:


New changeset 5b66ec166b81c8a77286da2c0d17be3579c3069a by Batuhan Taşkaya in 
branch 'master':
bpo-38870: Implement support for ast.FunctionType in ast.unparse (GH-19016)
https://github.com/python/cpython/commit/5b66ec166b81c8a77286da2c0d17be3579c3069a


--

___
Python tracker 

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



[issue9685] tuples should remember their hash value

2020-03-15 Thread Anthony Sottile

Anthony Sottile  added the comment:

hit this today unfortunately -- I'm working with some pretty complex (and 
nested) `typing.NamedTuple` objects and the lack of caching here results in 
quite the slowdown (in my macro benchmarks it's the difference between a render 
pass taking 180ms and 25ms)

the class in question is being used as a cache key:

https://github.com/asottile/babi/blob/1be4e80eddc1bff0eb8047cc89337fdf006ad148/babi/highlight.py#L217

with the hash cached:

```
μs  event
123744  startup
27833   kEND5
2859^X
```

without the hash cached:

```
μs  event
122575  startup
180415  kEND5
3725^X
```

(my hash cache of course being slower than it could be in C)

```
@@ -214,10 +214,21 @@ class Region(NamedTuple):
 scope: Scope
 
 
+_state_hash_cache = {}
+
+
 class State(NamedTuple):
 entries: Tuple['Entry', ...]
 while_stack: Tuple[Tuple['WhileRule', int], ...]
 
+def __hash__(self):
+k = id(self)
+try:
+return _state_hash_cache[k]
+except KeyError:
+ret = _state_hash_cache[k] = super().__hash__()
+return ret
+
 @classmethod
 def root(cls, entry: 'Entry') -> 'State':
 return cls((entry,), ())
```

___


I get that this is a pretty extreme case and it's unlikely to change the 
resolution of this issue, but figured I'd point it out in case anyone else is 
hitting similar issues

--
nosy: +Anthony Sottile

___
Python tracker 

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



[issue39360] python3.8 regression - ThreadPool join via __del__ hangs forever

2020-03-15 Thread Arkadiusz Miśkiewicz

Arkadiusz Miśkiewicz  added the comment:

Ok, so two test cases

1)

from multiprocessing.pool import ThreadPool
class A(object):
def __init__(self):
self.pool = ThreadPool()
def __del__(self):
self.pool.close()
self.pool.join()
a = A()
print(a)

2)

from multiprocessing import Pool
class A:
def __init__(self):
self.pool = Pool(processes=1)
def test():
problem = A()
problem.pool.map(float, tuple(range(10)))
if __name__ == "__main__":
test()

On two my test environments with Linux, 5.5.2 and 4.9.208 kernel, glibc 2.31 
(userspace is mostly the same on both) test 1) hangs, 2) doesn't hang.

Testing done on 3.8 branch + 
https://patch-diff.githubusercontent.com/raw/python/cpython/pull/19023.patch


For test 1) no traceback on ctrl+c and also no trace logged with faulthandler 
installed, so no idea where it hangt.

strace shows
[...]
[pid 232031] munmap(0x7f1baaffe000, 8392704 
[pid 232017] write(5, "\0\0\0\4\200\4N.", 8 
[pid 232031] <... munmap resumed>)  = 0
[pid 232017] <... write resumed>)   = 8
[pid 232031] exit(0)= ?
[pid 232017] futex(0x7f1b94000b60, 
FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 0, NULL, FUTEX_BITSET_MATCH_ANY 

[pid 232031] +++ exited with 0 +++
^C * ctrl + c pressed
[pid 232017] <... futex resumed>)   = ? ERESTARTSYS (To be restarted if 
SA_RESTART is set)
strace: Process 232017 detached
strace: Process 232032 detached
strace: Process 232033 detached
strace: Process 232034 detached
strace: Process 232035 detached

--

___
Python tracker 

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



[issue38938] Possible performance improvement for heaqq.merge()

2020-03-15 Thread Dennis Sweeney


Dennis Sweeney  added the comment:

My suspicion was confirmed about PyPy (My PyPy here is Python 3.6.1 
(784b254d6699, Apr 16 2019, 12:10:48) [PyPy 7.1.1-beta0 with MSC v.1910 32 bit] 
on win32). In what follows, "heapq2.py" had exactly the `class merge` Python 
implementation from PR 18427.

pypy -m pyperf timeit -s "from random import random; from heapq import merge; 
from collections import deque; iters = [sorted(random() for j in ra
nge(10_000)) for i in range(20)]" "deque(merge(*iters), maxlen=0)"

Mean +- std dev: 191 ms +- 3 ms

pypy -m pyperf timeit -s "from random import random; from heapq2 import merge; 
from collections import deque; iters = [sorted(random() for j in r
ange(10_000)) for i in range(20)]" "deque(merge(*iters), maxlen=0)"

Mean +- std dev: 69.3 ms +- 2.2 ms

Another test: PyPy merging 2 iterables of size 100_000:

heapq: Mean +- std dev: 91.4 ms +- 2.4 ms
heapq2: Mean +- std dev: 52.4 ms +- 2.1 ms

PyPy merging 10_000 iterables of size 100:

heapq: Mean +- std dev: 2.74 sec +- 0.07 sec
heapq2: Mean +- std dev: 781 ms +- 19 ms

--

___
Python tracker 

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



[issue39360] python3.8 regression - ThreadPool join via __del__ hangs forever

2020-03-15 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

Sadly, I am unable to reproduce, so without more clarification or a reliable 
reproducer, we cannot start debugging the issue.

> For test 1) no traceback on ctrl+c and also no trace logged with faulthandler 
> installed, so no idea where it hangt.

Can you attach with gdb and tell the C trace and the python trace (check the 
gdb helpers on the CPython repo for the later).

--

___
Python tracker 

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



[issue39360] python3.8 regression - ThreadPool join via __del__ hangs forever

2020-03-15 Thread miss-islington


miss-islington  added the comment:


New changeset 7f5302fed4ff0cc8042e639b29a0664a16bc2702 by Miss Islington (bot) 
in branch '3.8':
bpo-39360: Ensure all workers exit when finalizing a multiprocessing Pool 
(GH-19009)
https://github.com/python/cpython/commit/7f5302fed4ff0cc8042e639b29a0664a16bc2702


--
nosy: +miss-islington

___
Python tracker 

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



[issue39360] python3.8 regression - ThreadPool join via __del__ hangs forever

2020-03-15 Thread Arkadiusz Miśkiewicz

Arkadiusz Miśkiewicz  added the comment:

http://ixion.pld-linux.org/~arekm/python-gdb1.txt

it's a result of thread apply all bt, thread apply all bt full, where

pystack command shows nothing.

ps. I'm arekm@freenode and can give ssh account for playing with the issue

--

___
Python tracker 

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



[issue37860] Add netlify deploy preview for docs

2020-03-15 Thread Ashwin Ramaswami


Change by Ashwin Ramaswami :


--
pull_requests: +18373
pull_request: https://github.com/python/cpython/pull/19025

___
Python tracker 

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



[issue37860] Add netlify deploy preview for docs

2020-03-15 Thread Ashwin Ramaswami


Ashwin Ramaswami  added the comment:

Given Ernest's comment in 
https://github.com/python/cpython/pull/15288#issuecomment-579476340 about the 
limitations of Netlify (1000 build minutes per month), it doesn't seem like 
Netlify will be a viable alternative.

Instead, I've added a PR (https://github.com/python/cpython/pull/19025) that 
takes an alternative approach. It uses GitHub Actions to deploy the docs to the 
gh-pages branch, then adds a comment to the PR with a link to the deploy 
preview.

The way this works is that the gh-pages branch has subfolders with the SHA of 
each commit, and each deploy preview is deployed to each subfolder.

I've enabled this on my fork of cpython -- here's an example PR on my fork: 
https://github.com/epicfaace/cpython/pull/7

--

___
Python tracker 

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



[issue39360] python3.8 regression - ThreadPool join via __del__ hangs forever

2020-03-15 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

> ps. I'm arekm@freenode and can give ssh account for playing with the issue

Can you send me an email to pablog...@gmail.com to set up ssh access?

--

___
Python tracker 

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



[issue37860] Add netlify deploy preview for docs

2020-03-15 Thread Ashwin Ramaswami


Ashwin Ramaswami  added the comment:

GitHub Pages has no limit on "build limits" like Netlify does.

One limitation of this approach, though, is that GitHub Pages sites are limited 
to 1 GB in size. Each doc build is 50 MB, meaning that we could host at a 
maximum 20 builds. If we needed to, we could resolve this by doing one (or 
multiple) of the following:
- check with GitHub to see if they will increase the limit for this case
- only build PRs that have been tagged "documentation"
- add a workflow to automatically remove deploy previews after a certain amount 
of time has passed or after a PR has been merged
- don't deploy on GitHub Pages, but use something like https://surge.sh/, which 
apparently doesn't have a hard limit on size of a static site

--

___
Python tracker 

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



[issue39961] warning: this use of "defined" may not be portable (Mac OS)

2020-03-15 Thread Clem Wang


Clem Wang  added the comment:

Oops: forgot version numbers

MacOS Catalina (10.15.13 19D76)
2.6 Ghz 6-Code Intel i7
32 GB RAM

Homebrew 2.2.10
Homebrew/homebrew-core (git revision 58c0; last commit 2020-03-13)
Homebrew/homebrew-cask (git revision ab52c7; last commit 2020-03-14)

Not sure which compiler is being used, but I have these installed:

gcc --version
gcc (MacPorts gcc9 9.2.0_1) 9.2.0

(3.8-env) C02ZD5VVLVDQ:3.8-env clem.wang$ clang --version
clang version 9.0.0 (tags/RELEASE_900/final)
Target: x86_64-apple-darwin19.3.0
Thread model: posix
InstalledDir: /usr/local/opt/llvm/bin

--

___
Python tracker 

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



[issue39360] python3.8 regression - ThreadPool join via __del__ hangs forever

2020-03-15 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

I still cannot reproduce it in your system:

[test@ixion-pld cpython]$ hostname
ixion-pld
[test@ixion-pld cpython]$ uname -a
Linux ixion-pld 5.5.2-1 #1 SMP Wed Feb 5 19:26:43 CET 2020 x86_64 
Common_KVM_processor PLD Linux

[test@ixion-pld cpython]$ cat lel.py
from multiprocessing.pool import ThreadPool
class A(object):
def __init__(self):
self.pool = ThreadPool()
def __del__(self):
self.pool.close()
self.pool.join()
a = A()
print(a)
[test@ixion-pld cpython]$ time ./python lel.py
<__main__.A object at 0x7f9130becd20>

real0m0.124s
user0m0.105s
sys 0m0.021s

--

___
Python tracker 

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



[issue39360] python3.8 regression - ThreadPool join via __del__ hangs forever

2020-03-15 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

I tested it on the master branch with commit 
5b66ec166b81c8a77286da2c0d17be3579c3069a

--

___
Python tracker 

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



[issue39360] python3.8 regression - ThreadPool join via __del__ hangs forever

2020-03-15 Thread Arkadiusz Miśkiewicz

Arkadiusz Miśkiewicz  added the comment:

master works fine
3.8 branch hangs

so there is some other/related issue.

--

___
Python tracker 

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



[issue37860] Add netlify deploy preview for docs

2020-03-15 Thread Kyle Stanley


Kyle Stanley  added the comment:

> only build PRs that have been tagged "documentation"

My preference would be to have a "preview-with-netlify" label that could be 
manually added to use the netlify preview on a case-by-case basis. There are a 
substantial number of trivial PRs (such as typo fixes and similar minor 
changes) that are automatically labelled as "documentation" which wouldn't 
particularly benefit from the netlify preview and would needlessly occupy part 
of the limit.

Personally, I feel that it most largely benefits more significant documentation 
changes that involve modification of existing markup or the addition of new 
markup, rather than all documentation PRs. So a manually added label to trigger 
it makes the most sense to me. This would be very similar to the recently added 
"test-with-buildbots" label.

--
nosy: +aeros

___
Python tracker 

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



[issue39725] unrelated `from None` exceptions hide prior exception information

2020-03-15 Thread Nick Coghlan


Nick Coghlan  added the comment:

Tweaked title to be "hide" rather "lose" (all the info is theoretically still 
there in various places, it's just hidden by the default traceback printing 
machinery, and hard to extract from the exception tree).

Issue #18861 is the original report of this problem.

My concern with Serhiy's suggestion is that it would take us from merely hiding 
information to actually losing it.

I'm wondering if we're actually missing a piece of lower level infrastructure: 
a query API that reports *all* live exceptions in a thread.

For example, there might be a "sys.active_exceptions()" API that returned a 
list of all active exceptions.

* []: No exception active
* [exc]: Running an except/finally/__exit__ for "exc"
* [exc_inner, exc_outer]: Running an except/finally/__exit__ for "exc_inner" 
inside one for "exc_outer"
* etc

So in Serhiy's example, at the point where the context is suppressed, that new 
API would report [ValueError(), TypeError()] (with the relevant caught 
exception instances).

Given that extra low level API, we would gain more options for populating 
attributes on exceptions.

Alternatively, Serhiy's suggested approach might be sufficient, even without 
that new API, if we added a new __suppressed_context__ attribute to capture the 
original value of __context__ before it was replaced.

--
title: unrelated  `from None` exceptions lose prior exception information -> 
unrelated  `from None` exceptions hide prior exception information

___
Python tracker 

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



[issue39073] email incorrect handling of crlf in Address objects.

2020-03-15 Thread R. David Murray


R. David Murray  added the comment:

Thanks for the PR.  I've made some review comments.

--

___
Python tracker 

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



[issue39839] Non-working error handler when creating a task with assigning a variable

2020-03-15 Thread Caleb Hattingh


Caleb Hattingh  added the comment:

Can reproduce also on 3.8. Another version that "works" (raises the exception) 
is

task = loop.create_task(test())
del task

Suggests there's something going on with reference counting or garbage 
collection. In the version that "doesn't work", the task exception only appears 
in the custom exception handler when the loop is stopped, not before. I've 
added a log message to show each second that passes, and the loop is stopped 
after 5 seconds:

import asyncio
import logging


def handle_exception(loop, context):
msg = context.get("exception", context["message"])
logging.error("Caught exception: %s", msg)


async def test():
await asyncio.sleep(1)
raise Exception("Crash.")


def second_logger(loop, count) -> int:
logging.warning(count)
loop.call_later(1, lambda count=count: second_logger(loop, count + 1))


def main():
loop = asyncio.get_event_loop()
loop.call_later(1, lambda: second_logger(loop, 0))
loop.call_later(5, loop.stop)
loop.set_exception_handler(handle_exception)
task = loop.create_task(test())
try:
loop.run_forever()
finally:
loop.close()


if __name__ == "__main__":
main()

OUTPUT:

$ py -3.8 -u bpo-issue39839.py
WARNING:root:0
WARNING:root:1
WARNING:root:2
WARNING:root:3
WARNING:root:4
ERROR:root:Caught exception: Crash.

--
nosy: +cjrh

___
Python tracker 

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



[issue39971] Error on documentation - Quick fix.

2020-03-15 Thread Eric V. Smith


Eric V. Smith  added the comment:

I don't think that was meant to be a literal example. I think that "..." here 
means "and other strings".

--
nosy: +eric.smith

___
Python tracker 

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



[issue37860] Add deploy preview for docs

2020-03-15 Thread Ashwin Ramaswami


Change by Ashwin Ramaswami :


--
title: Add netlify deploy preview for docs -> Add deploy preview for docs

___
Python tracker 

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



[issue34882] f(a=1, *args) should be a SyntaxError

2020-03-15 Thread Batuhan Taskaya


Change by Batuhan Taskaya :


--
nosy: +BTaskaya

___
Python tracker 

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



[issue39883] Use BSD0 license for code in docs

2020-03-15 Thread Todd Jennings


Todd Jennings  added the comment:

Hi Terry,

Please take a look at the linked PR.  This was already discussed on the 
python-ideas mailing list and Guido agreed this is a good idea.  It is 
currently waiting on a PSF board decision.  Guido requested I create a blurb, 
and that required a corresponding issue number, so I created this issue.  

But to answer your question, the problem is incorporating code into an existing 
project.  The whole point of examples and recipes is that they be used in other 
projects.  But keeping them under the Python 2.0 license makes this hard, since 
it requires all the documentation keep that same license.  So you can't use, 
say, an itertools recipe without keeping a separate license for that code, and 
some way to identify which code falls under that license.

--

___
Python tracker 

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



[issue37860] Add deploy preview for docs

2020-03-15 Thread Batuhan Taskaya


Change by Batuhan Taskaya :


--
nosy: +BTaskaya

___
Python tracker 

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



[issue39939] Add str methods to remove prefixes or suffixes

2020-03-15 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Guido, do you support this API expansion?

--
nosy: +gvanrossum, rhettinger

___
Python tracker 

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



[issue39968] port extension modules' macros of `get_module_state()` to inline function.

2020-03-15 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Tim, do you approve of this kind of wholesale macro-to-inline function 
conversion?

My thought is that in most cases, there is no advantage to conversion and that 
sometimes there will be minor disadvantage in code generation when the macro is 
used across files.  I like inline functions as well as next person, but that 
doesn't mean all macros have to be rewritten.  Mostly, this seems like 
unnecessary code churn.

--
nosy: +rhettinger, tim.peters

___
Python tracker 

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



[issue38938] Possible performance improvement for heaqq.merge()

2020-03-15 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Serhiy, I've got this one.  It will still take a little to get to it, but I've 
already invested work in it.  The code idea is plausible but I want to think it 
through for both CPython and PyPy.

--

___
Python tracker 

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



[issue39824] Multi-phase extension module (PEP 489): don't call m_traverse, m_clear nor m_free before the module state is allocated

2020-03-15 Thread Nick Coghlan


Nick Coghlan  added the comment:

Petr's point that any subclass state should be managed in the subclass cleanup 
functions is a good one, so I withdraw my concern:

* custom module subclasses should clean up like any other class instance
* the module slots are then only needed if the module state actually gets 
populated, so we can safely skip them if it never even gets allocated

--

___
Python tracker 

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



[issue39892] Enable DeprecationWarnings by default when not explicit in unittest.main()

2020-03-15 Thread Nick Coghlan


Nick Coghlan  added the comment:

Issue 10535 says they should already be on by default in unittest.

I seem to recall checking that was still true when implementing the default 
warning filter changes in 3.7.

--

___
Python tracker 

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



[issue39970] Combined behavior of datetime.datetime.timestamp() and datetime.datetime.utcnow() on non-UTC timezoned machines

2020-03-15 Thread Yi Luan


Yi Luan  added the comment:

Hi,

Thanks for taking time to reply my question.

I suppose the title I put was a bit confusing.

And the recommended way to generate time in UTC does solve this issue, in 
Python.

However the message I was trying to convey is, the behavior of timestamp() is 
one action too much from my point of view.

Say, for example, if I'm sending data generated on my local machine (in CST 
time) to someone else, and for easy comparison and precision I used 
`datetime.datetime.now().timestamp()` as the value of time fields. I would 
naturally think that the timestamp() function returned the timestamp of my 
local time. And if the person who received the data, instead of using Python, 
used Node.js to import those timestamps, and told by me that the timestamps 
were in CST time. Then he/she will get the wrong time since those timestamps 
were actually in UTC.
As Scott Mayer, the author of Effective C++, once said, "APIs should be easy to 
use correctly and hard to use incorrectly", timestamp() functions from my point 
of view did one thing too much, it shouldn't shift any datetime object that it 
was fed into.
And in the documentation of datetime.timestamp(), there is no warning about 
this behavior, only a note on getting the UTC time. It only says "Return POSIX 
timestamp corresponding to the datetime instance". From my understanding POSIX 
timestamp is the time elapsed since epoch, not time elapsed -8 hours on CST 
timed machines since epoch.

By it's nature, timestamps couldn't and shouldn't incorporate any timezone 
information, when only presented with a naive datetime, program should only 
convert it to whatever datetime that timestamp represents, rather than thinking 
that the machine is in some timezone and shifts it by some time and then 
converts it.

Sorry if what I wrote does not make sense, the reason for me to use utcnow() is 
just to demonstrate, from my point of view utcnow() or utcfromtimestamp() did 
nothing wrong, but the problem lies with the timestamp() and fromtimestamp() 
functions' extra behavior.

Another example is, say, the current unix epoch is 1584330809, when I fed it 
into Python on my local machine, I get:
>>> datetime.datetime.fromtimestamp(1584330809)
datetime.datetime(2020, 3, 16, 11, 53, 29)

when I fed it into Node.js, I get:
> new Date(1584330809*1000)
2020-03-16T03:53:29.000Z

>From my point of view, the Node's behavior is much more natural and intuitive.

since we didn't know what timezone 1584330809 is in, the returned datetime 
should be just how many seconds elapsed since epoch, not my local time of the 
machine.

--

___
Python tracker 

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



[issue39970] Combined behavior of datetime.datetime.timestamp() and datetime.datetime.utcnow() on non-UTC timezoned machines

2020-03-15 Thread Yi Luan


Yi Luan  added the comment:

Sorry to make changes again but I typed his name wrong = =!
It's Scott Meyers. Apologies.

--

___
Python tracker 

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



[issue39939] Add str methods to remove prefixes or suffixes

2020-03-15 Thread Guido van Rossum


Guido van Rossum  added the comment:

I stopped following the discussion at some point, but I think this is worth 
adding it -- I have seen this done over and over again, and apparently lots of 
other people have felt the need too.

I think these names are fine, and about the best we can do (keeping in line 
with the "feel" of the rest of the string API).

I like the behavior of returning a copy of the string if there's no match (as 
opposed to failing, which was also brought up).  If the original object is 
immutable this should return the original object, but that should be considered 
a CPython optimization (IIRC all the string methods are pretty careful about 
that), but not required by the spec.

FWIW the pseudo code has a copy/paste error: In cutsuffix() it should use 
endswith() rather than startswith().

--

___
Python tracker 

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



[issue39972] Math library Bug Return None for "degrees(0)"

2020-03-15 Thread Ion SKALAMERA


New submission from Ion SKALAMERA :

I tried programming a recursive fractal with Python Turtle on repl.it:
https://repl.it/@IonSKALAMERA/simplefractalrecursive
and when my code came to calculating the angle degrees(0) returned NoneType 
which is a serious bug in the math library. I dont know with which Python 
version it operates

--
messages: 364285
nosy: Ion SKALAMERA
priority: normal
severity: normal
status: open
title: Math library Bug Return None for "degrees(0)"
type: behavior

___
Python tracker 

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



[issue39883] Use BSD0 license for code in docs

2020-03-15 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

OK.  I looked at the PR.  Normally, issue comes first, with justification and 
approval status.

--

___
Python tracker 

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



[issue39972] Math library Bug Return None for "degrees(0)"

2020-03-15 Thread Ion SKALAMERA


Change by Ion SKALAMERA :


--
nosy: +mark.dickinson, rhettinger, stutzbach -Ion SKALAMERA

___
Python tracker 

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



[issue39973] The documentation for PyObject_GenericSetDict() is incorrect

2020-03-15 Thread Zackery Spytz


New submission from Zackery Spytz :

PyObject_GenericSetDict() takes three arguments, but the documentation states 
that it takes just two.

--
assignee: docs@python
components: Documentation
messages: 364287
nosy: ZackerySpytz, docs@python
priority: normal
severity: normal
status: open
title: The documentation for PyObject_GenericSetDict() is incorrect
versions: Python 3.7, Python 3.8, Python 3.9

___
Python tracker 

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



[issue39973] The documentation for PyObject_GenericSetDict() is incorrect

2020-03-15 Thread Zackery Spytz


Change by Zackery Spytz :


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

___
Python tracker 

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



[issue39972] Math library Bug Return None for "degrees(0)"

2020-03-15 Thread Ion SKALAMERA


Change by Ion SKALAMERA :


--
components: +Library (Lib)

___
Python tracker 

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



[issue39974] A race condition with GIL releasing exists in stringlib_bytes_join

2020-03-15 Thread tzickel


New submission from tzickel :

bpo 36051 added optimization to release GIL on certain conditions of bytes 
joining, but it has missed a critical path.

If the number of items joining is less or equal to NB_STATIC_BUFFERS (10) than 
static_buffers will be used to hold the buffers.

https://github.com/python/cpython/blob/5b66ec166b81c8a77286da2c0d17be3579c3069a/Objects/stringlib/join.h#L54

But then the decision to release the GIL or not (drop_gil) does not take this 
into consideration, and the GIL might be released and then another thread is 
free to do the same code path, and hijack the static_buffers for it's own 
usage, causing a race condition.

A decision should be made if it's worth for the optimization to not use the 
static buffers in this case (although it's an early part of the code...) or not 
drop the GIL anyhow if it's static buffers (a thing which might make this 
optimization not worth it, since based on length of data to join, and not 
number of items to join).

--
messages: 364288
nosy: tzickel
priority: normal
severity: normal
status: open
title: A race condition with GIL releasing exists in stringlib_bytes_join
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



[issue39974] A race condition with GIL releasing exists in stringlib_bytes_join

2020-03-15 Thread tzickel


Change by tzickel :


--
nosy: +bmerry, inada.naoki

___
Python tracker 

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



[issue39972] Math library Bug Return None for "degrees(0)"

2020-03-15 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

math.degrees returns 0.0 and even has a test for this at 
https://github.com/python/cpython/blob/5b66ec166b81c8a77286da2c0d17be3579c3069a/Lib/test/test_math.py#L476
 . I am not sure of the environment under which repl.it runs as sys is not 
accessible. I guess it's an issue on their side.

./python.exe
Python 3.9.0a4+ (heads/master:5b66ec166b, Mar 16 2020, 10:41:43)
[Clang 10.0.1 (clang-1001.0.46.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import math
>>> math.degrees(0)
0.0

--
nosy: +xtreak

___
Python tracker 

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



[issue39974] A race condition with GIL releasing exists in stringlib_bytes_join

2020-03-15 Thread Bruce Merry


Bruce Merry  added the comment:

Good catch! I'll take a look this week to see what makes sense for the use case 
for which I originally proposed this optimisation.

--

___
Python tracker 

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



[issue39972] Math library Bug Return None for "degrees(0)"

2020-03-15 Thread Hamid Nazari


Hamid Nazari  added the comment:

You seem to be calling `turtle.degrees()`, not `math.degrees()`.

Try this in your Repl.it: (which does not use cpython, rather it uses Skulpt)

import math
import turtle
print(turtle.degrees(0))
print(math.degrees(0))

--
nosy: +hamidnazari

___
Python tracker 

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