[issue38389] Bug on sorted with count key

2019-10-06 Thread Benjamin Peterson


Benjamin Peterson  added the comment:

5 and 12 both appear twice in the list, so as far as the key function is 
concerned, they're equal.

--
nosy: +benjamin.peterson
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



[issue38389] Bug on sorted with count key

2019-10-06 Thread Tamirys Pino


New submission from Tamirys Pino :

>>> data=[2, 3, 2, 4, 5, 12, 2, 3, 3, 3, 12, 5]
>>> data
[2, 3, 2, 4, 5, 12, 2, 3, 3, 3, 12, 5]
>>> sorted(data)
[2, 2, 2, 3, 3, 3, 3, 4, 5, 5, 12, 12]
>>> sorted(data, key=data.count)
[4, 5, 12, 12, 5, 2, 2, 2, 3, 3, 3, 3]

[4, 5, 12, 12, 5, 2, 2, 2, 3, 3, 3, 3] should be [4, 5, 5, 12, 12, 2, 2, 2, 3, 
3, 3, 3]

--
messages: 354063
nosy: Tamirys Pino
priority: normal
severity: normal
status: open
title: Bug on sorted with count key
type: behavior
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



[issue26510] [argparse] Add required argument to add_subparsers

2019-10-06 Thread miss-islington


miss-islington  added the comment:


New changeset f19b4d7474973236e63d3d8260bfb8072acfff9d by Miss Islington (bot) 
in branch '3.8':
bpo-26510: Add versionchanged for required arg of add_subparsers (GH-16588)
https://github.com/python/cpython/commit/f19b4d7474973236e63d3d8260bfb8072acfff9d


--

___
Python tracker 

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



[issue26510] [argparse] Add required argument to add_subparsers

2019-10-06 Thread miss-islington


miss-islington  added the comment:


New changeset 50b8d579421e621130806e62d6108f5f83d4be7f by Miss Islington (bot) 
in branch '3.7':
bpo-26510: Add versionchanged for required arg of add_subparsers (GH-16588)
https://github.com/python/cpython/commit/50b8d579421e621130806e62d6108f5f83d4be7f


--

___
Python tracker 

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



[issue26510] [argparse] Add required argument to add_subparsers

2019-10-06 Thread miss-islington


Change by miss-islington :


--
pull_requests: +16197
pull_request: https://github.com/python/cpython/pull/16609

___
Python tracker 

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



[issue26510] [argparse] Add required argument to add_subparsers

2019-10-06 Thread miss-islington


Change by miss-islington :


--
pull_requests: +16196
pull_request: https://github.com/python/cpython/pull/16608

___
Python tracker 

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



[issue26510] [argparse] Add required argument to add_subparsers

2019-10-06 Thread miss-islington


miss-islington  added the comment:


New changeset 9e71917e0290972f65711f75510078f799cf0b59 by Miss Islington (bot) 
(Adam J. Stewart) in branch 'master':
 bpo-26510: Add versionchanged for required arg of add_subparsers (GH-16588)
https://github.com/python/cpython/commit/9e71917e0290972f65711f75510078f799cf0b59


--
nosy: +miss-islington

___
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-06 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

Thanks Warren, the resistance example is excellent, would you like to write up 
a PR to add it to the docs?

In the original design, I prohibited negative numbers because that seems to be 
what everyone says you should do, but as far as I can tell it is mathematically 
well defined so long as the sum of positive values doesn't equal the sum of 
negative values. And in that case, we could return a NAN.

I don't know that there's any physical meaning to the harmonic mean of negative 
values (circuits with negative resistances?), but I'm almost tempted to make 
this "consenting adults" and remove the restriction altogether. That would 
simplify the implementation and remove any arguments about early-out on zero.

I acknowledge Warren's point about permutations of data, but that applies to 
anything with an early-out. I don't think that's quite persuasive enough to 
justify losing the early exit on zero.

Warren, if you feel really strongly about this, feel free to try to change my 
mind. But for now, I think that documenting that zero triggers an early-out is 
the right solution.

By the way, I've just noticed that harmonic_mean([INF, INF]) raises. Should it 
return INF instead?

--

___
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-06 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

> I don't have a problem with the current behavior (early out on zero,
> even if later arguments are senseless).  So:
>
> > * Just document that there is an early-out for zero.

That make the most sense to me as well (even though the OP thinks otherwise).

--

___
Python tracker 

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



[issue38386] ModuleNotFoundError: No module named '_ctypes'

2019-10-06 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

I agree with Ned closing this issue, but just glancing at the logs, it looks to 
me like buildozer has shadowed your Python's ctypes with a broken ctypes in 
/home/yzw/Desktop/Test/.buildozer/android/platform/build/build/other_builds/hostpython3/desktop/hostpython3/Lib

If that's the case, this is definitely not a Python bug and should be reported 
to buildozer.

But one thing you should check first:

run ``which python3`` and make sure that the Python you are running (which has 
ctypes installed) is the same as the /usr/bin/python3 that buildozer is running.

Or run ``/usr/bin/python3 -c "import ctypes"`` and see what happens.

--
nosy: +steven.daprano

___
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-06 Thread Tim Peters


Tim Peters  added the comment:

I don't have a problem with the current behavior (early out on zero, even if 
later arguments are senseless).  So:

> * Just document that there is an early-out for zero.

--

___
Python tracker 

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



[issue38386] ModuleNotFoundError: No module named '_ctypes'

2019-10-06 Thread Ned Deily


Ned Deily  added the comment:

Sorry, you appear to be using a third-party packaging system that provides 
Python for Android platforms.  It's not something we provide or support.  You 
should ask your question of that project (python-for-android perhaps?) or on a 
forum like StackOverflow.  Good luck!

--
nosy: +ned.deily
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



[issue38388] Pickle protocol v 5 needs to be documented

2019-10-06 Thread Dima Tisnek

New submission from Dima Tisnek :

Python 3.8 brings new pickle protocol, version 5.
It's not documented.

```
(venv) … ~/m/proj> python
Python 3.7.4 (v3.7.4:e09359112e, Jul  8 2019, 14:54:52)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pickle
>>> pickle.HIGHEST_PROTOCOL
4
>>> ^D
(venv) … ~/m/proj> python3.8
Python 3.8.0rc1 (v3.8.0rc1:34214de6ab, Oct  1 2019, 12:56:49)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pickle
>>> pickle.HIGHEST_PROTOCOL
5
>>> ^D
```

Yet there's no mention of "protocol version 5" at:

https://github.com/python/cpython/blob/master/Doc/library/pickle.rst
https://docs.python.org/3.9/library/pickle.html#data-stream-format
https://docs.python.org/3.8/library/pickle.html#data-stream-format

--
assignee: docs@python
components: Documentation
messages: 354054
nosy: Dima.Tisnek, docs@python
priority: normal
severity: normal
status: open
title: Pickle protocol v 5 needs to be documented
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



[issue38387] Document PyDoc_STRVAR

2019-10-06 Thread Brad Solomon


New submission from Brad Solomon :

The C-API reference would benefit from a short mention of PyDoc_STRVAR usage, 
since it is used so frequently within Modules/.

--
assignee: docs@python
components: Documentation
messages: 354053
nosy: bsolomon1124, docs@python
priority: normal
pull_requests: 16195
severity: normal
status: open
title: Document PyDoc_STRVAR
type: enhancement

___
Python tracker 

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



[issue38386] ModuleNotFoundError: No module named '_ctypes'

2019-10-06 Thread yangzongwu


New submission from yangzongwu :

I have try the following, but it is no useful
sudo apt install libffi-dev
 
but when i import _ctypes under python,it is OK
yzw@yzw-virtual-machine:~/Desktop/Test$ python3
Python 3.6.8 (default, Aug 20 2019, 17:12:48) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import _ctypes
>>>


logs:
yzw@yzw-virtual-machine:~/Desktop/Test$ buildozer android clean

# Ensure build layout
No buildozer.spec found in the current directory. Abandon.
yzw@yzw-virtual-machine:~/Desktop/Test$ 
yzw@yzw-virtual-machine:~/Desktop/Test$ buildozer android clean
# Ensure build layout
No buildozer.spec found in the current directory. Abandon.
yzw@yzw-virtual-machine:~/Desktop/Test$ buildozer init
File buildozer.spec created, ready to customize!
yzw@yzw-virtual-machine:~/Desktop/Test$ buildozer -v android debug
# Check configuration tokens
# Ensure build layout
# Create directory /home/yzw/Desktop/Test/bin
# Check configuration tokens
# Preparing build
# Check requirements for android
# Run 'dpkg --version'
# Cwd None
Debian 'dpkg' package management program version 1.19.0.5 (amd64).
This is free software; see the GNU General Public License version 2 or
later for copying conditions. There is NO warranty.
# Search for Git (git)
#  -> found at /usr/bin/git
# Search for Cython (cython)
#  -> found at /home/yzw/.local/bin/cython
# Search for Java compiler (javac)
#  -> found at /usr/lib/jvm/java-8-openjdk-amd64/bin/javac
# Search for Java keytool (keytool)
#  -> found at /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/keytool
# Install platform
# Run '/usr/bin/python3 -m pip install -q --user \'appdirs\' 
\'colorama>=0.3.3\' \'jinja2\' \'six\' \'enum34; python_version<"3.4"\' 
\'sh>=1.10; sys_platform!="nt"\' \'pep517\' \'pytoml\' \'virtualenv\''
# Cwd None
# Apache ANT found at /home/yzw/.buildozer/android/platform/apache-ant-1.9.4
# Android SDK found at /home/yzw/.buildozer/android/platform/android-sdk
# Android NDK found at /home/yzw/.buildozer/android/platform/android-ndk-r17c
# Check application requirements
# Check garden requirements
# Compile platform
# Run '/usr/bin/python3 -m pythonforandroid.toolchain create --dist_name=myapp 
--bootstrap=sdl2 --requirements=python3,kivy --arch armeabi-v7a --copy-libs 
--color=always 
--storage-dir="/home/yzw/Desktop/Test/.buildozer/android/platform/build" 
--ndk-api=21'
# Cwd /home/yzw/Desktop/Test/.buildozer/android/platform/python-for-android
[INFO]:Will compile for the following archs: armeabi-v7a
[INFO]:Found Android API target in $ANDROIDAPI: 27
[INFO]:Available Android APIs are (27)
[INFO]:Requested API target 27 is available, continuing.
[INFO]:Found NDK dir in $ANDROIDNDK: 
/home/yzw/.buildozer/android/platform/android-ndk-r17c
[INFO]:Found NDK version 17c
[INFO]:Getting NDK API version (i.e. minimum supported API) from user 
argument
[INFO]:Found virtualenv at /home/yzw/.local/bin/virtualenv
[INFO]:ccache is missing, the build will not be optimized in the future.
[INFO]:Found the following toolchain versions: ['4.9']
[INFO]:Picking the latest gcc toolchain, here 4.9
[INFO]:No existing dists meet the given requirements!
[INFO]:No dist exists that meets your requirements, so one will be built.
[INFO]:Found a single valid recipe set: ['hostpython3', 'libffi', 
'openssl', 'sdl2_image', 'sdl2_mixer', 'sdl2_ttf', 'sqlite3', 'python3', 
'sdl2', 'setuptools', 'six', 'pyjnius', 'android', 'kivy']
[INFO]:The selected bootstrap is sdl2
[INFO]:# Creating dist with sdl2 bootstrap
[INFO]:Dist will have name myapp and requirements (python3, kivy)
[INFO]:Dist contains the following requirements as recipes: ['hostpython3', 
'libffi', 'openssl', 'sdl2_image', 'sdl2_mixer', 'sdl2_ttf', 'sqlite3', 
'python3', 'sdl2', 'setuptools', 'six', 'pyjnius', 'android', 'kivy']
[INFO]:Dist will also contain modules () installed from pip
[INFO]:-> directory context 
/home/yzw/Desktop/Test/.buildozer/android/platform/build/build/bootstrap_builds/sdl2-python3
[INFO]:<- directory context 
/home/yzw/Desktop/Test/.buildozer/android/platform/python-for-android
[INFO]:Recipe build order is ['hostpython3', 'libffi', 'openssl', 
'sdl2_image', 'sdl2_mixer', 'sdl2_ttf', 'sqlite3', 'python3', 'sdl2', 
'setuptools', 'six', 'pyjnius', 'android', 'kivy']
[INFO]:# Downloading recipes 
[INFO]:Downloading hostpython3
[INFO]:-> running mkdir -p /home/yzw/Desktop/Te...(and 57 more)
[INFO]:-> directory context 
/home/yzw/Desktop/Test/.buildozer/android/platform/build/packages/hostpython3
[INFO]:-> running basename https://www.python.or...(and 35 more)
[INFO]:hostpython3 download already cached, skipping  
[INFO]:<- directory context 
/home/yzw/Desktop/Test/.buildozer/android/platform/python-for-android
[INFO]:Downloading libffi
[INFO]:-> running mkdir -p /home/yzw/Desktop/Te...(and 52 more)
[INFO]:-> directory 

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

2019-10-06 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

The resistor example is persuasive :-)

--

___
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-06 Thread Warren Weckesser


Warren Weckesser  added the comment:

I find it hard to accept the first option.  It seems to let a detail of the 
current implementation take precedence over API design.  I don't see why we 
would want an API in which harmonic_mean([1, 0, -1]) returns 0 but 
harmonic_mean([-1, 0, 1]) raises an error.  The harmonic mean should be 
invariant to permutations of the input (well, at least to within normal 
floating point precision when the input is floating point).  I wouldn't expect 
such a radical change in behavior based on how I ordered my input to 
harmonic_mean.

The second option appears to be the API that was intended when the function was 
implemented.  Returning 0 when one or more inputs are 0 (and the rest are 
positive numbers) is justified by taking a limit.  Just like we *define* the 
sinc function (https://en.wikipedia.org/wiki/Sinc_function) to be 1 at x=0 and 
sin(x)/x when x != 0 (because the limit as x approaches 0 of sin(x)/x is 1), we 
can define the value of the harmonic mean with zeros in the input as the 
limiting value as one (or more) positive values goes to 0.  That limit is 0.  
(Also note that, in the case where just one input is 0, the expression for the 
harmonic mean can be manipulated into a form that gives 0 without requiring a 
limit. E.g. for three values, 1/(1/x0 + 1/x1 + 1/x2) = x0*x1*x2/(x1*x2 + x0*x2 
+ x0*x1).  If just one of those values is 0, the denominator is nonzero, so the 
result is simply 0.)

There is a nice analogy from electrical circuit theory.  Given, say, three 
resistances R1, R2 and R3 wired in parallel, the total resistance R is

   R = 1/(1/R1 + 1/R2 + 1/R3) = harmonic_mean([R1, R2, R3])/3

(https://en.wikipedia.org/wiki/Series_and_parallel_circuits#Resistance_units_2).
 Intuitively, we know that if any of those resistances is 0 (i.e. there is a 
short circuit), the total resistance is also 0.

The resistance analogy also gives the correct interpretation for the case where 
the input includes both 0 and +inf.  An infinite resistance is an open circuit 
(i.e. no connection), so putting that in parallel with a short circuit still 
results in a total resistance of 0.

The third option, in which any zero in the input is treated as an error, is a 
change in behavior. Given the justification for returning 0, and given that 
currently a call such as harmonic_mean([1, 0, 2]) *does* return 0, making that 
an error seems like an undesirable change.

--

___
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-06 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Paul and David, is the current PR complete in your opinion?  Are there known 
cases where the PR would break existing, working code?

Also there needs to be doc entry that is clear on both new and old strategy for 
distinguishing options from arguments when a dash or dashdash is present.  The 
PR's Misc/NEWS entry, "Fix behavior of argparse when '--' as argument to 
option", is insufficient.

--
assignee:  -> rhettinger
versions: +Python 3.8, Python 3.9 -Python 3.6

___
Python tracker 

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



[issue35005] argparse should accept json and yaml argument types

2019-10-06 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

I am going to decline this feature request on the principle of keeping our 
modules loosely coupled and orthogonal to one another.  

As paul.j3 pointed out, the "type" option seems to work best with simple 
conversions like "int".  As pointed-out by another respondent, FileType hasn't 
aged well and it may have been a mistake to include it all.  Likewise other 
converters like DateTime have been previously discussed and rejected.

There is a gray area between where argument parsing stops and application logic 
begins.   Since this is a standard library module, we should draw the line at 
simple converters/validators like "int", leaving anything more complex for 
downstream logic.  That will afford users greater flexibility and control than 
supported by the add_argument() API which intentionally only handles common 
cases.

[Braden Groom]
> I agree with Paul. This is probably simple enough for applications
> to implement. It also doesn't make sense to add either of these
> if the precedent was set by rejecting DateTime previously.

I concur as well.

[Mauricio Villegas]
> FYI there is a new python package that extends argparse 
> with the enhancements proposed here and more.

Thank you for the link. It will likely prove to be a valuable resource for 
people finding this issue in the future.  The referenced project shows the 
value of external projects being able to go in directions that are well beyond 
the scope of our standard library module: "Not exclusively intended for parsing 
command line arguments. The main focus is parsing yaml or jsonnet configuration 
files and not necessarily from a command line tool."

--
assignee: bob.ippolito -> rhettinger
resolution:  -> rejected
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



[issue38210] Intersection of dict view with iterator returns empty set

2019-10-06 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

It was added. Do you mean any special?

--

___
Python tracker 

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



[issue21360] mailbox.Maildir should ignore files named with a leading dot

2019-10-06 Thread Abhilash Raj


Abhilash Raj  added the comment:

David: How do you propose we move forward on this? 

Should we provide a switch to keep the original behaviour (which is off by 
default) so if there is someone depending on this bug, they could still 
continue to do it with relatively small change?

It is a change of behaviour, so probably isn't going to be back ported if it 
gets merged in 3.9 window.

--
nosy: +maxking

___
Python tracker 

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



[issue38210] Intersection of dict view with iterator returns empty set

2019-10-06 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Please add a test for this regression.

--

___
Python tracker 

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



[issue38385] statistics: incorrect documentation

2019-10-06 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

This is a reasonable suggestion (all iterators are iterable, but not all 
iterables are iterators).  I'll work on it shortly (in conjunction with some 
other minor doc fixups).

--
assignee: docs@python -> rhettinger
nosy: +rhettinger, steven.daprano

___
Python tracker 

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



[issue38385] statistics: incorrect documentation

2019-10-06 Thread Eric O. LEBIGOT


New submission from Eric O. LEBIGOT :

The documentation for the statistics package indicates that many of its 
functions (like median()) accept iterators. They seem to actually accept 
something more convenient, namely iterables.

Thus, iterator could probably be  usefully replaced by iterable on many of the 
functions (when applicable, which I would expect is everywhere).

--
assignee: docs@python
components: Documentation
messages: 354043
nosy: docs@python, lebigot
priority: normal
severity: normal
status: open
title: statistics: incorrect documentation
versions: Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 3.9

___
Python tracker 

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



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

2019-10-06 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Normally early-out behaviors are allowed to skip any checks for subsequent 
inputs (for example, the any() and all() builtins stop consuming inputs one a 
final value is found).

However, that reasoning might not apply to a zero input for harmonic_mean().  
Technically, the definition of harmonic mean doesn't allow for a zero input 
value at all (accordingly, MS Excel gives an error for a zero input).  
Presumably, the reason that Python's harmonic_mean() returns zero is so that 
the function degrades gracefully as one of the inputs gets closer to zero.

Options at this point:

* Just document that there is an early-out for zero.

* Stick with the strategy of treating zero as if it were just a very, very 
small positive input.  The would imply that all of the inputs should be 
considered and that TypeErrors or StatisticErrors should be raised for later 
data points (though I'm unclear what this world view implies when the inputs 
have both a zero and a positive infinity).

* Treat a zero input as an error.  This matches the usual specification of 
harmonic mean being defined only for non-negative real inputs.

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

___
Python tracker 

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



[issue38379] finalizer resurrection in gc

2019-10-06 Thread Tim Peters


Tim Peters  added the comment:

Just noting that check_garbage() currently only determines which trash objects 
are now directly reachable from outside.  To be usable for the intended 
purpose, it would need to go on to compute which trash objects are reachable 
from those too.

Maybe a new function

static void
deduce_unreachable(PyGC_Head *base, PyGC_Head *unreachable)

that packaged the steps through move_unreachable().  The main function would 
use that on `young`, and check_garbage() on `unreachable` to find the _still_ 
unreachable objects.

I don't care about the expense.  Outside of zleak.py, the number of unreachable 
objects is usually small, so it's usually cheap to make another pass over just 
them.

--

___
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-06 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
assignee:  -> rhettinger
nosy: +rhettinger, steven.daprano
versions: +Python 3.7, Python 3.8

___
Python tracker 

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



[issue38384] An assertion failure in test_pickle

2019-10-06 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

I do not understand how you got an assertion failure. Did you interrupt tests 
with Ctrl-C?

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue35005] argparse should accept json and yaml argument types

2019-10-06 Thread Mauricio Villegas


Mauricio Villegas  added the comment:

FYI there is a new python package that extends argparse with the enhancements 
proposed here and more.

https://pypi.org/project/jsonargparse/

--
nosy: +mauvilsa

___
Python tracker 

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



[issue38384] An assertion failure in test_pickle

2019-10-06 Thread Zackery Spytz


Change by Zackery Spytz :


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

___
Python tracker 

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



[issue38384] An assertion failure in test_pickle

2019-10-06 Thread Zackery Spytz


New submission from Zackery Spytz :

When running test_pickle, I sometimes see an assertion failure.

./python -m test test_pickle
0:00:00 load avg: 1.04 Run tests sequentially
0:00:00 load avg: 1.04 [1/1] test_pickle
python: Objects/typeobject.c:3151: _PyType_Lookup: Assertion 
`!PyErr_Occurred()' failed.
Fatal Python error: Aborted

Current thread 0x7f8158632140 (most recent call first):
  File "/home/lubuntu2/cpython/Lib/test/pickletester.py", line 3400 in 
test_unpickling_buffering_readline
  File "/home/lubuntu2/cpython/Lib/unittest/case.py", line 617 in 
_callTestMethod
  File "/home/lubuntu2/cpython/Lib/unittest/case.py", line 663 in run
  File "/home/lubuntu2/cpython/Lib/unittest/case.py", line 725 in __call__
  File "/home/lubuntu2/cpython/Lib/unittest/suite.py", line 122 in run
  File "/home/lubuntu2/cpython/Lib/unittest/suite.py", line 84 in __call__
  File "/home/lubuntu2/cpython/Lib/unittest/suite.py", line 122 in run
  File "/home/lubuntu2/cpython/Lib/unittest/suite.py", line 84 in __call__
  File "/home/lubuntu2/cpython/Lib/test/support/testresult.py", line 162 in run
  File "/home/lubuntu2/cpython/Lib/test/support/__init__.py", line 2032 in 
_run_suite
  File "/home/lubuntu2/cpython/Lib/test/support/__init__.py", line 2128 in 
run_unittest
  File "/home/lubuntu2/cpython/Lib/test/test_pickle.py", line 525 in test_main
  File "/home/lubuntu2/cpython/Lib/test/libregrtest/runtest.py", line 234 in 
_runtest_inner2
  File "/home/lubuntu2/cpython/Lib/test/libregrtest/runtest.py", line 270 in 
_runtest_inner
  File "/home/lubuntu2/cpython/Lib/test/libregrtest/runtest.py", line 153 in 
_runtest
  File "/home/lubuntu2/cpython/Lib/test/libregrtest/runtest.py", line 193 in 
runtest
  File "/home/lubuntu2/cpython/Lib/test/libregrtest/main.py", line 417 in 
run_tests_sequential
  File "/home/lubuntu2/cpython/Lib/test/libregrtest/main.py", line 515 in 
run_tests
  File "/home/lubuntu2/cpython/Lib/test/libregrtest/main.py", line 687 in _main
  File "/home/lubuntu2/cpython/Lib/test/libregrtest/main.py", line 634 in main
  File "/home/lubuntu2/cpython/Lib/test/libregrtest/main.py", line 712 in main
  File "/home/lubuntu2/cpython/Lib/test/__main__.py", line 2 in 
  File "/home/lubuntu2/cpython/Lib/runpy.py", line 85 in _run_code
  File "/home/lubuntu2/cpython/Lib/runpy.py", line 192 in _run_module_as_main
Aborted (core dumped)


In _Unpickler_SetInputStream(), _PyObject_LookupAttrId() is called three times 
in a row without any error handling.
If an exception occurs during the first or second call, 
_PyObject_LookupAttrId() will be called with a live exception.

--
components: Extension Modules
messages: 354038
nosy: ZackerySpytz
priority: normal
severity: normal
status: open
title: An assertion failure in test_pickle
type: crash
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



[issue38383] undefined behavior in tailmatch() of bytes_methods.c

2019-10-06 Thread miss-islington


miss-islington  added the comment:


New changeset ce3c913909746aa1d782ed8bca5076a656422931 by Miss Islington (bot) 
in branch '3.8':
bpo-38383: Fix possible integer overflow in startswith() of bytes and 
bytearray. (GH-16603)
https://github.com/python/cpython/commit/ce3c913909746aa1d782ed8bca5076a656422931


--

___
Python tracker 

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



[issue38383] undefined behavior in tailmatch() of bytes_methods.c

2019-10-06 Thread miss-islington


miss-islington  added the comment:


New changeset b40442ba88fec5e64ab1802ce37df0afec59fa53 by Miss Islington (bot) 
in branch '3.7':
bpo-38383: Fix possible integer overflow in startswith() of bytes and 
bytearray. (GH-16603)
https://github.com/python/cpython/commit/b40442ba88fec5e64ab1802ce37df0afec59fa53


--
nosy: +miss-islington

___
Python tracker 

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



[issue38383] undefined behavior in tailmatch() of bytes_methods.c

2019-10-06 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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



[issue38383] undefined behavior in tailmatch() of bytes_methods.c

2019-10-06 Thread miss-islington


Change by miss-islington :


--
pull_requests: +16193
pull_request: https://github.com/python/cpython/pull/16605

___
Python tracker 

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



[issue38383] undefined behavior in tailmatch() of bytes_methods.c

2019-10-06 Thread miss-islington


Change by miss-islington :


--
pull_requests: +16192
pull_request: https://github.com/python/cpython/pull/16604

___
Python tracker 

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



[issue38383] undefined behavior in tailmatch() of bytes_methods.c

2019-10-06 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 24ddd9c2d6ab61cbce7e68d6de36d4df9bd2c3fb by Serhiy Storchaka (Hai 
Shi) in branch 'master':
bpo-38383: Fix possible integer overflow in startswith() of bytes and 
bytearray. (GH-16603)
https://github.com/python/cpython/commit/24ddd9c2d6ab61cbce7e68d6de36d4df9bd2c3fb


--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue38210] Intersection of dict view with iterator returns empty set

2019-10-06 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Thank you Dong-hee for your fix!

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



[issue38210] Intersection of dict view with iterator returns empty set

2019-10-06 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset c38e725d17537b20ff090b1b5ec7db1820ff9b63 by Serhiy Storchaka 
(Dong-hee Na) in branch 'master':
bpo-38210: Fix intersection operation with dict view and iterator. (GH-16602)
https://github.com/python/cpython/commit/c38e725d17537b20ff090b1b5ec7db1820ff9b63


--

___
Python tracker 

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



[issue38383] undefined behavior in tailmatch() of bytes_methods.c

2019-10-06 Thread hai shi


Change by hai shi :


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

___
Python tracker 

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



[issue38383] undefined behavior in tailmatch() of bytes_methods.c

2019-10-06 Thread hai shi


New submission from hai shi :

`if (start + slen > len)` would cause undefined behavior?
such as: start=PY_SSIZE_T_MAX, slen=1

REFS:
[1] https://github.com/python/cpython/blob/master/Objects/bytes_methods.c#L746

--
components: Interpreter Core
messages: 354032
nosy: shihai1991
priority: normal
severity: normal
status: open
title: undefined behavior in tailmatch() of bytes_methods.c
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



[issue38210] Intersection of dict view with iterator returns empty set

2019-10-06 Thread Dong-hee Na


Change by Dong-hee Na :


--
nosy: +corona10

___
Python tracker 

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



[issue38381] Possible wordcode optimization for STORE/LOAD pairs

2019-10-06 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

I thought about this. But STORE_FAST x is followed by LOAD_FAST x just by 
accident. If you change the expression (1+x**2 or f(x**2)) they no longer be 
neighbors. I am not sure this pattern is common enough. There are more common 
pairs.

Also, note that LOAD_FAST belong to the different line of code. It should be 
preserved for debugging purpose. Otherwise you could not set a breakpoint on 
the first line of the loop body.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue38210] Intersection of dict view with iterator returns empty set

2019-10-06 Thread Dong-hee Na


Change by Dong-hee Na :


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

___
Python tracker 

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