[issue14074] argparse allows nargs>1 for positional arguments but doesn't allow metavar to be a tuple

2020-01-31 Thread hai shi


hai shi  added the comment:

I am not sure disallowing tuple metavars would break backup compatibility or 
not~

--
nosy: +shihai1991
versions: +Python 3.5 -Python 3.3

___
Python tracker 

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



[issue39496] Inelegant loops in Modules/_sqlite/cursor.c

2020-01-31 Thread Vedran Čačić

Vedran Čačić  added the comment:

It seems you haven't read carefully what I've written. This way some compilers 
might emit warnings. Please read 
https://stackoverflow.com/questions/5476759/compiler-warning-suggest-parentheses-around-assignment-used-as-truth-value

--

___
Python tracker 

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



[issue39496] Inelegant loops in Modules/_sqlite/cursor.c

2020-01-31 Thread Alex Henrie


Alex Henrie  added the comment:

You're right, that's even better. I forgot that the equals operator also 
returns the variable's new value. I just updated my pull request :-)

--

___
Python tracker 

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



[issue39391] Run-dependent Pydoc output for functions default parameters

2020-01-31 Thread Peter O.


Peter O.  added the comment:

Is this bug tracker the correct place to "ask the pydoc developers to add an 
option to improve [the Pydoc] output", in the sense that the option doesn't 
write out object IDs?  If not, where is the correct place to do so?

--

___
Python tracker 

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



[issue39496] Inelegant loops in Modules/_sqlite/cursor.c

2020-01-31 Thread Vedran Čačić

Vedran Čačić  added the comment:

You mean, something like

while ((row = pysqlite_cursor_iternext(self))) {
PyList_Append(list, row);
Py_DECREF(row);
}

? It's interesting that now we have walrus in Python, we see the opportunities 
for it in other languages. (In C, it's spelled (=).:)

--
nosy: +veky

___
Python tracker 

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



[issue39515] pathlib won't strip "\n" in path

2020-01-31 Thread 徐彻

New submission from 徐彻 :

Pathlib won't strip "\n" in path. Of course, "\n" should exist in a legal path.
For example:

>>>a=pathlib.Path(pathlib.Path("C:/Program Files/\n"),"./JetBrains/\n")
>>>a
WindowsPath('C:/Program Files/\n/JetBrains/\n')

--
components: Library (Lib)
messages: 361149
nosy: 徐彻
priority: normal
severity: normal
status: open
title: pathlib won't strip "\n" in path
type: behavior
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



[issue39514] http://sphinx.pocoo.org/

2020-01-31 Thread Berker Peksag


Berker Peksag  added the comment:

Thanks for the report. The link has already been fixed in 
https://github.com/python/python-docs-theme/commit/fc9f203dd79587c8aed2b822cf7401518cd65bb5
 I think it will be fixed once the new version of the theme is released.

We can discuss the details over at python/python-docs-theme. Closing this issue 
for now.

--
nosy: +berker.peksag, zach.ware
resolution:  -> out of date
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



[issue29249] Pathlib glob ** bug

2020-01-31 Thread Isaac Muse


Isaac Muse  added the comment:

I think the idea of adding a globmatch function is a decent idea.

That is what I did in a library I wrote to get more out of glob than what 
Python offered out of the box: 
https://facelessuser.github.io/wcmatch/pathlib/#purepathglobmatch. 

Specifically the differences are globmatch is just a pure match of a path, it 
doesn't do the implied `**` at the beginning of a pattern like match does. 
While it doesn't enable `**` by default, such features are controlled by flags

>>> pathlib.Path("a/b/c/d/e.txt").match('a/*/**/*', flags=pathlib.GLOBSTAR)
True

This isn't to promote my library, but more to say, as a user, I found such 
functionality worth adding. I think it would be generally nice to have such 
functionality in some form in Python by default. Maybe something called 
`globmatch` that offers that could be worthwhile.

--
nosy: +Isaac Muse

___
Python tracker 

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



[issue39511] [subinterpreters] Per-interpreter singletons (None, True, False, etc.)

2020-01-31 Thread STINNER Victor


STINNER Victor  added the comment:

PR 18301 is a WIP showing my intent. I'm not sure if it would be possible to 
land such change right now in Python. It has different drawbacks described in 
my previous messages. I don't know the impact on performance neither.

--

___
Python tracker 

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



[issue39511] [subinterpreters] Per-interpreter singletons (None, True, False, etc.)

2020-01-31 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +17678
pull_request: https://github.com/python/cpython/pull/18301

___
Python tracker 

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



[issue39511] [subinterpreters] Per-interpreter singletons (None, True, False, etc.)

2020-01-31 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 4d96b4635aeff1b8ad41d41422ce808ce0b971c8 by Victor Stinner in 
branch 'master':
bpo-39511: PyThreadState_Clear() calls on_delete (GH-18296)
https://github.com/python/cpython/commit/4d96b4635aeff1b8ad41d41422ce808ce0b971c8


--

___
Python tracker 

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



[issue39484] time_ns() and time() cannot be compared on windows

2020-01-31 Thread Larry Hastings


Larry Hastings  added the comment:

(Oh, wow, Victor, you wrote all that while I was writing my reply. ;-)

--

___
Python tracker 

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



[issue39484] time_ns() and time() cannot be compared on windows

2020-01-31 Thread Larry Hastings


Larry Hastings  added the comment:

I don't think this is fixable, because it's not exactly a bug.  The problem is 
we're running out of bits.  In converting the time around, we've lost some 
precision.  So the times that come out of time.time() and time.time_ns() should 
not be considered directly comparable.

Both functions, time.time() and time.time_ns(), call the same underlying 
function to get the current time.  That function is_PyTime_GetSystemClock(); it 
returns nanoseconds since the 1970 epoch, stored in an int64.  Each function 
then simply converts that time into its return format and returns that.

In the case of time.time_ns(), it loses no precision whatsoever.  In the case 
of time.time(), it (usually) converts to double and divides by 1e9, which is 
implicitly floor rounding.

Back-of-the-envelope math here: An IEEE double has 53 bits of resolution for 
the mantissa, not counting the leading 1. The current time in seconds since the 
1970 epoch uses about 29 bits of those 53 bits.  That leaves 24 bits for the 
fractional second.  But you'd need 30 bits to render all one billion fractional 
values.  We're six bits short.

Unless anybody has an amazing suggestion about how to ameliorate this 
situation, I think we should close this as wontfix.

--

___
Python tracker 

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



[issue39484] time_ns() and time() cannot be compared on windows

2020-01-31 Thread STINNER Victor


STINNER Victor  added the comment:

By the way, I wrote an article about the history on how Python rounds time... 
https://vstinner.github.io/pytime.html

I also wrote two articles about nanoseconds in Python:

* https://vstinner.github.io/python37-pep-564-nanoseconds.html
* https://vstinner.github.io/python37-perf-counter-nanoseconds.html

Oh and I forgot the main one: PEP 564 :-)

"Example 2: compare times with different resolution" sounds like this issue.

https://www.python.org/dev/peps/pep-0564/#example-2-compare-times-with-different-resolution

--

___
Python tracker 

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



[issue39484] time_ns() and time() cannot be compared on windows

2020-01-31 Thread STINNER Victor


STINNER Victor  added the comment:

Another way to understand the problem: nanosecond (int) => seconds (float) => 
nanoseconds (int) roundtrip looses precison.

>>> a=1580301619906185300
>>> a/1e9*1e9
1.5803016199061852e+18
>>> b=int(a/1e9*1e9)
>>> b
1580301619906185216
>>> a - b
84

The best would be to add a round parameter to _PyTime_AsSecondsDouble(), but 
I'm not sure how to implement it.

The following rounding mode is used to read a clock:

/* Round towards minus infinity (-inf).
   For example, used to read a clock. */
_PyTime_ROUND_FLOOR=0,

_PyTime_ROUND_FLOOR is used in time.clock_settime(), time.gmtime(), 
time.localtime() and time.ctime() functions: to round input arguments.

time.time(), time.monotonic() and time.perf_counter() converts _PyTime_t to 
float using _PyTime_AsSecondsDouble() (which currently has no round parameter) 
for their output.

See also my rejected PEP 410 ;-)

--

One way to solve this issue is to document how to compare time.time() and 
time.time_ns() timestamps in a reliable way.

--

___
Python tracker 

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



[issue39484] time_ns() and time() cannot be compared on windows

2020-01-31 Thread STINNER Victor


STINNER Victor  added the comment:

See also bpo-39277 which is similar issue. I proposed a fix which uses 
nextafter():
https://github.com/python/cpython/pull/17933

--

___
Python tracker 

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



[issue39484] time_ns() and time() cannot be compared on windows

2020-01-31 Thread STINNER Victor


STINNER Victor  added the comment:

>>> a / 10**9 <= b
False

Try to use a/1e9 <= b.

--

The C code to get the system clock is the same for time.time() and 
time.time_ns(). It's only the conversion of the result which is different:

static PyObject *
time_time(PyObject *self, PyObject *unused)
{
_PyTime_t t = _PyTime_GetSystemClock();
return _PyFloat_FromPyTime(t);
}

static PyObject *
time_time_ns(PyObject *self, PyObject *unused)
{
_PyTime_t t = _PyTime_GetSystemClock();
return _PyTime_AsNanosecondsObject(t);
}

where _PyTime_t is int64_t: 64-bit signed integer.


Conversions:

static PyObject*
_PyFloat_FromPyTime(_PyTime_t t)
{
double d = _PyTime_AsSecondsDouble(t);
return PyFloat_FromDouble(d);
}


double
_PyTime_AsSecondsDouble(_PyTime_t t)
{
/* volatile avoids optimization changing how numbers are rounded */
volatile double d;

if (t % SEC_TO_NS == 0) {
_PyTime_t secs;
/* Divide using integers to avoid rounding issues on the integer part.
   1e-9 cannot be stored exactly in IEEE 64-bit. */
secs = t / SEC_TO_NS;
d = (double)secs;
}
else {
d = (double)t;
d /= 1e9;
}
return d;
}

PyObject *
_PyTime_AsNanosecondsObject(_PyTime_t t)
{
Py_BUILD_ASSERT(sizeof(long long) >= sizeof(_PyTime_t));
return PyLong_FromLongLong((long long)t);
}

In short, time.time() = float(time.time_ns()) / 1e9.

--

The problem can be reproduced in Python:

>>> a=1580301619906185300
>>> b=a/1e9
>>> a / 10**9 <= b
False

I added time.time_ns() because we loose precision if you care about nanosecond 
resolution, with such "large number". float has a precision around 238 
nanoseconds:

>>> import math; ulp=math.ulp(b)
>>> ulp
2.384185791015625e-07
>>> "%.0f +- %.0f" % (b*1e9, ulp*1e9)
'1580301619906185216 +- 238'

int/int and int/float don't give the same result:

>>> a/10**9
1580301619.9061854
>>> a/1e9
1580301619.9061852

I'm not sure which one is "correct". To understand the issue, you can use the 
next math.nextafter() function to get the next floating point towards -inf:

>>> a/10**9
1580301619.9061854
>>> a/1e9
1580301619.9061852
>>> math.nextafter(a/10**9, -math.inf)
1580301619.9061852
>>> math.nextafter(a/1e9, -math.inf)
1580301619.906185

Handling floating point numbers are hard.

Why don't use only use integers? :-)

--

___
Python tracker 

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



[issue39511] [subinterpreters] Per-interpreter singletons (None, True, False, etc.)

2020-01-31 Thread STINNER Victor


STINNER Victor  added the comment:

> Would it not suffice to just make the singletons "immortal"?

The problem is to make Py_INCREF/Py_DECREF efficient. Last time someone tried 
to use an atomic variable for ob_refcnt, it was 20% slower if I recall 
correctly. If many threads start to update such atomic variable, the CPU 
cacheline of common singletons like None, True and False can quickly become a 
performance bottleneck.

On the other side, if each interpreter has its own objects, there is no need to 
protect ob_refcnt, the interpreter lock protects it.

--

___
Python tracker 

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



[issue39511] [subinterpreters] Per-interpreter singletons (None, True, False, etc.)

2020-01-31 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 7dc140126e918cc7c6e65aea321b7255f0020798 by Victor Stinner in 
branch 'master':
bpo-39511: Fix multiprocessing semlock_acquire() (GH-18298)
https://github.com/python/cpython/commit/7dc140126e918cc7c6e65aea321b7255f0020798


--

___
Python tracker 

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



[issue37130] pathlib.Path.with_name() handles '.' and '..' inconsistently

2020-01-31 Thread Brett Cannon


Change by Brett Cannon :


--
assignee: brett.cannon -> 

___
Python tracker 

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



[issue37130] pathlib.Path.with_name() handles '.' and '..' inconsistently

2020-01-31 Thread Brett Cannon


Brett Cannon  added the comment:

So I tried making pathlib.PurePath handle "." more like ".." and tests started 
failing all over the place in test_pathlib, which means it would be a change in 
semantics and could start silently breaking people as most of the checks are 
for specific exceptions.

So the next question is where is '..' being mishandled? It might be possible 
and better to tighten up how '..' is treated than try to make '.' suddenly be 
treated in a weaker way.

--
nosy: +jaraco

___
Python tracker 

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



[issue39509] Update HTTP status code to follow IANA

2020-01-31 Thread Dong-hee Na


Change by Dong-hee Na :


--
nosy: +rhettinger

___
Python tracker 

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



[issue39484] time_ns() and time() cannot be compared on windows

2020-01-31 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue16651] Find out what stdlib modules lack a pure Python implementation

2020-01-31 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
resolution:  -> out of date
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



[issue39514] http://sphinx.pocoo.org/

2020-01-31 Thread Carlos ESTEVES


New submission from Carlos ESTEVES :

Hi,

"Sphinx" link is break on webpage: https://docs.python.org/3/

See:
http://sphinx.pocoo.org/;>Sphinx

Thank You

--
assignee: docs@python
components: Documentation
messages: 361135
nosy: cesteves, docs@python
priority: normal
severity: normal
status: open
title: http://sphinx.pocoo.org/

___
Python tracker 

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



[issue29249] Pathlib glob ** bug

2020-01-31 Thread Gregory P. Smith


Change by Gregory P. Smith :


--
versions: +Python 3.8, Python 3.9

___
Python tracker 

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



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

2020-01-31 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

https://en.wikipedia.org/wiki/Hyper_Text_Coffee_Pot_Control_Protocol#Save_418_movement

--
nosy: +rhettinger

___
Python tracker 

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



[issue39484] time_ns() and time() cannot be compared on windows

2020-01-31 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
nosy: +larry

___
Python tracker 

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



[issue39484] time_ns() and time() cannot be compared on windows

2020-01-31 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
nosy: +vstinner

___
Python tracker 

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



[issue39480] referendum reference is needlessly annoying

2020-01-31 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

I concur with Steven and Raymond.  The 2016 Brexit votes were Leave 17.4 
million and Remain 16.1 million.  No resemblence to the hypothetical example.  
I think that this should be closed as 'not a bug'.

--
nosy: +terry.reedy

___
Python tracker 

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



[issue37224] test__xxsubinterpreters fails randomly

2020-01-31 Thread miss-islington


miss-islington  added the comment:


New changeset f03a8f8d5001963ad5b5b28dbd95497e9cc15596 by Kyle Stanley in 
branch 'master':
bpo-37224: Improve test__xxsubinterpreters.DestroyTests (GH-18058)
https://github.com/python/cpython/commit/f03a8f8d5001963ad5b5b28dbd95497e9cc15596


--
nosy: +miss-islington

___
Python tracker 

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



[issue26789] Please do not log during shutdown

2020-01-31 Thread Sandeep


Sandeep  added the comment:

I did import aiohttp and called function sys.is_finalizing() just before 
logging.basicConfig but still the same error.

Has  logging.basicConfig worked in past ? If yes what  additional package I 
need to add

Thanks

--
nosy: +Sandeep

___
Python tracker 

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



[issue39391] Run-dependent Pydoc output for functions default parameters

2020-01-31 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

repr(f2) is not 'non-deterministic'.  If one runs it again for the same 
function object, one gets the same answer. It only changes when one starts over 
and creates a new function object with the same name but (usually) different id.

I think it appropriate that the default object representation include the 
object id.  It may help with debugging or other operations.

I agree that pydoc output with run-dependent ids may not be suitable for 
storage in version control.  Either remove or normalize them yourself or ask 
the pydoc developers to add an option to improve its output.

Reclosing.

--
nosy: +terry.reedy
resolution:  -> third party
status: open -> closed
title: Nondeterministic Pydoc output on functions that have functions as 
default parameters -> Run-dependent Pydoc output for functions default 
parameters

___
Python tracker 

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



[issue39513] NameError: name 'open' is not defined

2020-01-31 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

See also https://bugs.python.org/issue26789

--
nosy: +vinay.sajip, xtreak
status: pending -> open

___
Python tracker 

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



[issue39350] Remove deprecated fractions.gcd()

2020-01-31 Thread Miro Hrončok

Miro Hrončok  added the comment:

Naively implementing this code, I'd use isinstance(numerator, int) over 
type(numerator) is int. Is that strict type check really needed?

I could not find anywhere whether numerator and denominator of numbers.Rational 
need to be numbers.Integral. I would expect so, however this is not written in 
the documentation of numbers.Rational. If that's the case, I think checking it 
for being numbers.Integral and failing hard if not is a reasonable thing to do.

--

___
Python tracker 

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



[issue39513] NameError: name 'open' is not defined

2020-01-31 Thread Sandeep


New submission from Sandeep :

Hi 
   I wrote a python script which gets file from other server and it works fine 
till the time I don't introduces logging feature to it. 
Please advice how to fix below

This is the code I am using for logging '

import logging
logging.basicConfig(filename=localLogfile, level=logging.DEBUG)

--Error Message 

Traceback (most recent call last):
  File "/d01/python3/lib64/python3.6/site-packages/pysftp/__init__.py", line 
1013, in __del__
  File "/d01/python3/lib64/python3.6/site-packages/pysftp/__init__.py", line 
785, in close
  File "/d01/python3/lib64/python3.6/site-packages/paramiko/sftp_client.py", 
line 194, in close
  File "/d01/python3/lib64/python3.6/site-packages/paramiko/sftp_client.py", 
line 185, in _log
  File "/d01/python3/lib64/python3.6/site-packages/paramiko/sftp.py", line 158, 
in _log
  File "/opt/rh/rh-python36/root/usr/lib64/python3.6/logging/__init__.py", line 
1372, in log
  File "/opt/rh/rh-python36/root/usr/lib64/python3.6/logging/__init__.py", line 
1442, in _log
  File "/opt/rh/rh-python36/root/usr/lib64/python3.6/logging/__init__.py", line 
1452, in handle
  File "/opt/rh/rh-python36/root/usr/lib64/python3.6/logging/__init__.py", line 
1514, in callHandlers
  File "/opt/rh/rh-python36/root/usr/lib64/python3.6/logging/__init__.py", line 
863, in handle
  File "/opt/rh/rh-python36/root/usr/lib64/python3.6/logging/__init__.py", line 
1069, in emit
  File "/opt/rh/rh-python36/root/usr/lib64/python3.6/logging/__init__.py", line 
1059, in _open
NameError: name 'open' is not defined

--
status: open -> pending

___
Python tracker 

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



[issue39513] NameError: name 'open' is not defined

2020-01-31 Thread Sandeep


Change by Sandeep :


--
components: Library (Lib)
nosy: Sandeep
priority: normal
severity: normal
status: open
title: NameError: name 'open' is not defined
type: crash
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



[issue39512] expat parser not xml 1.1 (breaks xmlrpclib) - still

2020-01-31 Thread Malte Forkel


New submission from Malte Forkel :

xmlrpc uses expat, which is not XML 1.1 compliant. Therefore, when transferring 
text, some characters which a valid according to the XML-RPC specification 
(http://xmlrpc.com/spec.md) will trigger expat to raise 
xml.parsers.expat.ExpatError: not well-formed (invalid token) exceptions.

Issue 11804 (https://bugs.python.org/issue11804) which reported this problem 
has been closed almost 20 years ago, referencing an expat bug report for XML 
1.1 support. That bug report is still open and there is no current plan to 
support XML 1.1 in expat 
(https://github.com/libexpat/libexpat/issues/378#issuecomment-578914067).

I would like to suggest to replace expat as the default parser in xmlrpc or at 
least make it easier to override the default (see 
https://bugs.python.org/issue6701).

--
components: XML
messages: 361124
nosy: mforkel
priority: normal
severity: normal
status: open
title: expat parser not xml 1.1 (breaks xmlrpclib) - still

___
Python tracker 

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



[issue39280] Don't allow datetime parsing to accept non-Ascii digits

2020-01-31 Thread Ram Rachum


Ram Rachum  added the comment:

Hi guys,

Can we please have a decision on whether we want to move forward with this 
issue or not? I have a patch in the PR, and I'll be happy to continue working 
on it, or close this issue if that's the decision.


Thanks,
Ram.

--

___
Python tracker 

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



[issue39503] [security][CVE-2020-8492] Denial of service in urllib.request.AbstractBasicAuthHandler

2020-01-31 Thread Anselmo Melo


Change by Anselmo Melo :


--
nosy: +Anselmo Melo

___
Python tracker 

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



[issue39511] [subinterpreters] Per-interpreter singletons (None, True, False, etc.)

2020-01-31 Thread Jeremy Kloth


Jeremy Kloth  added the comment:

Would it not suffice to just make the singletons "immortal"?

Without affecting the hotpaths that are Py_INCREF and Py_DECREF, changing 
_Py_Dealloc to test for objects with a "special" destructor could be used:

destructor dealloc = Py_TYPE(op)->tp_dealloc;
if (dealloc == _Py_SingletonSentinel) {
/* reset refcnt so as to not return here too often */
op->ob_refcnt = PY_SSIZE_T_MAX;
}
else {
(*dealloc)(op);
}

Even in the presence of multiple mutating threads, the object cannot be 
destroyed.  Worst case, they all call _Py_Dealloc.

--
nosy: +jkloth

___
Python tracker 

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



[issue39468] Improved the site module's permission handling while writing .python_history

2020-01-31 Thread Aurora


Change by Aurora :


--
title: .python_history write permission improvements -> Improved the site 
module's permission handling while writing .python_history

___
Python tracker 

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



[issue39468] Improved the site module's permission handling while writing .python_history

2020-01-31 Thread Aurora


Change by Aurora :


--
status: open -> pending

___
Python tracker 

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



[issue39468] .python_history write permission improvements

2020-01-31 Thread Aurora


Change by Aurora :


--
pull_requests:  -17675

___
Python tracker 

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



[issue39468] .python_history write permission improvements

2020-01-31 Thread Aurora


Change by Aurora :


--
pull_requests: +17677
pull_request: https://github.com/python/cpython/pull/18299

___
Python tracker 

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



[issue39468] .python_history write permission improvements

2020-01-31 Thread Aurora


Change by Aurora :


--
pull_requests:  -17589

___
Python tracker 

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



[issue39468] .python_history write permission improvements

2020-01-31 Thread Aurora


Change by Aurora :


--
pull_requests:  -17674

___
Python tracker 

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



[issue39468] .python_history write permission improvements

2020-01-31 Thread Aurora


Change by Aurora :


--
pull_requests: +17675
pull_request: https://github.com/python/cpython/pull/39468

___
Python tracker 

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



[issue39468] .python_history write permission improvements

2020-01-31 Thread Aurora


Change by Aurora :


--
pull_requests: +17674
pull_request: https://github.com/python/cpython/pull/18299

___
Python tracker 

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



[issue39455] Update the documentation for the linecache module

2020-01-31 Thread Aurora


Change by Aurora :


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



[issue39511] [subinterpreters] Per-interpreter singletons (None, True, False, etc.)

2020-01-31 Thread STINNER Victor


Change by STINNER Victor :


--
nosy: +eric.snow, nanjekyejoannah, ncoghlan

___
Python tracker 

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



[issue39314] (readline) Autofill the closing parenthesis during auto-completion for functions which accept no arguments at all

2020-01-31 Thread Aurora


Change by Aurora :


--
title: Autofill the closing paraenthesis during auto-completion for functions 
which accept no arguments at all -> (readline) Autofill the closing parenthesis 
during auto-completion for functions which accept no arguments at all

___
Python tracker 

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



[issue39455] Update the documentation for the linecache module

2020-01-31 Thread Aurora


Change by Aurora :


--
title: Update the documentation for linecache module -> Update the 
documentation for the linecache module

___
Python tracker 

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



[issue39511] [subinterpreters] Per-interpreter singletons (None, True, False, etc.)

2020-01-31 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +17673
pull_request: https://github.com/python/cpython/pull/18298

___
Python tracker 

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



[issue37304] compiler need support in(de)crement operation or all of it should have syntax error.

2020-01-31 Thread hai shi


Change by hai shi :


--
pull_requests: +17672
pull_request: https://github.com/python/cpython/pull/18297

___
Python tracker 

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



[issue39511] [subinterpreters] Per-interpreter singletons (None, True, False, etc.)

2020-01-31 Thread STINNER Victor


Change by STINNER Victor :


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

___
Python tracker 

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



[issue39511] [subinterpreters] Per-interpreter singletons (None, True, False, etc.)

2020-01-31 Thread STINNER Victor


New submission from STINNER Victor :

The long-term goal of the PEP 554 is to run two Python interpreters in 
parallel. To achieve this goal, no object must be shared between two 
interpreters. See for example my article "Pass the Python thread state 
explicitly" which gives a longer rationale:
https://vstinner.github.io/cpython-pass-tstate.html

In bpo-38858, I modified Objects/longobject.c to have per-interpreter small 
integer singletons: commit 630c8df5cf126594f8c1c4579c1888ca80a29d59.

This issue is about other singletons like None or Py_True which are currently 
shared between two interpreters.

I propose to add new functions. Example for None:

* Py_GetNone(): return a *borrowed* reference to the None singleton (similar to 
existing Py_None macro)
* Py_GetNoneRef(): return a *strong* reference to the None singleton (similar 
to "Py_INCREF(Py_None); return Py_None;" and Py_RETURN_NONE macro)

And add PyInterpreterState.none field: strong reference to the per-interpreter 
None object.


We should do that for each singletons:

* None (Py_None)
* True (Py_True)
* False (Py_False)
* Ellipsis (Py_Ellipsis)


GIL issue
=

Py_GetNone() would look like:

PyObject* Py_GetNone(void)
{ return _PyThreadState_GET()->interp->none; }

Problem: _PyThreadState_GET() returns NULL if the caller function doesn't hold 
the GIL.

Using the Python C API when the GIL is not held is a violation of the API: it 
is not supported. But it worked previously.

One solution is to fail with an assertion error (abort the process) in debug 
mode, and let Python crash in release mode.

Another option is to only fail with an assertion error in debug mode in Python 
3.9. In Python 3.9, Py_GetNone() would use PyGILState_GetThisThreadState() 
function which works even when the GIL is released. In Python 3.10, we would 
switch to _PyThreadState_GET() and so crash in release mode.

One concrete example of such issue can be found in the multiprocessing C code, 
in semlock_acquire():

Py_BEGIN_ALLOW_THREADS
if (timeout_obj == Py_None) {
res = sem_wait(self->handle);
}
else {
res = sem_timedwait(self->handle, );
}
Py_END_ALLOW_THREADS

Py_None is accessed when the GIL is released.

--
components: Interpreter Core
messages: 361121
nosy: vstinner
priority: normal
severity: normal
status: open
title: [subinterpreters] Per-interpreter singletons (None, True, False, etc.)
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



[issue18233] SSLSocket.getpeercertchain()

2020-01-31 Thread Kent Watsen


Kent Watsen  added the comment:

I agree that having both would be best, but there is a world of difference 
between a must-have (peer_cert_chain) and what seems to be a nice-to-have 
(authed_peer_cert_chain).

My request for clarification was not that I don't understand bags, etc. (see my 
first message), but that I don't understand the concrete use case in mind.  
That is, when is it that the app-logic would differ because the EE cert 
validated using one path versus another?

To explain the 'must-have' better, imagine one peer sending [A, B, C], where 
'A' is the EE cert, and the other peer having TA [F, E, D], where 'F' is the 
self-signed root TA and 'D' is the Issuer that signed 'C'.  The complete chain 
is [A-F] and this is what the SSL-level code will use during the handshake.  
But post-handshake, without peer_chain_cert(), there is NO WAY for the 
app-logic to create a valid chain.  This is broken, for the reason mentioned in 
my first message.

--

___
Python tracker 

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



[issue39510] use-after-free in BufferedReader.readinto()

2020-01-31 Thread Philipp Gesang


Change by Philipp Gesang :


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

___
Python tracker 

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



[issue39510] use-after-free in BufferedReader.readinto()

2020-01-31 Thread Philipp Gesang


New submission from Philipp Gesang :

reader = open ("/dev/zero", "rb")
_void  = reader.read (42)
reader.close ()
reader.readinto (bytearray (42)) ### BANG!

Bisected to commit dc469454ec. PR on Github to follow.

--
messages: 361119
nosy: phg
priority: normal
severity: normal
status: open
title: use-after-free in BufferedReader.readinto()

___
Python tracker 

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



[issue39509] Update HTTP status code to follow IANA

2020-01-31 Thread Dong-hee Na


Change by Dong-hee Na :


--
pull_requests: +17668
pull_request: https://github.com/python/cpython/pull/18294

___
Python tracker 

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



[issue39509] Update HTTP status code to follow IANA

2020-01-31 Thread Dong-hee Na


Change by Dong-hee Na :


--
pull_requests:  -17667

___
Python tracker 

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



[issue39502] test_zipfile fails on AIX due to time.localtime

2020-01-31 Thread Michael Felt


Michael Felt  added the comment:

p.s., I manually added #18282 to the test, and the results are the same as 
without - using 64-bit. Will rebuild the 32-bit and try test again.

--

___
Python tracker 

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



[issue37304] compiler need support in(de)crement operation or all of it should have syntax error.

2020-01-31 Thread hai shi


hai shi  added the comment:

Steven, Thank you for your quick comment.

sure, i will keep this bpo stay in `closed` status until enlist the support of 
core developers.

--

___
Python tracker 

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



[issue39509] Update HTTP status code to follow IANA

2020-01-31 Thread Dong-hee Na


Change by Dong-hee Na :


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

___
Python tracker 

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



[issue39502] test_zipfile fails on AIX due to time.localtime

2020-01-31 Thread Michael Felt


Michael Felt  added the comment:

OK. There have been some comments/questions re: PR18282.

a) my PR is missing that PR, seems we just missed each other.

b) when using my patch I took a suggestion from issue39460 to test again:

root@x065:[/home/python/python3-3.9]./python -m test -v test_zipfile -m 
test_add_file_after_2107 --tempdir /tmp
== CPython 3.9.0a3+ (heads/bpo-39502-dirty:c54fe56362, Jan 30 2020, 15:52:37) 
[C]
== AIX-3-00C291F54C00-powerpc-64bit big-endian
== cwd: /tmp/test_python_303120
== CPU count: 4
== encodings: locale=ISO8859-1, FS=iso8859-1
0:00:00 Run tests sequentially
0:00:00 [1/1] test_zipfile
test_add_file_after_2107 (test.test_zipfile.StoredTestsWithSourceFile) ... ok

--

Ran 1 test in 0.257s

OK

== Tests result: SUCCESS ==

1 test OK.

Total duration: 653 ms
Tests result: SUCCESS

Without the --tempdir setting it "skips" to PASS:

root@x065:[/home/python/python3-3.9]./python -m test -v test_zipfile -m 
test_add_file_after_2107
== CPython 3.9.0a3+ (heads/bpo-39502-dirty:c54fe56362, Jan 30 2020, 15:52:37) 
[C]
== AIX-3-00C291F54C00-powerpc-64bit big-endian
== cwd: /data/prj/python/python3-3.9/build/test_python_364784
== CPU count: 4
== encodings: locale=ISO8859-1, FS=iso8859-1
0:00:00 Run tests sequentially
0:00:00 [1/1] test_zipfile
test_add_file_after_2107 (test.test_zipfile.StoredTestsWithSourceFile) ... 
skipped 'Linux VFS/XFS kernel bug detected: mtime_ns=913015040'

--

Ran 1 test in 0.010s

OK (skipped=1)

== Tests result: SUCCESS ==

1 test OK.

Total duration: 252 ms
Tests result: SUCCESS

FYI

--

___
Python tracker 

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



[issue39509] Update HTTP status code to follow IANA

2020-01-31 Thread Dong-hee Na


Dong-hee Na  added the comment:

See the docs that we follow IANA
https://docs.python.org/3/library/http.html?highlight=iana#http-status-codes

--

___
Python tracker 

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



[issue39508] no module curses error although i downloaded the module - windows 10

2020-01-31 Thread haim


Change by haim :


Added file: https://bugs.python.org/file48875/p203.PNG

___
Python tracker 

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



[issue39509] Update HTTP status code to follow IANA

2020-01-31 Thread Dong-hee Na


New submission from Dong-hee Na :

status code 103 and 425 is missing.

https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

--
components: Library (Lib)
messages: 361114
nosy: corona10, martin.panter
priority: normal
severity: normal
status: open
title: Update HTTP status code to follow IANA
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



[issue37304] compiler need support in(de)crement operation or all of it should have syntax error.

2020-01-31 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

Please remember that not all Python programmers come from a C background 
where `++n` is a pre-increment operator. Then may have a OOP background 
where the unary `+` and `-` operators can do anything they like.

Making `--obj` or `++obj` a syntax error is a backwards-incompatible 
change that will break people's code. We take backwards compatibility 
seriously. Python is a mature language with millions of users, we don't 
break their code lightly.

As you were told (twice) last year, this change will not be considered 
until you take it to the Python-Ideas mailing list for feedback. If you 
have done this, please post a link to the discussion.

If you get a consensus that the change is a good idea, you need to find 
a core developer to sponsor a PEP, then write the PEP, and ask the 
Steering Council to approve it. Only then will the PR be approved.

--

___
Python tracker 

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



[issue39508] no module curses error although i downloaded the module - windows 10

2020-01-31 Thread haim


New submission from haim :

hi,
when i run my code its get error that ModuleNotFoundError: No module named 
'_curses'
altough i download windoows curses 2.1.0 library
i add a pictures
thanx

--
files: p204.PNG
messages: 361112
nosy: haim986
priority: normal
severity: normal
status: open
title: no module curses error although i downloaded the module - windows 10
type: compile error
versions: Python 3.7
Added file: https://bugs.python.org/file48874/p204.PNG

___
Python tracker 

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



[issue39350] Remove deprecated fractions.gcd()

2020-01-31 Thread Mark Dickinson


Mark Dickinson  added the comment:

The relevant piece of Python code from fractions.py looks like this:

if type(numerator) is int is type(denominator):
# *very* normal case
g = math.gcd(numerator, denominator)
if denominator < 0:
g = -g
else:
g = _gcd(numerator, denominator)

I wonder whether we should simply drop the type check: math.gcd should accept 
anything that supports __index__ (and that includes NumPy integer types and 
anything that implements numbers.Integral).

OTOH, math.gcd will return a plain int, and if we have some subclass myint of 
int, we might want all the arithmetic to stay in the domain of myints (though 
I'm not really sure _why_ we'd want that). In that case we'll need to restore 
the pure Python _gcd implementation.

--
status: closed -> open

___
Python tracker 

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



[issue37304] compiler need support in(de)crement operation or all of it should have syntax error.

2020-01-31 Thread hai shi


hai shi  added the comment:

A discussion was initiated in 
https://discuss.python.org/t/why-compiler-doesnt-support-in-de-crement-operation-should-we-support-it/2181.

And most of user tend not to support this in(de)crement operation.

--

___
Python tracker 

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



[issue39279] Don't allow non-Ascii digits in platform.py

2020-01-31 Thread Ram Rachum


Ram Rachum  added the comment:

Hey Victor, adding you here. This ticket is a continuation of the thread on the 
Python security mailing list. I see that there isn't a consensus here for 
changing from \d to [0-9]. Can you make a decision on whether to go ahead with 
this issue or not? Otherwise we can close it, and the corresponding PR.

--
nosy: +vstinner

___
Python tracker 

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



[issue37304] compiler need support in(de)crement operation or all of it should have syntax error.

2020-01-31 Thread hai shi


Change by hai shi :


--
pull_requests: +17666
pull_request: https://github.com/python/cpython/pull/18292

___
Python tracker 

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



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

2020-01-31 Thread Dong-hee Na


Dong-hee Na  added the comment:

IMHO, Although this status code is also listed on the MDN guide,
IANA left 418 as the unassigned code.

ref0: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status
ref1: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

--

___
Python tracker 

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



[issue39350] Remove deprecated fractions.gcd()

2020-01-31 Thread Mark Dickinson


Change by Mark Dickinson :


--
nosy: +mark.dickinson

___
Python tracker 

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



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

2020-01-31 Thread Ross Rhodes


Change by Ross Rhodes :


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

___
Python tracker 

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



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

2020-01-31 Thread Dong-hee Na


Dong-hee Na  added the comment:

I add martin.panter to review this issue as the core developer.

--
nosy: +corona10, martin.panter

___
Python tracker 

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



[issue12731] python lib re uses obsolete sense of \w in full violation of UTS#18 RL1.2a

2020-01-31 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
assignee: docs@python -> 
components: +Unicode -Documentation
nosy: +benjamin.peterson, lemburg, serhiy.storchaka

___
Python tracker 

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



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

2020-01-31 Thread Ross Rhodes


New submission from Ross Rhodes :

http library missing HTTP status code 418 "I'm a teapot".

--
messages: 361106
nosy: trrhodes
priority: normal
severity: normal
status: open
title: http library missing HTTP status code 418 "I'm a teapot"

___
Python tracker 

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



[issue12731] python lib re uses obsolete sense of \w in full violation of UTS#18 RL1.2a

2020-01-31 Thread Henry S. Thompson


Henry S. Thompson  added the comment:

[One year and 2 days later... :-[

Is this fixed in 3.9?  If not, the Versions list above should be updated.

The failure of lower() to preserve 'alpha-ness' is a serious bug, it causes 
significant failures in e.g. Turkish NLP, and it's _not_ just a failure of the 
documentation!

Please can we move this to category Unicode and get at least this aspect of the 
problem fixed?  Should I raise a separate issue on isalpha() etc.?

--

___
Python tracker 

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



[issue39350] Remove deprecated fractions.gcd()

2020-01-31 Thread Miro Hrončok

Miro Hrončok  added the comment:

Reproducer:

class myint(int):
def __mul__(self, other):
return type(self)(int(self)*int(other))
@property
def numerator(self):
return type(self)(super().numerator)
@property
def denominator(self):
return type(self)(super().denominator)


Before:

>>> fractions.Fraction(myint(1), myint(2))
Fraction(1, 2)


After:

>>> fractions.Fraction(myint(1), myint(2))
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib64/python3.9/fractions.py", line 164, in __new__
g = _gcd(numerator, denominator)
NameError: name '_gcd' is not defined

--

___
Python tracker 

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



[issue39350] Remove deprecated fractions.gcd()

2020-01-31 Thread Miro Hrončok

Miro Hrončok  added the comment:

I believe there is a regression here.

numpy fails to build with Python 3.9.0a3.

 TestMatmul.test_matmul_object _
self = 
def test_matmul_object(self):
import fractions

f = np.vectorize(fractions.Fraction)
def random_ints():
return np.random.randint(1, 1000, size=(10, 3, 3))
>   M1 = f(random_ints(), random_ints())
f  = 
fractions  = 
random_ints = .random_ints at 
0x7ff9bcc2d700>
self   = 
numpy/core/tests/test_multiarray.py:6259: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
numpy/lib/function_base.py:2091: in __call__
return self._vectorize_call(func=func, args=vargs)
numpy/lib/function_base.py:2161: in _vectorize_call
ufunc, otypes = self._get_ufunc_and_otypes(func=func, args=args)
numpy/lib/function_base.py:2121: in _get_ufunc_and_otypes
outputs = func(*inputs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
cls = , numerator = 483, denominator = 809
def __new__(cls, numerator=0, denominator=None, *, _normalize=True):
"""Constructs a Rational.

Takes a string like '3/2' or '1.5', another Rational instance, a
numerator/denominator pair, or a float.

Examples


>>> Fraction(10, -8)
Fraction(-5, 4)
>>> Fraction(Fraction(1, 7), 5)
Fraction(1, 35)
>>> Fraction(Fraction(1, 7), Fraction(2, 3))
Fraction(3, 14)
>>> Fraction('314')
Fraction(314, 1)
>>> Fraction('-35/4')
Fraction(-35, 4)
>>> Fraction('3.1415') # conversion from numeric string
Fraction(6283, 2000)
>>> Fraction('-47e-2') # string may include a decimal exponent
Fraction(-47, 100)
>>> Fraction(1.47)  # direct construction from float (exact conversion)
Fraction(6620291452234629, 4503599627370496)
>>> Fraction(2.25)
Fraction(9, 4)
>>> Fraction(Decimal('1.47'))
Fraction(147, 100)

"""
self = super(Fraction, cls).__new__(cls)

if denominator is None:
if type(numerator) is int:
self._numerator = numerator
self._denominator = 1
return self

elif isinstance(numerator, numbers.Rational):
self._numerator = numerator.numerator
self._denominator = numerator.denominator
return self

elif isinstance(numerator, (float, Decimal)):
# Exact conversion
self._numerator, self._denominator = 
numerator.as_integer_ratio()
return self

elif isinstance(numerator, str):
# Handle construction from strings.
m = _RATIONAL_FORMAT.match(numerator)
if m is None:
raise ValueError('Invalid literal for Fraction: %r' %
 numerator)
numerator = int(m.group('num') or '0')
denom = m.group('denom')
if denom:
denominator = int(denom)
else:
denominator = 1
decimal = m.group('decimal')
if decimal:
scale = 10**len(decimal)
numerator = numerator * scale + int(decimal)
denominator *= scale
exp = m.group('exp')
if exp:
exp = int(exp)
if exp >= 0:
numerator *= 10**exp
else:
denominator *= 10**-exp
if m.group('sign') == '-':
numerator = -numerator

else:
raise TypeError("argument should be a string "
"or a Rational instance")

elif type(numerator) is int is type(denominator):
pass # *very* normal case

elif (isinstance(numerator, numbers.Rational) and
isinstance(denominator, numbers.Rational)):
numerator, denominator = (
numerator.numerator * denominator.denominator,
denominator.numerator * numerator.denominator
)
else:
raise TypeError("both arguments should be "
"Rational instances")

if denominator == 0:
raise ZeroDivisionError('Fraction(%s, 0)' % numerator)
if _normalize:
if type(numerator) is int is type(denominator):
# *very* normal case
g = math.gcd(numerator, denominator)
if denominator < 0:
g = -g
else:
>   g = _gcd(numerator, denominator)
E 

[issue39479] [RFE] Add math.lcm() function: Least Common Multiple

2020-01-31 Thread Vedran Čačić

Vedran Čačić  added the comment:

And yeah, I managed to leave out 2. Speaking about "often implemented wrong"... 
:-))

--

___
Python tracker 

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



[issue39479] [RFE] Add math.lcm() function: Least Common Multiple

2020-01-31 Thread Vedran Čačić

Vedran Čačić  added the comment:

is_prime that's always correct is probably not the right thing to go into math. 
Besides, now we have isqrt, it's just

n>1 and n&1 and all(n%d for d in range(3,isqrt(n)+1,2))

-- yes, it's damn slow, but so is everything else you want to be absolutely 
correct. :-]

is_probable_prime is another matter, but there is an enormous amount of 
bikeshedding about the API of that one.

--

___
Python tracker 

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



[issue21622] ctypes.util incorrectly fails for libraries without DT_SONAME

2020-01-31 Thread Natanael Copa


Change by Natanael Copa :


--
nosy: +ncopa

___
Python tracker 

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



[issue39505] redundant ‘/’ in $env:VIRTUAL_ENV when use venv in powershell

2020-01-31 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +vinay.sajip

___
Python tracker 

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



[issue39483] Proposial add loop parametr to run in asyncio

2020-01-31 Thread Андрей Казанцев

Андрей Казанцев  added the comment:

Where can I find issue which you are discussing for this thread?

--
resolution: rejected -> 
status: closed -> open

___
Python tracker 

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



[issue39506] operator |= on sets does not behave like the update method

2020-01-31 Thread Ammar Askar


Ammar Askar  added the comment:

Take a look at 
https://docs.python.org/3/faq/programming.html#why-am-i-getting-an-unboundlocalerror-when-the-variable-has-a-value

What's happening is that because `a |= x` is treated as an assignment, i.e `a = 
a | x`. The compiler treats it as a local variable, but since it hasn't been 
initialized in inner() before it reaches `a |= set(["A"])` it fails with 
UnboundLocalError.

--
nosy: +ammar2
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



[issue39479] [RFE] Add math.lcm() function: Least Common Multiple

2020-01-31 Thread STINNER Victor


STINNER Victor  added the comment:

I dislike the idea of adding a is_prime() function in Python since users will 
likely stress Python with huge numbers and then complain that Python is too 
slow. Correct is_prime() is very slow for large numbers, and statistically 
approach is not 100% correct... Or we may have to add both approaches. But then 
you have to pick an algorithm which would fit "most use cases".

I concur with Tim, it would be better to put such opinionated code on PyPI ;-)

--

I'm -0 on adding math.lcm(). For example, I failed to find any request to add 
such function on python-ideas archives. This issue seems to be the first user 
request.

I'm not opposed to add it. Some people seem to like the idea of the 
completeness of the stdlib (gcd & lcm go together). So if someone wants to add 
it, go ahead and propose a PR :-)

--

___
Python tracker 

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



[issue39506] operator |= on sets does not behave like the update method

2020-01-31 Thread Gabriele Tornetta


New submission from Gabriele Tornetta :

def outer():
  a=set()
  def inner():
a |= set(["A"])
  inner()
  return a

print(outer())

Traceback (most recent call last):
  File "main.py", line 8, in 
print(outer())
  File "main.py", line 5, in outer
inner()
  File "main.py", line 4, in inner
a |= set(["A"])
UnboundLocalError: local variable 'a' referenced before assignment

However, the update method works as expected:

def outer():
  a=set()
  def inner():
a.update(set(["A"]))
  inner()
  return a

print(outer())

{'A'}

--
components: Interpreter Core
messages: 361097
nosy: Gabriele Tornetta
priority: normal
severity: normal
status: open
title: operator |= on sets does not behave like the update method
type: behavior
versions: Python 3.6, 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



[issue39483] Proposial add loop parametr to run in asyncio

2020-01-31 Thread Andrew Svetlov


Andrew Svetlov  added the comment:

Explicit error is better than error-prone design.
Think that we will deprecate asyncio.get_event_loop() and the loop 
instantiation on-demand in the main thread.

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



[issue39505] redundant ‘/’ in $env:VIRTUAL_ENV when use venv in powershell

2020-01-31 Thread Fuzheng Duan


Change by Fuzheng Duan :


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

___
Python tracker 

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



[issue18233] SSLSocket.getpeercertchain()

2020-01-31 Thread Nathaniel Smith


Nathaniel Smith  added the comment:

I'm not sure I agree about assuming that users will be able to work around 
these issues... I mean, nothing personal, I'm sure you're well-informed and 
maybe your code would work fine, but if you don't understand my example then 
how can you be entirely confident that you really understand all the risks that 
your code needs to watch out for?

Anyway, the proposed PR exposes both methods, so that's not a problem; it's 
just waiting on someone with openssl expertise like Christian to review it.

--

___
Python tracker 

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



[issue39505] redundant ‘/’ in $env:VIRTUAL_ENV when use venv in powershell

2020-01-31 Thread Fuzheng Duan

New submission from Fuzheng Duan :

When windows users use "python -m venv ENV_DIR", a python virtual environment 
will be created in ENV_DIR. 
Powershell users use ENV_DIR\Scripts\Activate.ps1 to activate virtual 
environment.
In powershell, a environment variable, "$env:VIRTUAL_ENV", is set and used by 
many tools to determine that there is an activated venv. In bash, it is 
"$VIRTUAL_ENV"
In python3.8 and python3.9, $env:VIRTUAL_ENV has a redundant '/', for example:
PS C:\Users\Test> python -m venv test_venv
PS C:\Users\Test> .\test_venv\Scripts\Activate.ps1
PS C:\Users\Test> $env:VIRTUAL_ENV
C:\Users\Test\test_venv/

using python3.7, or using virtualenv with python3.8 or 3.9, or in linux, there 
will be no such a '/' in the end.

This '/' matters because some tools many tools use this environment variable, 
for example, oh-my-posh will take "test_venv/" as virtual environment name 
rather than "test_venv"(Although venv's activate.ps 1 itself's default prompt 
is correct). And from the perspective of semantics and consistency with other 
platform, the '/' is redundant.

--
components: Library (Lib)
messages: 361094
nosy: Schwarzichet
priority: normal
severity: normal
status: open
title: redundant ‘/’ in $env:VIRTUAL_ENV when use venv in powershell
type: behavior
versions: Python 3.8, Python 3.9

___
Python tracker 

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