[issue37664] Update bundled pip and setuptools

2019-08-18 Thread rdb


rdb  added the comment:

@steve.dower It will be necessary to update to pip 19.2.3 for Python 3.8.0b4 
shortly, as per:
https://github.com/pypa/pip/pull/6874#issuecomment-50364

--
nosy: +rdb

___
Python tracker 

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



[issue37543] Optimize pymalloc for non PGO build

2019-08-18 Thread Hansraj Das


Change by Hansraj Das :


--
pull_requests: +15043
pull_request: https://github.com/python/cpython/pull/15309

___
Python tracker 

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



[issue32689] shutil.move raises AttributeError if first argument is a pathlib.Path object and destination is a directory

2019-08-18 Thread Roundup Robot


Change by Roundup Robot :


--
pull_requests: +15044
pull_request: https://github.com/python/cpython/pull/15326

___
Python tracker 

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



[issue37881] __text_signature__ parser doesn't handle globals in extension module

2019-08-18 Thread Antony Lee


New submission from Antony Lee :

Starting from the custom2 example at 
https://docs.python.org/3/extending/newtypes_tutorial.html#adding-data-and-methods-to-the-basic-example,
 change the methods table to

static PyMethodDef Custom_methods[] = {
{"foo", (PyCFunction) Custom_foo, METH_VARARGS,
"foo(x=ONE)\n--\n\nFoos this."
},
{NULL}  /* Sentinel */
};

and add a global ONE to the module dict:

PyModule_AddObject(m, "ONE", PyLong_FromLong(1));

Building and running e.g. pydoc on this module results in

Traceback (most recent call last):
File ".../lib/python3.7/inspect.py", line 2003, in wrap_value
value = eval(s, module_dict)
File "", line 1, in 
NameError: name 'ONE' is not defined

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File ".../lib/python3.7/inspect.py", line 2006, in wrap_value
value = eval(s, sys_module_dict)
File "", line 1, in 
NameError: name 'ONE' is not defined

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File ".../lib/python3.7/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)

File ".../lib/python3.7/inspect.py", line 2008, in wrap_value
raise RuntimeError()
RuntimeError

I think the fix is fairly simple; one needs to replace

module_name = getattr(obj, '__module__', None)

in inspect.py::_signature_fromstr by

module_name = (getattr(obj, '__module__', None)
   or getattr(getattr(obj, '__objclass__'), '__module__', None))

(This is a less general but simpler solution than 
https://bugs.python.org/issue23967.)

--
components: Extension Modules
messages: 349919
nosy: Antony.Lee
priority: normal
severity: normal
status: open
title: __text_signature__ parser doesn't handle globals in extension module

___
Python tracker 

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



[issue9350] add remove_argument_group to argparse

2019-08-18 Thread hai shi


hai shi  added the comment:

IMHO, if we supply the ability to add an argument group, we need add the 
ability to remove the argument group too.

--
nosy: +shihai1991

___
Python tracker 

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



[issue9350] add remove_argument_group to argparse

2019-08-18 Thread paul j3


paul j3  added the comment:

hai shi

Do you have a specific need for this, or do you want it just for the same of 
completeness?

--

___
Python tracker 

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



[issue37882] Code folding in IDLE

2019-08-18 Thread George Zhang


New submission from George Zhang :

Congrats on adding line numbers to IDLE.

With this change, a change to add code folding could be done more easily as the 
folding can reference the line numbers. Many other IDEs have code folding but 
IDLE should also have it.

Code folding could be done with a +/- to the right of the line numbers and can 
show/hide the indented suite under the header (compound statements). It should 
use indentation as tool to figure out which parts can be folded. Blank lines 
don't count. Single line compound statements cannot be folded.

Something like this:

1  - | def spam(ham):
2  - | if ham:
3| eggs()
4| 
5  + | def frob():
8| 
9  - | FOO = (
10   | 1, 2, 3, 4,
11   | 5, 6, 7, 8,
12   | )
13   | 
14   | BAR = (
17   | )
18   | 
19   | if True: print("True")
20   |

--
assignee: terry.reedy
components: IDLE
messages: 349922
nosy: GeeVye, terry.reedy
priority: normal
severity: normal
status: open
title: Code folding in IDLE
versions: Python 3.7, Python 3.8, Python 3.9

___
Python tracker 

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



[issue37882] Code folding in IDLE

2019-08-18 Thread George Zhang


Change by George Zhang :


--
type:  -> enhancement

___
Python tracker 

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



[issue16468] argparse only supports iterable choices

2019-08-18 Thread Joannah Nanjekye


Change by Joannah Nanjekye :


--
nosy: +nanjekyejoannah

___
Python tracker 

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



[issue37883] threading.Lock.locked is not documented

2019-08-18 Thread Rémi Lapeyre

New submission from Rémi Lapeyre :

As far as I can tell, it has never been documented. I'm not sure if it is 
deprecated but it has a docstring so it seems to me, that it just needs 
documentation in Doc/Library/threading.rst

PS: I don't know how to set the beginner friendly flag.

--
assignee: docs@python
components: Documentation, Library (Lib)
messages: 349923
nosy: docs@python, remi.lapeyre
priority: normal
severity: normal
status: open
title: threading.Lock.locked is not documented
type: enhancement
versions: Python 3.7, Python 3.8, Python 3.9

___
Python tracker 

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



[issue16468] argparse only supports iterable choices

2019-08-18 Thread paul j3


paul j3  added the comment:

But see

https://bugs.python.org/issue37793

for a discussion of whether 'container' is as good a descriptor as 'iterable'.

--

___
Python tracker 

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



[issue37882] Code folding in IDLE

2019-08-18 Thread SilentGhost


Change by SilentGhost :


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



[issue37882] Code folding in IDLE

2019-08-18 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

I am familiar with the feature in Notepad++ on Windows.  But I never use its +- 
code folding.  IDLE already has two different and, to me, generally better code 
folding features.

To get an outline view of a file's classes and functions, use File => Module 
Browser or its shortcut.  One can selectively expand any item with nested class 
and function definitions.  Such multilevel outline views are not possible with 
Notepad++, as [+] mean expands completely, not just nested definitions.  I 
suspect that this is generally true of IDEs with marginal -+.

[Module browser can still be improved, such as by processing the code in an 
editor buffer instead of on disk, and updating automatically, but that is a 
different issue.]

One can instead get a dynamic view of nested compound statement headers with 
Options => Code Context. Look at any file longer than the editor window with 
nested compound statements, such as idlelib/editor.py.  This feature is 
impossible with all or nothing -+ collapse.

There may be other use cases, but then we have a major technical problem.  Tk 
Text widgets do not support code folding.  They have no method to hide lines in 
their text buffers.  Nor, as far as I know, is there any workaround with a 
'Hide' tag.  Tk fonts have no 'visible' option.  Font size 1 or -1 is not 0, 
and size 0 is interpreted as a some default, around 15.

So hidden lines would have to be deleted.  The easiest option might be a 
dictionary mapping tk line numbers to lists of deleted lines and another 
function and data structure to map tk line numbers to the line numbers needed 
for display. Doing this without introducing bugs would be non-trivial.

I would not consider this unless there were a strong use case that would 
greatly benefit *and* be used by beginners.

Silent Ghost> This is an IDLE issue.  If this were added, which is extremely 
unlikely, it would be backported, just as line numbers were.  (See PEP 434.) It 
does not really matter which versions are marked here by the OP.

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



[issue37836] Support .as_integer_ratio() in fractions.Fraction

2019-08-18 Thread Jeroen Demeyer


Change by Jeroen Demeyer :


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

___
Python tracker 

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



[issue37836] Support .as_integer_ratio() in fractions.Fraction

2019-08-18 Thread Jeroen Demeyer


Change by Jeroen Demeyer :


--
pull_requests: +15046
pull_request: https://github.com/python/cpython/pull/15328

___
Python tracker 

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



[issue34529] add the option for json.dumps to return newline delimited json

2019-08-18 Thread Thibault Molleman


Change by Thibault Molleman :


--
nosy: +Thibault Molleman

___
Python tracker 

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



[issue37863] Speed up hash(fractions.Fraction)

2019-08-18 Thread Tim Peters


Tim Peters  added the comment:

For posterity:

"Modular Inverse Algorithms Without Multiplications for Cryptographic 
Applications"
Laszlo Hars
https://link.springer.com/article/10.1155/ES/2006/32192

"""
On the considered computational platforms for operand lengths used in 
cryptography, the fastest presented modular inverse algorithms need about twice 
the time of modular multiplications, or
even less.
"""

Lars considered a great many algorithm variations, and wrote up about ten of 
the best.  Several things surprised me here.  Most surprising:  under some 
realistic assumptions, _the_ best turned out to be a relatively simple 
variation of Euclid extended GCD.  Nutshell:  during a step, let the difference 
between the bit lengths of the then-current numerator and denominator be `f`.  
Then look at a few leading bits to pick whichever of `s` in {f-1, f, f+1} will 
clear the largest handful of leading bits in `numerator - (denominator << s)` 
(this test is meant to be fast, not exact - it's a refinement of an easier 
variant that just picks s=f).  The "quotient" in this step is then 2**s, and 
the rest is shifting and adding/subtracting.  No division or multiplication is 
needed.

This has a larger expected iteration count than some other methods, but, like 
regular old Euclid GCD, needs relatively little code per iteration.

--

___
Python tracker 

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



[issue7982] extend captured_output to simulate different stdout.encoding

2019-08-18 Thread Andrew Frost


Andrew Frost  added the comment:

The patch Berker attached back in 2014 was never added to Python, I'd like to 
submit a PR for it as my first Python contribution!

--
nosy: +adfrost

___
Python tracker 

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



[issue16468] argparse only supports iterable choices

2019-08-18 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

I think this should be dropped. IMO it is a pedantic nit.  There is the 
everyday usage of the word "container" which has a reasonable plain meaning.  
There is also an ABC that was unfortunately called Container (with a capital C) 
that means anything the defines __contains__.  IMO, we don't have to change all 
uses for the former just because the latter exists.

AFAICT, this "issue" for the argparse has never been a real problem for a real 
user ever in the entire history of the module.

So, unless there are strong objections, I would like to close this and we can 
shift our attention to matters of actual importance.

--
assignee:  -> rhettinger
nosy: +rhettinger
versions: +Python 3.9 -Python 2.7, Python 3.5, Python 3.6, Python 3.7

___
Python tracker 

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



[issue9350] add remove_argument_group to argparse

2019-08-18 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

> The use case for me is I create an argument group and 
> then conditionally add a bunch of arguments to it.  
> If zero arguments are added I would like to then remove
> the group so that an empty group does not show up 
> in the help output.

ISTM this use is likely rare enough that it doesn't warrant an API expansion.  
The argparse API is already somewhat large, so we should only expand it when 
there is a compelling benefit or the absence of a reasonable workaround (i.e. 
lazily adding a group only when the first argument is added).

--
nosy: +rhettinger

___
Python tracker 

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



[issue16468] argparse only supports iterable choices

2019-08-18 Thread Brendan Barnwell


Brendan Barnwell  added the comment:

Here is an example of someone who cares about the behavior and/or the 
documentation (and still cares enough to check up on their StackOverflow 
question six years later): 
https://stackoverflow.com/questions/13833566/python-argparse-choices-from-an-infinite-set/13833736
 .

The issue is not the use of the word "container".  The docs literally say "Any 
object that supports the `in` operator can be passed as the choices value" and 
that is not true.  In fact, changing it to say "any container type" would be an 
improvement as that is at least arguably correct, whereas the current 
documentation is unambiguously incorrect.

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



[issue37664] Update bundled pip and setuptools

2019-08-18 Thread Inada Naoki


Inada Naoki  added the comment:

When updating pip next time, please update setuptools too.
https://setuptools.readthedocs.io/en/latest/history.html#v41-1-0

> #1788: Changed compatibility fallback logic for html.unescape to avoid 
> accessing HTMLParser.unescape when not necessary. HTMLParser.unescape is 
> deprecated and will be removed in Python 3.9.

This is blocking #37328.

--
nosy: +inada.naoki

___
Python tracker 

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



[issue9350] add remove_argument_group to argparse

2019-08-18 Thread hai shi


hai shi  added the comment:

paul, raymond. Thanks for give me a quick answer:).
Looks raymond's reason is good enough, i just only consider this question from  
 
api completeness(as paul said) not from user case.

--

___
Python tracker 

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



[issue37836] Support .as_integer_ratio() in fractions.Fraction

2019-08-18 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

I afraid this can slow down the Fraction constructor.

--

___
Python tracker 

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



[issue16468] argparse only supports iterable choices

2019-08-18 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Okay, that makes sense.  Go ahead with the edit.

--

___
Python tracker 

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



[issue37882] Code folding in IDLE

2019-08-18 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Terry, you've made a good case that this feature request should be closed.

--
nosy: +rhettinger

___
Python tracker 

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



[issue37819] as_integer_ratio() missing from fractions.Fraction()

2019-08-18 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Sorry, but I do not understand why adding Fraction.as_integer_ratio() prevents 
adding math.as_integer_ratio().

The user code can not benefit from this until we add as_integer_ratio() to all 
numeric numbers, and this is not realistic. For the same reason there is 
str.join() which works with arbitrary iterable instead of adding the join() 
method to all collections, iterators and generators.

math.as_integer_ratio() makes the user code more general, clear and fast.

--

___
Python tracker 

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



[issue37862] Search doesn't find built-in functions

2019-08-18 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

The search page is the last thing one should use.  There is the index
https://docs.python.org/3/genindex-Z.html
and for builtin function, chapter 2 of the library manual.
https://docs.python.org/3/library/functions.html#built-in-functions

I don't know if the operation of the search page is documented anytwhere.

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

___
Python tracker 

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



[issue37873] unittest: execute tests in parallel

2019-08-18 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

test.regrtest has a  -j option. Perhaps some of the Python coding for that 
could be used for unitest also.

--
nosy: +terry.reedy

___
Python tracker 

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



[issue37873] unittest: execute tests in parallel

2019-08-18 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
nosy: +ezio.melotti, michael.foord

___
Python tracker 

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



[issue37884] Optimize Fraction() and statistics.mean()

2019-08-18 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

The proposed PR optimizes the Fraction constructor and statistics.mean() (and 
several other statistics functions) by using a private helper implemented in C 
which abstracts converting a number to an integer ratio.

$ ./python -m timeit -s "from fractions import Fraction as F" "F(123)"
50 loops, best of 5: 655 nsec per loop
50 loops, best of 5: 749 nsec per loop

$ ./python -m timeit -s "from fractions import Fraction as F" "F(1.23)"
20 loops, best of 5: 1.29 usec per loop
20 loops, best of 5: 1.03 usec per loop

$ ./python -m timeit -s "from fractions import Fraction as F; f = F(22, 7)" 
"F(f)"
20 loops, best of 5: 1.17 usec per loop
50 loops, best of 5: 899 nsec per loop

$ ./python -m timeit -s "from fractions import Fraction as F; from decimal 
import Decimal as D; d = D('1.23')" "F(d)"
20 loops, best of 5: 1.64 usec per loop
20 loops, best of 5: 1.29 usec per loop


$ ./python -m timeit -s "from statistics import mean; a = [1]*1000" "mean(a)"
500 loops, best of 5: 456 usec per loop
1000 loops, best of 5: 321 usec per loop

$ ./python -m timeit -s "from statistics import mean; a = [1.23]*1000" "mean(a)"
500 loops, best of 5: 645 usec per loop
500 loops, best of 5: 659 usec per loop

$ ./python -m timeit -s "from statistics import mean; from fractions import 
Fraction as F; a = [F(22, 7)]*1000" "mean(a)"
500 loops, best of 5: 637 usec per loop
500 loops, best of 5: 490 usec per loop

$ ./python -m timeit -s "from statistics import mean; from decimal import 
Decimal as D; a = [D('1.23')]*1000" "mean(a)"
500 loops, best of 5: 946 usec per loop
500 loops, best of 5: 915 usec per loop

There is a 14% regression in creating a Fraction from an integer, but for 
non-integer numbers it gains 25% speed up. The effect on statistics.mean() 
varies from insignificant to +40%.

--
components: Library (Lib)
messages: 349939
nosy: mark.dickinson, rhettinger, serhiy.storchaka, steven.daprano
priority: normal
severity: normal
status: open
title: Optimize Fraction() and statistics.mean()
type: performance
versions: Python 3.9

___
Python tracker 

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



[issue37884] Optimize Fraction() and statistics.mean()

2019-08-18 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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

___
Python tracker 

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



[issue37836] Support .as_integer_ratio() in fractions.Fraction

2019-08-18 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

See issue37884 which uses a C accelerator.

--

___
Python tracker 

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