[issue32374] Document that m_traverse for multi-phase initialized modules can be called with m_state=NULL

2018-03-16 Thread miss-islington

Change by miss-islington :


--
pull_requests: +5890

___
Python tracker 

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



[issue32374] Document that m_traverse for multi-phase initialized modules can be called with m_state=NULL

2018-03-16 Thread miss-islington

Change by miss-islington :


--
pull_requests: +5891

___
Python tracker 

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



[issue32374] Document that m_traverse for multi-phase initialized modules can be called with m_state=NULL

2018-03-16 Thread Nick Coghlan

Nick Coghlan  added the comment:


New changeset c2b0b12d1a137ada1023ab7c10b8d9a0249d95f9 by Nick Coghlan (Marcel 
Plch) in branch 'master':
bpo-32374:  m_traverse may be called with m_state=NULL (GH-5140)
https://github.com/python/cpython/commit/c2b0b12d1a137ada1023ab7c10b8d9a0249d95f9


--

___
Python tracker 

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



[issue33047] "RuntimeError: dictionary changed size during iteration" using trace.py module

2018-03-16 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

Running on MacOs, I can't reproduce the failure.

--
nosy: +rhettinger

___
Python tracker 

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



[issue29270] super call in ctypes sub-class fails in 3.6

2018-03-16 Thread Asdger Gdsfe

Asdger Gdsfe  added the comment:

Hey 3.6 is pretty old now so can we get this patch merged I'd really like this 
code to start working again, appreciate all your hard work!

class Something(ctypes.c_ulong):
  def __repr__(self):
return super(Something, self).value

Traceback (most recent call last):
  File "", line 1, in 
TypeError: __class__ set to  defining 'Something' 
as 

--
nosy: +Asdger Gdsfe

___
Python tracker 

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



[issue33089] Add multi-dimensional Euclidean distance function to the math module

2018-03-16 Thread Steven D'Aprano

Steven D'Aprano  added the comment:

Ah wait, I appear to have misunderstood Raymond's request. Sorry Raymond!

(I've been spending too much time teaching Pythagoras' theorem and my mind was 
primed to go directly from Euclidean distance to hypotenuse.)

Not withstanding my misunderstanding, if hypot supported arbitrary number of 
arguments, then the implementation of distance could simply defer to hypot:

def distance(p, q):
# TODO error checking that p and q have the same number of items
return hypot(*(x-y for x,y in zip(p, q)))


giving results like this:

py> distance((11, 21), (14, 17))
5.0


In either case, I agree with Raymond that this would be a useful feature.

--

___
Python tracker 

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



[issue33089] Add multi-dimensional Euclidean distance function to the math module

2018-03-16 Thread Steven D'Aprano

Steven D'Aprano  added the comment:

The obvious work-around of calling hypot multiple times is not only tedious, 
but it loses precision. For example, the body diagonal through a 1x1x1 cube 
should be √3 exactly:

py> from math import hypot, sqrt
py> hypot(hypot(1, 1), 1) == sqrt(3)
False


I know of at least five languages or toolkits which support this feature, or 
something close to it: Javascript, Julia, Matlab, GNU Scientific Library, and 
C++.

Javascript and Julia support arbitrary numbers of arguments:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/hypot

https://github.com/JuliaLang/julia/pull/15649

Using Firefox's javascript console, I get the correct body diagonal for the 
cube:

>> Math.hypot(1, 1, 1) == Math.sqrt(3)
true


Matlab's hypot() function only takes two arguments, but norm(vector) returns 
the Euclidean 2-norm of the vector, i.e. equivalent to the hypot of multiple 
arguments.

https://au.mathworks.com/help/matlab/ref/norm.html

The GNU Scientific Library and C++ support a three-argument form of hypot:

http://git.savannah.gnu.org/cgit/gsl.git/commit/?id=e1711c84f7ba5c2b22d023dcb7e10810233fff27

http://en.cppreference.com/w/cpp/numeric/math/hypot
http://open-std.org/JTC1/SC22/WG21/docs/papers/2015/p0030r1.pdf


So +1 on math.hypot supporting arbitrary number of arguments.

--

___
Python tracker 

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



[issue33021] Some fstat() calls do not release the GIL, possibly hanging all threads

2018-03-16 Thread Nir Soffer

Nir Soffer  added the comment:

Attaching reproducer for os.fdopen()

--
Added file: https://bugs.python.org/file47492/fdopen_nfs_test.py

___
Python tracker 

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



[issue33021] Some fstat() calls do not release the GIL, possibly hanging all threads

2018-03-16 Thread Nir Soffer

Nir Soffer  added the comment:

Attaching reproducer for mmapobject.size()

--
Added file: https://bugs.python.org/file47491/mmap_size_nfs_test.py

___
Python tracker 

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



[issue33021] Some fstat() calls do not release the GIL, possibly hanging all threads

2018-03-16 Thread Nir Soffer

Nir Soffer  added the comment:

Antoine, thanks for fixing this on master! but I don't think this issue
can be closed yet.

First, the issue is not a performance but reliability. I probably made 
bad choice when I marked this as performance.

When you call mmap.mmap() in one thread, the entire process hangs for
an hour because the file descriptor is on a non-responsive NFS server.

With the fix, only the thread accessing the file descriptor is affected.
The rest of the system can function normally.

Second, the issue affects python 2.7, which is the production version on
many servers, and will be for many years e.g. on RHEL/CentOS 7. I think
it is important to fix this issue for these users.

Here is examples of the issue using reproducer scripts I uploaded to the
bug.

When mmap.mmap block, the entire process hangs. I unblocked the process from 
another shell by removing the iptables rule.

# python bpo-33021/mmap_nfs_test.py mnt dumbo.tlv.redhat.com
2018-03-17 01:17:57,846 - (MainThread) - Starting canary thread
2018-03-17 01:17:57,846 - (Canary) - Blocking access to storage
2018-03-17 01:17:57,857 - (Canary) - If this test is hang, please run: iptables 
-D OUTPUT -p tcp -d dumbo.tlv.redhat.com --dport 2049 -j DROP
2018-03-17 01:17:57,857 - (Canary) - check 0
2018-03-17 01:17:58,858 - (Canary) - check 1
2018-03-17 01:17:59,858 - (Canary) - check 2
2018-03-17 01:18:00,859 - (Canary) - check 3
2018-03-17 01:18:01,859 - (Canary) - check 4
2018-03-17 01:18:02,859 - (Canary) - check 5
2018-03-17 01:18:03,860 - (Canary) - check 6
2018-03-17 01:18:04,860 - (Canary) - check 7
2018-03-17 01:18:05,861 - (Canary) - check 8
2018-03-17 01:18:06,861 - (Canary) - check 9
2018-03-17 01:18:07,862 - (Canary) - check 10
2018-03-17 01:18:07,868 - (MainThread) - Calling mmap.mmap

(I remove the iptables rule here)

2018-03-17 01:18:57,683 - (MainThread) - OK
2018-03-17 01:18:57,683 - (MainThread) - Done
2018-03-17 01:18:57,683 - (Canary) - check 11

When mmapobject.size() was called, the entire process was hang. I unblocked the
process from another shell by removing the iptables rule.

# python bpo-33021/mmap_size_nfs_test.py mnt dumbo.tlv.redhat.com
2018-03-17 01:22:17,991 - (MainThread) - Starting canary thread
2018-03-17 01:22:17,992 - (Canary) - Blocking access to storage
2018-03-17 01:22:18,001 - (Canary) - If this test is hang, please run: iptables 
-D OUTPUT -p tcp -d dumbo.tlv.redhat.com --dport 2049 -j DROP
2018-03-17 01:22:18,001 - (Canary) - check 0
2018-03-17 01:22:19,002 - (Canary) - check 1
2018-03-17 01:22:20,002 - (Canary) - check 2
2018-03-17 01:22:21,002 - (Canary) - check 3
2018-03-17 01:22:22,003 - (Canary) - check 4
2018-03-17 01:22:23,003 - (Canary) - check 5
2018-03-17 01:22:24,004 - (Canary) - check 6
2018-03-17 01:22:25,004 - (Canary) - check 7
2018-03-17 01:22:26,004 - (Canary) - check 8
2018-03-17 01:22:27,005 - (Canary) - check 9
2018-03-17 01:22:28,005 - (MainThread) - Calling mmapobject.size

(I removed the ipatables rule here)

2018-03-17 01:23:38,701 - (MainThread) - OK
2018-03-17 01:23:38,701 - (MainThread) - Done
2018-03-17 01:23:38,701 - (Canary) - check 10

I found that os.fdopen issue does not affect RHEL/CentOS 7, because they
use python 2.7.5, and the issue was introduced in python 2.7.7, in:

commit 5c863bf93809cefeb4469512eadac291b7046051
Author: Benjamin Peterson 
Date:   Mon Apr 14 19:45:46 2014 -0400

when an exception is raised in fdopen, never close the fd (changing on my 
mind on #21191)

This issue affects Fedora (python 2.7.14) and probably other distros using
latest python 2.7.

Here is example run show how this affects Fedora 27:

# python fdopen_nfs_test.py mnt dumbo.tlv.redhat.com
2018-03-17 01:43:52,718 - (MainThread) - Starting canary thread
2018-03-17 01:43:52,718 - (Canary) - Blocking access to storage
2018-03-17 01:43:52,823 - (Canary) - If this test is hang, please run: iptables 
-D OUTPUT -p tcp -d dumbo.tlv.redhat.com --dport 2049 -j DROP
2018-03-17 01:43:52,824 - (Canary) - check 0
2018-03-17 01:43:53,824 - (Canary) - check 1
2018-03-17 01:43:54,824 - (Canary) - check 2
2018-03-17 01:43:55,825 - (Canary) - check 3
2018-03-17 01:43:56,825 - (Canary) - check 4
2018-03-17 01:43:57,825 - (Canary) - check 5
2018-03-17 01:43:58,826 - (Canary) - check 6
2018-03-17 01:43:59,826 - (Canary) - check 7
2018-03-17 01:44:00,826 - (Canary) - check 8
2018-03-17 01:44:01,827 - (Canary) - check 9
2018-03-17 01:44:02,827 - (Canary) - check 10
2018-03-17 01:44:02,834 - (MainThread) - Calling os.fdopen

(remove iptbales rule, and force-unmount here) 

2018-03-17 01:50:25,853 - (MainThread) - OK
2018-03-17 01:50:25,854 - (Canary) - check 11
2018-03-17 01:50:25,895 - (MainThread) - Done
Traceback (most recent call last):
  File "fdopen_nfs_test.py", line 75, in 
os.unlink(filename)
OSError: [Errno 2] No such file or directory: 'mnt/test'


So, I think we should:
- backport to 3.7, 3.6
- reconsider backport to 2.7, at least for mmap and 

[issue33089] Add multi-dimensional Euclidean distance function to the math module

2018-03-16 Thread Steven D'Aprano

Steven D'Aprano  added the comment:

This was requested once before, but rejected. I would like to see that decision 
re-considered.

https://bugs.python.org/issue1880

Some months ago, there was a very brief discussion started by Lawrence 
D’Oliveiro about this on the comp.lang.python newsgroup. Unfortunately neither 
his posts nor any replies to them seem to have been archived at the Python-List 
mailing list. His original post is on google groups:

https://groups.google.com/forum/#!topic/comp.lang.python/GmrGx9QQINQ

but I see no replies there. There is one reply on comp.lang.python, from Stefan 
Ram, but that doesn't appear on either the mailing list or Google Groups.

--

___
Python tracker 

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



[issue33047] "RuntimeError: dictionary changed size during iteration" using trace.py module

2018-03-16 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

I copied the three lines into a file, deleted '> ', added  print('done'), and 
saved.  I ran the file, on Windows 10, with installed 2.7, 3.5, 3.6, and 
repository 3.6, 3.7, and 3.8.  No failures.
  
Adrien, please retest by copying what you posted, and if you still get a 
failure, upgrade to 3.6.4 and try again.  Unless we see a failure on another 
machine, this should be closed.

--
nosy: +terry.reedy

___
Python tracker 

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



[issue33055] bytes does not implement __bytes__()

2018-03-16 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

It is against Guido's general policy to add things not needed purely for 
consistency.  Unless there is a compelling use case, I think this should be 
closed.

FHTM: I don't think Serhiy posts on SO, so you might consider adding his answer 
to yours, or make it a separate answer.

--
nosy: +terry.reedy

___
Python tracker 

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



[issue33049] itertools.count() confusingly mentions zip() and sequence numbers

2018-03-16 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

Since I don't like "sequential numbers", let's opt for the "leave it alone" 
option :-)

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



[issue33049] itertools.count() confusingly mentions zip() and sequence numbers

2018-03-16 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

I think 'sequential numbers' would be slightly better than 'sequence numbers'.  
To be, it better includes stepped and descending sequences.  (Enough better 
that I would be willing to do the PR and merge.)  Otherwise, I think leave it 
alone.

--
nosy: +terry.reedy
versions:  -Python 3.4, Python 3.5

___
Python tracker 

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



[issue33044] pdb from base class, get inside a method of derived class

2018-03-16 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

bugs.python.org is for issues about patching the Python docs or the CPython 
implementation, for future releases.  Questions about using python/cpython 
should go to Q forums, such a python-list or Stackoverflow.

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



[issue33091] ssl.SSLError: Invalid error code (_ssl.c:2217)

2018-03-16 Thread Alfred Krohmer

New submission from Alfred Krohmer :

OpenSSL version: 1.1.0.g-1
OS: Arch Linux

I'm creating an SSL socket like this:

s = socket.create_connection((self.host, 443), 60)
c = ssl.create_default_context()
c.set_alpn_protocols(['spdy/2'])
self.ss = c.wrap_socket(s, server_hostname=self.host)

I'm then reading from the socket in one thread and writing to it in another 
thread.

I'm experiencing strange behaviour.

Sometimes I randomly get the error message in the title when invoking 
self.ss.recv(). After investigating the exception, I found that exc.errno = 10, 
which, according to the OpenSSL documentation means SSL_ERROR_WANT_ASYNC_JOB. 
This constant is never used in the _ssl.c file in cpython. This seems to me 
like an OpenSSL error that needs to be handled in the Python implementation but 
is not.

Also sometimes I have random write timeouts when invoking self.ss.send() (in 
those cases it seems unlikely to me that those are caused by the server).

Also I found here:

https://github.com/python/cpython/blob/v3.6.4/Modules/_ssl.c#L2184

that Python uses SSL_get_error in an non-mutex locked section. But the OpenSSL 
documentation of SSL_get_error states the following:

In addition to ssl and ret, SSL_get_error() inspects the current thread's 
OpenSSL error queue. Thus, SSL_get_error() must be used in the same thread that 
performed the TLS/SSL I/O operation, and no other OpenSSL function calls should 
appear in between. The current thread's error queue must be empty before the 
TLS/SSL I/O operation is attempted, or SSL_get_error() will not work reliably.

According to that, shouldn't the _PySSL_UPDATE_ERRNO_IF macro be called *after* 
PySSL_END_ALLOW_THREADS?

--
assignee: christian.heimes
components: SSL
messages: 313973
nosy: christian.heimes, devkid
priority: normal
severity: normal
status: open
title: ssl.SSLError: Invalid error code (_ssl.c:2217)
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



[issue33084] Computing median, median_high an median_low in statistics library

2018-03-16 Thread Luc

Luc  added the comment:

If we are trying to fix this, the behavior should be like computing the mean or 
harmonic mean with the statistics library when there are missing values in the 
data.  At least that way, it is consistent with how the statistics library 
works when computing with NaNs in the data.  Then again, it should be mentioned 
somewhere in the docs.

import statistics as stats
import numpy as np
import pandas as pd
data = [75, 90,85, 92, 95, 80, np.nan]
stats.mean(data)
nan
stats.harmonic_mean(data)
nan
stats.stdev(data)
nan
As you can see, when there is a missing value, computing the mean, harmonic 
mean and sample standard deviation with the statistics library 
return a nan.
However, with the median, median_high and median_low, it computes those 
statistics incorrectly with the missing values present in the data.
It is better to return a nan, then let the user drop (or resolve) any missing 
values before computing.
## Another example using pandas serie
df = pd.DataFrame(data, columns=['data'])
df.head()
data
0   75.0
1   90.0
2   85.0
3   92.0
4   95.0
5   80.0
6   NaN

### Use the statistics library to compute the median of the serie
stats.median(df1['data'])
90
 
## Pandas returns the correct median by dropping the missing values
## Now use pandas to compute the median of the serie with missing value
df['data'].median()
87.5

I did not test the median_grouped in statistics library, but will let you know 
afterwards if its affected as well.

--

___
Python tracker 

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



[issue33088] Cannot pass a SyncManager proxy to a multiprocessing subprocess on Windows

2018-03-16 Thread Ned Deily

Change by Ned Deily :


--
nosy: +davin, pitrou

___
Python tracker 

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



[issue33053] Running a module with `-m` will add empty directory to sys.path

2018-03-16 Thread Ned Deily

Change by Ned Deily :


--
nosy: +ncoghlan

___
Python tracker 

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



[issue33086] pip: IndexError

2018-03-16 Thread Eric V. Smith

Change by Eric V. Smith :


--
status: open -> pending

___
Python tracker 

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



[issue33061] NoReturn missing from __all__ in typing.py

2018-03-16 Thread Roundup Robot

Change by Roundup Robot :


--
keywords: +patch
pull_requests: +5889
stage:  -> patch review

___
Python tracker 

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



[issue25410] Clean up and fix OrderedDict

2018-03-16 Thread Cheryl Sabella

Cheryl Sabella  added the comment:

Is this issue still relevant?

--
nosy: +csabella

___
Python tracker 

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



[issue33090] race condition between send and recv in _ssl with non-zero timeout

2018-03-16 Thread Robert Xiao

New submission from Robert Xiao :

Environment: Several versions of Python (see below), macOS 10.12.6

The attached script creates an SSL echo server (fairly standard), connects to 
the server, and spawns a read and write thread.

The write thread repeatedly shovels data into the connection, while the read 
thread receives data and prints a dot for each successful read.

The socket has a timeout of 10 seconds set: if the timeout is 0, the script 
blows up immediately due to blocking, and if the timeout is -1 nothing bad 
happens.

On Linux and the default Mac Python 2.6, the script prints an endless series of 
dots as expected.

On most other versions of Mac Python (2.7, 3.5, 3.6), the script dies quite 
quickly (within 1-2 seconds) with an error like this:


$ /usr/bin/python2.7 test_ssl.py 
Got connection from ('127.0.0.1', 49683)
..Exception in thread ReadThread:
Traceback (most recent call last):
  File 
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py",
 line 810, in __bootstrap_inner
self.run()
  File 
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py",
 line 763, in run
self.__target(*self.__args, **self.__kwargs)
  File "test_ssl.py", line 93, in read_thread
csocket.recv()
  File 
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py",
 line 734, in recv
return self.read(buflen)
  File 
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py",
 line 621, in read
v = self._sslobj.read(len or 1024)
error: [Errno 35] Resource temporarily unavailable


The error can be one of the following:

[Py2.7] error: [Errno 35] Resource temporarily unavailable
[Py2.7] SSLWantReadError: The operation did not complete (read) (_ssl.c:1752)
[Py3.x] BlockingIOError: [Errno 35] Resource temporarily unavailable
[Py3.x] ssl.SSLWantReadError: The operation did not complete (read) 
(_ssl.c:1974)
[Py3.6] ssl.SSLError: Invalid error code (_ssl.c:2217)

The last error occurs under much rarer circumstances, but appears to be 
associated with the same underlying bug. The "invalid error code" is 0 when 
tested with a debugger, indicating a successful completion (but somehow the 
error logic gets triggered anyway).

This was tested with the following configurations:

macOS: /usr/bin/python2.6: Python 2.6.9 from Apple [ok]
macOS: /usr/bin/python2.7: Python 2.7.10 from Apple [crashes]
macOS: /usr/local/bin/python2.7: Python 2.7.13 from Python.org [crashes]
macOS: /usr/local/bin/python3.5: Python 3.5.1 from Python.org [crashes]
macOS: /usr/local/bin/python3.6: Python 3.6.4 from Python.org [crashes]
macOS: /opt/local/bin/python2.7: Python 2.7.14 from MacPorts [crashes]

A number of these were tested on a second machine (to rule out any strange 
environment issues), and the same results were obtained.

--
assignee: christian.heimes
components: SSL, macOS
files: test_ssl.py
messages: 313970
nosy: christian.heimes, ned.deily, nneonneo, ronaldoussoren
priority: normal
severity: normal
status: open
title: race condition between send and recv in _ssl with non-zero timeout
type: crash
versions: Python 2.7, Python 3.5, Python 3.6
Added file: https://bugs.python.org/file47489/test_ssl.py

___
Python tracker 

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



[issue33087] No reliable clean shutdown method

2018-03-16 Thread Josh Rosenberg

Josh Rosenberg  added the comment:

To my knowledge, there is no safe way to do this for other threads for a reason.

If you make all your worker threads daemons, then they will terminate with the 
main thread, but they won't perform cleanup actions.

If you don't make them daemons, any "clean exit" procedure risks the threads 
choosing not to exit (even if you inject a SystemExit into every other thread, 
they might be in a try/except: or try/finally that suppresses it, or blocks 
waiting for something from another thread that has already exited, etc.). 
Exiting the thread that calls sys.exit() this way is considered okay, since you 
control when it is called, and it's up to you to do it at a safe place, but 
doing so asynchronously in other threads introduces all sorts of problems.

Basically, you want a reliable "shut down the process" and a reliable "clean up 
every thread", but anything that allows clean up in arbitrary threads also 
allows them to block your desired "shut down the process". Do you have a 
proposal for handling this?

--
nosy: +josh.r

___
Python tracker 

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



[issue30940] Documentation for round() is incorrect.

2018-03-16 Thread Raymond Hettinger

Change by Raymond Hettinger :


--
assignee: docs@python -> lisroach
nosy: +lisroach

___
Python tracker 

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



[issue32822] finally block doesn't re-raise exception if return statement exists inside

2018-03-16 Thread David Rebbe

David Rebbe  added the comment:

I'll have to look into this as I have yet to commit anything but I'll put it on 
my list of things to do.

--

___
Python tracker 

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



[issue33089] Add multi-dimensional Euclidean distance function to the math module

2018-03-16 Thread Raymond Hettinger

New submission from Raymond Hettinger :

A need for a distance-between-two-points function arises frequently enough to 
warrant consideration for inclusion in the math module.   It shows-up 
throughout mathematics -- everywhere from simple homework problems for kids to 
machine learning and computer vision.

In the latter cases, the function is called frequently and would benefit from a 
fast C implementation that includes good error checking and is algorithmically 
smart about numerical issues such as overflow and loss-of-precision.

A simple implementation would be something like this:

def dist(p, q):
'Multi-dimensional Euclidean distance'
# XXX needs error checking:  len(p) == len(q)
return sqrt(sum((x0 - x1) ** 2 for x0, x1 in zip(p, q)))

The implementation could also include value added features such as hypot() 
style scaling to mitigate overflow during the squaring step:

def dist2(p, q):
# https://en.wikipedia.org/wiki/Hypot#Implementation
diffs = [x0 - x1 for x0, x1 in zip(p, q)]
scale = max(diffs, key=abs)
return abs(scale) * sqrt(fsum((d/scale) ** 2 for d in diffs))

--
components: Library (Lib)
messages: 313967
nosy: mark.dickinson, rhettinger, skrah, steven.daprano, tim.peters
priority: normal
severity: normal
status: open
title: Add multi-dimensional Euclidean distance function to the math module
type: enhancement
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



[issue33053] Running a module with `-m` will add empty directory to sys.path

2018-03-16 Thread Jakub Wilk

Jakub Wilk  added the comment:

FWIW, this behavior is documented:

https://docs.python.org/3/using/cmdline.html#cmdoption-m
"As with the -c option, the current directory will be added to the start of 
sys.path."

With the -c option, at least you could easily remove the sys.path element 
yourself:

   python -c 'import sys; sys.path.remove(""); ...'

(This works, because sys is always a builtin module, so it won't be imported 
from cwd.)

I don't see any obvious way to make "python -m foo" secure in untrusted cwd, 
though.
The best I could come up with is:

   python -c 'import sys; sys.path.remove(""); import runpy; 
runpy._run_module_as_main("foo")'

which is quite insane.

--
nosy: +jwilk

___
Python tracker 

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



[issue33084] Computing median, median_high an median_low in statistics library

2018-03-16 Thread Maheshwar Kumar

Maheshwar Kumar  added the comment:

So From the above i am to conclude that removing np.nan is the best path to be 
taken? Also the above step is to be included in median_grouped as well right?

--

___
Python tracker 

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



[issue33088] Cannot pass a SyncManager proxy to a multiprocessing subprocess on Windows

2018-03-16 Thread Jeff DuMonthier

New submission from Jeff DuMonthier :

The following simple example code creates a started SyncManager and passes it 
as an argument to a subprocess started with multiprocessing.Process().  It 
works on Linux and Mac OS but fails on Windows.

import multiprocessing as mp

def subProcFn(m1):
pass

if __name__ == "__main__":

__spec__ = None

m1 = mp.Manager()

p1 = mp.Process(target=subProcFn, args=(m1,))
p1.start()
p1.join()

This is the traceback in Spyder:

runfile('D:/ManagerBug.py', wdir='D:')
Traceback (most recent call last):

  File "", line 1, in 
runfile('D:/ManagerBug.py', wdir='D:')

  File "...\anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", 
line 705, in runfile
execfile(filename, namespace)

  File "...\anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", 
line 102, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)

  File "D:/ManagerBug.py", line 22, in 
p1.start()

  File "...\anaconda3\lib\multiprocessing\process.py", line 105, in start
self._popen = self._Popen(self)

  File "...\anaconda3\lib\multiprocessing\context.py", line 223, in _Popen
return _default_context.get_context().Process._Popen(process_obj)

  File "...\anaconda3\lib\multiprocessing\context.py", line 322, in _Popen
return Popen(process_obj)

  File "...\anaconda3\lib\multiprocessing\popen_spawn_win32.py", line 65, in 
__init__
reduction.dump(process_obj, to_child)

  File "...\anaconda3\lib\multiprocessing\reduction.py", line 60, in dump
ForkingPickler(file, protocol).dump(obj)

TypeError: can't pickle weakref objects

--
components: Windows
messages: 313964
nosy: jjdmon, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: Cannot pass a SyncManager proxy to a multiprocessing subprocess on 
Windows
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



[issue33061] NoReturn missing from __all__ in typing.py

2018-03-16 Thread Guido van Rossum

Guido van Rossum  added the comment:

Yes please! Updating __all__ is too easy to forget.

IIRC there are scripts that check for this but they are too strict.

--

___
Python tracker 

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



[issue33061] NoReturn missing from __all__ in typing.py

2018-03-16 Thread Ivan Levkivskyi

New submission from Ivan Levkivskyi :

This is clearly a bug. Would you like to make a PR?

--
nosy: +levkivskyi

___
Python tracker 

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



[issue33061] NoReturn missing from __all__ in typing.py

2018-03-16 Thread Ivan Levkivskyi

Change by Ivan Levkivskyi :


--
nosy: +gvanrossum

___
Python tracker 

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



[issue33087] No reliable clean shutdown method

2018-03-16 Thread Elliot Jenner

New submission from Elliot Jenner :

Ptyhon lacks a reliable clean shutdown method. sys.exit(), which should be this 
method, does not reliably perform this function as it merely terminates the 
thread it is called from (duplicating the functionality of thread.exit()), 
exit() and quit() are not supposed to be used except in terminal windows, raise 
SystemExit has the same issues as sys.exit() and is bad practice, and 
os._exit() immediately kills everything and does not clean up, which can cause 
issues with residuals.

This is especially important as some interpreters will break calls (including 
most worryingly try-except clauses) into threads invisibly, leading to 
whichever method is used being called in a non-main thread without anything the 
programmer can do about it even when you are not intentionally using threading.

Ideally, sys.exit() should be changed to properly close down the entire 
program, as there is no need for 2 functionally identical exit functions, but 
this may cause legacy issues. Regardless, a method that ALWAYS kill the program 
and all threads while still cleaning up, regardless of where it is called from, 
is needed.

--
components: Library (Lib)
messages: 313961
nosy: Void2258
priority: normal
severity: normal
status: open
title: No reliable clean shutdown method
type: behavior
versions: Python 2.7, Python 3.4, Python 3.5, Python 3.6, Python 3.7

___
Python tracker 

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



[issue33086] pip: IndexError

2018-03-16 Thread Eric V. Smith

Eric V. Smith  added the comment:

You did not provide enough information for us to reproduce this problem. To see 
the kind of information we need, see for example 
https://leantesting.com/write-good-bug-report/

And if you already have determined this is a problem with pip, they have their 
own issue tracker: https://github.com/pypa/pip/issues

--
nosy: +eric.smith

___
Python tracker 

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



[issue32476] Add concat functionality to ElementTree xpath find

2018-03-16 Thread Stefan Behnel

Stefan Behnel  added the comment:

I can't see why this should be restricted to attribute values and not text 
content in general. Therefore, I would suggest adding general support for 
functions, and making this only a special case. Otherwise, this would only 
solve a very niche problem, and would require pretty much a rewrite in order to 
extend it into the "obvious" direction.

--
components: +XML

___
Python tracker 

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



[issue33086] pip: IndexError

2018-03-16 Thread Gabriel Hearot

New submission from Gabriel Hearot :

Traceback (most recent call last):
  File "setup.py", line 45, in 
classifiers=[]
  File "/usr/lib/python3.6/distutils/core.py", line 148, in setup
dist.run_commands()
  File "/usr/lib/python3.6/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
  File "/usr/lib/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
  File "/usr/lib/python3.6/distutils/command/upload.py", line 63, in run
self.upload_file(command, pyversion, filename)
  File "/usr/lib/python3.6/distutils/command/upload.py", line 156, in 
upload_file
value = value[1]
IndexError: tuple index out of range

--
components: Library (Lib)
messages: 313958
nosy: hearot
priority: normal
severity: normal
status: open
title: pip: IndexError
type: behavior
versions: Python 3.4

___
Python tracker 

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



[issue33077] typing: Unexpected result with value of instance of class inherited from typing.NamedTuple

2018-03-16 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

Would it be worthwhile to show an example of a subclass that overrides or 
extends  __new__?   

Elsewhere in Python, the usual technique for changing method defaults is for a 
subclass to override or extend the method in question.  

class A:
def somemeth(self, value: bool = True):
print(value)

class B(A):
def somemeth(self, value: bool = False):
super().somemeth(value)

--
nosy: +rhettinger

___
Python tracker 

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



[issue33084] Computing median, median_high an median_low in statistics library

2018-03-16 Thread Luc

Luc  added the comment:

Just to make sure we are focused on the issue, the reported bug is with the 
statistics library (not with numpy). It happens, when there is at least one 
missing value in the data and involves the computation of the median, 
median_low and median_high using the statistics library.
The test was performed on Python 3.6.4.

When there is no missing values (NaNs) in the data, computing the median, 
median_high and median_low from the statistics library work fine.
So, yes, removing the NaNs (or imputing for them) before computing the 
median(s) resolve the issue.
Also, just like statistics.mean(data) when data has missing return a nan, the 
median, median_high and median_low should  behave the same way.

import numpy
import statistics as stats

data = [75, 90,85, 92, 95, 80, np.nan]

Median = stats.median(data) 
Median_high = stats.median_high(data)
Median_low = stats.median_low(data)
print("The incorrect Median is", Median)
The incorrect Median is, 90
print("The incorrect median high is", Median_high)
The incorrect median high is, 90
print("The incorrect median low is", Median_low)
The incorrect median low is, 90

## Mean returns nan
Mean = stats.mean(data)
prin("The mean is", Mean)
The mean is, nan

Now, when we drop the missing values, we have:
data2 = [75, 90,85, 92, 95, 80]
stats.median(data2)
87.5
stats.median_high(data2)
90
stats.median_low(data2)
85

--

___
Python tracker 

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



[issue21018] [patch] added missing documentation about escaping characters for configparser

2018-03-16 Thread Arun Persaud

Arun Persaud  added the comment:

> @Arun.Persaud, would you be interested in converting your patch to a Github 
> pull request?

sure, I'll give it a try.

Arun

--

___
Python tracker 

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



[issue29673] Some gdb macros are broken in 3.6

2018-03-16 Thread Marcel Plch

Marcel Plch  added the comment:

I have created a PR here - https://github.com/python/cpython/pull/6126

The problem was, indeed, change in the code structure. The macro checked for 
presence inside of PyEval_EvalFrame() using address of a neighbouring function.
Also, arguments to PyEval_EvalFrame() were changed, so the macro responsible 
for printing of the frame needed a little tweak.

--
nosy: +Dormouse759

___
Python tracker 

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



[issue29673] Some gdb macros are broken in 3.6

2018-03-16 Thread Marcel Plch

Change by Marcel Plch :


--
keywords: +patch
pull_requests: +5888
stage:  -> patch review

___
Python tracker 

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



[issue33084] Computing median, median_high an median_low in statistics library

2018-03-16 Thread Steven D'Aprano

Steven D'Aprano  added the comment:

On Fri, Mar 16, 2018 at 02:32:36PM +, Mark Dickinson wrote:
> For what it's worth, NumPy gives a result of NaN for the median of an array 
> that contains NaNs:

By default, R gives the median of a list containing either NaN or NA 
("not available", intended as a missing value) as NA:

> median(c(1, 2, 3, 4, NA))
[1] NA
> median(c(1, 2, 3, 4, NaN))
[1] NA

but you can ignore them too:

> median(c(1, 2, 3, 4, NA), na.rm=TRUE)
[1] 2.5
> median(c(1, 2, 3, 4, NaN), na.rm=TRUE)
[1] 2.5

--

___
Python tracker 

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



[issue33036] test_selectors.PollSelectorTestCase failing on macOS 10.13.3

2018-03-16 Thread Ned Deily

Ned Deily  added the comment:

Glad you found the problem - and that it wasn't a Python bug!

--
resolution:  -> works for me
status: open -> closed

___
Python tracker 

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



[issue33036] test_selectors.PollSelectorTestCase failing on macOS 10.13.3

2018-03-16 Thread Nathan Henrie

Nathan Henrie  added the comment:

Update -- I found the following plist at 
`/Library/LaunchDaemons/limit.maxfiles.plist`:

```xml

http://www.apple.com/DTDs/PropertyList-1.0.dtd;>

  
Label
limit.maxfiles
ProgramArguments

  launchctl
  limit
  maxfiles
  64000
  524288

RunAtLoad

ServiceIPC

  

```

I think I made this file at some point to deal with an error about insufficient 
file descriptors while playing with asyncio / sockets. After `launchctl 
unload`ing it and rebooting **the test now passes**, and I now see a *much* 
higher hard limit (similar to that posted by Ned) with the `getrlimit()` 
command, and `unlimited` as the hard limit with `launchtl limit`.

I can reproduce the failure by restoring my prior settings:

```bash
$ sudo launchctl limit maxfiles 64000 524288
$ ulimit -n 64000
$ 
$ ./python.exe -m unittest -v 
test.test_selectors.PollSelectorTestCase.test_above_fd_setsize
test_above_fd_setsize (test.test_selectors.PollSelectorTestCase) ... ERROR

==
ERROR: test_above_fd_setsize (test.test_selectors.PollSelectorTestCase)
--
Traceback (most recent call last):
  File "/Users/n8henrie/git/cpython/Lib/test/support/__init__.py", line 600, in 
wrapper
return func(*args, **kw)
  File "/Users/n8henrie/git/cpython/Lib/test/test_selectors.py", line 453, in 
test_above_fd_setsize
self.assertEqual(NUM_FDS // 2, len(s.select()))
  File "/Users/n8henrie/git/cpython/Lib/selectors.py", line 376, in select
fd_event_list = self._poll.poll(timeout)
OSError: [Errno 22] Invalid argument

--
Ran 1 test in 9.771s

FAILED (errors=1)

```

--
resolution: works for me -> 
status: closed -> open

___
Python tracker 

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



[issue33084] Computing median, median_high an median_low in statistics library

2018-03-16 Thread Mark Dickinson

Mark Dickinson  added the comment:

> then the answer being 90 is correct,right?

How do you deduce that? Why 90 rather than 85 (or 87.5, or some other value)?

For what it's worth, NumPy gives a result of NaN for the median of an array 
that contains NaNs:

>>> np.median([1.0, 2.0, 3.0, np.nan])
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/lib/function_base.py:4033:
 RuntimeWarning: Invalid value encountered in median
  r = func(a, **kwargs)
nan

--

___
Python tracker 

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



[issue33084] Computing median, median_high an median_low in statistics library

2018-03-16 Thread Maheshwar Kumar

Maheshwar Kumar  added the comment:

Well if i dont consider np.nan as missing data and consider all other values 
then the answer being 90 is correct,right?

--

___
Python tracker 

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



[issue1100942] Add datetime.time.strptime and datetime.date.strptime

2018-03-16 Thread Stéphane Wirtel

Stéphane Wirtel  added the comment:

Hello, just a small reminder for this issue and the PR ;-) when you have time

--

___
Python tracker 

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



[issue21611] int() docstring - unclear what number is

2018-03-16 Thread Cheryl Sabella

Change by Cheryl Sabella :


--
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> Documentation for int constructor mentions __int__ but not 
__trunc__

___
Python tracker 

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



[issue33034] urllib.parse.urlparse and urlsplit not raising ValueError for bad port

2018-03-16 Thread Matt Eaton

Matt Eaton  added the comment:

Jonathan, thank you very much for your thoughts I appreciate the pros and cons 
of each option.

In regards to your option C, if we provided a flag to optionally raise the 
error in urlsplit and urlparse were you thinking the default flag to be set to 
True?  

For example:

def urlparse(url, scheme='', allow_fragments=True, port_validation=True):


def urlsplit(url, scheme='', allow_fragments=True, port_validation=True):

--

___
Python tracker 

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



[issue33057] logging.Manager.logRecordFactory is never used

2018-03-16 Thread Ben Feinstein

Ben Feinstein  added the comment:

General loggers are used in the standard way (message, args, etc), but data
loggers are used for different types of data. Instead of message, they
receive the experiment results (dict/list/np.array/binary data) and their
`formatMessage()` method should be modified in order to account for the
changed data-type.

This might indeed be an XY problem on my side. However, it seems that
someone already thought about it before and started implementing this
mechanism (`Manager.setLogRecordFactory()`), but didn't finish. That's why
I suggested this modification.

On Thu, Mar 15, 2018 at 4:21 PM Vinay Sajip  wrote:

>
> Vinay Sajip  added the comment:
>
> >  I have two types of loggers, one for experiment results ("data") and
> another for general information
>
> In what way is the behaviour of the two types of logger different? I'm
> concerned that this might be an XY problem ...
>
> --
>
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

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



[issue33077] typing: Unexpected result with value of instance of class inherited from typing.NamedTuple

2018-03-16 Thread Ivan Levkivskyi

Ivan Levkivskyi  added the comment:

> Apart from the fact that it's too late, if you had to do it over again,
could it be done as a class decorator?

Yes, this could be done as a decorator which would replace the original class 
with a named tuple after inspecting `__annotations__` and `__dict__`. (But 
again, the name would be different, since `@NamedTuple` looks weird to me.)

--
assignee:  -> docs@python
components: +Documentation
nosy: +docs@python
stage:  -> needs patch

___
Python tracker 

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



[issue33034] urllib.parse.urlparse and urlsplit not raising ValueError for bad port

2018-03-16 Thread Jonathan

Jonathan  added the comment:

Interesting conversation

As I see it, there are two ways to solve this, both discussed above:
A) Python can compute and ValueError at parse-time
B) Python can ValueError at property-call time. (Current method)

But both have Advantages/Disadvantages.
A - Pros) - The function is more consistent with all the other Python builtins 
(well, the one's I've dealt with).
A - Pros) - Not carrying around a "bad" port.
A - Cons) - As Matt suggests, we could be "taking something from the user" 
because they may want the other values. (although in that case, the current 
semi-related behaviour: "Unmatched square brackets in the netloc attribute will 
raise a ValueError" is also potentially taking something from the user).

B - Pros) - User gets the other values even if they don't get the port.
B - Cons) - User needs to have more Try/Excepts in the code (whereever you may 
access the property), or to write their own wrapper function.


Given the above, of the those options I still think option (A) is better. The 
other values may have a reduced worth if the port is invalid (depending on the 
user's goal).

May I suggest a third option:
C) A flag for urlsplit/urlparse to indicate we don't want to do port 
validation, and to just return whatever it thinks is there. 
(example.com:3293849038 would return 3293849038. example.com:gibberish would 
return "gibberish" etc). 

This way the user can choose what behaviour they want with the bad port and 
test the value of the port themselves if they care (something I was going to do 
anyway before I discovered it was included in the builtin). Some of the url 
quoting functions have a similar flag ("errors") for handling bad data 
transparently or not.

--

___
Python tracker 

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



[issue32328] ttk.Treeview: _tkinter.TclError: list element in quotes followed by "; " instead of space

2018-03-16 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

> If the issue really boils down to incorrectly passing a single string when 
> there is only one item in 'values', and a single-item tuple should be used 
> instead, then shouldn't the better solution be for Python to handle this 
> automatically and re-cast the errant string into a tuple?

Tkinter is rather a thin wrapper around Tcl/Tk. I just passes values to Tcl. 
Tcl is a weak typed language. Internally it can use different types for 
performance, but semantically all are strings. "a b" is a string and a 
2-element list, and a 1-element dict at the same time. It is Tcl try to re-cast 
the errant string into a Tcl list, and fails because it has incorrect syntax. 
Python can't know your intention. It supposes that you know what you do. If 
under re-casting you meant passing a string to a tuple constructor, 
`tuple(values)`, this will be obviously wrong. If your meant parsing a string 
to a tuple at Python side -- it will file as well as parsing it at Tcl side. If 
you meant wrapping a string into a one-element tuple, `(values,)`, this can 
break working code when a user intentionally passes a space separated list of 
words:

tv.insert("", END, values=(foo, bar), tags="foo bar")

Additionally, any special cases will complicate the code of Tkinter (currently 
it is rather a thin wrapper) and complicate the mental model.

--

___
Python tracker 

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



[issue33083] math.factorial accepts non-integral Decimal instances

2018-03-16 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

I agree. And I suggest also to deprecate accepting integral float instances.

--

___
Python tracker 

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



[issue21611] int() docstring - unclear what number is

2018-03-16 Thread Dmitry Andreychuk

Dmitry Andreychuk  added the comment:

I created this issue almost 4 years ago. Looking at it now, I think that I was 
asking too much of that docstring. I believe it's current version quite 
sufficient.

I would close the issue, but I'm not sure if it's up to me to decide.

--

___
Python tracker 

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



[issue33084] Computing median, median_high an median_low in statistics library

2018-03-16 Thread Mark Dickinson

Mark Dickinson  added the comment:

> Will just removing all np.nan values do the job?

Unfortunately, I don't think it's that simple. You want consistency across the 
various library calls, so if the various `median` functions are changed to 
treat NaNs as missing data, then the other functions should be, too.

--
nosy: +mark.dickinson, steven.daprano

___
Python tracker 

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



[issue33084] Computing median, median_high an median_low in statistics library

2018-03-16 Thread Maheshwar Kumar

Maheshwar Kumar  added the comment:

Will just removing all np.nan values do the job? Btw the values will be:
median = 88.5
median_low = 85
median_high = 90
I can correct it and send a pull request.

--
nosy: +maheshwark97

___
Python tracker 

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



[issue33073] Add as_integer_ratio() to int() objects

2018-03-16 Thread Nathaniel Smith

Nathaniel Smith  added the comment:

Sorry, I misspoke -- I meant he opened a related PR. The PR is to add 
as_integer_ratio to np.float16, np.float32, np.longdouble, not to add it to the 
numpy integer types. There are similar issues though.

--

___
Python tracker 

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



[issue33073] Add as_integer_ratio() to int() objects

2018-03-16 Thread Nathaniel Smith

Nathaniel Smith  added the comment:

Eric Wieser (added to CC) actually just opened a PR for this against NumPy: 
https://github.com/numpy/numpy/pull/10741

I have weak and mixed feelings about the whole thing: 
https://github.com/numpy/numpy/pull/10741#issuecomment-373637440

--
nosy: +Eric.Wieser

___
Python tracker 

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



[issue33083] math.factorial accepts non-integral Decimal instances

2018-03-16 Thread Mark Dickinson

Mark Dickinson  added the comment:

I'd suggest that in the not-float branch of math_factorial, we use 
PyNumber_Index to catch integer-like things. (That would also be consistent 
with what we do in math_gcd.)

--

___
Python tracker 

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



[issue32328] ttk.Treeview: _tkinter.TclError: list element in quotes followed by "; " instead of space

2018-03-16 Thread Joshua Kinard

Joshua Kinard  added the comment:

I have to disagree rather strongly with closing this as "not a bug".  If the 
issue really boils down to incorrectly passing a single string when there is 
only one item in 'values', and a single-item tuple should be used instead, then 
shouldn't the better solution be for Python to handle this automatically and 
re-cast the errant string into a tuple?

My example indicates a case of where I got the Tcl interpreter itself to choke 
on invalid user input.  Even though the tkinter binding module catches the 
exception from the Tcl interpreter, I think it's Python's job as the wrapping 
language to catch any user stupidity done in Python and try to work around it 
if it's simple to do so.  A user coding against Tkinter/Ttk should not be 
required to have or need knowledge of Tcl/Tk itself to code a GUI.  That 
knowledge certainly helps, but not having it is one of Python's selling points 
for using Tkinter in the first place.

I have a coding project where I initially tripped up the semi-colon issue while 
parsing data from a text file into a Treeview widget (in listbox mode), that 
has a single-column.  The data being parsed included quoted regular expression 
syntax.  The function doing the parsing passed the parsed data to another 
function that populated the Treeview using **kwargs to send "values" and "tags" 
to Treeview's "insert" method.  It was a backslash character in the quoted 
regular expression string, at a point before the semi-colon, that eventually 
goofed the Tcl interpreter up, but //only// when passed in via **kwargs syntax.

The original code was too complex to replicate for the bug, so I reduced things 
down to a smaller testcase.  During this, I inadvertently tripped up the other 
bug with the unmatched open quote error, so I reported both.

My current workaround involves scanning the input for a backslash character or 
a whitespace character (which also trips things up), and if found, wrap the 
string in curly braces, which disables Tcl's substitution mechanism for that 
string, then calling Treeview's "insert" method.  It's more complicated this 
way, but safe for dealing with regular expression strings as possible input.

--

___
Python tracker 

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



[issue33085] *** Error in `python': double free or corruption (out): 0x00007ff5254d50d0 ***

2018-03-16 Thread chenkai

New submission from chenkai <13016135...@163.com>:

When I finished the installation of readline (6.2.4.1) and then run python, 
it's crashed:
*** Error in `python': double free or corruption (out): 0x7ff5254d50d0 ***
=== Backtrace: =
/lib64/libc.so.6(+0x7c503)[0x7ff52416e503]
/lib/libpython3.6m.so.1.0(PyOS_Readline+0xec)[0x7ff524e3ff3c]
/lib/libpython3.6m.so.1.0(+0x694d6)[0x7ff524e414d6]
/lib/libpython3.6m.so.1.0(+0x6ae78)[0x7ff524e42e78]
/lib/libpython3.6m.so.1.0(PyTokenizer_Get+0x9)[0x7ff524e43cb9]
/lib/libpython3.6m.so.1.0(+0x6811e)[0x7ff524e4011e]
/lib/libpython3.6m.so.1.0(PyParser_ASTFromFileObject+0x8b)[0x7ff524f76ecb]
/lib/libpython3.6m.so.1.0(+0x19f0ea)[0x7ff524f770ea]
/lib/libpython3.6m.so.1.0(PyRun_InteractiveLoopFlags+0x76)[0x7ff524f77416]
/lib/libpython3.6m.so.1.0(PyRun_AnyFileExFlags+0x3e)[0x7ff524f77c7e]
/lib/libpython3.6m.so.1.0(Py_Main+0xd97)[0x7ff524f93827]
python(main+0x16c)[0x400b1c]
/lib64/libc.so.6(__libc_start_main+0xf5)[0x7ff524113b35]
python[0x400bda]
=== Memory map: 
0040-00401000 r-xp  08:03 52652831   
/root/python36/bin/python3
00601000-00602000 r--p 1000 08:03 52652831   
/root/python36/bin/python3
00602000-00603000 rw-p 2000 08:03 52652831   
/root/python36/bin/python3
01bb5000-01c92000 rw-p  00:00 0  [heap]
7ff51800-7ff518021000 rw-p  00:00 0 
7ff518021000-7ff51c00 ---p  00:00 0 
7ff51d0c4000-7ff51d0d9000 r-xp  08:03 84 
/usr/lib64/libgcc_s-4.8.5-20150702.so.1
7ff51d0d9000-7ff51d2d8000 ---p 00015000 08:03 84 
/usr/lib64/libgcc_s-4.8.5-20150702.so.1
7ff51d2d8000-7ff51d2d9000 r--p 00014000 08:03 84 
/usr/lib64/libgcc_s-4.8.5-20150702.so.1
7ff51d2d9000-7ff51d2da000 rw-p 00015000 08:03 84 
/usr/lib64/libgcc_s-4.8.5-20150702.so.1
7ff51d2da000-7ff51d2ff000 r-xp  08:03 106273 
/usr/lib64/libtinfo.so.5.9
7ff51d2ff000-7ff51d4ff000 ---p 00025000 08:03 106273 
/usr/lib64/libtinfo.so.5.9
7ff51d4ff000-7ff51d503000 r--p 00025000 08:03 106273 
/usr/lib64/libtinfo.so.5.9
7ff51d503000-7ff51d504000 rw-p 00029000 08:03 106273 
/usr/lib64/libtinfo.so.5.9
7ff51d504000-7ff51d52a000 r-xp  08:03 90038  
/usr/lib64/libncurses.so.5.9
7ff51d52a000-7ff51d729000 ---p 00026000 08:03 90038  
/usr/lib64/libncurses.so.5.9
7ff51d729000-7ff51d72a000 r--p 00025000 08:03 90038  
/usr/lib64/libncurses.so.5.9
7ff51d72a000-7ff51d72b000 rw-p 00026000 08:03 90038  
/usr/lib64/libncurses.so.5.9
7ff51d73e000-7ff51d779000 r-xp  08:03 18819792   
/root/python36/lib/python3.6/site-packages/readline.cpython-36m-x86_64-linux-gnu.so
7ff51d779000-7ff51d979000 ---p 0003b000 08:03 18819792   
/root/python36/lib/python3.6/site-packages/readline.cpython-36m-x86_64-linux-gnu.so
7ff51d979000-7ff51d97b000 r--p 0003b000 08:03 18819792   
/root/python36/lib/python3.6/site-packages/readline.cpython-36m-x86_64-linux-gnu.so
7ff51d97b000-7ff51d982000 rw-p 0003d000 08:03 18819792   
/root/python36/lib/python3.6/site-packages/readline.cpython-36m-x86_64-linux-gnu.so
7ff51d982000-7ff51d9c4000 rw-p  00:00 0 
7ff51d9c4000-7ff51d9c6000 r-xp  08:03 35550108   
/usr/lib/python3.6/lib-dynload/_heapq.cpython-36m-x86_64-linux-gnu.so
7ff51d9c6000-7ff51dbc6000 ---p 2000 08:03 35550108   
/usr/lib/python3.6/lib-dynload/_heapq.cpython-36m-x86_64-linux-gnu.so
7ff51dbc6000-7ff51dbc7000 r--p 2000 08:03 35550108   
/usr/lib/python3.6/lib-dynload/_heapq.cpython-36m-x86_64-linux-gnu.so
7ff51dbc7000-7ff51dbc9000 rw-p 3000 08:03 35550108   
/usr/lib/python3.6/lib-dynload/_heapq.cpython-36m-x86_64-linux-gnu.so
7ff51dbc9000-7ff5240f2000 r--p  08:03 16882256   
/usr/lib/locale/locale-archive
7ff5240f2000-7ff5242a8000 r-xp  08:03 65201  
/usr/lib64/libc-2.17.so
7ff5242a8000-7ff5244a8000 ---p 001b6000 08:03 65201  
/usr/lib64/libc-2.17.so
7ff5244a8000-7ff5244ac000 r--p 001b6000 08:03 65201  
/usr/lib64/libc-2.17.so
7ff5244ac000-7ff5244ae000 rw-p 001ba000 08:03 65201  
/usr/lib64/libc-2.17.so
7ff5244ae000-7ff5244b3000 rw-p  00:00 0 
7ff5244b3000-7ff5245b3000 r-xp  08:03 65209  
/usr/lib64/libm-2.17.so
7ff5245b3000-7ff5247b3000 ---p 0010 08:03 65209  
/usr/lib64/libm-2.17.so
7ff5247b3000-7ff5247b4000 r--p 0010 08:03 65209  
/usr/lib64/libm-2.17.so
7ff5247b4000-7ff5247b5000 rw-p 00101000 08:03 65209  
/usr/lib64/libm-2.17.so