[issue39660] Contextvars: Optional callbacks on state change

2020-02-16 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +yselivanov

___
Python tracker 

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



[issue33604] HMAC default to MD5 marked as to be removed in 3.6

2020-02-16 Thread Gregory P. Smith


Gregory P. Smith  added the comment:

Noted, but making it a keyword only argument would break a lot of existing code 
that has always just been passing three positional args.  Needless pain.

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



[issue39652] sqlite3 bug handling column names that contain square braces

2020-02-16 Thread Simon Willison


Simon Willison  added the comment:

Oh how interesting - yes it looks like this is deliberate behavior introduced 
in this commit: 
https://github.com/python/cpython/commit/0e3f591aeeef9ed715f8770320f4c4c7332a8794

--

___
Python tracker 

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



[issue39660] Contextvars: Optional callbacks on state change

2020-02-16 Thread Leonard Lausen


New submission from Leonard Lausen :

contextvars provide APIs to manage, store, and access context-local state.

Unfortunately, if Python is used as a frontend for a native libray (eg accessed 
via ctypes), and in case that the state of interest is managed in the native 
library, contextvar API is insufficient.

To support native libraries, instead of simply exposing the current state via 
`contextvar.get()`, contextvar API could allow specification of callbacks to 
update the state in the native library.

--
messages: 362118
nosy: leezu
priority: normal
severity: normal
status: open
title: Contextvars: Optional callbacks on state change
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



[issue39652] sqlite3 bug handling column names that contain square braces

2020-02-16 Thread Raul Gallegos


Raul Gallegos  added the comment:

Thanks for reporting this issue, I have a PR here 
https://github.com/python/cpython/pull/18533 but that still needs some 
clarification, because there were some tests that were actually testing that we 
were stripping everything after the square brackets.

P.D. this is my first contribution :)

--
nosy: +elrull

___
Python tracker 

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



[issue39652] sqlite3 bug handling column names that contain square braces

2020-02-16 Thread Roundup Robot


Change by Roundup Robot :


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

___
Python tracker 

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



[issue38857] AsyncMock issue with awaitable return_value/side_effect/wraps

2020-02-16 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +xtreak

___
Python tracker 

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



[issue38857] AsyncMock issue with awaitable return_value/side_effect/wraps

2020-02-16 Thread Dima Tisnek


Dima Tisnek  added the comment:

I think this deserves discussion :)

On one hand, it's a welcome change, on another it's kind of a regression.

Up until 3.8, our tests used to look like this:

---
# code under test

async def foo():
return await bar()


# test

async def helper(value):
return value


async def test_foo():
with patch("bar", return_value=helper(42)):
assert await foo() == 42
---

I feel that the default class `patch()` uses for `new` has crept in too quietly 
in 3.8.

At the same time, `helper` was only used because there was no `AsyncMock`.
(or at times, a 3rd party library, `asynctest` was used).



So, on one hand, it's a bit of a regression, but on the other, looking ahead, I 
would really like `unittest.mock` to do the right thing.



Can we have it both ways? If not, what way is a better way?

--
nosy: +Dima.Tisnek

___
Python tracker 

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



[issue39659] pathlib calls `os.getcwd()` without using accessor

2020-02-16 Thread Barney Gale


New submission from Barney Gale :

Whereas most calls to `os` functions from `pathlib.Path` methods happen via 
`pathlib._Accessor` methods, retrieving the current working directory does not. 
This problem occurs when calling the `pathlib.Path.cwd()`, `~resolve()` and 
`~absolute()` methods.

--
components: Library (Lib)
messages: 362114
nosy: barneygale
priority: normal
severity: normal
status: open
title: pathlib calls `os.getcwd()` without using accessor
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



[issue39617] max_workers argument to concurrent.futures.ProcessPoolExecutor is not flexible enough

2020-02-16 Thread sds


sds  added the comment:

I don't think you need this complexity - just keep the pool max size and submit 
jobs only when the loadavg drops below the threshold.
See my implementation attached.

--
Added file: https://bugs.python.org/file48898/run-at-load-avg.py

___
Python tracker 

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



[issue27873] multiprocessing.pool.Pool.map should take more than one iterable

2020-02-16 Thread Kyle Stanley


Kyle Stanley  added the comment:

> Can this issue be closed, I see it was merged successfully?

Yep, I'll go ahead and close the issue now. Thanks for the reminder; I got 
caught up in a few other projects.

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



[issue39649] bdb.Bdb.format_stack_entry: checks for obsolete __args__

2020-02-16 Thread daniel hahler


daniel hahler  added the comment:

Sure: https://github.com/python/cpython/pull/18531

--

___
Python tracker 

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



[issue39649] bdb.Bdb.format_stack_entry: checks for obsolete __args__

2020-02-16 Thread daniel hahler


Change by daniel hahler :


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

___
Python tracker 

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



[issue39645] Expand concurrent.futures.Future's public API

2020-02-16 Thread Guido van Rossum


Guido van Rossum  added the comment:

I'll leave it to Brian and/or Antoine to review this. Good luck!

--

___
Python tracker 

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



[issue39649] bdb.Bdb.format_stack_entry: checks for obsolete __args__

2020-02-16 Thread Guido van Rossum


Guido van Rossum  added the comment:

That seems to be a correct observation. @blueyed, do you want to submit a PR to 
gt rid of the redundant check?

--

___
Python tracker 

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



[issue39658] Include user scripts folder to PATH on Windows

2020-02-16 Thread Luca

New submission from Luca :

When installing Python on Windows, and selecting the option “Add Python to 
PATH”, the following folders are added to the "PATH" environment variable:
- C:\Users\[username]\AppData\Local\Programs\Python\Python38\Scripts\
- C:\Users\[username]\AppData\Local\Programs\Python\Python38\
However also the following folder should be added, _before_ the other two:
- C:\Users\[username]\AppData\Roaming\Python\Python38\Scripts\
This is needed to correctly expose scripts of packages installed with `pip 
install --user` (`pip` emits a warning when installing a script with `--user` 
flag if that folder is not in "PATH").

--
components: Installation
messages: 362108
nosy: lucatrv
priority: normal
severity: normal
status: open
title: Include user scripts folder to PATH on Windows

___
Python tracker 

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



[issue27657] urlparse fails if the path is numeric

2020-02-16 Thread Senthil Kumaran


Senthil Kumaran  added the comment:


New changeset ea316fd21527dec53e704a5b04833ac462ce3863 by Senthil Kumaran in 
branch '3.8':
Revert "[3.8] bpo-27657: Fix urlparse() with numeric paths (GH-16839)" 
(GH-18525)
https://github.com/python/cpython/commit/ea316fd21527dec53e704a5b04833ac462ce3863


--

___
Python tracker 

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



[issue39657] Bezout and Chinese Remainder Theorem in the Standard Library?

2020-02-16 Thread Dennis Sweeney


New submission from Dennis Sweeney :

Should something like the following go in the standard library, most likely in 
the math module? I know I had to use such a thing before pow(a, -1, b) worked, 
but Bezout is more general. And many of the easy stackoverflow implementations 
of CRT congruence-combining neglect the case where the divisors are not 
coprime, so that's an easy thing to miss. 

def bezout(a, b):
"""
Given integers a and b, return a tuple (x, y, g),
where x*a + y*b == g == gcd(a, b).
"""
# Apply the Extended Euclidean Algorithm:
# use the normal Euclidean Algorithm on the RHS
# of the equations
# u1*a + v1*b == r1
# u2*a + v2*b == r2
# But carry the LHS along for the ride.
u1, v1, r1 = 1, 0, a
u2, v2, r2 = 0, 1, b

while r2:
q = r1 // r2
u1, u2 = u2, u1-q*u2
v1, v2 = v2, v1-q*v2
r1, r2 = r2, r1-q*r2
assert u1*a + v1*b == r1
assert u2*a + v2*b == r2

if r1 < 0:
u1, v1, r1 = -u1, -v1, -r1

# a_coefficient, b_coefficient, gcd
return (u1, v1, r1)

def crt(cong1, cong2):
"""
Apply the Chinese Remainder Theorem:
If there are any integers x such that 
x == a1 (mod n1) and x == a2 (mod n2),
then there are integers a and n such that the
above congruences both hold iff x == a (mod n)
Given two compatible congruences (a1, n1), (a2, n2),
return a single congruence (a, n) that is equivalent
to both of the given congruences at the same time.

Not all congruences are compatible. For example, there
are no solutions to x == 1 (mod 2) and x == 2 (mod 4).
For congruences (a1, n1), (a2, n2) to be compatible, it
is sufficient, but not necessary, that gcd(n1, n2) == 1.
"""
a1, n1 = cong1
a2, n2 = cong2
c1, c2, g = bezout(n1, n2)
assert n1*c1 + n2*c2 == g

if (a1 - a2) % g != 0:
raise ValueError(f"Incompatible congruences {cong1} and {cong2}.")

lcm = n1 // g * n2
rem = (a1*c2*n2 + a2*c1*n1)//g
return rem % lcm, lcm

assert crt((1,4),(2,3)) == (5, 12)
assert crt((1,6),(7,4)) == (7, 12)

--
components: Library (Lib)
messages: 362106
nosy: Dennis Sweeney
priority: normal
severity: normal
status: open
title: Bezout and Chinese Remainder Theorem in the Standard Library?
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



[issue39655] Shared_Memory attaching to incorrect Address in Windows 10

2020-02-16 Thread Eryk Sun


Eryk Sun  added the comment:

shared_memory is not the problem here. Your example assumes that a.dtype is 
int64, but a numpy array defaults to "the minimum type required to hold the 
objects in the sequence", and the actual minimum depends on the size of the 
platform `long`. In Windows, a `long` is always 32-bit, regardless of whether 
the process is 32-bit or 64-bit. If [1, 1], [2, 3], and [5, 8]  are stored as 
int32 values, then we have the following values when unpacked as 64-bit:

>>> int.from_bytes(b'\x01\x00\x00\x00\x01\x00\x00\x00', 'little')
4294967297
>>> int.from_bytes(b'\x02\x00\x00\x00\x03\x00\x00\x00', 'little')
12884901890
>>> int.from_bytes(b'\x05\x00\x00\x00\x08\x00\x00\x00', 'little')
34359738373

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



[issue39382] abstract_issubclass() doesn't take bases tuple item ref

2020-02-16 Thread Yonatan Goldschmidt


Change by Yonatan Goldschmidt :


--
pull_requests: +17906
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/18530

___
Python tracker 

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



[issue39244] multiprocessing.get_all_start_methods() wrong default on macOS

2020-02-16 Thread Ido Michael


Ido Michael  added the comment:

Fixed the bug to default any macos into 'spawn'
PR: GH-18529

--
nosy: +Ido Michael

___
Python tracker 

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



[issue39244] multiprocessing.get_all_start_methods() wrong default on macOS

2020-02-16 Thread Ido Michael


Change by Ido Michael :


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

___
Python tracker 

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



[issue27657] urlparse fails if the path is numeric

2020-02-16 Thread Senthil Kumaran


Senthil Kumaran  added the comment:


New changeset 505b6015a1579fc50d9697e4a285ecc64976397a by Senthil Kumaran in 
branch '3.7':
Revert "bpo-27657: Fix urlparse() with numeric paths (GH-661)" (#18526)
https://github.com/python/cpython/commit/505b6015a1579fc50d9697e4a285ecc64976397a


--

___
Python tracker 

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



[issue37970] urllib.parse docstrings incomplete

2020-02-16 Thread Ido Michael


Ido Michael  added the comment:

Tal, I can also fix that so we can close this issue.
Are you talking about the Doc/library/urllib.parse.rst file?

--

___
Python tracker 

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



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

2020-02-16 Thread Ned Deily


Ned Deily  added the comment:

As noted in the review of the PR, keep in mind that tests are included in an 
installed Python instance; there is a list of test directories in the main 
Makefile (Makefile.pre.in) that is used by "make install".  Any movement of 
test directories thus needs to update the Makefile and test with an installed 
Python.

That said, I'm not sure what this buys us. And are any of the moved tests 
inherited from third-party packages that we've semi-vendorized into the cpython 
repo?

--

___
Python tracker 

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



[issue39648] Update math.gcd() to accept "n" arguments.

2020-02-16 Thread Dennis Sweeney


Dennis Sweeney  added the comment:

Correction correction: returning zero preserves the invariant below.

from math import gcd as GCD
from functools import reduce
from itertools import starmap, chain

def gcd(*args):
return reduce(GCD, args, 0)

iterables = [[10, 20, 30],
 [],
 [0, 0, 0],
 [5],
 [-15, -1000]]

a = gcd(*chain.from_iterable(iterables))
b = gcd(*starmap(gcd, iterables))
assert a == b == 5

--

___
Python tracker 

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



[issue39648] Update math.gcd() to accept "n" arguments.

2020-02-16 Thread Dennis Sweeney


Dennis Sweeney  added the comment:

Correction: gcd(itertools.chain(iterables)) == gcd(*map(gcd, iterables))

--

___
Python tracker 

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



[issue39648] Update math.gcd() to accept "n" arguments.

2020-02-16 Thread Dennis Sweeney


Dennis Sweeney  added the comment:

I think the behavior of gcd() == 0 is correct, but it should be documented, 
because it isn't completely obvious.

Arguments for gcd() == 0:

- Preserves the invariant gcd(itertools.chain(iterables)) == 
gcd(itertools.starmap(gcd, iterables)) in the case that some iterables are 
empty.

- Return a "neutral element" (not technically true for negative integers 
because gcd(0, a) == abs(a) != a, but it does get "ignored")

Other considerations:

- The "common divisors" of the empty set are the integers d such that for all x 
in the empty set, d divides x, which is to say, all of the integers. Then there 
is no greatest of these common divisors. The same is true if we try gcd(0, 0, 
... 0).

- The above is only fixed if we interpret "greatest" in the sense of 
divisibility, where 0 > everything because everything divides 0. In particular, 
we can say that g is a greatest common divisor of a_1, ..., a_n if g | a_i for 
all i, and for any d with d | a_i for all i, we also have d | g. Using this 
definition also requires that we specify that if there are two gcds, we return 
the positive one.
I believe this is the correct interpretation, but it may not be obvious, since 
it assumes that proof that such a number even exists.

- Another common definition of the greatest common divisor of {a_1, ..., a_n} 
is the smallest positive integer expressible as an integer linear combination 
x_1 a_1 + ... + x_1 a_2, where x_i are integers. But this definition breaks on 
gcd(), gcd(0), gcd(0, 0), etc, since no positive integers are expressible.

In short, while I agree with the behavior, I think there should be a clarifying 
sentence in the docs saying "returns 0 if all of the arguments are 0".

--
nosy: +Dennis Sweeney

___
Python tracker 

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



[issue39244] multiprocessing.get_all_start_methods() wrong default on macOS

2020-02-16 Thread Tal Einat


Tal Einat  added the comment:

Good catch, Stefen!

This seems like we forgot to update multiprocessing.get_all_start_methods() 
when making the change to make "spawn" the default on macOS. I suggest updating 
it accordingly.

--
keywords: +newcomer friendly
nosy: +taleinat
stage:  -> needs patch

___
Python tracker 

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



[issue39655] Shared_Memory attaching to incorrect Address in Windows 10

2020-02-16 Thread Orwell


Change by Orwell :


--
title: Shared_Memory attaching to incorrect Address in Windows -> Shared_Memory 
attaching to incorrect Address in Windows 10

___
Python tracker 

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



[issue37970] urllib.parse docstrings incomplete

2020-02-16 Thread Tal Einat


Tal Einat  added the comment:

Ido Michael's PR GH-16458, which I've just merged, addresses the issues brought 
up here regarding the doc-strings.

>From the discussion it seems that the documentation of these functions should 
>be updated as well. I'll leave this issue open until that's done as well.

--

___
Python tracker 

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



[issue39656] shebanged scripts can escape from `venv` depending on how it was created

2020-02-16 Thread Anthony Sottile


New submission from Anthony Sottile :

This is distilled from a larger example to be small/silly, however this caused 
real problems

A script which was intended for python3.6 exactly was written as follows:

```
#!/usr/bin/env python3.6
...
```

when creating a virtualenv with `python3.6 -m venv venv36` you end up with 
`python` / `python3` / `python3.6` executables in the venv

however, when creating a virtualenv with `python3 -m venv venv36` you only end 
up with `python` / `python3` executables

___

using `-mvirtualenv` (pypa/virtualenv) instead of venv, all three are reliably 
created

___

the fix is fairly straightforward, adding `f'python3.{sys.version_info[0]}'` to 
this tuple: 
https://github.com/python/cpython/blob/c33bdbb20cf55b3a2aa7a91bd3d91fcb59796fad/Lib/venv/__init__.py#L246

--
components: Library (Lib)
messages: 362095
nosy: Anthony Sottile
priority: normal
severity: normal
status: open
title: shebanged scripts can escape from `venv` depending on how it was created
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



[issue37970] urllib.parse docstrings incomplete

2020-02-16 Thread Tal Einat


Tal Einat  added the comment:


New changeset c33bdbb20cf55b3a2aa7a91bd3d91fcb59796fad by idomic in branch 
'master':
bpo-37970: update and improve urlparse and urlsplit doc-strings (GH-16458)
https://github.com/python/cpython/commit/c33bdbb20cf55b3a2aa7a91bd3d91fcb59796fad


--
nosy: +taleinat

___
Python tracker 

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



[issue39655] Shared_Memory attaching to incorrect Address in Windows

2020-02-16 Thread Orwell


New submission from Orwell :

Shared Memory is attaching to incorrect memory location ,
ex : retried the documentation example.

>>> import numpy as np
>>> a = np.array([1, 1, 2, 3, 5, 8])
>>> from multiprocessing import shared_memory
>>> shm = shared_memory.SharedMemory(create=True, size=a.nbytes)
>>> b = np.ndarray(a.shape, dtype=a.dtype, buffer=shm.buf)
>>> b[:] = a[:]
>>> b
array([1, 1, 2, 3, 5, 8])
>>> type(b)

>>> type(a)

>>> shm.name
'wnsm_62040dca'
>>> shm.buf


# In either the same shell or a new Python shell on the same machine

>>> import numpy as np
>>> from multiprocessing import shared_memory
>>> existing_shm = shared_memory.SharedMemory(name='wnsm_62040dca')
>>> c = np.ndarray((6,), dtype=np.int64, buffer=existing_shm.buf)
>>> c
array([ 4294967297, 12884901890, 34359738373,   0,   0,
 0], dtype=int64)
>>> c[-1]
0
>>> existing_shm.buf


--
components: Windows
messages: 362093
nosy: OH, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: Shared_Memory attaching to incorrect Address in Windows
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



[issue39648] Update math.gcd() to accept "n" arguments.

2020-02-16 Thread Tim Peters


Tim Peters  added the comment:

This is almost all down to pragmatics for me.

For sum() and prod(), if there are only two operands then there are trivial 
other ways to spell that (+ and *).  So it makes most sense for them to accept 
iterables instead.  Essentially, e.g., nobody would ever _want_ to write sum(2, 
3) instead of 2+3.

max() and min() differ in that there is no other simple way to write the 
2-argument forms.  max(x, y) _is_ commonly wanted - but so is max(iterable).  
It's a weird function signature, but nearly always does what's intended.

gcd() (and lcm()!) differ from both in that they're nearly always wanted with 2 
arguments.  "0, 1, or >= 3 arguments" are possibilities, but rarely wanted.  It 
would be a PITA to need to write, e.g., gcd((x, y)) instead of gcd(x, y) for 
the overwhelmingly most common 2-argument case.  So they should be *args 
functions - provided we want to cater directly to "0, 1, or >= 3 arguments" at 
all.  Fine by me if we don't.  I'm only +0 on generalizing beyond "exactly 2 
arguments".

For the rest, I agree with Mark.  In particular, gcd() must be 0.

Serhiy, a "bulk" gcd can be more efficient than nested function calls by 
exploiting a common case:  it can get out early when the gcd-so-far becomes 1 
(since gcd(1, anything) == 1, it doesn't matter what the remaining arguments 
are).  For "random" integers, it's already the case that gcd(i, j) == 1 over 
60% of the time.

--

___
Python tracker 

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



[issue39654] pyclbr: remove old references to class browser & add explain readmodule

2020-02-16 Thread Batuhan Taskaya


New submission from Batuhan Taskaya :

This is something revealed during issue 39411. As @terry.reedy commented 
pyclbr's scope is extended to functions and classes instead of just classes.

--
nosy: +BTaskaya, terry.reedy

___
Python tracker 

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



[issue39654] pyclbr: remove old references to class browser & add explain readmodule

2020-02-16 Thread Hakan


Change by Hakan :


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

___
Python tracker 

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



[issue39654] pyclbr: remove old references to class browser & add explain readmodule

2020-02-16 Thread Hakan


Change by Hakan :


--
assignee: docs@python
components: Documentation
nosy: docs@python, hakancelik
priority: normal
severity: normal
status: open
title: pyclbr: remove old references to class browser & add explain readmodule
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



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

2020-02-16 Thread Ido Michael


Ido Michael  added the comment:

Moved all 6 modules tests under Lib/test/MODULE_NAME_test
Created this PR: GH-18524

--

___
Python tracker 

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



[issue27657] urlparse fails if the path is numeric

2020-02-16 Thread Senthil Kumaran


Change by Senthil Kumaran :


--
pull_requests: +17903
pull_request: https://github.com/python/cpython/pull/18526

___
Python tracker 

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



[issue27657] urlparse fails if the path is numeric

2020-02-16 Thread Senthil Kumaran


Change by Senthil Kumaran :


--
keywords: +patch
pull_requests: +17902
stage: commit review -> patch review
pull_request: https://github.com/python/cpython/pull/18525

___
Python tracker 

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



[issue39104] ProcessPoolExecutor hangs on shutdown nowait with pickling failure

2020-02-16 Thread Antoine Pitrou


Antoine Pitrou  added the comment:

Thank you Thomas. Ii'd rather not backport delicate changes, so closing now.

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
type:  -> behavior
versions:  -Python 3.7, Python 3.8

___
Python tracker 

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



[issue39104] ProcessPoolExecutor hangs on shutdown nowait with pickling failure

2020-02-16 Thread miss-islington


miss-islington  added the comment:


New changeset a5cbab552d294d99fde864306632d7e511a75d3c by Thomas Moreau in 
branch 'master':
bpo-39104: Fix hanging ProcessPoolExecutor on shutdown nowait with pickling 
failure (GH-17670)
https://github.com/python/cpython/commit/a5cbab552d294d99fde864306632d7e511a75d3c


--
nosy: +miss-islington

___
Python tracker 

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



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

2020-02-16 Thread Ido Michael


Change by Ido Michael :


--
pull_requests: +17901
pull_request: https://github.com/python/cpython/pull/18524

___
Python tracker 

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



[issue39128] Document happy eyeball parameters in loop.create_connection signature docs

2020-02-16 Thread Ido Michael


Ido Michael  added the comment:

Created 2nd PR with the Algorithm documentation:
GH-18523

--

___
Python tracker 

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



[issue39128] Document happy eyeball parameters in loop.create_connection signature docs

2020-02-16 Thread Ido Michael


Change by Ido Michael :


--
pull_requests: +17900
pull_request: https://github.com/python/cpython/pull/18523

___
Python tracker 

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



[issue35885] configparser: indentation

2020-02-16 Thread Ido Michael


Ido Michael  added the comment:

Created PR GH-18522

--

___
Python tracker 

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



[issue35885] configparser: indentation

2020-02-16 Thread Ido Michael


Change by Ido Michael :


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

___
Python tracker 

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



[issue39573] Make PyObject an opaque structure in the limited C API

2020-02-16 Thread Dong-hee Na


Change by Dong-hee Na :


--
pull_requests: +17898
pull_request: https://github.com/python/cpython/pull/18521

___
Python tracker 

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



[issue27873] multiprocessing.pool.Pool.map should take more than one iterable

2020-02-16 Thread Ido Michael


Ido Michael  added the comment:

Can this issue be closed, I see it was merged successfully?

--

___
Python tracker 

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



[issue39653] test_posix fails during make test

2020-02-16 Thread Zachary


New submission from Zachary :

Forgive me, for I am a newb and this is the first Python issue I have ever 
created.

My system:
Linux debian-thinkpad 4.9.0-12-amd64 #1 SMP Debian 4.9.210-1 (2020-01-20) 
x86_64 GNU/Linux

While attempting to run "make test" test_posix failed. As you can see in the 
output apparently test_posix.py can't find a directory.

I'm not sure if I can paste output here without it being illegible so I'm 
putting it in a paste:
https://pastebin.com/xfqEzKiw

--
components: Installation
messages: 362084
nosy: jaguardown
priority: normal
severity: normal
status: open
title: test_posix fails during make test
type: compile error
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



[issue39648] Update math.gcd() to accept "n" arguments.

2020-02-16 Thread Mark Dickinson


Mark Dickinson  added the comment:

What's slightly more interesting is the return value for a single argument  
`a`, where we should be careful to return `abs(a)` rather than simply `a`.

--

___
Python tracker 

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



[issue39648] Update math.gcd() to accept "n" arguments.

2020-02-16 Thread Mark Dickinson


Mark Dickinson  added the comment:

> Should it take variable number of positional arguments or a single iterable 
> argument as max() and min()?

Good question: the obvious extension to the current function would be to allow 
it to take multiple scalar arguments. But I don't much like the mismatch that 
introduces with `sum` and `math.prod`, which accept a single iterable argument.

I *definitely* don't want to give `gcd` a combination API like the one `min` 
and `max` have.

> What should it return for 0 arguments?

That one's easy. It should return `0`. `0` is an identity for the binary `gcd` 
operation, and mathematically, the `gcd` is defined for *any* set of integers 
(finite or infinite), including the empty set. The gcd of the empty set is zero.

--

___
Python tracker 

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



[issue39652] sqlite3 bug handling column names that contain square braces

2020-02-16 Thread Simon Willison


Change by Simon Willison :


--
type:  -> behavior

___
Python tracker 

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



[issue39652] sqlite3 bug handling column names that contain square braces

2020-02-16 Thread Simon Willison


New submission from Simon Willison :

Bit of an obscure bug this one. SQLite allows column names to contain [ and ] 
characters, even though those are often used as delimiters in SQLite. Here's 
how to create such a database with bash:

```
sqlite3 /tmp/demo.db <
In [5]: cursor.fetchall()   
   
Out[5]: [('01.01.2016 00:00 - 01.01.2016 01:00', '23.86')]
In [6]: cursor.description  
   
Out[6]: 
(('MTU (CET)', None, None, None, None, None, None),
 ('Day-ahead Price', None, None, None, None, None, None))
In [7]: conn.row_factory = sqlite3.Row  
   
In [8]: cursor = conn.cursor()  
   
In [9]: cursor.execute("select * from data")
   
Out[9]: 
In [10]: row = cursor.fetchall()
 
In [12]: row
   
Out[12]: 
In [15]: row.keys() 
   
Out[15]: ['MTU (CET)', 'Day-ahead Price']
```
As you can see, it is missing from both `cursor.description` and from 
`row.keys()` here.

But... if you query that database using SQLite directly (with `.headers on` so 
you can see the name of the columns) it works as expected:
```
$ sqlite3 /tmp/demo.db 
SQLite version 3.24.0 2018-06-04 14:10:15
Enter ".help" for usage hints.
sqlite> .schema
CREATE TABLE IF NOT EXISTS "data" (
"MTU (CET)" TEXT,
"Day-ahead Price [EUR/MWh]" TEXT
);
sqlite> .headers on
sqlite> select * from data;
MTU (CET)|Day-ahead Price [EUR/MWh]
01.01.2016 00:00 - 01.01.2016 01:00|23.86
sqlite> 
```
It looks to me like this is a bug in Python's SQLite3 module.

This was first reported here: https://github.com/simonw/sqlite-utils/issues/86

--
components: Extension Modules
messages: 362081
nosy: simonw
priority: normal
severity: normal
status: open
title: sqlite3 bug handling column names that contain square braces
versions: Python 2.7, Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 3.9

___
Python tracker 

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



[issue39648] Update math.gcd() to accept "n" arguments.

2020-02-16 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Python as programming language provides builtin blocks. This is a good example 
of using functools.reduce().

But if you can provide an algorithm for calculating the GCD and LCM more 
efficient than sequential applying gcd() and lcm() for two arguments, it would 
be an argument for implementing it in the stdlib.

--

___
Python tracker 

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



[issue39648] Update math.gcd() to accept "n" arguments.

2020-02-16 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Should it take variable number of positional arguments or a single iterable 
argument as max() and min()?

What should it return for 0 arguments?

--

___
Python tracker 

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



[issue39651] Exceptions raised by EventLoop.call_soon_threadsafe

2020-02-16 Thread Ben Darnell


New submission from Ben Darnell :

Proactor and selector event loops behave differently when call_soon_threadsafe 
races with a concurrent call to loop.close(). In a selector event loop, 
call_soon_threadsafe will either succeed or raise a RuntimeError("Event loop is 
closed"). In a proactor event loop, it could raise this RuntimeError, but it 
can also raise an AttributeError due to an unguarded access to self._csock. 

https://github.com/python/cpython/blob/1ed61617a4a6632905ad6a0b440cd2cafb8b6414/Lib/asyncio/proactor_events.py#L785-L787

Comments in BaseSelectorEventLoop._write_to_self indicate that this is 
deliberate, so the `csock is not None` check here should probably be copied to 
the proactor event loop version.

https://github.com/python/cpython/blob/1ed61617a4a6632905ad6a0b440cd2cafb8b6414/Lib/asyncio/selector_events.py#L129-L136


I'd also accept an answer that the exact behavior of this race is undefined and 
it's up to the application to either arrange for all calls to 
call_soon_threadsafe to stop before closing the loop. However, I've had users 
of Tornado argue that they use the equivalent of call_soon_threadsafe in 
contexts where this coordination would be difficult, and I've decided that 
tornado's version of this method would never raise, even if there is a 
concurrent close. So if asyncio declines to specify which exceptions are 
allowed in this case, tornado will need to add a blanket `except Exception:` 
around calls to call_soon_threadsafe.

--
components: asyncio
messages: 362078
nosy: Ben.Darnell, asvetlov, yselivanov
priority: normal
severity: normal
status: open
title: Exceptions raised by EventLoop.call_soon_threadsafe
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



[issue39648] Update math.gcd() to accept "n" arguments.

2020-02-16 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

+1  This isn't hard for us to do and may be occasionally useful.

--
nosy: +rhettinger, tim.peters

___
Python tracker 

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



[issue39010] ProactorEventLoop raises unhandled ConnectionResetError

2020-02-16 Thread Ben Darnell


Ben Darnell  added the comment:

I just spent some time digging into this. Each call to `run_forever` starts a 
call to `_loop_self_reading`, then attempts to cancel it before returning:

https://github.com/python/cpython/blob/1ed61617a4a6632905ad6a0b440cd2cafb8b6414/Lib/asyncio/windows_events.py#L312-L325

The comment at line 321 is not entirely accurate: the future will not resolve 
in the future, but it may have *already* resolved, and added its callback to 
the call_soon queue. This callback will run if the event loop is restarted 
again. Since `_loop_self_reading` calls itself, this results in two copies of 
the "loop" running concurrently and stepping on each other's 
`_self_reading_futures`. 

This appears to be fairly harmless except for noise in the logs when only one 
of the loops is stopped cleanly.

I believe the simplest fix is for `_loop_self_reading` to compare its argument 
to `self._self_reading_future` to determine if it is the "current" loop and if 
not, don't reschedule anything.

--
nosy: +Ben.Darnell

___
Python tracker 

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



[issue39633] venv does not include python. symlink by default

2020-02-16 Thread Eryk Sun


Eryk Sun  added the comment:

> That means that libraries should assume they are being installed into
> venvs. Therefore makefiles should be invoking plain "python" rather
> than "pythonX.Y"

In Unix, 3.x virtual environments include a "python3" symlink or copy, even if 
created with a "python" command. A makefile that needs Python 3 can rely on 
running "python3" -- but only in Unix. Though someone using Unix tools in 
Windows (not Cygwin or MSYS2) must already be prepared for this.

--
nosy: +eryksun

___
Python tracker 

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



[issue39648] Update math.gcd() to accept "n" arguments.

2020-02-16 Thread SilentGhost


SilentGhost  added the comment:

You could (should?) use reduce, then:

>>> functools.reduce(math.gcd, (6, 30, 40, 60, 20, 40))
2

--
nosy: +SilentGhost

___
Python tracker 

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



[issue39648] Update math.gcd() to accept "n" arguments.

2020-02-16 Thread Ananthakrishnan


Ananthakrishnan  added the comment:

It will take more time to write the statement itself and there are chances of 
getting mistakes as the statement is complicated.

--

___
Python tracker 

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



[issue39650] Creating zip file where names in local header don't match with central header

2020-02-16 Thread Paul Marquess


New submission from Paul Marquess :

Consider this code (based on code from an issue on StackOverflow)

import zipfile
import os

allFilesToZip = ["/tmp/tom"]

with zipfile.ZipFile(allZipPath, 'w') as allZip:
for f in allFilesToZip:
allZip.write(f, compress_type=zipfile.ZIP_DEFLATED)
for zip_info in allZip.infolist():
if zip_info.filename[-1] == '/':
continue
zip_info.filename = os.path.basename(zip_info.filename)

The intention of the code is to add a number of files without the path 
component. The problem is with the use of infolist. (Forget for now that there 
is an easier way to achieve the expected result.)

The code works in two steps. First it uses the zipfile.write method which will 
immediately writes the local file header data and the compressed payload to the 
zipfile on disk. Next the zipinfo entry is used to update the filename. That 
data gets written only to the central directory in the zip file.

The end result is a badly-formed zip file.

Here is what I see when I run the code above with both Python 2.7 & 3.7. First 
create the zip file

echo abcd >/tmp/tom
python zip.py

Unzip sees there is a problem

$ unzip -t abc.zip
Archive:  abc.zip
tom:  mismatching "local" filename (tmp/tom),
 continuing with "central" filename version
testing: tom  OK
At least one warning-error was detected in abc.zip.

Next dump the internal structure of the zip file - Note the different filename 
fields output

$ zipdetails abc.zip

 LOCAL HEADER #1   04034B50
0004 Extract Zip Spec  14 '2.0'
0005 Extract OS00 'MS-DOS'
0006 General Purpose Flag  
 [Bits 1-2]0 'Normal Compression'
0008 Compression Method0008 'Deflated'
000A Last Mod Time 50487109 'Sat Feb  8 14:08:18 2020'
000E CRC   2CA20FEB
0012 Compressed Length 00D8
0016 Uncompressed Length   0180
001A Filename Length   0007
001C Extra Length  
001E Filename  'tmp/tom'
0025 PAYLOAD   eP...0.,m.F\?. .
   888)RbM.b..$R...YB./...Y...Nc...m{D.
   pyi.I<..J..G..{:o..'?3.#E.u.
   .).O.%d}V..0pz..Z..r]Bc;.U.u
   |:U.k.}.Zov..zUh.tm1...
   i.8CUA6.#...?.A8z...S..

00FD CENTRAL HEADER #1 02014B50
0101 Created Zip Spec  14 '2.0'
0102 Created OS03 'Unix'
0103 Extract Zip Spec  14 '2.0'
0104 Extract OS00 'MS-DOS'
0105 General Purpose Flag  
 [Bits 1-2]0 'Normal Compression'
0107 Compression Method0008 'Deflated'
0109 Last Mod Time 50487109 'Sat Feb  8 14:08:18 2020'
010D CRC   1234
0111 Compressed Length 00D8
0115 Uncompressed Length   0180
0119 Filename Length   0003
011B Extra Length  
011D Comment Length
011F Disk Start
0121 Int File Attributes   
 [Bit 0]   0 'Binary Data'
0123 Ext File Attributes   81B4
0127 Local Header Offset   
012B Filename  'tom'

012E END CENTRAL HEADER06054B50
0132 Number of this disk   
0134 Central Dir Disk no   
0136 Entries in this disk  0001
0138 Total Entries 0001
013A Size of Central Dir   0031
013E Offset to Central Dir 00FD
0142 Comment Length

Should zipfile allow the user to do this?

--
components: Library (Lib)
messages: 362072
nosy: pmqs
priority: normal
severity: normal
status: open
title: Creating zip file where names in local header don't match with central 
header
type: behavior
versions: Python 2.7, Python 3.7

___
Python tracker 

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



[issue39648] Update math.gcd() to accept "n" arguments.

2020-02-16 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

What problems it will create?

--

___
Python tracker 

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



[issue39649] bdb.Bdb.format_stack_entry: checks for obsolete __args__

2020-02-16 Thread SilentGhost


Change by SilentGhost :


--
nosy: +gvanrossum
versions:  -Python 2.7, Python 3.5, 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



[issue39649] bdb.Bdb.format_stack_entry: checks for obsolete __args__

2020-02-16 Thread daniel hahler


New submission from daniel hahler :

It does:
```
if '__args__' in frame.f_locals:
args = frame.f_locals['__args__']
else:
args = None
if args:
s += reprlib.repr(args)
else:
s += '()'
```

However that appears to be wrong/unnecessary since the following likely, but
maybe also others:

commit 75bb54c3d8
Author: Guido van Rossum 
Date:   Mon Sep 28 15:33:38 1998 +

Don't set a local variable named __args__; this feature no longer
works and Greg Ward just reported a problem it caused...

diff --git a/Lib/bdb.py b/Lib/bdb.py
index 3ca25adbbf..f2cf4caa36 100644
--- a/Lib/bdb.py
+++ b/Lib/bdb.py
@@ -46,7 +46,7 @@ def dispatch_line(self, frame):
return self.trace_dispatch

def dispatch_call(self, frame, arg):
-   frame.f_locals['__args__'] = arg
+   # XXX 'arg' is no longer used
if self.botframe is None:
# First call of dispatch since reset()
self.botframe = frame

Code ref: 
https://github.com/python/cpython/blob/1ed61617a4a6632905ad6a0b440cd2cafb8b6414/Lib/bdb.py#L551-L558.

So it should either get removed, or likely be replaced with actually displaying
the args.

For this the part could be factored out of `do_args` maybe, adjusting it for
handling non-current frames.

Of course somebody might inject/set `__args__` still (I've thought about doing 
that initially for pdb++, but will rather re-implement/override 
`format_stack_entry` instead), so support for this could be kept additionally.

--
components: Library (Lib)
messages: 362070
nosy: blueyed
priority: normal
severity: normal
status: open
title: bdb.Bdb.format_stack_entry: checks for obsolete __args__
type: behavior
versions: Python 2.7, Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 3.9

___
Python tracker 

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



[issue39648] Update math.gcd() to accept "n" arguments.

2020-02-16 Thread Ananthakrishnan


New submission from Ananthakrishnan :

If we have to find the gcd of three or more numbers, now we should use 
gcd(a, gcd(b, gcd(c, gcd(d, e)
which will create lot of problems.

math.gcd should take "n" number of arguments,like:

gcd(a,b,c,)

gcd(4,6,8)//returns 2
gcd(2,5,8,6)//returns 1
gcd(6,30,40,60,20,40)//returns 2

--
components: Library (Lib)
messages: 362069
nosy: Ananthakrishnan, mark.dickinson, serhiy.storchaka, steven.daprano
priority: normal
severity: normal
status: open
title: Update math.gcd() to accept "n" arguments.
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



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

2020-02-16 Thread hai shi


hai shi  added the comment:

Leave a note for myself:
I check the remaining object roughly(though dump_refs function), most of 
remaining object is 'str', such as:
'0x7f779cf0 [13] str'->'0x7f779cf0 [26] str'

So far, I don't know which file and fileno create those object. MAYBE I need 
find a hack way to sign this mallocing operation?(not sure)

--

___
Python tracker 

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



[issue4080] unittest: display time used by each test case

2020-02-16 Thread Giampaolo Rodola'


Giampaolo Rodola'  added the comment:

I updated the PR for Python 3.9. I think it's ready to be merged. Can someone 
involved in unittest take a look at it?

--

___
Python tracker 

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



[issue39647] Update doc of init_config.rst

2020-02-16 Thread hai shi


Change by hai shi :


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

___
Python tracker 

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



[issue39647] Update doc of init_config.rst

2020-02-16 Thread hai shi


New submission from hai shi :

Due to issue36465, the desc of `dump_refs` in init_config.rst should be udpated.

--
assignee: docs@python
components: Documentation
messages: 362066
nosy: docs@python, shihai1991, vstinner
priority: normal
severity: normal
status: open
title: Update doc of init_config.rst
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



[issue39617] max_workers argument to concurrent.futures.ProcessPoolExecutor is not flexible enough

2020-02-16 Thread Kyle Stanley


Change by Kyle Stanley :


--
nosy: +bquinlan, pitrou

___
Python tracker 

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



[issue39617] max_workers argument to concurrent.futures.ProcessPoolExecutor is not flexible enough

2020-02-16 Thread Kyle Stanley


Kyle Stanley  added the comment:

So, essentially, are you looking for a way to dynamically adjust 
ProcessPoolExecutor's (PPE) max_workers, rather than just upon initialization?

This seems like it would be a very reasonable enhancement to the Executor API. 
Specifically for PPE, it would involve expanding the call queue, which is where 
pending work items are moved to just before being executed by the subprocesses 
(and then moved to the results queue). In order for futures submitted to the 
executor to be cancel-able, it has to have a fixed upper limit based on the 
number of max_workers (but not too low so it doesn't have idle workers).

Fortunately, we are able to adjust the *maxsize* of the call queue in real-time 
since it's part of the public API for Queue (rather than having to create a new 
queue and copy all of the elements over to a new one). 

Also, in order for this to be of real benefit, we would have to join all of the 
processes that are no longer being used. This would likely take some time to 
implement properly, but without doing so, there wouldn't be a whole lot of real 
benefit from being able to dynamically adjust the max workers; you'd still be 
using up the resources to keep a bunch of idle processes alive.

I also suspect that it would require fairly extensive tests to ensure it's 
stability, and would be decently involved to implement it in a way that doesn't 
negatively impact or modify the existing behavior for ProcessPoolExecutor. But 
with some time and effort, I suspect it would be possible to implement this 
feature.

Assuming Antoine P. and Brian Q. (primary maintainers/experts for 
concurrent.futures) are on-board with implementing this feature, I would be 
willing to look into it working on it when I get the chance to.

--
nosy: +aeros

___
Python tracker 

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



[issue39641] concatenation of Tuples

2020-02-16 Thread bruce blosser


bruce blosser  added the comment:

ok -  well sorry, I am obviously in way over my head, and now very confused...  

I was just going by what was being said on a number of python web sites, 
including one where I am taking a class in intermediate python coding, and 
thought I was seeing a confiict between what i was being told, and what I was 
finding when running code.

so I will try not to come back here, unless I have some major problem, that 
seems more like a bug

thanks
bruce

--

___
Python tracker 

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



[issue39641] concatenation of Tuples

2020-02-16 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

[Bruce]
> but try this, and it will NOT work:
> 
> FatThing= [(5, 4, "First Place"),
>(6, 6, "Fifer Place"),
>(2, 2, "Slowr Place")]
> print(FatThing)  #this works
> 
> FFThing = FatThing + ('22', '32', '55')  #this causes an error!

That is correct, it should cause an error because you are trying to 
concatenate a list and a tuple. This is an easier way to show the same 
behaviour:

[] + ()  # fails with TypeError

[Bruce]
> however if you change all the members to strings, it will work!!!

I'm afraid you are mistaken. It still fails, as it should.

py> FatThing = [("a", "b", "First Place"),
... ("c", "d", "Fifer Place"),
... ("e", "f", "Slowr Place")]
py> FFThing = FatThing + ('22', '32', '55')
Traceback (most recent call last):
  File "", line 1, in 
TypeError: can only concatenate list (not "tuple") to list

Please take more care when trying to report what you think is a bug. 
Remember that Python is about 30 years old and there are tens or 
hundreds of thousands of people using it every single day. 99% of the 
time, anything you, or I, find that looks like a bug, is a bug in *our* 
code, not Python. Especially when it is something as basic and 
fundamental as tuple concatenation.

--

___
Python tracker 

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



[issue39644] Add Binary module.

2020-02-16 Thread Mark Dickinson


Change by Mark Dickinson :


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

___
Python tracker 

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



[issue39644] Add Binary module.

2020-02-16 Thread Mark Dickinson


Mark Dickinson  added the comment:

I'm going to close this, for two reasons:

- It's not well-formed enough for a b.p.o. issue: there are too many details to 
be worked out and questions to be answered. As it stands, there's nothing 
actionable here.

- Adding a new module to the Python std. lib. would be a PEP-level change.

If you want to move this forward, please first take it to the python-ideas 
mailing list[1] for further discussion; it'll get a wider audience there than 
here, so that's a better place to hash out the details. Once the details are 
clearer, if people still think it's a good idea, then it would be time to start 
working on a PEP and reference implementation.

[1] https://mail.python.org/archives/list/python-id...@python.org/

--

___
Python tracker 

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



[issue39644] Add Binary module.

2020-02-16 Thread Ananthakrishnan


Ananthakrishnan  added the comment:

I think this is not present in python.
This module should contain operations that can be performed on binary numbers.
In the below examples a and b are binary numbers.

binary.add(a,b)
binary.sub(a,b)
binary.mul(a,b)
binary.div(a,b)
binary.ones_complement(a)//returns 1's complement of a.
binary.twos_complement(a)//returns 2's complement of a.
binary.dectobi(a)//converts decimal "a" to binary of "a".
binary.bcd(a)//returns bcd of a.
binary.gray(a)   //returns grey code of a.
binary.min() //minimizes.
binarybitodec//converts binar "a" to decimal of "a".

--

___
Python tracker 

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



[issue39644] Add Binary module.

2020-02-16 Thread SilentGhost


SilentGhost  added the comment:

>>> 0b1110 + 0b1010
24
>>> bin(0b1110 + 0b1010)
'0b11000'

Can you explain how this is not enough?

--

___
Python tracker 

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



[issue39644] Add Binary module.

2020-02-16 Thread Ananthakrishnan


Ananthakrishnan  added the comment:

I meant a module for "binary number".
It can do operations on binary number.

--

___
Python tracker 

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



[issue39644] Add Binary module.

2020-02-16 Thread Ananthakrishnan


Change by Ananthakrishnan :


--
components: +Library (Lib) -C API

___
Python tracker 

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



[issue39644] Add Binary module.

2020-02-16 Thread SilentGhost


SilentGhost  added the comment:

Ananthakrishnan, you've marked this issue as belonging to C API component, why? 
Besides, all this functionality is already present in python, what is it you're 
actually interested in? What is not covered by the independent packages on pypi?

--
nosy: +SilentGhost

___
Python tracker 

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



[issue39641] concatenation of Tuples

2020-02-16 Thread SilentGhost


SilentGhost  added the comment:

Bruce, error message says exactly why it doesn't work: you're trying to add a 
tuple to a list, and that doesn't work. There isn't a "third" string created 
anywhere, you're confused about the types of the objects. Also, please, do not 
re-open closed issues.

--
nosy: +SilentGhost
status: open -> closed

___
Python tracker 

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



[issue39633] venv does not include python. symlink by default

2020-02-16 Thread Vinay Sajip


Change by Vinay Sajip :


--
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed
type:  -> behavior

___
Python tracker 

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



[issue39641] concatenation of Tuples

2020-02-16 Thread bruce blosser


bruce blosser  added the comment:

read the advice...
Yes this does work:

  ("Hello", 1, None) + (23, 19.5, "Goodbye")
('Hello', 1, None, 23, 19.5, 'Goodbye')
because you are not creating a 3rd string!

but try this, and it will NOT work:

FatThing= [(5, 4, "First Place"),
   (6, 6, "Fifer Place"),
   (2, 2, "Slowr Place")]
print(FatThing)  #this works

FFThing = FatThing + ('22', '32', '55')  #this causes an error!

however if you change all the members to strings, it will work!!!

--
status: closed -> open

___
Python tracker 

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



[issue39646] compile warning in unicodeobject.c

2020-02-16 Thread hai shi


hai shi  added the comment:

I don't find a good idea so I just add init operation :(

--

___
Python tracker 

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



[issue39646] compile warning in unicodeobject.c

2020-02-16 Thread hai shi


Change by hai shi :


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

___
Python tracker 

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



[issue39644] Add Binary module.

2020-02-16 Thread Ananthakrishnan


Ananthakrishnan  added the comment:

It operates only on 0 and 1

--

___
Python tracker 

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



[issue39644] Add Binary module.

2020-02-16 Thread Ananthakrishnan


Ananthakrishnan  added the comment:

It is "addition". I meant binary addition:

1110+1010=11000.
-1000=0111

--

___
Python tracker 

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



[issue39625] Traceback needs more details

2020-02-16 Thread Ammar Askar


Ammar Askar  added the comment:

I don't know how common this situation is, the fact that all constructors go to 
__init__ here makes it a little tough in this case but normally you'd be able 
to tell by the function name.

One potential solution might be to show which file the error came from like 
this:

Traceback (most recent call last):
  File "D:\x.py", line 13, in 
c = C(C1("C1"), C2("C2"))
TypeError: [D:\x.py:6] __init__() missing 1 required positional argument: 'p'

This is a pretty trivial change in ceval.c:3779 but might make the errors 
pretty long unless (especially now that co_filename is an absolute path) we 
chop them off to just the name of the file.

Including the frame information for the function about to be called would be 
much more difficult.

Overall this situation might not be worth improving because it's so rare but 
having the function location in the error might be worth having just as an 
extra information point.

--
nosy: +ammar2

___
Python tracker 

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



[issue39644] Add Binary module.

2020-02-16 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

What is binary addition, how it differs from just addition, what type of 
objects it operates?

--

___
Python tracker 

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