[issue28629] Emit ResourceWarning when implicitly terminating a suspended frame?

2016-11-06 Thread Nathaniel Smith

Nathaniel Smith added the comment:

+1 to the change for generators. This is actually in the PEP 533 draft: 
https://www.python.org/dev/peps/pep-0533/#modifications-to-basic-iterator-types

For coroutines, doesn't this overlap with the existing "coroutine not awaited" 
warning?

--

___
Python tracker 

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



[issue28398] Return singleton empty string in _PyUnicode_FromASCII

2016-11-06 Thread Xiang Zhang

Xiang Zhang added the comment:

IMHO, _PyUnicode_FromASCII is a private API and could be used in other places 
in future. We should not rely on the caller to check and return the singleton 
empty string.

--

___
Python tracker 

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



[issue28623] Let `shlex.quote` accept a `PathLike` object

2016-11-06 Thread R. David Murray

R. David Murray added the comment:

Which IMO is correct.  shlex.quote takes an arbitrary string, not a filename.  
I'm -1 on this proposal.

--
nosy: +r.david.murray

___
Python tracker 

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



[issue27781] Change sys.getfilesystemencoding() on Windows to UTF-8

2016-11-06 Thread Roundup Robot

Roundup Robot added the comment:

New changeset b26c8104e54f by Steve Dower in branch '3.6':
Closes #27781: Removes special cases for the experimental aspect of PEP 529
https://hg.python.org/cpython/rev/b26c8104e54f

New changeset b8233c779ff7 by Steve Dower in branch 'default':
Closes #27781: Removes special cases for the experimental aspect of PEP 529
https://hg.python.org/cpython/rev/b8233c779ff7

--
resolution:  -> fixed
stage: needs patch -> 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



[issue28629] Emit ResourceWarning when implicitly terminating a suspended frame?

2016-11-06 Thread Nick Coghlan

New submission from Nick Coghlan:

There have been a few discussions recently regarding the fact that generator 
and coroutine cleanup can suppress ResourceWarnings from other components. For 
example:

def mygen(fname):
with open(fname) as f:
yield from f

print(next(mygen("README.md")))

Here, the opened file is actually being cleaned up by __del__ on the 
generator-iterator instance (when it throws GeneratorExit into the suspended 
frame), but there's no ResourceWarning as the *file itself* is being cleaned up 
by the file's __exit__ method.

I've been thinking about how we might be able to help developers better manage 
this, and one conclusion I've come to is that it means we need to start 
thinking about suspended frames that don't terminate naturally during the 
course of program execution as resources to be managed - their locals can and 
do reference scarce system resources, and folks are expecting "with" and 
"try-finally" statements to provide reliable management of those resources, 
even when there's a "yield", "yield from" or "await" in the nested suite.

So what do folks think of the idea of making __del__ on generator-iterator 
objects emit ResourceWarning in cases where:

- gi_frame is not None (i.e. the frame hasn't completed execution)
- gi_frame.f_lasti isn't -1 (i.e. the frame has started execution)

and similarly for coroutines and cr_frame?

--
messages: 280185
nosy: haypo, ncoghlan, njs, yselivanov
priority: normal
severity: normal
status: open
title: Emit ResourceWarning when implicitly terminating a suspended frame?
type: resource usage
versions: Python 3.7

___
Python tracker 

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



[issue28628] Failure to add signal handlers for any signal but SIGINT

2016-11-06 Thread Guido van Rossum

Guido van Rossum added the comment:

Hm... We've seen this exact same crash reported several times before, and it 
was closed without a fix AFAICT each time.

- https://github.com/python/asyncio/issues/396
- http://bugs.python.org/issue23548

IIUC the conclusion in the latter was that this is due to a bug in the user 
code (forgetting to close() the event loop).

--

___
Python tracker 

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



[issue28622] Remove redundant variable annotation test from test_grammar

2016-11-06 Thread Guido van Rossum

Changes by Guido van Rossum :


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



[issue28622] Remove redundant variable annotation test from test_grammar

2016-11-06 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 048f82c86928 by Guido van Rossum in branch '3.6':
issue #28622: Remove redundant variable annotation test from test_grammar. Ivan 
L.
https://hg.python.org/cpython/rev/048f82c86928

New changeset e60c1aef639a by Guido van Rossum in branch 'default':
issue #28622: Remove redundant variable annotation test from test_grammar. Ivan 
L. (3.6->3.7)
https://hg.python.org/cpython/rev/e60c1aef639a

--
nosy: +python-dev

___
Python tracker 

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



[issue28628] Failure to add signal handlers for any signal but SIGINT

2016-11-06 Thread A.M. Kuchling

Changes by A.M. Kuchling :


--
title: Failure to add -> Failure to add signal handlers for any signal but 
SIGINT

___
Python tracker 

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



[issue28628] Failure to add

2016-11-06 Thread brotherBox

New submission from brotherBox:

This is the first bug that I file, so please bear with me here. I was advised 
to file this after running into a strange situation with asyncio 3.4.3. Adding 
signal handlers for any other signal but SIGINT throws strange exceptions. The 
attached source code produces the following traceback:

Exception ignored in: >
Traceback (most recent call last):
  File "/usr/lib/python3.5/asyncio/base_events.py", line 501, in __del__
  File "/usr/lib/python3.5/asyncio/unix_events.py", line 58, in close
  File "/usr/lib/python3.5/asyncio/unix_events.py", line 139, in 
remove_signal_handler
  File "/usr/lib/python3.5/signal.py", line 47, in signal
TypeError: signal handler must be signal.SIG_IGN, signal.SIG_DFL, or a callable 
object

I asked in #python on freenode and was asked to file this bug.

Thank you for your consideration

--
components: asyncio
files: signal_bug.py
messages: 280182
nosy: brotherBox, gvanrossum, yselivanov
priority: normal
severity: normal
status: open
title: Failure to add
type: behavior
versions: Python 3.5
Added file: http://bugs.python.org/file45378/signal_bug.py

___
Python tracker 

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



[issue28609] argparse claims '*' positional argument is required in error output

2016-11-06 Thread paul j3

paul j3 added the comment:

My suggestion to use `metavar=('A','')` to streamline the usage creates 
problems with the help code

http://bugs.python.org/issue14074

The tuple metavar does not work right for positionals.  That's a old issue that 
should have been fixed long ago.

So streamlining the usage has to be done with a custom HelpFormatter subclass.

--

___
Python tracker 

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



[issue28609] argparse claims '*' positional argument is required in error output

2016-11-06 Thread paul j3

paul j3 added the comment:

Simply including a `default` parameter, even with the default default None, 
changes the error message

 In [395]: parser=argparse.ArgumentParser()
 In [396]: parser.add_argument('cmd');
 In [397]: a=parser.add_argument('args',nargs='*',default=None)
 In [398]: a.required
 Out[398]: False
 In [399]: parser.parse_args([])

 usage: ipython3 [-h] cmd [args [args ...]]
 ipython3: error: the following arguments are required: cmd

You shouldn't see any other changes in behavior (except maybe if the positional 
is in a mutually_exclusive_group).  The code that sets 'required' for 
positionals only looks for the presence of the parameter in kwargs, not its 
value: `'default' not in kwargs`.

An alternative is to change the value of 'required' after creation:
  
 a.required = False

Anyways I remain convinced that changing the 'required' attribute is the 
correct way to change the error message, not adding more tests to the message 
generator.

--

___
Python tracker 

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



[issue24658] open().write() fails on 2 GB+ data (OS X)

2016-11-06 Thread Harry Li

Changes by Harry Li :


--
nosy: +Harry Li

___
Python tracker 

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



[issue28627] [alpine] shutil.copytree fail to copy a direcotry with broken symlinks

2016-11-06 Thread Israel Fruchter

Israel Fruchter added the comment:

the failure looks like that:

Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/local/lib/python3.5/shutil.py", line 359, in copytree
raise Error(errors)
shutil.Error: [('/bug/broken', '/temp/broken', "[Errno 95] Not supported: 
'/temp/broken'")]

--

___
Python tracker 

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



[issue28627] [alpine] shutil.copytree fail to copy a direcotry with broken symlinks

2016-11-06 Thread Israel Fruchter

New submission from Israel Fruchter:

this fails on python3.5-alpine and python3.6-alpine
(works as fine in python2.7-alpine)

cd /bug && ln -s /broken_path/to_nowhere broken
python -c "import shutil; shutil.copytree('/bug', '/temp', symlinks=True)"

Dockerfile example here:
https://github.com/docker-library/python/issues/155

https://github.com/python/cpython/blob/c30098c8c6014f3340a369a31df9c74bdbacc269/Lib/shutil.py#L198

seem like its suppressing NotImplementedError, and in our case OsError with 
ENOSUP was raised

--
components: Library (Lib)
messages: 280178
nosy: fruch
priority: normal
severity: normal
status: open
title: [alpine] shutil.copytree fail to copy a direcotry with broken symlinks
type: behavior
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



[issue28563] Arbitrary code execution in gettext.c2py

2016-11-06 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
assignee:  -> serhiy.storchaka
stage:  -> patch review

___
Python tracker 

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



[issue28586] Convert os.scandir to Argument Clinic

2016-11-06 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

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



[issue25996] Add support of file descriptor in os.scandir()

2016-11-06 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Proposed patch adds support for file descriptors in os.scandir() and implements 
os.fwalk() with os.scandir().

The effect of using os.scandir() in os.fwalk():

$ ./python -m timeit -n1 -r5 -s 'import os' -- 'list(os.walk("/usr/lib"))'
1 loop, best of 5: 934 msec per loop

$ ./python -m timeit -n1 -r5 -s 'import os' -- 'list(os.walk("/usr/lib", 
topdown=False))'
1 loop, best of 5: 718 msec per loop

$ ./python -m timeit -n1 -r5 -s 'import os' -- 'list(os.fwalk("/usr/lib"))'
Unpatched: 1 loops, best of 5: 1.78 sec per loop
Patched:   1 loop, best of 5: 934 msec per loop

$ ./python -m timeit -n1 -r5 -s 'import os' -- 'list(os.fwalk("/usr/lib", 
topdown=False))'
Unpatched: 1 loops, best of 5: 1.76 sec per loop
Patched:   1 loop, best of 5: 947 msec per loop

--
keywords: +patch
stage:  -> patch review
versions: +Python 3.7 -Python 3.6
Added file: http://bugs.python.org/file45377/os-scandir-fd.patch

___
Python tracker 

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



[issue28587] list.index documentation missing start and stop arguments

2016-11-06 Thread Mariatta Wijaya

Mariatta Wijaya added the comment:

Here is an updated patch.
Please review :)
Thanks.

--
Added file: http://bugs.python.org/file45376/issue28587v3.patch

___
Python tracker 

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



[issue10605] ElementTree documentation

2016-11-06 Thread A.M. Kuchling

A.M. Kuchling added the comment:

I don't see an 'entity' argument or attribute for TreeBuilder either.  
XMLParser has a .entity attribute, though.  Perhaps this was simple confusion?  
Adrian: please feel free to re-open and provide a patch if there's actually a 
bug here.

--
nosy: +akuchling
resolution:  -> not a bug
status: open -> closed

___
Python tracker 

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



[issue9621] Graphviz output for 2to3 fixer patterns

2016-11-06 Thread A.M. Kuchling

A.M. Kuchling added the comment:

Matt, do you just want to drop the issue or provide a new patch?  Your code 
might well still be useful, but it's been 6 years, so you may not even have the 
code any longer.

--
nosy: +akuchling

___
Python tracker 

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



[issue11368] Document why xml.etree.ElementTree.Element has no reference to parent

2016-11-06 Thread A.M. Kuchling

A.M. Kuchling added the comment:

Closing this old issue.

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

___
Python tracker 

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



[issue4713] Installing sgmlop causes xmlrpclib error

2016-11-06 Thread A.M. Kuchling

A.M. Kuchling added the comment:

I don't believe this bug is still present in Python 2.7.  Issue #5767 removed 
sgmlop support from xmlrpclib in 2.7 alpha 1, and trying the test program 
succeeds.  Closing.

--
nosy: +akuchling
resolution:  -> works for me
status: open -> closed

___
Python tracker 

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



[issue28609] argparse claims '*' positional argument is required in error output

2016-11-06 Thread Reuben Thomas

Reuben Thomas added the comment:

> Try `nargs='?'` or try providing a `default` along with the '*'.

Why would I do that? I want 0 or more arguments, and there's no default value.

> Including your ARGUMENT action in the error message is intentional.

It will likely confuse the user. The syntax message says that it's optional, 
the error suggests (wrongly) that it is required.

Patching the Python documentation will not help in this case, because the user 
of my program will not be reading the Python documentation to understand how it 
works, only the program's own documentation.

Note that I did not suggest that the behavior be changed, only the message that 
is output.

The analysis of why the message is output is useful, but it does not 
demonstrate that the error message is correct; the error message, as I've 
already demonstrated, is undeniably wrong. In no sense is "ARGUMENT" missing, 
because 0 occurrences are entirely legal. Therefore although in terms of the 
API the argument is "required", it makes no sense to tell the user this (the 
user will assume that "required" has its colloquial sense, not a technical 
sense).

I entirely sympathise with the argument that the behavior of argparse should 
not change; I see nothing wrong with the behavior, in any case.

The problems are purely cosmetic:

1. The syntax message says, redundantly and confusingly, "[ARGUMENT [ARGUMENT 
...]]" where it should say just  "[ARGUMENT ...]".

2. The error message says that ARGUMENT is "required", whereas, from the user's 
point of view, it clearly is not.

These are serious annoyances from the developer's point of view (in this case, 
from my point of view), because they mean that in order to release a 
production-quality tool, I have to hack around argparse's shortcomings.

So in fact, you're quite right that the documentation should be fixed; only in 
this case it is the documentation generated by argparse, not the documentation 
of argparse (which, again, is fine as far as I can see).

--

___
Python tracker 

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



[issue1778] SyntaxError.offset sometimes wrong

2016-11-06 Thread A.M. Kuchling

A.M. Kuchling added the comment:

Fixed in Python 3.2 alpha 3, so there's no longer any work to be done for this 
issue.  Closing.

--
nosy: +akuchling
resolution:  -> fixed
status: open -> closed

___
Python tracker 

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



[issue28609] argparse claims '*' positional argument is required in error output

2016-11-06 Thread paul j3

paul j3 added the comment:

Try `nargs='?'` or try providing a `default` along with the '*'.

Including your ARGUMENT action in the error message is intentional.

The test for this error message is:

required_actions = []
for action in self._actions:
if action not in seen_actions:
if action.required:

Originally the code just checked if `positionals` was empty.  That was the list 
of positional Actions.  Actions were popped as they were parsed.  Now it 
maintains a set `seen_actions`, and checks the `required` attribute.  This test 
applies to both positionals and optionals.

For optionals, `required` is set by the programmer.  But for positionals it is 
set with:

def _get_positional_kwargs
 ...
# mark positional arguments as required if at least one is
# always required
if kwargs.get('nargs') not in [OPTIONAL, ZERO_OR_MORE]:
kwargs['required'] = True
if kwargs.get('nargs') == ZERO_OR_MORE and 'default' not in kwargs:
kwargs['required'] = True

So for '?' argument, required is False.  But for '*', it must also have a 
'default' parameter (not just the default None).

So the proposed patch is overriding the 'required' value that was set during 
'add_argument'.  And issuing this error message is the main purpose of the 
'required' attribute.

I would not implement this patch.  

But it would be a good idea to check if this method of setting the required 
attribute has been discussed in other bug/issues.  (There is an open issue 
concerning how the 'required' is set/or not for the subparsers positional.)

Off hand I don't see anything about this in the documentation.  Maybe that's 
what needs to be patched.  (It's easier and safer to change the documentation 
than the working code.  Backward compatibility is a major concern when changing 
the code.)

--

___
Python tracker 

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



[issue8840] truncate() semantics changed in 3.1.2

2016-11-06 Thread A.M. Kuchling

A.M. Kuchling added the comment:

"Why, this is a simple docstring change.  How difficult can it be?", I thought.

Ah ha ha ha.

Here's a patch against the 3.5 branch. It should also apply cleanly to 3.6 or 
3.7, except for a little Argument Clinic noise. 

The patch changes 3 occurrences of the truncate() docstring in Lib/_pyio.py, 
and 1 each in Modules/_io/{bytesio.c,fileio.c,iobase.c,stringio.c}.  Whew!  Do 
we want to change all of these occurrences, or just the one specific case of 
StringIO?  It seemed to me that we want to change them all.

--
nosy: +akuchling
Added file: http://bugs.python.org/file45375/issue8840.txt

___
Python tracker 

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



[issue6519] Reorder 'with' statement for files in Python Tutorial

2016-11-06 Thread A.M. Kuchling

A.M. Kuchling added the comment:

Good suggestion -- here's a patch that moves it and rewrites a little.

--
nosy: +akuchling
Added file: http://bugs.python.org/file45374/issue6519.txt

___
Python tracker 

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



[issue26855] android: add platform.android_ver()

2016-11-06 Thread Xavier de Gaye

Xavier de Gaye added the comment:

ANDROID_API_LEVEL can only be used in the Python test suite and 
platform.android_ver() must be used in the standard library. The reason why 
ANDROID_API_LEVEL can be used in the tests instead of using the runtime API 
level is that the Python test suite purpose is not to test the compatibilities 
betweeen all the possible subjacent bionic libc(s) and the tests need only be 
run on the platform for which they have been built.

platform.android_ver() is a welcome enhancement, and since we are at 3.6 beta 
now it's too late for 3.6 and it will be implemented in 3.7. Sorry about this 
delay.

--
assignee:  -> xdegaye
components: +Library (Lib)
stage:  -> patch review
versions: +Python 3.7 -Python 3.6

___
Python tracker 

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



[issue28587] list.index documentation missing start and stop arguments

2016-11-06 Thread Mariatta Wijaya

Mariatta Wijaya added the comment:

Thanks for the feedback :) Makes sense, I'll work on another patch.

--

___
Python tracker 

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



[issue28587] list.index documentation missing start and stop arguments

2016-11-06 Thread A.M. Kuchling

A.M. Kuchling added the comment:

The patch looks fine, though I suggest clarifying the example for a.index(333, 
2)  by adding a comment such as '# begin searching at index 2' to explain 
what's going on.

--
nosy: +akuchling

___
Python tracker 

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



[issue21590] Systemtap and DTrace support

2016-11-06 Thread Berker Peksag

Berker Peksag added the comment:

Thanks. SilentGhost. I went with ".. highlight:: shell-session" to simplify the 
patch a bit.

Łukasz, can we close this one and create new issues for further improvements 
now?

--

___
Python tracker 

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



[issue21590] Systemtap and DTrace support

2016-11-06 Thread Roundup Robot

Roundup Robot added the comment:

New changeset d05d312161f2 by Berker Peksag in branch '3.6':
Issue #21590: Silence Sphinx warnings in instrumentation.rst
https://hg.python.org/cpython/rev/d05d312161f2

New changeset 442453fa3370 by Berker Peksag in branch 'default':
Issue #21590: Merge from 3.6
https://hg.python.org/cpython/rev/442453fa3370

--
nosy: +python-dev

___
Python tracker 

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



[issue28609] argparse claims '*' positional argument is required in error output

2016-11-06 Thread paul j3

paul j3 added the comment:

The current error message is the result of http://bugs.python.org/issue10424 
and http://bugs.python.org/issue12776

Before the test was just:

   if positionals:
   self.error(_('too few arguments'))

The 2nd patch reworked the test to include the revised handling of defaults.

So the current error message just lists all the positionals which haven't been 
consumed.  ARGUMENT wasn't consumed because COMMAND wasn't consumed. And 
technically that would be true even if ARGUMENT required arguments. Well, to be 
pickier, it as a 're' pattern like 'AA*' that failed. 

The proposed patch looks like it would work, but I haven't tested or looked at 
the unittests.  But I wonder if such a patch is really needed. Are users really 
misled by the the current message?

===

As for the usage, the current version allows you to give a tuple METAVAR, 
producing lines like:

In [359]: a.metavar=('A','B')
In [360]: parser.print_usage()
usage: ipython3 [-h] [A [B ...]]
In [361]: a.nargs='+'
In [362]: parser.print_usage()
usage: ipython3 [-h] A [B ...]

This display pattern is generated in HelpFormater._format_args, with these lines

elif action.nargs == ZERO_OR_MORE:
result = '[%s [%s ...]]' % get_metavar(2)
elif action.nargs == ONE_OR_MORE:
result = '%s [%s ...]' % get_metavar(2)
elif action.nargs == REMAINDER:
result = '...'

You could subclass HelpFormatter, and replace this method with one that 
performs as you want, (I just tried this)

result = '[%s ...]' % get_metavar(1)

I wouldn't recommend this as default change, but if there was a enough demand 
it could added as another HelpFormatter subclass.

METAVAR lets me approximate your shorter version:

In [4]: p.print_usage()
usage: ipython3 [-h] [pos [pos ...]]
In [5]: a.metavar=('pos','')
In [6]: p.print_usage()
usage: ipython3 [-h] [pos [...]]
In [7]: a.nargs='+'
In [8]: p.print_usage()
usage: ipython3 [-h] pos [...]

It still has the [], but the name is gone.

--
nosy: +paul.j3

___
Python tracker 

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



[issue21864] Error in documentation of point 9.8 'Exceptions are classes too'

2016-11-06 Thread Berker Peksag

Berker Peksag added the comment:

Thank you for the review, Andrew!

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
versions: +Python 3.7

___
Python tracker 

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



[issue21864] Error in documentation of point 9.8 'Exceptions are classes too'

2016-11-06 Thread Roundup Robot

Roundup Robot added the comment:

New changeset db6d556365d7 by Berker Peksag in branch '3.5':
Issue #21864: Remove outdated section about exceptions from the tutorial
https://hg.python.org/cpython/rev/db6d556365d7

New changeset f82e348946e3 by Berker Peksag in branch '3.6':
Issue #21864: Merge from 3.5
https://hg.python.org/cpython/rev/f82e348946e3

New changeset 6ec669efeea5 by Berker Peksag in branch 'default':
Issue #21864: Merge from 3.6
https://hg.python.org/cpython/rev/6ec669efeea5

--
nosy: +python-dev

___
Python tracker 

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



[issue12913] Add a debugging howto

2016-11-06 Thread A.M. Kuchling

A.M. Kuchling added the comment:

Éric Araujo: did you ever make any progress on this, such as producing a draft 
version?

--
nosy: +akuchling

___
Python tracker 

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



[issue28563] Arbitrary code execution in gettext.c2py

2016-11-06 Thread Xiang Zhang

Xiang Zhang added the comment:

gettext_c2py_v2.patch implements a simple C expression parser. More tests are 
included.

Carl, hope you are willing to test it.

--
Added file: http://bugs.python.org/file45373/gettext_c2py_v2.patch

___
Python tracker 

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



[issue21864] Error in documentation of point 9.8 'Exceptions are classes too'

2016-11-06 Thread A.M. Kuchling

A.M. Kuchling added the comment:

The patch looks good to me; I think it should just be applied.

--
nosy: +akuchling

___
Python tracker 

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



[issue28626] Tutorial: rearrange discussion of output formatting to encourage f-strings

2016-11-06 Thread A.M. Kuchling

A.M. Kuchling added the comment:

Oh, I didn't finish my thought on open questions: should we just drop the 
discussion of .ljust(), .zfill(), or should it be there so users are aware of 
it?  Similarly, is it still worth mentioning string.Template?

--

___
Python tracker 

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



[issue28626] Tutorial: rearrange discussion of output formatting to encourage f-strings

2016-11-06 Thread A.M. Kuchling

New submission from A.M. Kuchling:

The 'output formatting' section of the tutorial talks a lot about manual 
formatting with things like .rjust() and .zfill(), with only a passing 
reference to 3.6's new f-strings.

The attached patch doesn't drop all of the old material, but it does rearrange 
the topics into a more modern order: f-strings first, featuring the discussion 
of formatting specifiers; then calling .format(); finally manual formatting 
with .ljust().

Open question:

--
assignee: docs@python
components: Documentation
files: tutorial-patch.txt
keywords: needs review, patch
messages: 280153
nosy: akuchling, docs@python
priority: normal
severity: normal
stage: patch review
status: open
title: Tutorial: rearrange discussion of output formatting to encourage 
f-strings
type: enhancement
versions: Python 3.6
Added file: http://bugs.python.org/file45372/tutorial-patch.txt

___
Python tracker 

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



[issue19569] Use __attribute__((deprecated)) to warn usage of deprecated functions and macros

2016-11-06 Thread Arfrever Frehtes Taifersar Arahesis

Arfrever Frehtes Taifersar Arahesis added the comment:

_Pragma syntax would be more suitable since it could be used with macros:
https://gcc.gnu.org/onlinedocs/gcc-6.2.0/cpp/Pragmas.html


Then Include/pyport.h (which defines Py_DEPRECATED) could also define:

#if defined(__GNUC__) && ((__GNUC__ >= 5) || (__GNUC__ == 4) && (__GNUC_MINOR__ 
>= 6))
#define Py_COMPILER_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
#define Py_COMPILER_DIAGNOSTIC_IGNORE_DEPRECATED_DECLARATIONS _Pragma("GCC 
diagnostic ignored \"-Wdeprecated-declarations\"")
#define Py_COMPILER_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
#else
#define Py_COMPILER_DIAGNOSTIC_PUSH
#define Py_COMPILER_DIAGNOSTIC_IGNORE_DEPRECATED_DECLARATIONS
#define Py_COMPILER_DIAGNOSTIC_POP
#endif


These macros would be used in this way:
void some_function(void)
{
  int x, y;
Py_COMPILER_DIAGNOSTIC_PUSH
Py_COMPILER_DIAGNOSTIC_IGNORE_DEPRECATED_DECLARATIONS
  x = some_deprecated_function();
Py_COMPILER_DIAGNOSTIC_POP
  y = x + 1;
}

--

___
Python tracker 

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



[issue26934] android: test_faulthandler fails

2016-11-06 Thread STINNER Victor

STINNER Victor added the comment:

Can you try to write a decorator to not suplicate the same long skipIf()?

--

___
Python tracker 

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



[issue28590] fstring's '{' from escape sequences does not start an expression

2016-11-06 Thread Eric V. Smith

Eric V. Smith added the comment:

Thanks, Jason. I updated the PEP, so now I think the docs and PEP match the 
implementation.

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



[issue19569] Use __attribute__((deprecated)) to warn usage of deprecated functions and macros

2016-11-06 Thread Arfrever Frehtes Taifersar Arahesis

Arfrever Frehtes Taifersar Arahesis added the comment:

GCC supports pragmas to locally control warnings.
https://gcc.gnu.org/onlinedocs/gcc-6.2.0/gcc/Diagnostic-Pragmas.html

Example:

__attribute__((__deprecated__)) int some_deprecated_function(void)
{
  return 0;
};

void some_function(void)
{
  int x, y;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
  x = some_deprecated_function();
#pragma GCC diagnostic pop
  y = x + 1;
} 

int main(int argc, char** argv)
{
  return 0;
}

In the above example, call to some_deprecated_function() does not trigger 
deprecation warning.


'#pragma GCC diagnostic push' and '#pragma GCC diagnostic pop' are supported 
since GCC 4.6.0.
https://gcc.gnu.org/gcc-4.6/changes.html

'#pragma GCC diagnostic ignored' is documented in documentation of GCC since 
4.2.0.


Clang supposedly supports both '#pragma GCC diagnostic ...' and '#pragma clang 
diagnostic ...':
http://clang.llvm.org/docs/UsersManual.html#controlling-diagnostics-via-pragmas

--

___
Python tracker 

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



[issue23996] _PyGen_FetchStopIterationValue() crashes on unnormalised exceptions

2016-11-06 Thread Roundup Robot

Roundup Robot added the comment:

New changeset bce18f5c0bc4 by Serhiy Storchaka in branch '3.5':
Issue #23996: Added _PyGen_SetStopIterationValue for safe raising
https://hg.python.org/cpython/rev/bce18f5c0bc4

New changeset a2c9f06ada28 by Serhiy Storchaka in branch '3.6':
Issue #23996: Added _PyGen_SetStopIterationValue for safe raising
https://hg.python.org/cpython/rev/a2c9f06ada28

New changeset d33b9fd46cef by Serhiy Storchaka in branch 'default':
Issue #23996: Added _PyGen_SetStopIterationValue for safe raising
https://hg.python.org/cpython/rev/d33b9fd46cef

--

___
Python tracker 

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



[issue21501] submitting mmap example for use in documentation

2016-11-06 Thread Guido van Rossum

Guido van Rossum added the comment:

Can you say it in the form of a patch?

--
nosy: +gvanrossum

___
Python tracker 

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



[issue26855] android: add platform.android_ver()

2016-11-06 Thread Chi Hsuan Yen

Chi Hsuan Yen added the comment:

I see Xavier de Gaye uses sysconfig.get_config_var('ANDROID_API_LEVEL') is 
various patches. That's OK if the build-time target API level of CPython 
matches runtime Android API level. Does CPython force API level matching? If so 
this issue is no longer necessary.

--

___
Python tracker 

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



[issue28625] multiprocessing.Pool.imap swallows exceptions thrown by generators

2016-11-06 Thread Elias Zamaria

New submission from Elias Zamaria:

I have the following code:

from multiprocessing import Pool

def double(x):
return 2 * x

def get_numbers():
raise Exception("oops")
yield 1
yield 2

print(list(Pool(processes=2).imap(double, get_numbers(


I would expect it to raise an exception, but instead it just prints "[]", 
seeming to indicate that imap ran fine and produced no values.

This seems similar to the behavior described in bugs 23051 and 26333, but this 
happens if the iterator directly raises an exception before yielding anything. 
If I move the raise statement below one or both of the yields, I get an 
exception from imap as expected.

I am experiencing this with Python 3.5.2 on OS X 10.11.6. I haven't tried it 
with any other versions.

--
components: Library (Lib)
messages: 280146
nosy: elias
priority: normal
severity: normal
status: open
title: multiprocessing.Pool.imap swallows exceptions thrown by generators
type: behavior
versions: Python 3.5

___
Python tracker 

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



[issue28590] fstring's '{' from escape sequences does not start an expression

2016-11-06 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 1d8b8a67b657 by Jason R. Coombs in branch '3.6':
Additionally show that a backslash-escaped opening brace is treated as a 
literal and thus triggers the single closing brace error, clarifying #28590.
https://hg.python.org/cpython/rev/1d8b8a67b657

--
nosy: +python-dev

___
Python tracker 

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



[issue28590] fstring's '{' from escape sequences does not start an expression

2016-11-06 Thread Jason R. Coombs

Jason R. Coombs added the comment:

The reason that those test_no_escapes_for_braces assertions pass is because 
they're only dealing with opening curly braces and in an f-string, they're 
treated as literal opening braces.

In the example you've given, the error occurs when the f-string handler 
encounters the closing curly brace without an opening one. It's the same as if 
you had written:

>>> f'{{4*10}'
SyntaxError: f-string: single '}' is not allowed

I will add a test to capture this specific case (backslash-escaped unicode 
opening bracken).

--

___
Python tracker 

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



[issue26934] android: test_faulthandler fails

2016-11-06 Thread Xavier de Gaye

Xavier de Gaye added the comment:

The problem: raise() does not cause the program to exit in a Python interactive 
session and a spawned Python process exits with 0.  Android fixed this problem 
at API level 24 (Android 6.0 aka Marshmallow).
The attached patch fixes this (tested at API levels 21 et 24).

--
assignee:  -> xdegaye
components: +Tests -Cross-Build, Library (Lib)
keywords: +patch
stage:  -> patch review
versions: +Python 3.7
Added file: http://bugs.python.org/file45371/buggy_raise.patch

___
Python tracker 

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



[issue28590] fstring's '{' from escape sequences does not start an expression

2016-11-06 Thread Jason R. Coombs

Jason R. Coombs added the comment:

I've got a patch ready for this and will be applying it shortly after we update 
the spec.

--
assignee: docs@python -> jason.coombs
nosy: +jason.coombs

___
Python tracker 

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



[issue28398] Return singleton empty string in _PyUnicode_FromASCII

2016-11-06 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

The case for size=0 often is handled before calling _PyUnicode_FromASCII. In 
what circumstances _PyUnicode_FromASCII is called with size=0? Is this case 
covered by tests?

--

___
Python tracker 

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



[issue28147] Unbounded memory growth resizing split-table dicts

2016-11-06 Thread Serhiy Storchaka

Changes 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



[issue28199] Compact dict resizing is doing too much work

2016-11-06 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Re-committed. It might be dangerous to commit this in 3.6 at that stage.

--
resolution:  -> fixed
stage: commit 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



[issue28199] Compact dict resizing is doing too much work

2016-11-06 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 39f33c15243b by Serhiy Storchaka in branch 'default':
Issue #28199: Microoptimized dict resizing.  Based on patch by Naoki Inada.
https://hg.python.org/cpython/rev/39f33c15243b

--

___
Python tracker 

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



[issue28123] _PyDict_GetItem_KnownHash ignores DKIX_ERROR return

2016-11-06 Thread STINNER Victor

STINNER Victor added the comment:

Sorry, I didn't have time to review this issue :-(

Thanks Xiang and Serhiy for fixing the issue! I prefer the new API (don't
ignore the error).

--

___
Python tracker 

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



[issue28543] Incomplete fast path codecs aliases in codecs doc

2016-11-06 Thread Berker Peksag

Berker Peksag added the comment:

This is a duplicate of issue 28393.

--
nosy: +berker.peksag
resolution:  -> duplicate
stage: patch review -> resolved
status: open -> closed
superseder:  -> Update encoding lookup docs wrt #27938
type: enhancement -> behavior

___
Python tracker 

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



[issue28624] Make the `cwd` argument to `subprocess.Popen` accept a `PathLike`

2016-11-06 Thread Ram Rachum

Changes by Ram Rachum :


--
components: Library (Lib)
nosy: cool-RR
priority: normal
severity: normal
status: open
title: Make the `cwd` argument to `subprocess.Popen` accept a `PathLike`
versions: Python 3.7

___
Python tracker 

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



[issue28624] Make the `cwd` argument to `subprocess.Popen` accept a `PathLike`

2016-11-06 Thread Ram Rachum

Changes by Ram Rachum :


--
type:  -> enhancement

___
Python tracker 

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



[issue28586] Convert os.scandir to Argument Clinic

2016-11-06 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 0590b9c5a18e by Serhiy Storchaka in branch 'default':
Issue #28586: Converted os.scandir() to Argument Clinic.
https://hg.python.org/cpython/rev/0590b9c5a18e

--
nosy: +python-dev

___
Python tracker 

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



[issue28123] _PyDict_GetItem_KnownHash ignores DKIX_ERROR return

2016-11-06 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
resolution:  -> fixed
stage: commit 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



[issue28123] _PyDict_GetItem_KnownHash ignores DKIX_ERROR return

2016-11-06 Thread Roundup Robot

Roundup Robot added the comment:

New changeset d06a6b0fd992 by Serhiy Storchaka in branch '3.6':
Issue #28123: _PyDict_GetItem_KnownHash() now can raise an exception as
https://hg.python.org/cpython/rev/d06a6b0fd992

New changeset 805467de22fc by Serhiy Storchaka in branch 'default':
Issue #28123: _PyDict_GetItem_KnownHash() now can raise an exception as
https://hg.python.org/cpython/rev/805467de22fc

--
nosy: +python-dev

___
Python tracker 

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



[issue19569] Use __attribute__((deprecated)) to warn usage of deprecated functions and macros

2016-11-06 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Updated documentation. This part should be backported to all maintained 3.x 
versions.

--
Added file: http://bugs.python.org/file45370/mark-deprecated-functions-2.patch

___
Python tracker 

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



[issue28623] Let `shlex.quote` accept a `PathLike` object

2016-11-06 Thread Ram Rachum

New submission from Ram Rachum:

Currently it complains that you haven't fed it a string-like object.

--
components: Library (Lib)
messages: 280133
nosy: cool-RR
priority: normal
severity: normal
status: open
title: Let `shlex.quote` accept a `PathLike` object
type: enhancement
versions: Python 3.7

___
Python tracker 

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



[issue28622] Remove redundant variable annotation test from test_grammar

2016-11-06 Thread Ivan Levkivskyi

New submission from Ivan Levkivskyi:

This will remove one test from test_grammar that depends on typing module API 
(this test case is already covered in test_typing).

--
components: Tests
files: test-grammar-patch.diff
keywords: patch
messages: 280132
nosy: gvanrossum, levkivskyi
priority: normal
severity: normal
status: open
title: Remove redundant variable annotation test from test_grammar
versions: Python 3.6, Python 3.7
Added file: http://bugs.python.org/file45369/test-grammar-patch.diff

___
Python tracker 

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



[issue28621] Refactor duplicate code calculating digit's bit length

2016-11-06 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

LGTM.

--
nosy: +serhiy.storchaka
stage: patch review -> commit review

___
Python tracker 

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