[issue38382] statistics.harmonic_mean fails to raise error with negative input that follows a 0

2019-10-05 Thread Warren Weckesser


Change by Warren Weckesser :


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

___
Python tracker 

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



[issue38382] statistics.harmonic_mean fails to raise error with negative input that follows a 0

2019-10-05 Thread Warren Weckesser


Warren Weckesser  added the comment:

The premature return on ZeroDivisionError also causes an inconsistency in how 
types are handled.  For example,

>>> harmonic_mean([1, 0, "foo"])
0

We get an error as expected if "foo" occurs before 0:

>>> harmonic_mean([1, "foo", 0])
Traceback (most recent call last):
  File "", line 1, in 
  File "/Users/warren/repos/git/forks/cpython/Lib/statistics.py", line 406, in 
harmonic_mean
T, total, count = _sum(1/x for x in _fail_neg(data, errmsg))
  File "/Users/warren/repos/git/forks/cpython/Lib/statistics.py", line 166, in 
_sum
for n,d in map(_exact_ratio, values):
  File "/Users/warren/repos/git/forks/cpython/Lib/statistics.py", line 406, in 

T, total, count = _sum(1/x for x in _fail_neg(data, errmsg))
  File "/Users/warren/repos/git/forks/cpython/Lib/statistics.py", line 288, in 
_fail_neg
if x < 0:
TypeError: '<' not supported between instances of 'str' and 'int'

--

___
Python tracker 

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



[issue37736] asyncio.wait_for is still confusing

2019-10-05 Thread Caleb Hattingh


Caleb Hattingh  added the comment:

> asyncio.wait_for is still confusing

Perhaps the confusion can be fixed with improvements to the docs? To me, these 
specific docs seem pretty clear now, but I might not be a good judge of that.

> However, we still have the case where a misbehaving Task can cause wait_for 
> to hang indefinitely.

The key word here is "misbehaving". Cooperative concurrency does require 
cooperation. There are many ways in which coroutines can misbehave, the popular 
one being calling blocking functions when they shouldn't. I would be very 
uncomfortable with my coroutine being killable (e.g. by wait_for) by some other 
means besides CancelledError (which I can intercept and manage cleanup).  

The contract is: if my coroutine has a CancelledError raised, I take that to 
mean that I need to clean up whatever resources need cleanup, in a timely 
manner and then exit. If my coro refuses to exit, it is my coroutine that is 
wrong, not wait_for being unable to kill the coroutine.

I definitely agree with Yury that the previous behaviour, the one where 
wait_for could raise TimeoutError *before* the inner coro has exited, was buggy 
and needed to be fixed.

--
nosy: +cjrh

___
Python tracker 

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



[issue38382] statistics.harmonic_mean fails to raise error with negative input that follows a 0

2019-10-05 Thread Warren Weckesser


New submission from Warren Weckesser :

The function statistics.harmonic_mean is supposed to raise a StatisticsError if 
any element in the input is negative.  It fails to do so if the negative 
element is preceded by a zero.  When there is a zero before the negative 
element, the function returns 0:

>>> from statistics import harmonic_mean
>>> harmonic_mean([0, -1, 3])
0

If the zero occurs after the negative value, the StatisticsError exception is 
correctly raised:

>>> harmonic_mean([-1, 0, 3])
Traceback (most recent call last):
  File "", line 1, in 
  File "/Users/warren/repos/git/forks/cpython/Lib/statistics.py", line 406, in 
harmonic_mean
T, total, count = _sum(1/x for x in _fail_neg(data, errmsg))
  File "/Users/warren/repos/git/forks/cpython/Lib/statistics.py", line 164, in 
_sum
for typ, values in groupby(data, type):
  File "/Users/warren/repos/git/forks/cpython/Lib/statistics.py", line 406, in 

T, total, count = _sum(1/x for x in _fail_neg(data, errmsg))
  File "/Users/warren/repos/git/forks/cpython/Lib/statistics.py", line 289, in 
_fail_neg
raise StatisticsError(errmsg)
statistics.StatisticsError: harmonic mean does not support negative values
>>> 

The problem is in this code in the function harmonic_mean:

try:
T, total, count = _sum(1/x for x in _fail_neg(data, errmsg))
except ZeroDivisionError:
return 0

When the zero occurs before the negative value, the ZeroDivisionError is raised 
before the negative value has been seen by the generator _fail_neg, and the 
function returns 0.

--
components: Library (Lib)
messages: 354028
nosy: WarrenWeckesser
priority: normal
severity: normal
status: open
title: statistics.harmonic_mean fails to raise error with negative input that 
follows a 0
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



[issue22257] PEP 432 (PEP 587): Redesign the interpreter startup sequence

2019-10-05 Thread Nick Coghlan


Nick Coghlan  added the comment:

Agreed. I've also added PEP 587 to the issue title to make the connection to 
that PEP more obvious.

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
title: PEP 432: Redesign the interpreter startup sequence -> PEP 432 (PEP 587): 
Redesign the interpreter startup sequence

___
Python tracker 

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



[issue18578] Rename and document test.bytecode_helper as test.support.bytecode_helper

2019-10-05 Thread Nick Coghlan


Nick Coghlan  added the comment:

Just noting for the record that the reason a new warning wasn't needed here is 
because there is already a general "No compatibility guarantees" warning for 
the entire test package: https://docs.python.org/3/library/test.html

Thanks for getting this resolved!

--

___
Python tracker 

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



[issue38364] inspect.iscoroutinefunction / isgeneratorfunction / isasyncgenfunction can't handle partialmethod objects

2019-10-05 Thread Martijn Pieters


Change by Martijn Pieters :


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

___
Python tracker 

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



[issue38380] Update SQLite to 3.30 in Windows and macOS installer builds

2019-10-05 Thread Ned Deily


Ned Deily  added the comment:

I verified it is exploitable via the sqlite3 module by adapting the test case 
from the SQLite ticket (https://www.sqlite.org/src/info/e4598ecbdd18bd82).  But 
since it requires the exploiter to be able to specify raw SQL statements, it 
doesn't sound like it needs to be treated as a Python security issue.  We 
should plan to to update to the latest SQLite but it doesn't need to be a 
release blocker.

--
components: +Build, Windows, macOS
nosy: +ned.deily, paul.moore, ronaldoussoren, steve.dower, tim.golden, zach.ware
stage:  -> needs patch
versions: +Python 2.7, 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



[issue38381] Possible wordcode optimization for STORE/LOAD pairs

2019-10-05 Thread Raymond Hettinger


New submission from Raymond Hettinger :

In the show code below, the STORE_FAST x is FOLLOWED by LOAD_FAST x.   This is 
a common word code pairing.  Perhaps a new combined opcode would help:

case TARGET(LOAD_AND_STORE_FAST): {
PyObject *value = GETLOCAL(oparg);
if (value == NULL) {
format_exc_check_arg(tstate, PyExc_UnboundLocalError,
 UNBOUNDLOCAL_ERROR_MSG,
 PyTuple_GetItem(co->co_varnames, oparg));
goto error;
}
Py_INCREF(value);
SETLOCAL(oparg, value);
FAST_DISPATCH();
}

The combined opcode saves one one trip around the eval-loop and it saves
unnecessary stack manipulations (a PUSH() immediately followed by a POP()).

The code generation would likely need to be a compiler or AST step because it 
crosses basic block boundaries.  Care would need to be taken to not adversely 
affect tracing the code in a debugger.

Note in the following code, the "x" is never used after the STORE/LOAD pair.  
In theory, the two opcodes could be dropped entirely; however, would affect a 
call to "locals()".

 Code disassembly --

>>> def f(s):
for x in g:
yield x**2


>>> dis(f)
  2   0 LOAD_GLOBAL  0 (g)
  2 GET_ITER
>>4 FOR_ITER14 (to 20)
  6 STORE_FAST   1 (x)

  3   8 LOAD_FAST1 (x)
 10 LOAD_CONST   1 (2)
 12 BINARY_POWER
 14 YIELD_VALUE
 16 POP_TOP
 18 JUMP_ABSOLUTE4
>>   20 LOAD_CONST   0 (None)
 22 RETURN_VALUE

--
components: Interpreter Core
messages: 354024
nosy: rhettinger
priority: normal
severity: normal
status: open
title: Possible wordcode optimization for STORE/LOAD pairs
type: performance
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



[issue38380] Update SQLite to 3.30 in Windows and macOS installer builds

2019-10-05 Thread Big Stone


New submission from Big Stone :

there is a security fix in sqlite-3.30

https://nvd.nist.gov/vuln/detail/CVE-2019-16168#VulnChangeHistorySection

https://www.sqlite.org/releaselog/3_30_0.html

--
messages: 354023
nosy: Big Stone
priority: normal
severity: normal
status: open
title: Update SQLite to 3.30 in Windows and macOS installer builds

___
Python tracker 

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



[issue38295] test_relative_path of test_py_compile fails on macOS 10.15 Catalina

2019-10-05 Thread Ned Deily


Ned Deily  added the comment:

Also the similar single test in 2.7.x fails on 10.15 (pre-release):

==
ERROR: test_relative_path (test.test_py_compile.PyCompileTests)
--
Traceback (most recent call last):
  File 
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/test/test_py_compile.py",
 line 45, in test_relative_path
os.path.relpath(self.pyc_path))
  File 
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/py_compile.py",
 line 123, in compile
with open(cfile, 'wb') as fc:
IOError: [Errno 2] No such file or directory: 
'../../../../../../../var/folders/n6/q3475zjd38bc3q197d77wjc8gn/T/tmpLPxkJN/_test.pyc'

--
title: macOS Catalina test failures -> test_relative_path of test_py_compile 
fails on macOS 10.15 Catalina
versions: +Python 2.7

___
Python tracker 

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



[issue36161] Use thread-safe functions instead of unsafe ones (crypt, ttyname)

2019-10-05 Thread Antonio Gutierrez


Change by Antonio Gutierrez :


--
pull_requests: +16187
pull_request: https://github.com/python/cpython/pull/16599

___
Python tracker 

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



[issue38324] [Windows] test_locale and test__locale failures on Windows

2019-10-05 Thread Eryk Sun


Eryk Sun  added the comment:

Terry, the test_winconsoleio problem is issue 38325. Test cases with surrogate 
pairs that are known to fail in recent builds of Windows 10 have to be split 
out.

For the "ps_AF" locale failure that you noted, in my case with Windows 10 
18362, I have to first modify the tests in Lib/test/test__locale.py to set 
LC_CTYPE before setting LC_NUMERIC. Otherwise the lconv result in C has the 
wrong encoding, and PyUnicode_DecodeLocale fails. 

After making this change, I can reproduce the noted failure. The "ps_AF" 
(Pashto, Afghanistan) case will have to be skipped in Windows because the 
system NLS data does not agree with the assumed Arabic decimal and thousands 
separator, U+066B and U+066C, but instead uses "," and ".". This can be 
verified directly via WINAPI GetLocaleInfoEx:

>>> n = kernel32.GetLocaleInfoEx('ps-AF', LOCALE_SSCRIPTS, buf, len(buf))
>>> buf.value
'Arab;'
>>> n = kernel32.GetLocaleInfoEx('ps-AF', LOCALE_SDECIMAL, buf, len(buf))
>>> buf.value
','
>>> n = kernel32.GetLocaleInfoEx('ps-AF', LOCALE_STHOUSAND, buf, len(buf))
>>> buf.value
'.'

In case this was a quirk in the NLS data for languages that use a Perso-Arabic 
script, such as Pashto, I also checked Saudi Arabia ("ar-SA"), which uses a 
standard Arabic script, but the result was the same.

--
nosy: +eryksun

___
Python tracker 

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



[issue36356] Failure to build with address sanitizer

2019-10-05 Thread Ben Harper


Change by Ben Harper :


--
pull_requests: +16186
pull_request: https://github.com/python/cpython/pull/16598

___
Python tracker 

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



[issue38379] finalizer resurrection in gc

2019-10-05 Thread Tim Peters


New submission from Tim Peters :

While people are thinking about gc, zleak.py shows a small bug, and a possible 
opportunity for improvement, in the way gc treats finalizers that resurrect 
objects.

The bug:  the stats keep claiming gc is collecting an enormous number of 
objects, but in fact it's not collecting any.  Objects in the unreachable set 
shouldn't add to the "collected" count unless they _are_ collected.

Output:

resurrecting
collect 202
gen 2 stats {'collections': 2, 'collected': 202, 'uncollectable': 0}
resurrecting
collect 404
gen 2 stats {'collections': 3, 'collected': 606, 'uncollectable': 0}
resurrecting
collect 606
gen 2 stats {'collections': 4, 'collected': 1212, 'uncollectable': 0}
resurrecting
collect 808
gen 2 stats {'collections': 5, 'collected': 2020, 'uncollectable': 0}
resurrecting
collect 1010
gen 2 stats {'collections': 6, 'collected': 3030, 'uncollectable': 0}
...

Memory use grows without bound, and collections take ever longer.

The opportunity:  if any finalizer resurrects anything, gc gives up.  But the 
process of computing whether anything was resurrected also determines which 
initially-trash objects are reachable from the risen dead.  Offhand I don't see 
why we couldn't proceed collecting what remains trash.  Then zleak.py would 
reclaim everything instead of nothing.

Sketch:  rather than just set a flag, check_garbage() could move now-reachable 
objects to the old generation (and, for each one moved, decrement the count of 
collected objects).  Then delete_garbage() could proceed on what remains in the 
unreachable list.

--
components: Interpreter Core
files: zleak.py
messages: 354020
nosy: nascheme, pitrou, tim.peters
priority: normal
severity: normal
stage: needs patch
status: open
title: finalizer resurrection in gc
type: behavior
versions: Python 3.9
Added file: https://bugs.python.org/file48644/zleak.py

___
Python tracker 

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



[issue38332] invalid content-transfer-encoding in encoded-word causes KeyError

2019-10-05 Thread miss-islington


Change by miss-islington :


--
pull_requests: +16185
pull_request: https://github.com/python/cpython/pull/16597

___
Python tracker 

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



[issue38332] invalid content-transfer-encoding in encoded-word causes KeyError

2019-10-05 Thread miss-islington


Change by miss-islington :


--
pull_requests: +16184
pull_request: https://github.com/python/cpython/pull/16596

___
Python tracker 

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



[issue38332] invalid content-transfer-encoding in encoded-word causes KeyError

2019-10-05 Thread Abhilash Raj


Abhilash Raj  added the comment:


New changeset 65dcc8a8dc41d3453fd6b987073a5f1b30c5c0fd by Abhilash Raj (Andrei 
Troie) in branch 'master':
bpo-38332: Catch KeyError from unknown cte in encoded-word. (GH-16503)
https://github.com/python/cpython/commit/65dcc8a8dc41d3453fd6b987073a5f1b30c5c0fd


--
nosy: +maxking

___
Python tracker 

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



[issue38349] Email example using imaginary library installation error.

2019-10-05 Thread Abhilash Raj


Abhilash Raj  added the comment:

We could move that comment to the top near the import, I am totally fine with 
that.

--

___
Python tracker 

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



[issue38349] Email example using imaginary library installation error.

2019-10-05 Thread jackotonye

jackotonye  added the comment:

I’m fine with closing the issue. 

Seems trivial now after reading the comments but noting that most developers 
take examples as running code and spend less time going over the comments and a 
dependency that had similar names makes it even harder to make the point. 

If the comment was at the usage rather than at import it would be more obvious 
that it needs to be a custom implementation.

--

___
Python tracker 

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



[issue38349] Email example using imaginary library installation error.

2019-10-05 Thread Abhilash Raj


Abhilash Raj  added the comment:

The comment should make it clear that it is an made up imaginary module. The no 
dependencies outside of standard library is not written, I guess?

--

___
Python tracker 

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



[issue38349] Email example using imaginary library installation error.

2019-10-05 Thread Abhilash Raj


Abhilash Raj  added the comment:

The function of this imaginary method is described below:

# The magic_html_parser has to rewrite the href="cid:" attributes to
# point to the filenames in partfiles.  It also has to do a safety-sanitize
# of the html.  It could be written using html.parser.

This implementation is going to be non-trivial (more than just a wrapper around 
html.parser) I think, and I would like to not make the example related to email 
even longer due to that implementation.

And I agree with Terry, the comment should make it pretty clear, there aren't 
any dependencies in the examples outside of standard library.

Any other synonym that we'd choose could end up being a package in pypi someday 
:)

--

___
Python tracker 

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



[issue38376] ./configure --with-assertions generates a broken build

2019-10-05 Thread Thomas Wouters


Thomas Wouters  added the comment:

The problem is _PyUnicode_CheckConsistency switched from being only defined 
when Py_DEBUG is set, to being defined unconditionally. That was a good change, 
but it made the API-compatibility hack of #defining _PyUnicode_CheckConsistency 
in Include/unicodeobject.h do the wrong thing. PR #16594.

--
stage: patch review -> 

___
Python tracker 

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



[issue38376] ./configure --with-assertions generates a broken build

2019-10-05 Thread Thomas Wouters


Change by Thomas Wouters :


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

___
Python tracker 

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



[issue38378] os.sendfile() has improperly named parameter

2019-10-05 Thread Zackery Spytz


Zackery Spytz  added the comment:

See also bpo-15078.

--
nosy: +ZackerySpytz

___
Python tracker 

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



[issue38378] os.sendfile() has improperly named parameter

2019-10-05 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

os.sendfile() has a keyword-or-positional parameter named "in". Since it is a 
keyword in Python, it is not possible to pass it as a keyword argument. You can 
only pass it as a positional argument or using a var-keyword argument (unlikely 
anybody uses the latter). The preceding parameter, "out", also can not be 
passed by keyword because of this.

It is weird, but usually does not cause a problem. You cannot use a keyword 
argument, period. But it prevents os.sendfile() from converting to Argument 
Clinic, because Argument Clinic does not allow using Python keywords as 
parameter names (I already created a patch for conversion, but in needs to 
solve this issue first).

There are two ways to solve this issue.

1. Rename parameter "in" (and maybe "out" for consistency). "out_fd" and 
"in_fd" look good names (they are use in Linux manpage).

2. Make "out" and "in" positional-only parameters.

--
components: Extension Modules
messages: 354012
nosy: serhiy.storchaka
priority: normal
severity: normal
status: open
title: os.sendfile() has improperly named parameter
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



[issue38376] ./configure --with-assertions generates a broken build

2019-10-05 Thread Vinay Sajip


Vinay Sajip  added the comment:

Adding Thomas and Victor based on git blame on some of the source lines 
concerned.

--
nosy: +twouters, vstinner

___
Python tracker 

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



[issue38377] test_asyncio.test_events.GetEventLoopTestsMixin.test_get_event_loop_new_process mixin breaks in the Unix environment without working /dev/shm

2019-10-05 Thread Matej Cepl


Change by Matej Cepl :


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

___
Python tracker 

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



[issue38377] test_asyncio.test_events.GetEventLoopTestsMixin.test_get_event_loop_new_process mixin breaks in the Unix environment without working /dev/shm

2019-10-05 Thread Matej Cepl

New submission from Matej Cepl :

==
ERROR: test_get_event_loop_new_process 
(test.test_asyncio.test_events.TestCGetEventLoop)
--
Traceback (most recent call last):
  File 
"/home/abuild/rpmbuild/BUILD/Python-3.8.0rc1/Lib/test/test_asyncio/test_events.py",
 line 2647, in test_get_event_loop_new_process
self.loop.run_until_complete(main()),
  File 
"/home/abuild/rpmbuild/BUILD/Python-3.8.0rc1/Lib/asyncio/base_events.py", line 
608, in run_until_complete
return future.result()
  File 
"/home/abuild/rpmbuild/BUILD/Python-3.8.0rc1/Lib/test/test_asyncio/test_events.py",
 line 2640, in main
pool = concurrent.futures.ProcessPoolExecutor()
  File 
"/home/abuild/rpmbuild/BUILD/Python-3.8.0rc1/Lib/concurrent/futures/process.py",
 line 555, in __init__
self._call_queue = _SafeQueue(
  File 
"/home/abuild/rpmbuild/BUILD/Python-3.8.0rc1/Lib/concurrent/futures/process.py",
 line 165, in __init__
super().__init__(max_size, ctx=ctx)
  File 
"/home/abuild/rpmbuild/BUILD/Python-3.8.0rc1/Lib/multiprocessing/queues.py", 
line 42, in __init__
self._rlock = ctx.Lock()
  File 
"/home/abuild/rpmbuild/BUILD/Python-3.8.0rc1/Lib/multiprocessing/context.py", 
line 68, in Lock
return Lock(ctx=self.get_context())
  File 
"/home/abuild/rpmbuild/BUILD/Python-3.8.0rc1/Lib/multiprocessing/synchronize.py",
 line 162, in __init__
SemLock.__init__(self, SEMAPHORE, 1, 1, ctx=ctx)
  File 
"/home/abuild/rpmbuild/BUILD/Python-3.8.0rc1/Lib/multiprocessing/synchronize.py",
 line 57, in __init__
sl = self._semlock = _multiprocessing.SemLock(
OSError: [Errno 38] Function not implemented

==
ERROR: test_get_event_loop_new_process 
(test.test_asyncio.test_events.TestPyGetEventLoop)
--
Traceback (most recent call last):
  File 
"/home/abuild/rpmbuild/BUILD/Python-3.8.0rc1/Lib/test/test_asyncio/test_events.py",
 line 2647, in test_get_event_loop_new_process
self.loop.run_until_complete(main()),
  File 
"/home/abuild/rpmbuild/BUILD/Python-3.8.0rc1/Lib/asyncio/base_events.py", line 
608, in run_until_complete
return future.result()
  File 
"/home/abuild/rpmbuild/BUILD/Python-3.8.0rc1/Lib/test/test_asyncio/test_events.py",
 line 2640, in main
pool = concurrent.futures.ProcessPoolExecutor()
  File 
"/home/abuild/rpmbuild/BUILD/Python-3.8.0rc1/Lib/concurrent/futures/process.py",
 line 555, in __init__
self._call_queue = _SafeQueue(
  File 
"/home/abuild/rpmbuild/BUILD/Python-3.8.0rc1/Lib/concurrent/futures/process.py",
 line 165, in __init__
super().__init__(max_size, ctx=ctx)
  File 
"/home/abuild/rpmbuild/BUILD/Python-3.8.0rc1/Lib/multiprocessing/queues.py", 
line 42, in __init__
self._rlock = ctx.Lock()
  File 
"/home/abuild/rpmbuild/BUILD/Python-3.8.0rc1/Lib/multiprocessing/context.py", 
line 68, in Lock
return Lock(ctx=self.get_context())
  File 
"/home/abuild/rpmbuild/BUILD/Python-3.8.0rc1/Lib/multiprocessing/synchronize.py",
 line 162, in __init__
SemLock.__init__(self, SEMAPHORE, 1, 1, ctx=ctx)
  File 
"/home/abuild/rpmbuild/BUILD/Python-3.8.0rc1/Lib/multiprocessing/synchronize.py",
 line 57, in __init__
sl = self._semlock = _multiprocessing.SemLock(
OSError: [Errno 38] Function not implemented

--

The problem is that in the OpenBuildService (the build system of SUSE 
distributions) /dev/shm is limited to:

abuild@milic:~/rpmbuild/BUILD/Python-3.8.0rc1> ls -ld /dev/shm
drwxr-xr-x 1 root root 0 Oct  5 13:23 /dev/shm
abuild@milic:~/rpmbuild/BUILD/Python-3.8.0rc1>

Provided PR will skip test if /dev/shm doesn’t exist or it doesn’t sufficient 
permissions.

--
components: asyncio
messages: 354010
nosy: asvetlov, mcepl, yselivanov
priority: normal
severity: normal
status: open
title: 
test_asyncio.test_events.GetEventLoopTestsMixin.test_get_event_loop_new_process 
mixin breaks in the Unix environment without working /dev/shm
versions: Python 3.8, Python 3.9

___
Python tracker 

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



[issue38375] Enum lookup fails for callable values

2019-10-05 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

Some relevant threads

* 
https://stackoverflow.com/questions/40338652/how-to-define-enum-values-that-are-functions
* https://mail.python.org/pipermail/python-ideas/2017-April/045428.html

--

___
Python tracker 

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



[issue38375] Enum lookup fails for callable values

2019-10-05 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

https://docs.python.org/3/library/enum.html#allowed-members-and-attributes-of-enumerations

> The rules for what is allowed are as follows: names that start and end with a 
> single underscore are reserved by enum and cannot be used; all other 
> attributes defined within an enumeration will become members of this 
> enumeration, with the exception of special methods (__str__(), __add__(), 
> etc.), descriptors (methods are also descriptors), and variable names listed 
> in _ignore_.

Looking at the code _member_names has the list of member names internally that 
stores the members. I guess with a callable assigned to TEST it becomes a 
method and is not added as a member as per the above doc to skip descriptor as 
method.

--
nosy: +xtreak

___
Python tracker 

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



[issue38376] ./configure --with-assertions generates a broken build

2019-10-05 Thread Vinay Sajip


Vinay Sajip  added the comment:

BTW it also seems to fail when just Py_DEBUG is specified (no 
--with-assertions).

--

___
Python tracker 

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



[issue38376] ./configure --with-assertions generates a broken build

2019-10-05 Thread Vinay Sajip

New submission from Vinay Sajip :

Following

./configure --prefix=$HOME/.local --with-assertions

and then running make leads to an error:

$ make
gcc -pthread -c -Wno-unused-result -Wsign-compare -g -fwrapv -O3 -Wall
-std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter 
-Wno-missing-field-initializers -Werror=implicit-function-declaration  
-I./Include/internal  -I. -I./Include-DPy_BUILD_CORE -o 
Objects/codeobject.o Objects/codeobject.c
gcc -pthread -c -Wno-unused-result -Wsign-compare -g -fwrapv -O3 -Wall
-std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter 
-Wno-missing-field-initializers -Werror=implicit-function-declaration  
-I./Include/internal  -I. -I./Include-DPy_BUILD_CORE -o 
Objects/complexobject.o Objects/complexobject.c
gcc -pthread -c -Wno-unused-result -Wsign-compare -g -fwrapv -O3 -Wall
-std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter 
-Wno-missing-field-initializers -Werror=implicit-function-declaration  
-I./Include/internal  -I. -I./Include-DPy_BUILD_CORE -o 
Objects/descrobject.o Objects/descrobject.c
In file included from ./Include/object.h:746:0,
 from ./Include/pytime.h:6,
 from ./Include/Python.h:85,
 from Objects/descrobject.c:3:
./Include/object.h:111:38: error: expected ‘)’ before ‘*’ token
 #define _PyObject_CAST(op) ((PyObject*)(op))
  ^
./Include/cpython/object.h:337:36: note: in definition of macro 
‘PyType_HasFeature’
 #define PyType_HasFeature(t,f)  (((t)->tp_flags & (f)) != 0)
^
./Include/unicodeobject.h:115:18: note: in expansion of macro 
‘PyType_FastSubclass’
  PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_UNICODE_SUBCLASS)
  ^
./Include/object.h:122:34: note: in expansion of macro ‘_PyObject_CAST’
 #define Py_TYPE(ob) (_PyObject_CAST(ob)->ob_type)
  ^
./Include/unicodeobject.h:115:38: note: in expansion of macro ‘Py_TYPE’
  PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_UNICODE_SUBCLASS)
  ^
./Include/unicodeobject.h:1042:56: note: in expansion of macro ‘PyUnicode_Check’
 #define _PyUnicode_CheckConsistency(op, check_content) PyUnicode_Check(op)
^
./Include/internal/pycore_object.h:14:17: note: in expansion of macro 
‘_PyUnicode_CheckConsistency’
 PyAPI_FUNC(int) _PyUnicode_CheckConsistency(PyObject *op, int check_content);
 ^
./Include/object.h:111:40: error: expected ‘)’ before ‘(’ token
 #define _PyObject_CAST(op) ((PyObject*)(op))
^
./Include/cpython/object.h:337:36: note: in definition of macro 
‘PyType_HasFeature’
 #define PyType_HasFeature(t,f)  (((t)->tp_flags & (f)) != 0)
^
./Include/unicodeobject.h:115:18: note: in expansion of macro 
‘PyType_FastSubclass’
  PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_UNICODE_SUBCLASS)
  ^
./Include/object.h:122:34: note: in expansion of macro ‘_PyObject_CAST’
 #define Py_TYPE(ob) (_PyObject_CAST(ob)->ob_type)
  ^
./Include/unicodeobject.h:115:38: note: in expansion of macro ‘Py_TYPE’
  PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_UNICODE_SUBCLASS)
  ^
./Include/unicodeobject.h:1042:56: note: in expansion of macro ‘PyUnicode_Check’
 #define _PyUnicode_CheckConsistency(op, check_content) PyUnicode_Check(op)
^
./Include/internal/pycore_object.h:14:17: note: in expansion of macro 
‘_PyUnicode_CheckConsistency’
 PyAPI_FUNC(int) _PyUnicode_CheckConsistency(PyObject *op, int check_content);
 ^
./Include/object.h:122:52: error: expected ‘)’ before ‘->’ token
 #define Py_TYPE(ob) (_PyObject_CAST(ob)->ob_type)
^
./Include/cpython/object.h:337:36: note: in definition of macro 
‘PyType_HasFeature’
 #define PyType_HasFeature(t,f)  (((t)->tp_flags & (f)) != 0)
^
./Include/unicodeobject.h:115:18: note: in expansion of macro 
‘PyType_FastSubclass’
  PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_UNICODE_SUBCLASS)
  ^
./Include/unicodeobject.h:115:38: note: in expansion of macro ‘Py_TYPE’
  PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_UNICODE_SUBCLASS)
  ^
./Include/unicodeobject.h:1042:56: note: in expansion of macro ‘PyUnicode_Check’
 #define _PyUnicode_CheckConsistency(op, check_content) PyUnicode_Check(op)
^
./Include/internal/pycore_object.h:14:17: note: in expansion of macro 
‘_PyUnicode_CheckConsistency’
 PyAPI_FUNC(int) _PyUnicode_CheckConsistency(PyObject *op, int 

[issue38335] simplify overlaps function in ipaddress.py

2019-10-05 Thread Sanjay


Sanjay  added the comment:

the version in the patch is less code a or b or c or d becomes a or d

the version in PR is using the subnet_of, supernet_of function because overlap 
means either a is subnet_of or supernet_of b. So was trying to consolidate the 
implementation of overlap from 2 to 1.

--

___
Python tracker 

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



[issue38335] simplify overlaps function in ipaddress.py

2019-10-05 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

What is the benefit of your version?

--

___
Python tracker 

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



[issue38375] Enum lookup fails for callable values

2019-10-05 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +ethan.furman

___
Python tracker 

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



[issue38375] Enum lookup fails for callable values

2019-10-05 Thread Massimo


New submission from Massimo :

```
from enum import Enum

class T(Enum):
  TEST = 1

print(T["TEST"])

class S(Enum):
  TEST = lambda a: a

print(S["TEST"])
```
fails with `KeyError: 'TEST'` on the last line.

--
components: Interpreter Core
messages: 354003
nosy: typish
priority: normal
severity: normal
status: open
title: Enum lookup fails for callable values
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



[issue38346] Wrong behavior when using `assert_called_with` with mutable object

2019-10-05 Thread Mario Corchero


Mario Corchero  added the comment:

Thanks! We can look at adding a copying mock if we see people needing it, but 
yeah, adding copy by default would be quite complex if we don't want to break 
existing users.

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



[issue14364] Argparse incorrectly handles '--' as argument to option

2019-10-05 Thread hai shi


hai shi  added the comment:

Hi, Jonas. Thanks for your report.
Let us wait core team's discuss;)

--

___
Python tracker 

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



[issue38266] Revert bpo-37878: Make PyThreadState_DeleteCurrent() Internal

2019-10-05 Thread STINNER Victor


STINNER Victor  added the comment:

> This is great -- thank you for handling this so quickly.

Thanks for testing the master branch and reporting regressions quickly as well 
;-)

--

___
Python tracker 

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



[issue38308] Add optional weighting to statistics.harmonic_mean()

2019-10-05 Thread Dong-hee Na


Dong-hee Na  added the comment:

Oh.. Thank you for letting me know

--

___
Python tracker 

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



[issue33714] module can set an exception in tp_clear

2019-10-05 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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

___
Python tracker 

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



[issue38349] Email example using imaginary library installation error.

2019-10-05 Thread SilentGhost


SilentGhost  added the comment:

One fairly naive solution would be to define a magic_html_parser directly in 
the example and move explanatory comment there. In order not to break the code 
it could return an empty string.

--

___
Python tracker 

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



[issue38349] Email example using imaginary library installation error.

2019-10-05 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

The rest of the overly long title was "The install shows that it only supports 
python 2.x but is listed under python 3.6+ docs."

The lines in question are from the 2nd to last example.

  # An imaginary module that would make this work and be safe.
  from imaginary import magic_html_parser

The comment plus the names 'imaginary' and 'magic_html_parser' should make it 
pretty clear that 'imaginary' is meant to be an imaginary, hypothetical module 
with an imaginary, hypothetical method, not an actual module named 'imaginary' 
with an actual 'magic_html_parser' method.

jackotonye, do you have a concrete suggestion?  I am tempted to close this, but 
will wait for suggestion and let the email people see this.

Also, when responding by email, please remove the quoted previous post and it 
is redundant on the web page.

--
nosy: +barry, maxking, r.david.murray, terry.reedy
title: Email example using imaginary library installation error. The install 
shows that it only supports python 2.x but is listed under python 3.6+ docs. -> 
Email example using imaginary library installation error.
versions:  -Python 3.6

___
Python tracker 

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



[issue38345] Add end lines to pyclbr objects

2019-10-05 Thread Terry J. Reedy


New submission from Terry J. Reedy :

I am closing this for now because there is no information upon which to 
proceed, and because you closed your PR (without explanation).  The nested 
dicts returned by pyclbr already constitute a tree of nesting relationships 
between the functions and classes defined in a module.  IDLE, for instance, 
uses this for its module browser.  (The obsolete name 'pyclbr' comes from when 
it only returned, I believe, a dict of top-level classes.)

--
nosy: +terry.reedy
resolution:  -> postponed
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



[issue38331] Exec not recognizing global variables inside function

2019-10-05 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

Ronald is correct, and for the reason given.  Python functions are lexically 
scoped, not dynamically scoped, and you are expecting the latter.  The exec 
global and local namespaces are used to resolve identifier in the code you 
pass.  Your first example passes 'func' and that is resolved to the 
*pre-compiled* function object which uses is lexicographical globals.  It does 
not contain the func-local 'var'.  You second example contains a def statement 
to be compiled in the exec namespaces.  Please post to python-list if you want 
further discussion.

--
nosy: +terry.reedy
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



[issue38324] [Windows] test_locale and test__locale failures on Windows

2019-10-05 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

I started a report on failures on my machine a few days ago, but never finished 
editing.  I am pasting in what I wrote so far. The same 4 tests fail today with 
a rebuild 12 hours ago.
---

I ran the test suite on my 64-bit Win10 machine with fresh debug 32 builds in 
freshly updated repository.
3.9 - tests failed for _locale, locale, and winconsoleio and import
3.8 - tests failed for _locale, locale, and winconsoleio
3.7 - tests failed for _locale, locale, and winconsoleio

=
f:\dev\3x>python -m test -j0 -ugui
Running Debug|Win32 interpreter...
== CPython 3.9.0a0 (heads/master:c5a7e0ce19, Sep 28 2019, 13:58:57) [MSC v.1900 
32 bit (Intel)]
== Windows-10-10.0.18362-SP0 little-endian
== cwd: F:\dev\3x\build\test_python_12736
== CPU count: 12
== encodings: locale=cp1252, FS=utf-8
Run tests in parallel using 14 child processes

Failure 1.
test test__locale failed -- Traceback (most recent call last):
  File "F:\dev\3x\lib\test\test__locale.py", line 133, in 
test_lc_numeric_localeconv
if self.numeric_tester('localeconv', formatting[lc], lc, loc):
  File "F:\dev\3x\lib\test\test__locale.py", line 97, in numeric_tester
self.assertEqual(calc_value, known_value,
AssertionError: ',' != '\u066b'
- ,
+ \u066b
 : , != \u066b (localeconv for decimal_point; set to ps_AF, using ps_AF)
___

Failure 2:
test_importlib failed -- running: test_concurrent_futures (1 min 6 sec)
Failed to import test module: test.test_importlib.import_.test_fromlist
Traceback (most recent call last):
  File "F:\dev\3x\lib\unittest\loader.py", line 436, in _find_test_path
module = self._get_module_from_name(name)
  File "F:\dev\3x\lib\unittest\loader.py", line 377, in _get_module_from_name
__import__(name)
ValueError: source code string cannot contain null bytes

test test_importlib crashed -- Traceback (most recent call last):
  File "F:\dev\3x\lib\test\libregrtest\runtest.py", line 270, in _runtest_inner
refleak = _runtest_inner2(ns, test_name)
  File "F:\dev\3x\lib\test\libregrtest\runtest.py", line 234, in _runtest_inner2
test_runner()
  File "F:\dev\3x\lib\test\libregrtest\runtest.py", line 208, in _test_module
raise Exception("errors while loading tests")
Exception: errors while loading tests
_

Failure 3.
test test_locale failed -- Traceback (most recent call last):
  File "F:\dev\3x\lib\test\test_locale.py", line 567, in 
test_getsetlocale_issue1813
locale.setlocale(locale.LC_CTYPE, loc)
  File "F:\dev\3x\lib\locale.py", line 608, in setlocale
return _setlocale(category, locale)
locale.Error: unsupported locale setting
_

Failure 4. test_winconsoleio

ERROR: test_input (test.test_winconsoleio.WindowsConsoleIOTests)
--
Traceback (most recent call last):
  File "F:\dev\3x\lib\test\test_winconsoleio.py", line 148, in test_input
self.assertStdinRoundTrip('\U0010\U0010\U0010fffd')
  File "F:\dev\3x\lib\test\test_winconsoleio.py", line 135, in 
assertStdinRoundTrip
actual = input()
OSError: [WinError 87] The parameter is incorrect

==
ERROR: test_partial_reads (test.test_winconsoleio.WindowsConsoleIOTests)
--
Traceback (most recent call last):
  File "F:\dev\3x\lib\test\test_winconsoleio.py", line 161, in 
test_partial_reads
b = stdin.read(read_count)
OSError: [WinError 87] The parameter is incorrect

==
ERROR: test_partial_surrogate_reads 
(test.test_winconsoleio.WindowsConsoleIOTests)
--
Traceback (most recent call last):
  File "F:\dev\3x\lib\test\test_winconsoleio.py", line 178, in 
test_partial_surrogate_reads
b = stdin.read(read_count)
OSError: [WinError 87] The parameter is incorrect
__

5. Non-failure tracebacks displayed passing test_concurrent_futures

Cancelling an overlapped future failed
future: <_OverlappedFuture pending overlapped= 
cb=[BaseProactorEventLoop._loop_self_reading()]>
Traceback (most recent call last):
  File "F:\dev\3x\lib\asyncio\windows_events.py", line 66, in _cancel_overlapped
self._ov.cancel()
OSError: [WinError 6] The handle is invalid
Cancelling an overlapped future failed
future: <_OverlappedFuture pending overlapped= 
cb=[BaseProactorEventLoop._loop_self_reading()]>
Traceback (most recent