[issue29296] convert print() to METH_FASTCALL

2017-01-19 Thread STINNER Victor

STINNER Victor added the comment:

Since the title of the issue is "convert print() to METH_FASTCALL", I consider 
that the issue is now done. As I wrote, as soon as AC will support **kwargs, we 
will be able to print() to use AC.

Thanks Naoki for the change.

--
dependencies:  -Argument Clinic should understand *args and **kwargs parameters
status: open -> closed

___
Python tracker 

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



[issue29327] SystemError or crash in sorted(iterable=

2017-01-19 Thread STINNER Victor

STINNER Victor added the comment:

"The patch uses new feature of 3.6 -- supporting positional-only
parameters in PyArg_ParseTupleAndKeywords()  (see issue26282)."

Oh, I didn't recall that it's a new feature. It's a nice feature by
the way, thanks for implementing it :-)

In that case, yeah it's ok to leave Python 3.5 unchanged. I proposed
to fix 3.5 because I expected that you could use exactly the same
patch.

--
title: SystemError or crash in sorted(iterable=[]) -> SystemError or crash in 
sorted(iterable=

___
Python tracker 

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



[issue29241] sys._enablelegacywindowsfsencoding() don't apply to os.fsencode and os.fsdecode

2017-01-19 Thread JGoutin

JGoutin added the comment:

A little encoding cache benchmark.


Current Code:
=

import sys

def _fscodec():
encoding = sys.getfilesystemencoding()
errors = sys.getfilesystemencodeerrors()

def fsencode(filename):
filename = fspath(filename)  # Does type-checking of `filename`.
if isinstance(filename, str):
return filename.encode(encoding, errors)
else:
return filename

def fsdecode(filename):
filename = fspath(filename)  # Does type-checking of `filename`.
if isinstance(filename, bytes):
return filename.decode(encoding, errors)
else:
return filename

return fsencode, fsdecode

fsencode, fsdecode = _fscodec()
del _fscodec

-

import os

%timeit os.fsdecode(b'\xc3\xa9')
The slowest run took 21.59 times longer than the fastest. This could mean that 
an intermediate result is being cached.
100 loops, best of 3: 449 ns per loop

%timeit os.fsencode('é')
The slowest run took 24.20 times longer than the fastest. This could mean that 
an intermediate result is being cached.
100 loops, best of 3: 412 ns per loop


Modified Code:
==

from sys import getfilesystemencoding, getfilesystemencodeerrors

def fsencode(filename):
filename = fspath(filename)  # Does type-checking of `filename`.
if isinstance(filename, str):
return filename.encode(getfilesystemencoding(),
   getfilesystemencodeerrors())
else:
return filename

def fsdecode(filename):
filename = fspath(filename)  # Does type-checking of `filename`.
if isinstance(filename, bytes):
return filename.decode(getfilesystemencoding(),
   getfilesystemencodeerrors())
else:
return filename

-

import os

%timeit os.fsdecode(b'\xc3\xa9')
The slowest run took 15.88 times longer than the fastest. This could mean that 
an intermediate result is being cached.
100 loops, best of 3: 541 ns per loop

%timeit os.fsencode('é')
The slowest run took 19.32 times longer than the fastest. This could mean that 
an intermediate result is being cached.
100 loops, best of 3: 502 ns per loop


Result:
===

Cache is a 17% speed up optimization.

--

___
Python tracker 

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



[issue29331] Simplify argument parsing in sorted() and list.sort()

2017-01-19 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

Proposed patch simplifies argument parsing in sorted() and list.sort().

list.sort() now uses the support of keyword-only parameters in 
PyArg_ParseTupleAndKeywords().

Keyword arguments now are passed as is to list.sorted() in sorted().

--
components: Interpreter Core
files: sort-arg-parse.patch
keywords: patch
messages: 285887
nosy: haypo, rhettinger, serhiy.storchaka
priority: normal
severity: normal
stage: patch review
status: open
title: Simplify argument parsing in sorted() and list.sort()
type: enhancement
versions: Python 3.7
Added file: http://bugs.python.org/file46351/sort-arg-parse.patch

___
Python tracker 

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



[issue29296] convert print() to METH_FASTCALL

2017-01-19 Thread INADA Naoki

INADA Naoki added the comment:

> Can we close the issue, or do you prefer to keep it open?

I don't care.

--

___
Python tracker 

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



[issue29327] SystemError or crash in sorted(iterable=[])

2017-01-19 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 1827b64cfce8 by Serhiy Storchaka in branch '3.6':
Issue #29327: Fixed a crash when pass the iterable keyword argument to sorted().
https://hg.python.org/cpython/rev/1827b64cfce8

New changeset f44f44b14dfc by Serhiy Storchaka in branch 'default':
Issue #29327: Fixed a crash when pass the iterable keyword argument to sorted().
https://hg.python.org/cpython/rev/f44f44b14dfc

--
nosy: +python-dev

___
Python tracker 

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



[issue29327] SystemError or crash in sorted(iterable=[])

2017-01-19 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

The title is spoiled when reply by email. I suppose [] has special meaning in 
email subject.

--
title: SystemError or crash in sorted(iterable= -> SystemError or crash in 
sorted(iterable=[])

___
Python tracker 

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



[issue29327] SystemError or crash in sorted(iterable=

2017-01-19 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

> Serhiy, this patch passes tests and looks fine.  I think you can go ahead
> with this patch.

Right now I'm building 3.6 with applied patch before final testing and 
committing. My netbook is very slow. :(

--
title: SystemError or crash in sorted(iterable=[]) -> SystemError or crash in 
sorted(iterable=

___
Python tracker 

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



[issue29328] struct module should support variable-length strings

2017-01-19 Thread Raymond Hettinger

Raymond Hettinger added the comment:

FWIW, I concur with Mark and Yuri that the feature request isn't compatible 
with the design and purpose of the struct module

--
nosy: +rhettinger

___
Python tracker 

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



[issue29327] SystemError or crash in sorted(iterable=[])

2017-01-19 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Serhiy, this patch passes tests and looks fine.  I think you can go ahead with 
this patch.

--
assignee:  -> serhiy.storchaka

___
Python tracker 

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



[issue29327] SystemError or crash in sorted(iterable=[])

2017-01-19 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
title: SystemError or crash in sorted(iterable= -> SystemError or crash in 
sorted(iterable=[])

___
Python tracker 

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



[issue29327] SystemError or crash in sorted(iterable=

2017-01-19 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

> While Python 3.5 doesn't crash, I consider that it has also the bug. So I
> added Python 3.5 in Versions.

The patch uses new feature of 3.6 -- supporting positional-only parameters in 
PyArg_ParseTupleAndKeywords()  (see issue26282). Since passing an iterable as 
a keyword argument never worked, it is safe to make the first parameter 
positional-only.

Actually I think that argument parsing code of sorted() and list.sort() can be 
simplified, but this is separate issue. I tried to make the bugfix patch simple.

--
title: SystemError or crash in sorted(iterable=[]) -> SystemError or crash in 
sorted(iterable=

___
Python tracker 

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



[issue29281] json.loads documentation missing "versionchanged" statement

2017-01-19 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Thanks for the patch.

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



[issue29281] json.loads documentation missing "versionchanged" statement

2017-01-19 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 3452ff9e8f0a by Raymond Hettinger in branch '3.6':
Issue #29281:  Fill-in a missing versionchanged entry
https://hg.python.org/cpython/rev/3452ff9e8f0a

--
nosy: +python-dev

___
Python tracker 

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



[issue29298] argparse fails with required subparsers, un-named dest, and empty argv

2017-01-19 Thread paul j3

paul j3 added the comment:

http://bugs.python.org/issue9253  argparse: optional subparsers

Initially this bug/issue was a request to allow subparsers to be optional.  But 
with the change in how required actions are handled, subparsers are now 
optional by default.

As you learned from the SO question you now have to specify

subparsers.required = True

This is also discussed in my post (and following ones)

http://bugs.python.org/issue9253#msg186387

The default 'dest' is SUPPRESS.  The error you report occurs because the 
'required' error mechanism cannot handle that value. The suggest fix is to 
assign `dest`, even if it is not needed in the Namespace.  For now it is needed 
for error reporting.

Reviewing my suggested patches, it looks like I generate a 'dest' substitute 
from the subparser names.  So the 'required' error would look like

python: error: the following arguments are required: {cmd1, cmd2}

I think this issue can be closed with a reference to 9253. Or maybe that issue 
is too old, long and confusing, and we need a new bug/issue.

--
nosy: +paul.j3

___
Python tracker 

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



[issue29281] json.loads documentation missing "versionchanged" statement

2017-01-19 Thread Raymond Hettinger

Changes by Raymond Hettinger :


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

___
Python tracker 

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



[issue29325] pysqlite: Evaluate removal of sqlite3_stmt_readonly

2017-01-19 Thread Ma Lin

Ma Lin added the comment:

RHEL6's life-cycle is around 10 years [1], it will be alive until 2020.
https://access.redhat.com/support/policy/updates/errata/

Let's wait issue28518, IMO, that issue will decide whether we can get around 
sqlite3_stmt_readonly().

--

___
Python tracker 

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



[issue29325] pysqlite: Evaluate removal of sqlite3_stmt_readonly

2017-01-19 Thread Xiang Zhang

Xiang Zhang added the comment:

Hi Ma Lin. If you find this is also a problem in sqlite3 module, feel free to 
open another issue against sqlite3. :-)

--

___
Python tracker 

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



[issue29325] pysqlite: Evaluate removal of sqlite3_stmt_readonly

2017-01-19 Thread Ma Lin

Ma Lin added the comment:

sqlite3 module in CPython 3.6.0 also uses sqlite3_stmt_readonly(). see 
284676cf2ac8.
sqlite3_stmt_readonly() was used twice [1][2], but it seems that we can avoid 
using this function in both of them.

[1] https://hg.python.org/cpython/file/3.6/Modules/_sqlite/cursor.c#l517
In palaviv's patch of issue28518, we can eliminate sqlite3_stmt_readonly() in 
here.

[2] https://hg.python.org/cpython/file/3.6/Modules/_sqlite/cursor.c#l612
We can using the old way, so that we can get around it in here.

--
nosy: +Ma Lin

___
Python tracker 

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



[issue29327] SystemError or crash in sorted(iterable=[])

2017-01-19 Thread Raymond Hettinger

Raymond Hettinger added the comment:

A few random thoughts that may or may not be helpful:

* We now have two seasoned developers and one new core developer that 
collectively are creating many non-trivial patches to core parts of Python at 
an unprecedented rate of change.  The patches are coming in much faster than 
they can reasonably be reviewed and carefully considered, especially by devs 
such as myself who have very limited time available.  IMO, taken as whole, 
these changes are destabilizing the language.  Python is so successful and 
widely adopted that we can't afford a "shit happens" attitude.  Perhaps that 
works in corners of the language, infrequently used modules, but it makes less 
sense when touching the critical paths that have had slow and careful evolution 
over 26 years.

* Besides the volume of patches, one other reason that reviews are hard to come 
by is that they apply new APIs that I don't fully understand yet.  There are 
perhaps two people on the planet who could currently give thoughtful, correct, 
and critical evaluation of all those patches.  Everyone else is just watching 
them all fly by and hoping that something good is happening.

* One other reason for the lack of review comments in the enthusiasm and fervor 
surrounding the patches.  I feel like there is a cost of questioning whether 
the patches should be done or how they are done, like I am burning little karma 
every time.  Sometimes it feels safest and most cordial to just say nothing and 
let you make hundreds of semi-reviewed changes to just about every critical 
part of the language.

* Historically, if there was creator or maintainer of the code who was still 
active, that person would always be consulted and have a final say on whether a 
change should be applied.  Now, we have code constantly being changed without 
consulting the original author (for example, the recent and catastrophic random 
initialization bug was due to application of a patch without consulting the 
author of _randommodule.c and the maintainer of random.py, or this change to 
sorted(), or the changes to decimal, etc).

* In general, Guido has been opposed to sweeping changes across the code base 
for only tiny benefits.  Of late, that rule seems to have been lost.

* The benefits of FASTCALL mainly apply to fine grained functions which only do 
a little work and tend to be called frequently in loops.  For functions such as 
sorted(), the calling overhead is dominated by the cost of actually doing the 
sort.  For sorted(), FASTCALL is truly irrelevant and likely wasn't worth the 
complexity, or the actual bug, or any of the time we've now put in it.  There 
was no actual problem being solved, just a desire to broadly apply new 
optimizations.

* Historically, we've relied on core developers showing restraint.  Not every 
idea that pops into their head is immediately turned into a patch accompanied 
by pressure to apply it.  Devs tended to restrict themselves to parts of the 
code they knew best through long and careful study rather sweeping through 
modules and altering other people's carefully crafted code.

* FWIW, I applaud your efforts to reduce call overhead -- that has long been a 
sore spot for the language.

* Guido has long opposed optimizations that increase risk of bugs, introduce 
complexity, or that affect long-term maintainability.   In some places, it 
looks like FASTCALL is increasing the complexity (replacing something simple 
and well-understood with a wordier, more intricate API that I don't yet fully 
understand and will affect my ability to maintain the surrounding code).

* It was no long ago that you fought tooth-and-nail against a single line patch 
optimization I submitted.  The code was clearly correct and had a simple 
disassembly to prove its benefit.  Your opposition was based on "it increases 
the complexity of the code, introduces a maintenance cost, and increases the 
risk of bugs".  In the end, your opposition killed the patch.  But now, the AC 
and FASTCALL patches don't seem to mind any of these considerations.

* AC is supposed to be a CPython-only concept.  But along the way APIs are 
being changed without discussion.  I don't mind that sorted() now exposes 
*iterable* as a keyword argument, but it was originally left out on purpose 
(Tim opined that code would look worse with iterable as a keyword argument).  
That decision was reversed unilaterally without consulting the author and 
without a test.  Also as AC is being applied, the variable names are being 
changed.  I never really liked the "mp" that used in dicts and prefer the use 
of "self" better, but it is a gratuitous change that unilaterally reverses the 
decisions of the authors and makes the code not match any of the surrounding 
code that uses the prior conventions.

* FWIW, the claim that the help is much better is specious.  AFAICT, there has 
never been the slightest problem with "sorted(iterable, key=None, 
reverse=False) --> new 

[issue29325] pysqlite: Evaluate removal of sqlite3_stmt_readonly

2017-01-19 Thread Xiang Zhang

Xiang Zhang added the comment:

pysqlite is not part of Python stdlib so here is not the right place. :-(
Maybe you could go to https://github.com/ghaering/pysqlite for help.

--
nosy: +xiang.zhang
resolution:  -> third party
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



[issue29292] Missing a parameter in PyEval_EvalCodeEx doc

2017-01-19 Thread Xiang Zhang

Xiang Zhang added the comment:

Thanks Ammar. :-)

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



[issue29292] Missing a parameter in PyEval_EvalCodeEx doc

2017-01-19 Thread Roundup Robot

Roundup Robot added the comment:

New changeset bb76ea32a32f by Xiang Zhang in branch '3.5':
Issue #29292: Update outdated doc of PyEval_EvalCodeEx.
https://hg.python.org/cpython/rev/bb76ea32a32f

New changeset bd121b7517ee by Xiang Zhang in branch '3.6':
Issue #29292: Merge 3.5.
https://hg.python.org/cpython/rev/bd121b7517ee

New changeset ef1146c95860 by Xiang Zhang in branch 'default':
Issue #29292: Merge 3.6.
https://hg.python.org/cpython/rev/ef1146c95860

--
nosy: +python-dev

___
Python tracker 

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



[issue29281] json.loads documentation missing "versionchanged" statement

2017-01-19 Thread Ammar Askar

Ammar Askar added the comment:

Attached patch adds a versionchanged block to specify that bytes and bytesarray 
can now be used and the types of encodings it supports (as taken from the 
whatsnew changes here https://hg.python.org/cpython/rev/e9e1bf9ec2ac#l2.7)

--
keywords: +patch
Added file: http://bugs.python.org/file46350/json_loads_bytes.diff

___
Python tracker 

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



[issue29292] Missing a parameter in PyEval_EvalCodeEx doc

2017-01-19 Thread Ammar Askar

Ammar Askar added the comment:

Updated patch to include a cross reference to keyword-only arguments since I 
think not everyone will know about this rather new feature.

--
Added file: http://bugs.python.org/file46349/kwdefs_docs.diff4

___
Python tracker 

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



[issue29292] Missing a parameter in PyEval_EvalCodeEx doc

2017-01-19 Thread Ammar Askar

Ammar Askar added the comment:

Updated patch for review comments

--
Added file: http://bugs.python.org/file46348/kwdefs_docs.diff3

___
Python tracker 

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



[issue9338] argparse optionals with nargs='?', '*' or '+' can't be followed by positionals

2017-01-19 Thread paul j3

paul j3 added the comment:

Recent StackOverFlow question related to this issue - where the following 
positional is a subparsers.


http://stackoverflow.com/questions/41742205/how-to-argparse-with-nargs-and-subcommands

--

___
Python tracker 

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



[issue9625] argparse: Problem with defaults for variable nargs when using choices

2017-01-19 Thread paul j3

paul j3 added the comment:

Recent StackOverFlow question related to this issue

http://stackoverflow.com/questions/41750896/python-argparse-type-inconsistencies-when-combining-choices-nargs-and-def/41751730#41751730

--

___
Python tracker 

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



[issue29316] Keep typing.py provisional for the duration of the Python 3.6 release cycle

2017-01-19 Thread Guido van Rossum

Guido van Rossum added the comment:

Thanks everybody! We'll make typing.py provisional again for 3.6. @levkivskyi 
do you have the stomach to upload a patch here?

--
title: Can we keep typing.py provisional for the duration of the Python 3.6 
release cycle? -> Keep typing.py provisional for the duration of the Python 3.6 
release cycle

___
Python tracker 

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



[issue29259] Add tp_fastcall to PyTypeObject: support FASTCALL calling convention for all callable objects

2017-01-19 Thread STINNER Victor

STINNER Victor added the comment:

tp_fastcall-5.patch: Rebased patch. I already tried to push changes not 
directly related to tp_fastcall, so the new patch should be a *little bit* 
shorter.

--
Added file: http://bugs.python.org/file46347/tp_fastcall-5.patch

___
Python tracker 

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



[issue29323] Wrong documentation (Library) for unicode and str comparison

2017-01-19 Thread R. David Murray

R. David Murray added the comment:

That's a good point, I think that is exactly the issue with that paragraph.

--

___
Python tracker 

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



[issue29316] Can we keep typing.py provisional for the duration of the Python 3.6 release cycle?

2017-01-19 Thread Ned Deily

Ned Deily added the comment:

As far as I can tell, the only places that typing was declared as provisional 
were in PEP 484 and twice in the 3.5 What's New document 
(https://docs.python.org/3.5/whatsnew/3.5.html); it doesn't appear to have been 
mentioned in the library reference 
(https://docs.python.org/3.5/library/typing.html) and probably should have 
been.  FTR, it looks like there was some discussion of removing typing's 
provisional status in https://github.com/python/typing/issues/278 and 
https://github.com/python/typing/issues/247.  While it seems somewhat unusual 
to reinstate a feature's provisional status, I don't have an objection as 3.6 
release manager since it is clear that typing is still a new and evolving 
module.  To make the change in status, the 3.6 What's New document should be 
updated, a Misc/NEWS entry added for 3.6.1, and the provisional status added to 
Docs/library/typing.rst.

--
stage:  -> needs patch

___
Python tracker 

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



[issue29330] __slots__ needs documentation

2017-01-19 Thread Raymond Hettinger

Changes by Raymond Hettinger :


--
assignee: docs@python -> rhettinger

___
Python tracker 

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



[issue29330] __slots__ needs documentation

2017-01-19 Thread Eryk Sun

Eryk Sun added the comment:

Are you suggesting that the Helper class in Lib/pydoc.py should index 
[sub-]topics by special names such as "__slots__"? Currently you can see the 
__slots__ documentation via the topics "ATTRIBUTEMETHODS" and "SPECIALMETHODS". 
The list of topics can be printed via help('topics'). Also when you exit out of 
help('__') it refers you to the SPECIALMETHODS topic.

--
nosy: +eryksun

___
Python tracker 

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



[issue27596] Build failure with Xcode 8 beta on OSX 10.11

2017-01-19 Thread Maxime Belanger

Maxime Belanger added the comment:

Glad to hear it! Thanks for the quick followup :).

--

___
Python tracker 

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



[issue29328] struct module should support variable-length strings

2017-01-19 Thread Yury Selivanov

Yury Selivanov added the comment:

Ethan, thanks for moving my reply on the list to here.  Also +1 to what Mark 
said.

--
nosy: +yselivanov

___
Python tracker 

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



[issue27596] Build failure with Xcode 8 beta on OSX 10.11

2017-01-19 Thread Ned Deily

Ned Deily added the comment:

Maxime, there have been a couple of attempts to address this problem.  We 
believe it now finally fixed for all versions of macOS from 10.6 through 10.12 
by the changes in Issue29057.  Unfortunately, for 2.7,x the last set of fixes 
were after the release of 2.7.13 in December so, until 2.7.14 is released, you 
may need to manually apply changeset 74eb71b91112.  (Closing this issue as a 
duplicate of Issue29057)

--
resolution:  -> duplicate
stage: needs patch -> resolved
status: open -> closed
superseder:  -> Compiler failure on Mac OS X - sys/random.h

___
Python tracker 

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



[issue29057] Compiler failure on Mac OS X - sys/random.h

2017-01-19 Thread Ned Deily

Changes by Ned Deily :


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



[issue9338] argparse optionals with nargs='?', '*' or '+' can't be followed by positionals

2017-01-19 Thread paul j3

Changes by paul j3 :


--
priority: normal -> high

___
Python tracker 

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



[issue9625] argparse: Problem with defaults for variable nargs when using choices

2017-01-19 Thread paul j3

Changes by paul j3 :


--
priority: normal -> high

___
Python tracker 

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



[issue29330] __slots__ needs documentation

2017-01-19 Thread saumitra paul

saumitra paul added the comment:

Python 2.7.10 (default, Oct 23 2015, 19:19:21)

[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin

Type "help", "copyright", "credits" or "license" for more information.

>>> help(__slots__)

Traceback (most recent call last):

  File "", line 1, in 

NameError: name '__slots__' is not defined

>>> help('__slots__')

no Python documentation found for '__slots__'

>>>

On Thu, Jan 19, 2017 at 2:48 PM, Martin Panter 
wrote:

>
> Martin Panter added the comment:
>
> Have you seen ?
> There is also .
>
> --
> assignee:  -> docs@python
> components: +Documentation
> nosy: +docs@python, martin.panter
>
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

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



[issue29327] SystemError or crash in sorted(iterable=[])

2017-01-19 Thread STINNER Victor

STINNER Victor added the comment:

Raymond: "Please be careful with all of these AC changes.  They need to have 
tests.  They need to not change APIs.  They need to not introduce bugs."

The bug was not introduced by an Argument Clinic change.

I agree that switching to AC must not change the API.

I didn't look much at the "recent" AC changes (it started somethings like 2 
years ago, no?), but it seems like the most common trap are default values of 
optional positional arguments. Sometimes, there are inconsistencies between 
.rst doc (in Doc/ directory), the docstring and the C implementation. The trap 
is when the default is documented as None, the C code uses NULL and passing 
None behaves differently...


Raymond: "The whole effort seems to be being pushed forward in a cavalier and 
aggressive manner. In this case, there was an API change and bugs introduced 
for basically zero benefit."

I converted a few functions to AC. I used regular reviews for that, since I 
noticed that it's easy to make mistakes. My hope is that the AC conversion will 
also help to fix inconsistencies.

The benefit of switching to AC is a better docstring and a correct signature 
for inspect.signature(func). Python 3.5:
---
sorted(...)
sorted(iterable, key=None, reverse=False) --> new sorted list
---
versus Python 3.7
---
sorted(iterable, key=None, reverse=False)
Return a new list containing all items from the iterable in ascending order.

A custom key function can be supplied to customize the sort order, and the
reverse flag can be set to request the result in descending order.
---

IHMO Python 3.7 docstring looks better. (Sadly, sorted() doesn't use AC yet, 
the "AC code" was genereted manually. AC should support **kwargs, issue #20291.)



I guess "cavalier" and "aggressive" is more related to my FASTCALL work. I'm 
waiting for reviews for major API changes. I agree that I pushed a lot of code 
without reviews when I considered that the change was safe and simple. It 
became hard to get a review, there are too few reviewers, especially on the C 
code.

The benefit of FASTCALL are better performances. I'm trying to provide 
benchmarks whenever possible, but since I modified dozens of functions, 
sometimes I didn't publish all benchmark results (sometimes even to not spam an 
issue).


Microbenchmark on sorted() on Python 3.7 compared to 3.5 (before FASTCALL):
---
haypo@smithers$ ./python -m perf timeit 'seq=list(range(10))' 'sorted(seq)' 
--compare-to=../3.5/python -v
Median +- std dev: [3.5] 1.07 us +- 0.06 us -> [3.7] 958 ns +- 15 ns: 1.12x 
faster (-11%)

haypo@smithers$ ./python -m perf timeit 'seq=list(range(10)); k=lambda x:x' 
'sorted(seq, key=k)' --compare-to=../3.5/python -v
Median +- std dev: [3.5] 3.34 us +- 0.07 us -> [3.7] 2.66 us +- 0.05 us: 1.26x 
faster (-21%)
---

It's not easy nor interesting to measure the speedup of the changes limited to 
sorted(). Sadly, FASTCALL requires to modify a lot of code to show its full 
power. Otherwise, the gain is much smaller.


The latest major "API change" was made by you 14 years ago. Yes, I introduced a 
bug, and I'm sorry about that. Shit happens.

Let's be more constructive: to avoid bugs, the best is to get reviews. I have 
dozens of patches waiting for your review, so please come to help me to spot 
bugs before releases ;-)

--

___
Python tracker 

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



[issue29330] __slots__ needs documentation

2017-01-19 Thread Martin Panter

Martin Panter added the comment:

Have you seen ? 
There is also .

--
assignee:  -> docs@python
components: +Documentation
nosy: +docs@python, martin.panter

___
Python tracker 

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



[issue27596] Build failure with Xcode 8 beta on OSX 10.11

2017-01-19 Thread Maxime Belanger

Maxime Belanger added the comment:

We're hitting this issue with Python 2.7 (which we deploy on Mac OS X 
10.6-10.12). We've worked around it by manually patching `pyconfig.h` to 
un-define `HAVE_GETENTROPY` before `make`ing. Is a patch is in the works to 
support weak-linking this symbol (and the other new Sierra additions)?

--
nosy: +Maxime Belanger

___
Python tracker 

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



[issue29323] Wrong documentation (Library) for unicode and str comparison

2017-01-19 Thread Martin Panter

Martin Panter added the comment:

If you read the whole paragraph carefully, I don't think it is too misleading. 
"In particular, tuples and lists . . ." suggests the author was just trying to 
say that a tuple never compares equal to a list. Maybe we just need to make 
that more obvious?

However there are other problems in this part of the reference about comparing 
different types. See Issue 22000, about the earlier section on Comparisons of 
built-in types.

--
nosy: +martin.panter

___
Python tracker 

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



[issue29327] SystemError or crash in sorted(iterable=[])

2017-01-19 Thread STINNER Victor

STINNER Victor added the comment:

While Python 3.5 doesn't crash, I consider that it has also the bug. So I added 
Python 3.5 in Versions.

sorted.diff LGTM. And thank you for the unit test!

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



[issue29330] __slots__ needs documentation

2017-01-19 Thread saumitra paul

New submission from saumitra paul:

As you said..assiging it to you :)

--
messages: 285850
nosy: rhettinger, saumitra1978
priority: normal
severity: normal
status: open
title: __slots__ needs documentation
versions: Python 2.7

___
Python tracker 

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



[issue29327] SystemError or crash in sorted(iterable=[])

2017-01-19 Thread STINNER Victor

STINNER Victor added the comment:

Oh, this issue is very subtle.

Since the list.sorted() class method became a builtin sorted() method (Python 
2.4.0, change c06b570adf12 by Raymond Hettinger), the sorted() function accepts 
an iterable as a keyword argument, whereas list.sort() doesn't. 
sorted(iterable=[]) fails on calling internally list.sort(iterable=[]), not 
when sorted() parses its arguments.

The change 6219aa966a5f (issue #20184) converted sorted() to Argument Clinic. 
This change was released in Python 3.5.3 and 3.6.0... but it didn't introduce 
the bug. It's not the fault of Argument Clinic!

The change b34d2ef5c412 (issue #27809) replacing METH_VARARGS|METH_KEYWORDS 
with METH_FASTCALL didn't introduce the bug neither.

It's the change 15eab21bf934 (issue #27809) which replaced 
PyEval_CallObjectWithKeywords() with _PyObject_FastCallDict(). This change also 
replaces PyTuple_GetSlice(args, 1, argc) with _GET_ITEM(args, 1) which 
introduced the bug. I didn't notice that args can be an empty tuple. I never 
tried to call sorted(iterable=seq), I didn't know the name of the first 
parameter :-)

I also replaced PyTuple_GetSlice(args, 1, argc) with _GET_ITEM(args, 1) 
in methoddescr_call(), but this function make sure that we have at least one 
positional argument and so doesn't have this bug. Moreover, this method doesn't 
use Argument Clinic (yet? ;-)). I'm quite sure that I didn't replace 
PyTuple_GetSlice() in other functions.

--

___
Python tracker 

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



[issue29327] SystemError or crash in sorted(iterable=[])

2017-01-19 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Please be careful with all of these AC changes.  They need to have tests.  They 
need to not change APIs.  They need to not introduce bugs.  The whole effort 
seems to be being pushed forward in a cavalier and aggressive manner.

In this case, there was an API change and bugs introduced for basically zero 
benefit.

--
nosy: +rhettinger
priority: normal -> high

___
Python tracker 

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



[issue29296] convert print() to METH_FASTCALL

2017-01-19 Thread STINNER Victor

STINNER Victor added the comment:

Serhiy Storchaka:
> When the fastcall protocol be changed, this would require changing more 
> handwritten code.

I don't plan to modify the fastcall protocol. I'm not sure that it's
really possible to modify it anymore. It would probably be simpler to
add a new protocol. But it may become a little bit annoying to have to
support so many calling convention :-) So someone should come up with
a serious rationale to add another one :-)

I tried to make fastcall as private as possible, but recently I
noticed that METH_FASTCALL is now public in Python 3.6 API (but
hopefully excluded from the stable ABI). I know that it's already used
by Cython since 0.25:
https://mail.python.org/pipermail/cython-devel/2016-October/004959.html

About the maintenance burden, I'm ok to handle it :-) My final goal is
to use Argument Clinic everywhere. While converting existing code to
AC is a slow process, I consider (from my recent experiences with AC)
that the new code is easier to maintain! It's a slow process beause AC
still has limitaitons, but also because it's used an opportunity to
review (and enhance!) the existing docstrings.

--

___
Python tracker 

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



[issue29328] struct module should support variable-length strings

2017-01-19 Thread Ethan Furman

Ethan Furman added the comment:

>From Yury Selivanov:
---
This is a neat idea, but this will only work for parsing framed
binary protocols.  For example, if you protocol prefixes all packets
with a length field, you can write an efficient read buffer and
use your proposal to decode all of message's fields in one shot.
Which is good.

Not all protocols use framing though.  For instance, your proposal
won't help to write Thrift or Postgres protocols parsers.

Overall, I'm not sure that this is worth the hassle.  With proposal:

   data, = struct.unpack('!H$', buf)
   buf = buf[2+len(data):]

with the current struct module:

   len, = struct.unpack('!H', buf)
   data = buf[2:2+len]
   buf = buf[2+len:]

Another thing: struct.calcsize won't work with structs that use
variable length fields.

--

___
Python tracker 

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



[issue29311] Argument Clinic: convert dict methods

2017-01-19 Thread Martin Panter

Martin Panter added the comment:

D.get(key[, default]) -> D[key] if key in D, else default.

There is no big problem with that. D is defined at the start. The only thing I 
would have suggested is avoid using square brackets to mean two things in the 
one expression. Since it is no longer the signature, calling with both 
parameters should be okay:

'''
get($self, key, default=None, /)
--
D.get(key, default) -> D[key] if key in D, else default.
'''

However the other method no longer defines D:

'''
setdefault($self, key, default=None, /)
--
D.get(key,default), also set D[key]=default if key not in D.
'''

You could restore the initial text as “D.setdefault(key,default) ->”, or maybe 
rewrite it like

“Like get(), but also insert the default value if it is missing.”

--
nosy: +martin.panter

___
Python tracker 

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



[issue29282] Fused multiply-add: proposal to add math.fma()

2017-01-19 Thread Mark Dickinson

Mark Dickinson added the comment:

Thanks, Serhiy. I'm going to hold off committing this for 24 hours or so, 
because I want to follow the buildbots when I do (and I don't have time for 
that right now). I wouldn't be at all surprised to see platform-specific test 
failures.

--

___
Python tracker 

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



[issue29282] Fused multiply-add: proposal to add math.fma()

2017-01-19 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Then LGTM unconditionally.

--

___
Python tracker 

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



[issue13285] signal module ignores external signal changes

2017-01-19 Thread R. David Murray

R. David Murray added the comment:

IMO the signal handler context manager would be useful (I have existing code 
where I wrote one that didn't quite work right :).  I suggest you propose this 
on python-ideas.

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



[issue29282] Fused multiply-add: proposal to add math.fma()

2017-01-19 Thread Mark Dickinson

Mark Dickinson added the comment:

Ah, the dev guide says 80 characters. 
(https://docs.python.org/devguide/documenting.html)

--

___
Python tracker 

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



[issue29282] Fused multiply-add: proposal to add math.fma()

2017-01-19 Thread Mark Dickinson

Mark Dickinson added the comment:

> lines in What's New are too long.

Thanks. Fixed (I think). I'm not sure what the limit is, but the lines are now 
all <= 79 characters long.

--
Added file: http://bugs.python.org/file46346/math_fma3.patch

___
Python tracker 

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



[issue29282] Fused multiply-add: proposal to add math.fma()

2017-01-19 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

LGTM except that lines in What's New are too long.

--
assignee:  -> mark.dickinson
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



[issue29282] Fused multiply-add: proposal to add math.fma()

2017-01-19 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
Removed message: http://bugs.python.org/msg285838

___
Python tracker 

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



[issue29282] Fused multiply-add: proposal to add math.fma()

2017-01-19 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Have you missed the patch?

--

___
Python tracker 

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



[issue29329] Incorrect documentation for custom `hex()` support on Python 2

2017-01-19 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
assignee:  -> docs@python
components: +Documentation
keywords: +easy
nosy: +docs@python
stage:  -> needs patch
versions: +Python 2.7

___
Python tracker 

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



[issue29282] Fused multiply-add: proposal to add math.fma()

2017-01-19 Thread Mark Dickinson

Mark Dickinson added the comment:

Whoops; looks like I failed to attach the updated patch. Here it is.

--
Added file: http://bugs.python.org/file46345/math_fma2.patch

___
Python tracker 

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



[issue29282] Fused multiply-add: proposal to add math.fma()

2017-01-19 Thread Mark Dickinson

Mark Dickinson added the comment:

Serhiy, Victor: thanks for the reviews. Here's a new patch. Differences w.r.t. 
the old one:

- Converted to argument clinic.
- Updated docstring to talk about special cases.
- More tests, as suggested by Serhiy.
- whatsnew entry and ..versionadded in docs.

--

___
Python tracker 

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



[issue29329] Incorrect documentation for custom `hex()` support on Python 2

2017-01-19 Thread Eryk Sun

Eryk Sun added the comment:

Python 3 uses __index__ for bin(), oct(), and hex(), but Python 2 only uses 
__index__ for bin() and otherwise uses __oct__ and __hex__. Antoine overlooked 
this when updating the 2.7 docs for hex() in issue 16665.

--
nosy: +eryksun

___
Python tracker 

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



[issue29328] struct module should support variable-length strings

2017-01-19 Thread Mark Dickinson

Mark Dickinson added the comment:

IMO, as one of the previous maintainers of the struct module, this feature 
request isn't compatible with the current design and purpose of the struct 
module. I agree that there's an important problem to solve (and one I've had to 
solve many times for various formats in consulting work); it's simply that the 
struct module isn't the right place to solve it.

--
nosy: +mark.dickinson

___
Python tracker 

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



[issue20186] Derby #18: Convert 31 sites to Argument Clinic across 23 files

2017-01-19 Thread Tal Einat

Tal Einat added the comment:

Serhiy, no apology is required. On the contrary, thank you for the taking the 
time to review this and commit, I don't have time available for this these days.

--

___
Python tracker 

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



[issue29328] struct module should support variable-length strings

2017-01-19 Thread Ethan Furman

Changes by Ethan Furman :


--
nosy: +ethan.furman

___
Python tracker 

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



[issue29329] Incorrect documentation for custom `hex()` support on Python 2

2017-01-19 Thread Pekka Klärck

New submission from Pekka Klärck:

Documentation of `hex()` on Python 2 says that custom objects need to implement 
`__index__` to support it. Based on my tests that doesn't work but `__hex__` is 
needed instead. Docs are at 
https://docs.python.org/2/library/functions.html?highlight=hex#hex and here's 
an example session:

Python 2.7.6 (default, Oct 26 2016, 20:30:19) 
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> class Hex(object):
... def __index__(self):
... return 255
... 
>>> hex(Hex())
Traceback (most recent call last):
  File "", line 1, in 
TypeError: hex() argument can't be converted to hex
>>> 
>>> class Hex(object):
... def __hex__(self):
... return hex(255)
... 
>>> hex(Hex())
'0xff'


 
Assuming this is fixed, should probably note that with Python 3 you actually 
*need* to implement `__index__` and `__hex__` has no effect.

--
messages: 285832
nosy: pekka.klarck
priority: normal
severity: normal
status: open
title: Incorrect documentation for custom `hex()` support on Python 2

___
Python tracker 

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



[issue13285] signal module ignores external signal changes

2017-01-19 Thread Thomas Kluyver

Thomas Kluyver added the comment:

I'd like to make the case for a fix in the code again. Our use case is, I 
believe, the same as Vilya's. We want to temporarily set a signal handler from 
Python and then restore the previous handler. This is fairly straightforward 
for Python handler functions, and SIG_DFL and SIG_IGN, but it breaks if 
anything has set a C level signal handler.

The opaque wrapper object is a solution that had occurred to me too. Another 
option would be a context manager implemented in C (I assume context managers 
can be written in C) which can set one or more signal handlers on entry, and 
restore them on exit.

--
nosy: +takluyver

___
Python tracker 

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



[issue29328] struct module should support variable-length strings

2017-01-19 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Could you provide some examples of using these format specifiers? I suppose 
that due to limitations of the struct module the way in which they can be 
implemented would be not particularly useful for you.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue29327] SystemError or crash in sorted(iterable=[])

2017-01-19 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Proposed patch fixes the bug.

--
keywords: +patch
nosy: +haypo
stage:  -> patch review
title: SystemError in sorted(iterable=[]) -> SystemError or crash in 
sorted(iterable=[])
Added file: http://bugs.python.org/file46344/sorted.diff

___
Python tracker 

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



[issue29328] struct module should support variable-length strings

2017-01-19 Thread Elizabeth Myers

New submission from Elizabeth Myers:

There was some discussion on python-ideas about this, and I figured it would be 
more productive to bring it here since to me this appears to be a glaring 
omission.

The struct module has no capability to support variable-length strings; this 
includes null-terminated and Pascal-ish strings with a different integer 
datatype (usually in binary) specifying length.

This unfortunate omission makes the struct module extremely unwieldy to use in 
situations where you need to unpack a lot of variable-length strings, 
especially iteratively; see 
https://mail.python.org/pipermail/python-ideas/2017-January/044328.html for 
why. For zero-terminated strings, it is essentially impossible.

It's worth noting many modern protocols use variable-length strings, including 
DHCP.

I therefore propose the following extensions to the struct module (details can 
be bikeshedded over :P):

- Z (uppercase) format specifier (I did not invent this idea, see 
https://github.com/stendec/netstruct - although that uses $), which states the 
preceding whole-number datatype is the length of a string that follows.
- z (lowercase) format specifier, which specifies a null-terminated (also known 
as C style) string. An optional length parameter can be added to specify the 
maximum search length.

These two additions will make the struct module much more usable in a wider 
variety of contexts.

--
components: Library (Lib)
messages: 285828
nosy: Elizacat
priority: normal
severity: normal
status: open
title: struct module should support variable-length strings
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



[issue29327] SystemError in sorted(iterable=[])

2017-01-19 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

In debug build Python is crashed.

>>> sorted(iterable=[])
python: Objects/abstract.c:2317: _PyObject_FastCallDict: Assertion `nargs >= 0' 
failed.
Aborted (core dumped)

--
type: behavior -> crash

___
Python tracker 

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



[issue29327] SystemError in sorted(iterable=[])

2017-01-19 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Seems this regression was introduced in issue27809.

--

___
Python tracker 

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



[issue2771] Test issue

2017-01-19 Thread Brett Cannon

Changes by Brett Cannon :


--
pull_requests: +19

___
Python tracker 

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



[issue28837] 2to3 does not wrap zip correctly

2017-01-19 Thread Stuart Berg

Changes by Stuart Berg :


Added file: http://bugs.python.org/file46343/fix-28837.patch

___
Python tracker 

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



[issue28837] 2to3 does not wrap zip correctly

2017-01-19 Thread Stuart Berg

Changes by Stuart Berg :


Removed file: http://bugs.python.org/file46342/fix-28837.patch

___
Python tracker 

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



[issue29319] Embedded 3.6.0 distribution cannot run pyz files

2017-01-19 Thread Steve Dower

Steve Dower added the comment:

I'd say it definitely qualifies as a bug fix, even in 3.5 (which repros), 
assuming we don't break any existing APIs in the process.

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



[issue29316] Can we keep typing.py provisional for the duration of the Python 3.6 release cycle?

2017-01-19 Thread Brett Cannon

Brett Cannon added the comment:

Keeping it provisional sounds reasonable to me, especially if it helps land 
protocol support.

--
nosy: +brett.cannon

___
Python tracker 

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



[issue28837] 2to3 does not wrap zip correctly

2017-01-19 Thread Stuart Berg

Changes by Stuart Berg :


Removed file: http://bugs.python.org/file46341/fix-28837.patch

___
Python tracker 

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



[issue28837] 2to3 does not wrap zip correctly

2017-01-19 Thread Stuart Berg

Stuart Berg added the comment:

Sorry for re-uploading the patch; I made some pep8 fixes.

--
Added file: http://bugs.python.org/file46342/fix-28837.patch

___
Python tracker 

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



[issue29319] Embedded 3.6.0 distribution cannot run pyz files

2017-01-19 Thread Paul Moore

Paul Moore added the comment:

Nice! Thanks for finding this. I don't suppose there's any chance this would 
qualify as a bugfix for 3.6.1? I've been holding off on working on 
https://github.com/pfmoore/pylaunch until 3.6 because 3.5 doesn't handle being 
in a subdirectory very well. It'd be a shame if this meant I could only really 
support 3.7+

But it is a pretty minor use case, so I'll live either way.

FWIW, I'm inclined to think we shouldn't be blindly overwriting things, at the 
very least we should check that what we're overwriting is what we expect. But 
my knowledge of this part of the interpreter is pretty much zero, so I'll defer 
to the experts.

--

___
Python tracker 

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



[issue29311] Argument Clinic: convert dict methods

2017-01-19 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

There was a context in old docstrings removed in new docstrings.

It is not always possible just to copy docstrings in Argument Clinic. Sometimes 
rewriting docstrings is the hardest part of converting to Argument Clinic.

I suggest either restore the context that defines D, or better totally rewrite 
docstrings, getting the wording from the documentation.

--

___
Python tracker 

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



[issue28837] 2to3 does not wrap zip correctly

2017-01-19 Thread Stuart Berg

Changes by Stuart Berg :


Added file: http://bugs.python.org/file46341/fix-28837.patch

___
Python tracker 

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



[issue29289] Convert OrderedDict methods to Argument Clinic

2017-01-19 Thread Roundup Robot

Roundup Robot added the comment:

New changeset c144bf6c0ff7 by Serhiy Storchaka in branch 'default':
Issue #29289: Argument Clinic generates reasonable name for the parameter 
"default".
https://hg.python.org/cpython/rev/c144bf6c0ff7

--

___
Python tracker 

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



[issue28837] 2to3 does not wrap zip correctly

2017-01-19 Thread Stuart Berg

Changes by Stuart Berg :


Removed file: http://bugs.python.org/file46339/fix-28837.patch

___
Python tracker 

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



[issue29311] Argument Clinic: convert dict methods

2017-01-19 Thread STINNER Victor

STINNER Victor added the comment:

> There are same problems with docstrings as in OrderedDict. The name "D" is 
> not defined.

I copied the old docstring to AC.

Python 3.6 doc:
---
get(...)
D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None.
---

D was already implicitly "self".


Python 3.7 (new) doc:
---
get(self, key, default=None, /)
D.get(key[, default]) -> D[key] if key in D, else default.
---

What do you propose? Use self?

--

___
Python tracker 

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



[issue29327] SystemError in sorted(iterable=[])

2017-01-19 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

In Python 3.6:

>>> sorted(iterable=[])
Traceback (most recent call last):
  File "", line 1, in 
SystemError: Objects/tupleobject.c:81: bad argument to internal function

In Python 3.5 and 2.7:

>>> sorted(iterable=[])
Traceback (most recent call last):
  File "", line 1, in 
TypeError: 'iterable' is an invalid keyword argument for this function

--
components: Interpreter Core
keywords: 3.6regression
messages: 285817
nosy: serhiy.storchaka
priority: normal
severity: normal
status: open
title: SystemError in sorted(iterable=[])
type: behavior
versions: 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



[issue29311] Argument Clinic: convert dict methods

2017-01-19 Thread STINNER Victor

STINNER Victor added the comment:

> Argument Clinic generates reasonable name for the parameter "default".
> -default as failobj: object = None
> +default: object = None

Thanks, that's a better name :-)

FYI I wanted to limit changes when converting to AC, the change is already big 
enough and hard to review.

--

___
Python tracker 

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



[issue29323] Wrong documentation (Library) for unicode and str comparison

2017-01-19 Thread R. David Murray

R. David Murray added the comment:

As per your other issue, though, the real issue is that the two objects must be 
*comparable*, not that they be of the same type, and the language should 
probably be updated to reflect that.

--

___
Python tracker 

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



[issue29323] Wrong documentation (Library) for unicode and str comparison

2017-01-19 Thread R. David Murray

R. David Murray added the comment:

Unicode and string *are* of the same type: basestring.  This is a specific 
example of the liskov substitution principle, so I don't think it should be 
called out explicitly in this section.

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



[issue29319] Embedded 3.6.0 distribution cannot run pyz files

2017-01-19 Thread Steve Dower

Steve Dower added the comment:

Found it in Modules/main.c in RunMainFromImporter():

/* argv0 is usable as an import source, so put it in sys.path[0]
   and import __main__ */
sys_path = PySys_GetObject("path");
if (sys_path == NULL) {
PyErr_SetString(PyExc_RuntimeError, "unable to get sys.path");
goto error;
}
if (PyList_SetItem(sys_path, 0, argv0)) {
argv0 = NULL;
goto error;
}
Py_INCREF(argv0);

When running with a ._pth file, we force the -I option, which removes the empty 
entry at sys.path[0]. Instead, it becomes the path to the .zip file with the 
standard library, so when RunMainFromImporter overwrites it blindly, it's 
cutting out the only hope it has of finding runpy.

You can see this in a normal install by doing:

py -I -c "import sys; print(sys.path)"
[correct output]

py -Ii test.pyz
[output from test.pyz]
>>> import sys; sys.path
[incorrect output]

So we need to stop blindly overwriting sys.path[0] here. I'm not sure what the 
best approach would be, but maybe Nick has a preference? Perhaps we should pass 
the zip file path into runpy._run_module_as_main so it can initialize __path__ 
with it rather than making a global change? Or maybe an insert rather than a 
set is the right way and I'm over-thinking this.

--
assignee: steve.dower -> 
nosy: +ncoghlan
stage:  -> needs patch
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



[issue29311] Argument Clinic: convert dict methods

2017-01-19 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

There are same problems with docstrings as in OrderedDict. The name "D" is not 
defined.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue29311] Argument Clinic: convert dict methods

2017-01-19 Thread Roundup Robot

Roundup Robot added the comment:

New changeset fe1d83fe29d6 by Serhiy Storchaka in branch 'default':
Issue #29311: Argument Clinic generates reasonable name for the parameter 
"default".
https://hg.python.org/cpython/rev/fe1d83fe29d6

--

___
Python tracker 

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



[issue29319] Embedded 3.6.0 distribution cannot run pyz files

2017-01-19 Thread Steve Dower

Steve Dower added the comment:

I just tried it and it makes no difference.

Omitting the "._pth" file seems to fix it, but apart from issue29326 (benign) 
sys.path is fine.

Still digging, but don't worry about testing on other machines.

--

___
Python tracker 

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



[issue13886] readline-related test_builtin failure

2017-01-19 Thread Xavier de Gaye

Xavier de Gaye added the comment:

With input-readline.v3.patch, test_builtin runs with success on Android api 21.

With pep538_coerce_legacy_c_locale_v4.diff that implements PEP 538 in issue 
28180, and with input-readline.v3.patch modified to have 'readline_encoding = 
locale.getpreferredencoding()' even when 'is_android' is True, test_builtin 
runs with success. This means that no specific Android handling would be needed 
if PEP 538 were to be adopted.

The new input-readline.v4.patch is a slight improvement over the previous patch 
and sets readline_encoding to 'UTF-8' on Android when test_builtin is run with 
the environment variable LANG set to 'en_US.UTF-8' and in that case the test 
exercises all the code paths including those with the readline module.  This is 
because locale.getdefaultlocale() returns ('en_US', 'UTF-8') on Android in that 
case and because both getdefaultlocale() and readline scan the environment to 
check for the locale.  This new patch is only useful if tests on Android are 
expected to be run also with one of the locale environment variables set to 
UTF-8 (and PEP 538 is rejected).

I have left some comments on Rietveld.

--
Added file: http://bugs.python.org/file46340/input-readline.v4.patch

___
Python tracker 

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



[issue29326] Blank lines in ._pth file are not ignored

2017-01-19 Thread Steve Dower

New submission from Steve Dower:

If a python._pth file includes a blank line, it gets treated as '\n' which is 
then appended to the directory and used as an entry in sys.path.

Empty lines should be ignored completely.

--
components: Windows
messages: 285809
nosy: paul.moore, steve.dower, tim.golden, zach.ware
priority: low
severity: normal
stage: needs patch
status: open
title: Blank lines in ._pth file are not ignored
type: behavior
versions: 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



[issue20186] Derby #18: Convert 31 sites to Argument Clinic across 23 files

2017-01-19 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Sorry for committing patches for you Tal, but they were hanging so long time.

--

___
Python tracker 

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



[issue20186] Derby #18: Convert 31 sites to Argument Clinic across 23 files

2017-01-19 Thread Roundup Robot

Roundup Robot added the comment:

New changeset e3db9bccff3f by Serhiy Storchaka in branch 'default':
Issue #20186: Converted builtins enumerate() and reversed() to Argument Clinic.
https://hg.python.org/cpython/rev/e3db9bccff3f

--

___
Python tracker 

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



[issue20186] Derby #18: Convert 31 sites to Argument Clinic across 23 files

2017-01-19 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

issue20186.enumobject.patch LGTM too.

--

___
Python tracker 

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



  1   2   >