[issue30163] argparse mx_group is required, when action value equal default will be ignore

2017-04-25 Thread paul j3

paul j3 added the comment:

And only for integers smaller than 257!

The problem is with this test in `take_action` function

# error if this argument is not allowed with other previously
# seen arguments, assuming that actions that use the default
# value don't really count as "present"
if argument_values is not action.default:
seen_non_default_actions.add(action)
for conflict_action in action_conflicts.get(action, []):
if conflict_action in seen_non_default_actions:
msg = _('not allowed with argument %s')
action_name = _get_action_name(conflict_action)
raise ArgumentError(action, msg % action_name)

Specifically with the

argument_values is not action.default

test.  In CPython integers below 257 are unique, so that

In [33]: int('10') is 10
Out[33]: True
In [34]: int('257') is 257
Out[34]: False

(and strings from 'sys.argv' do not match in the 'is' sense with strings set 
via 'default'.  So the problem is unique to small integers.)

The test is really meant to catch the default that is added in '_get_values()' 
for positionals with optional nargs ('?').

This issue was raised by some PyPy developers several years ago. 
 PyPy does not treat the small integers as unique.  I'll have to dig around to 
see what the resolution was, if any.

For now the solution is to use a string '10' as the default.

--
nosy: +paul.j3

___
Python tracker 

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



[issue30052] URL Quoting page links to function Bytes instead of defintion

2017-04-25 Thread Nick Coghlan

Nick Coghlan added the comment:


New changeset c6db4811f9ea3aeff0e1fafe1c60a22835ef359e by Nick Coghlan 
(csabella) in branch 'master':
bpo-30052: Link `bytes` & `bytearray` to stdtypes not functions  (GH-1271)
https://github.com/python/cpython/commit/c6db4811f9ea3aeff0e1fafe1c60a22835ef359e


--
nosy: +ncoghlan

___
Python tracker 

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



[issue30164] Testing FTP support in urllib shouldn't use Debian FTP server

2017-04-25 Thread Senthil Kumaran

Senthil Kumaran added the comment:

I had started taking some action on it recently: 
https://github.com/python/pythondotorg/issues/1069 

I verified that only one test module is affected and rest of our ftp.debian.org 
references are examples/docstrings that will need to be updated eventually too.

--

___
Python tracker 

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



[issue30164] Testing FTP support in urllib shouldn't use Debian FTP server

2017-04-25 Thread Senthil Kumaran

Changes by Senthil Kumaran :


--
assignee:  -> orsenthil

___
Python tracker 

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



[issue30164] Testing FTP support in urllib shouldn't use Debian FTP server

2017-04-25 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

test_urllib2net.py uses ftp://ftp.debian.org/ for testing FTP support in 
urllib. But Debian just announced shutting down its public FTP services.

https://lists.debian.org/debian-announce/2017/msg1.html

--
components: Tests
messages: 292299
nosy: orsenthil, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Testing FTP support in urllib shouldn't use Debian FTP server
type: behavior
versions: Python 2.7, Python 3.5, Python 3.6, Python 3.7

___
Python tracker 

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



[issue30163] argparse mx_group is required, when action value equal default will be ignore

2017-04-25 Thread Louie Lu

Louie Lu added the comment:

Maybe documentation should note that:
"""
# error if this argument is not allowed with other previously
# seen arguments, assuming that actions that use the default
# value don't really count as "present"
"""

--

___
Python tracker 

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



[issue30162] Add _PyTuple_Empty and make PyTuple_New(0) never failing

2017-04-25 Thread Raymond Hettinger

Raymond Hettinger added the comment:

The patch shows a nice payoff from this short-cut, so go ahead and apply it.

Still, I wish there were some aversion to posting a new patch every two days 
that alters twenty files all over the standard library.  The rate of churn is 
alarming.

--
nosy: +rhettinger

___
Python tracker 

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



[issue21150] Add quick links table to argparse docs

2017-04-25 Thread Louie Lu

Louie Lu added the comment:

Could Raymond, Gaurav or paul help to review the PR's summary table?
Thanks!

--

___
Python tracker 

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



[issue30163] argparse mx_group is required, when action value equal default will be ignore

2017-04-25 Thread Louie Lu

Louie Lu added the comment:

Strange, this will only trigger when that argument type is int.

--

___
Python tracker 

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



[issue30157] csv.Sniffer.sniff() regex error

2017-04-25 Thread Jake Davis

Jake Davis added the comment:

Will do! I will try to get a regression proof test into test_csv.py in the next 
24 hours. Essentially I will make sure that the sniffer returns a positive 
match for each of the patterns that the regex is intended to hit.

--

___
Python tracker 

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



[issue30107] python.core file created when running tests on AMD64 FreeBSD CURRENT Non-Debug 3.x buildbot

2017-04-25 Thread Mariatta Wijaya

Changes by Mariatta Wijaya :


--
stage:  -> backport needed

___
Python tracker 

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



[issue29887] test_normalization doesn't work

2017-04-25 Thread Mariatta Wijaya

Changes by Mariatta Wijaya :


--
stage:  -> backport needed

___
Python tracker 

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



[issue29960] _random.Random state corrupted on exception

2017-04-25 Thread Mariatta Wijaya

Changes by Mariatta Wijaya :


--
pull_requests: +1396

___
Python tracker 

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



[issue29960] _random.Random state corrupted on exception

2017-04-25 Thread Mariatta Wijaya

Changes by Mariatta Wijaya :


--
pull_requests: +1395

___
Python tracker 

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



[issue29960] _random.Random state corrupted on exception

2017-04-25 Thread Mariatta Wijaya

Changes by Mariatta Wijaya :


--
pull_requests: +1397

___
Python tracker 

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



[issue30163] argparse mx_group is required, when action value equal default will be ignore

2017-04-25 Thread Louie Lu

New submission from Louie Lu:

When adding mutually exclusive group and required is True, and the group 
argument has default value. If we type its default value, argparse will ignore 
the input and return `argument is required`


--- PoC 
import argparse

parser = argparse.ArgumentParser()
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument('-v', type=int, default=10)

print(parser.parse_args())

-

$ python tests.py -v 10
usage: tests.py [-h] -v V
tests.py: error: one of the arguments -v is required
$ python tests.py -v 11
Namespace(v=11)

--
components: Library (Lib)
messages: 292293
nosy: louielu
priority: normal
severity: normal
status: open
title: argparse mx_group is required, when action value equal default will be 
ignore
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



[issue30163] argparse mx_group is required, when action value equal default will be ignore

2017-04-25 Thread Louie Lu

Changes by Louie Lu :


--
type:  -> behavior

___
Python tracker 

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



[issue28851] namedtuples field_names sequence preferred

2017-04-25 Thread Mariatta Wijaya

Mariatta Wijaya added the comment:

Backported to 3.6.

Thanks, everyone :)

--
resolution: later -> fixed
stage: backport needed -> 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



[issue28851] namedtuples field_names sequence preferred

2017-04-25 Thread Mariatta Wijaya

Mariatta Wijaya added the comment:


New changeset 16b6f971bd8afc72b439b83324eba744460adb67 by Mariatta in branch 
'3.6':
[3.6] bpo-28851: Improve namedtuple documentation (GH-1274) (GH-1286)
https://github.com/python/cpython/commit/16b6f971bd8afc72b439b83324eba744460adb67


--

___
Python tracker 

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



[issue28851] namedtuples field_names sequence preferred

2017-04-25 Thread Mariatta Wijaya

Changes by Mariatta Wijaya :


--
pull_requests: +1394

___
Python tracker 

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



[issue30157] csv.Sniffer.sniff() regex error

2017-04-25 Thread R. David Murray

R. David Murray added the comment:

If it is a bug that indicates there is at least one missing unit test :)  Maybe 
the OP will contribute a test.

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



[issue26828] Implement __length_hint__() on map() and filter() to optimize list(map) and list(filter)

2017-04-25 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Also, the ifilter() suggestion is a complete non-starter.  There is no way to 
know in advance whether filter will return all the elements of the input or 
none of them.  In the absence of other knowledge, the best strategy is what 
list.append() already does (a strategy of mild over-allocations, not exceeding 
12.5% for large lists).

--

___
Python tracker 

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



[issue26828] Implement __length_hint__() on map() and filter() to optimize list(map) and list(filter)

2017-04-25 Thread Raymond Hettinger

Raymond Hettinger added the comment:

> But isn't that the point of the length_hint?

Where it could be used reliably, it was used and used broadly.  However, there 
are circumstances (iterator vs iterable) where it can't know how to make an 
estimate and is perhaps wildly off.

I would like to mark this tracker item as closed.  IMO it is a dead-end. 

Like you, I share enthusiasm for length_hint and its potential (that I why I 
created the concept many years ago and worked very hard to apply it everywhere 
it would fit).  But trust me, it doesn't fit everywhere.  I left it out of 
imap() for a reason (it just didn't make sense).

--

___
Python tracker 

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



[issue26828] Implement __length_hint__() on map() and filter() to optimize list(map) and list(filter)

2017-04-25 Thread Michael Seifert

Michael Seifert added the comment:

> I explored that notion of iterator length transparency years ago.  While I 
> don't remember all the details, I did record some notes at the top of 
> Lib/test/test_iterlen.py.

But isn't that the point of the length_hint? To provide an *estimate* for the 
length? So generally I would expect the length_hint to be accurate (at least 
accurate enough to avoid reallocations) for well-behaved iterators. And I think 
that's possible for "zip" and "map" (but also for several itertools: product, 
permutations, combinations, islice, accumulate, starmap, zip_longest). At least 
in theory.

Also it would allow to prohibit infinite iterators to be passed to 
"length_hint"-aware functions. For example `list(count())` could raise an 
exception when `count.length_hint` would return math.inf or sys.maxsize + 1.

The pull request was just because I was curious how it performed and wanted to 
share the code. Feel free to reject it. The performance improvement wasn't 
amazing in the micro-benchmarks.

--
nosy: +MSeifert

___
Python tracker 

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



[issue29576] Improve some deprecations in the importlib

2017-04-25 Thread STINNER Victor

STINNER Victor added the comment:

This issue introduced new warnings when running test_importlib: see issue 
#30158.

--
nosy: +haypo

___
Python tracker 

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



[issue30158] Deprecation warnings emitted in test_importlib

2017-04-25 Thread STINNER Victor

STINNER Victor added the comment:

Deprecation introduced by issue #29576 according to the PR.

--

___
Python tracker 

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



[issue30158] Deprecation warnings emitted in test_importlib

2017-04-25 Thread STINNER Victor

STINNER Victor added the comment:

> DeprecationWarning: MetaPathFinder.find_module() is deprecated since Python 
> 3.4 in favor of MetaPathFinder.find_spec()(available since 3.4)

Is a space missing in the error message between "MetaPathFinder.find_spec()" 
and "(available since 3.4)"?

--
nosy: +haypo

___
Python tracker 

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



[issue30107] python.core file created when running tests on AMD64 FreeBSD CURRENT Non-Debug 3.x buildbot

2017-04-25 Thread STINNER Victor

STINNER Victor added the comment:


New changeset d819ad9832292d854e9710493ecdf959b69802e3 by Victor Stinner in 
branch 'master':
bpo-30107: Make SuppressCrashReport quiet on macOS (#1279)
https://github.com/python/cpython/commit/d819ad9832292d854e9710493ecdf959b69802e3


--

___
Python tracker 

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



[issue30157] csv.Sniffer.sniff() regex error

2017-04-25 Thread STINNER Victor

STINNER Victor added the comment:

Can you please try to write a unit test to check for non-regression? Or at 
least give an example?

--

___
Python tracker 

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



[issue30124] Fix C aliasing issue in Python/dtoa.c to use strict aliasing on Clang 4.0

2017-04-25 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

It seems to me that the purpose of using unions was avoiding aliasing issues. 
But something went wrong.

--

___
Python tracker 

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



[issue30124] Fix C aliasing issue in Python/dtoa.c to use strict aliasing on Clang 4.0

2017-04-25 Thread Dimitry Andric

Dimitry Andric added the comment:

STINNER Victor writes:
> Would it be technically possible to completely get ride of the union? 

Probably, it's just more work, and it has to be done pretty carefully to avoid 
regressions.  It seems Python already does some exercising of these dtoa 
functions in its test suite, but ideally you would want to check against 
upstream's full tests, if those exist.

There are probably many edge cases for a set of tricky functions like this...

--

___
Python tracker 

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



[issue30140] Binary arithmetic does not always call subclasses first

2017-04-25 Thread Stephan Hoyer

Stephan Hoyer added the comment:

> The design pattern that has problems here is a bit unorthodox to start with.

I agree. This was meant strictly as a simple example for illustrative purposes. 
Steven D'Aprano's example from python-ideas may be a better one:
https://mail.python.org/pipermail/python-ideas/2017-April/045455.html

class A:
def __add__(self, other):
self.log()
...
__radd__ = __add__

class B(A):
def log(self):
...

Our actual use case for NumPy involved writing a mixin that look more like 
this, that expects a specified method to implement arithmetic, i.e.,

class NDArrayOperatorsMixin:
def __add__(self, other):
return self._calculate(np.add, self, other)
def __radd__(self, other):
return self._calculate(np.add, other, self)
...  # repeat for all special methods

class A(NDArrayOperatorsMixin):
def _calculate(self, op, *args):
if not all(isinstance(arg, A) for arg in args):
return NotImplemented
...  # implement calculation

class B(A):
def _calculate(self, op, *args):
...  # something different

In A() + B(), B never gets the chance to override A's implementation of __add__ 
via _calculate, because it overrode a different method (_calculate) which 
happens to contain the *implementation* for __radd__, but not __radd__ itself.

Anyways, if you have serious concerns about changing this, it is probably best 
respond to Guido on python-ideas:
https://mail.python.org/pipermail/python-ideas/2017-April/045468.html

--

___
Python tracker 

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



[issue30140] Binary arithmetic does not always call subclasses first

2017-04-25 Thread Josh Rosenberg

Josh Rosenberg added the comment:

I'd assume the preference for __rop__ only on subclass overload is because 
__rop__ method are usually fallback methods, and differ behaviorally from the 
__op__ methods in type strictness.

In particular, the __rop__ fallbacks are often so non-strict that they return a 
completely different type; fractions.Fraction.__rop__ is willing to coerce 
itself and the other operand to float and produce a float result if the other 
operand is a numbers.Real (and not a Rational). They also tend to be slower 
(checking against ABCs and doing more type coercion) than the __op__ path.

If you jump straight to __rop__ because the right hand side is a subclass, but 
the subclass didn't overload it, you end up going through that fallback, 
assumed extra liberal and slow, code path.

It doesn't work this way with comparison operators because those are 100% 
reflexive; there is no expectation that comparing in one direction will be more 
or less type permissive than comparing in the other direction (stuff like 
__rcmp__ has been gone for ages after all), so unconditionally comparing using 
the child class comparator first is fine, and more likely to get correct 
results.

The design pattern that has problems here is a bit unorthodox to start with. It 
assumes that the child class constructor will work exactly the same as the 
parent (no additional mandatory arguments for instance), and that it's always 
correct for parent + child to produce the type of child. Usually, in an OO 
design, the parent is not supposed to have any specific knowledge of children; 
it's the job of the children to work with instances of the parent, if 
necessary. If delegation to the child is desired, implement __op__ with 
stricter type checking (to preclude subclasses) and __rop__ with relaxed type 
checking (to allow them); when the __op__ executes, it will return 
NotImplemented for the child class, then delegate to __rop__, which will use 
the child's type.

--
nosy: +josh.r

___
Python tracker 

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



[issue30158] Deprecation warnings emitted in test_importlib

2017-04-25 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
stage:  -> patch review
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



[issue29576] Improve some deprecations in the importlib

2017-04-25 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
pull_requests: +1393

___
Python tracker 

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



[issue30158] Deprecation warnings emitted in test_importlib

2017-04-25 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
pull_requests: +1392

___
Python tracker 

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



[issue29576] Improve some deprecations in the importlib

2017-04-25 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

This change made test_importlib emitting warnings. See issue30158.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue29943] PySlice_GetIndicesEx change broke ABI in 3.5 and 3.6 branches

2017-04-25 Thread Nathaniel Smith

Nathaniel Smith added the comment:

Apparently this also broke pyqt for multiple users; here's the maintainers at 
conda-forge struggling to figure out the best workaround: 
https://github.com/conda-forge/pyqt-feedstock/pull/25

I really think it would be good to fix this in 3.6 sooner rather than later. 
Downstairs projects are accumulating workarounds and pinning 3.6.0 as we speak.

--

___
Python tracker 

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



[issue29950] Rename SlotWrapperType to WrapperDescriptorType

2017-04-25 Thread Berker Peksag

Changes by Berker Peksag :


--
resolution:  -> fixed

___
Python tracker 

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



[issue29950] Rename SlotWrapperType to WrapperDescriptorType

2017-04-25 Thread Berker Peksag

Berker Peksag added the comment:

Merged in 08c16016e2a2d1368d001ddebfe9ca92465773c4.

Thanks!

--
nosy: +berker.peksag
type:  -> behavior

___
Python tracker 

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



[issue30162] Add _PyTuple_Empty and make PyTuple_New(0) never failing

2017-04-25 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
pull_requests: +1391

___
Python tracker 

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



[issue30162] Add _PyTuple_Empty and make PyTuple_New(0) never failing

2017-04-25 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

Proposed patch makes the empty tuple be allocated in static memory rather than 
dynamic memory, expose a reference to it as _PyTuple_Empty, and makes 
PyTuple_New(0) never raising exceptions. This allows to simplify the code. No 
longer need to call PyTuple_New(0), check it's result for errors, and clean up 
it after the use, you just can use a borrowed reference _PyTuple_Empty.

_PyTuple_Empty is for CPython internal use only.

--
components: Interpreter Core
messages: 292274
nosy: haypo, serhiy.storchaka
priority: normal
severity: normal
stage: patch review
status: open
title: Add _PyTuple_Empty and make PyTuple_New(0) never failing
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



[issue30161] Using `with` statement causes dict to start papering over attribute errors

2017-04-25 Thread Tim Golden

Tim Golden added the comment:

I think you're suppressing sys.stderr after the "with". Try a NameError 
or anything.

Alternatively, try a "with" which isn't using sys.stderr

Obviously, the next question is why *that's* happening.

--
nosy: +tim.golden

___
Python tracker 

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



[issue30161] Using `with` statement causes dict to start papering over attribute errors

2017-04-25 Thread Charles Cazabon

Charles Cazabon added the comment:

oh ffs ;)

--

___
Python tracker 

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



[issue30161] Using `with` statement causes dict to start papering over attribute errors

2017-04-25 Thread R. David Murray

R. David Murray added the comment:

You've closed stderr.

--
nosy: +r.david.murray
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



[issue29581] __init_subclass__ causes TypeError when used with standard library metaclasses (such as ABCMeta)

2017-04-25 Thread Nate Soares

Changes by Nate Soares :


--
pull_requests: +1390

___
Python tracker 

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



[issue30161] Using `with` statement causes dict to start papering over attribute errors

2017-04-25 Thread Charles Cazabon

New submission from Charles Cazabon:

This is a weird one.  I've reproduced it with 3 versions of 2.7, including the 
latest 2.7.13.  I didn't find an open bug about this, but I had difficulty 
crafting a search string for it, so I may have missed something.

Basically, using a `with` statement (maybe any such statement, but using an 
open file definitely does it, even when I do nothing with it) causes the 
built-in dict class to stop raising AttributeErrors, which can result in odd 
bugs.

Example:

Python 2.7.13 (default, Apr 25 2017, 10:12:36) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> with sys.stderr as foo:
... pass
... 
>>> {}.nosuchattribute
>>> {}.nosuchattribute is None
>>> 

I haven't tried the latest 3.x, but it's definitely still there in 3.2.3:

Python 3.2.3 (default, Nov 17 2016, 01:04:00) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> with sys.stderr as foo:
... pass
... 
>>> {}.nosuchattribute
>>> {}.nosuchattribute is None
>>>

--
components: Interpreter Core
messages: 292270
nosy: charlesc
priority: normal
severity: normal
status: open
title: Using `with` statement causes dict to start papering over attribute 
errors
type: behavior
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



[issue28851] namedtuples field_names sequence preferred

2017-04-25 Thread Mariatta Wijaya

Mariatta Wijaya added the comment:

My pleasure :) I merged the PR, and will do the backport later today.

--
stage:  -> backport needed

___
Python tracker 

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



[issue28851] namedtuples field_names sequence preferred

2017-04-25 Thread Mariatta Wijaya

Mariatta Wijaya added the comment:


New changeset 97bf722fcd1de1236824377e052369dc7686b644 by Mariatta (csabella) 
in branch 'master':
bpo-28851: Improve namedtuple documentation (GH-1274)
https://github.com/python/cpython/commit/97bf722fcd1de1236824377e052369dc7686b644


--

___
Python tracker 

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



[issue30157] csv.Sniffer.sniff() regex error

2017-04-25 Thread Matthew Barnett

Matthew Barnett added the comment:

There are 4 patterns. They try to determine the delimiter and quote by looking 
for matches. Each pattern supposedly covers one of 4 cases:

1. Delimiter, quote, value, quote, delimiter.

2. Start of line/text, quote, value, quote, delimiter.

3. Delimiter, quote, value, quote, end of line/text.

4. Start of line/text, quote, value, quote, end of line/text.

On that basis, case 3 looks wrong because the pattern for delimiter is:

>[^\w\n"\']

instead of the expected:

[^\w\n"\']

Looks like a bug to me.

--
nosy: +mrabarnett

___
Python tracker 

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



[issue30160] BaseHTTPRequestHandler.wfile: supported usage unclear

2017-04-25 Thread Mike

Mike added the comment:

That would certainly satisfy me!

--

___
Python tracker 

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



[issue29727] collections.abc.Reversible doesn't fully support the reversing protocol

2017-04-25 Thread Guido van Rossum

Guido van Rossum added the comment:

I'm with Raymond.

I propose to register array.array() in all the appropriate places and then 
close this bug as a won't fix.

The typing issue might eventually be resolved via PEP 544 (if accepted), or not 
-- the"fallback protocols" based on __getitem__ and __len__ seem to be a 
complicating special case that we may want to put off.

--

___
Python tracker 

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



[issue30160] BaseHTTPRequestHandler.wfile: supported usage unclear

2017-04-25 Thread R. David Murray

R. David Murray added the comment:

I would like to say that the latter interpretation is "obviously" correct, 
except that it clearly wasn't obvious to you.  The fact that it "contains the 
output stream" I would have thought was pretty clear: if you are writing to it, 
you are responsible for anything you do to that output stream.  The "must" 
refers to the same the the RFC "must" refers to: in order to be RFC compliant, 
you must conform to the RFC.

Perhaps we could clarify that sentence by saying: "Proper adherence to the HTTP 
protocol must be used when writing to this stream in order to achieve 
successful interoperation with http clients."  I think that would make it clear 
that if you don't, you'll be testing the client's response to protocol 
violations :)

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



[issue30160] BaseHTTPRequestHandler.wfile: supported usage unclear

2017-04-25 Thread Mike

New submission from Mike:

The documentation for BaseHTTPRequestHandler explicitly prohibits protocol
violations when writing to the `wfile` stream:

> BaseHTTPRequestHandler has the following instance variables:
>
> [...]
>
> **`wfile`**
>
> > Contains the output stream for writing a response back to the client.
> > Proper adherence to the HTTP protocol must be used when writing to this
> > stream.

I am interested in testing web browser behavior in response to protocol
violations, and my initial interpretation of this text (and the term "must" in
particular) is that such conditions are not guaranteed to achievable with this
module. However, my colleague believes the text is simply intended to
communicate that there is no safety mechanism in place, and that protocol
violations will not be corrected. [1]

Local testing and a quick reading of the source tends to confirm the latter
interpretation, but this may simply be coincidental and not necessarily stable
behavior.

If it is in fact stable, then I would like to request a modification to the
documentation. Changing the word "must" to "should" would help, although it
might be better to be more explicit--something like, "Bytes are transmitted
'as-is'; HTTP protocol violations will not be corrected."

Thanks!

[1] https://github.com/w3c/web-platform-tests/issues/5668

--
assignee: docs@python
components: Documentation
messages: 292263
nosy: docs@python, jugglinmike
priority: normal
severity: normal
status: open
title: BaseHTTPRequestHandler.wfile: supported usage unclear

___
Python tracker 

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



[issue29727] collections.abc.Reversible doesn't fully support the reversing protocol

2017-04-25 Thread Raymond Hettinger

Changes by Raymond Hettinger :


--
assignee: rhettinger -> 

___
Python tracker 

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



[issue28851] namedtuples field_names sequence preferred

2017-04-25 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Mariatta, I've approved Cheryl's PR.  Would like to do the honors and apply it.

--
assignee: rhettinger -> Mariatta
nosy: +Mariatta

___
Python tracker 

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



[issue26082] functools.lru_cache user specified cachedict support

2017-04-25 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Marking as closed/rejected for the reasons lists by Josh.  The 
functools.lru_cache() decorator is somewhat tightly focused and is trying to do 
one thing well.  Another reason is that at some point, we want to be able to 
change the internals (perhaps using the new compact/ordereddict) and that would 
be precluded by this feature request.

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

___
Python tracker 

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



[issue30159] gdb autoloading python-gdb.py

2017-04-25 Thread Дилян Палаузов

New submission from Дилян Палаузов:

Please install python-gdb.py in 
$(datarootdir)/gdb/auto-load/$(libdir)/libpython3.5m.so.1.0-gdb.py during "make 
install", so that programs linked towards libpython3.5m.so.1.0 will auto-load 
the -gdb.py script, when debugged.

Likewise for the other gdb versions.

An alternative to achieve the same effect is to put python-gdb.py in a 
.debug_gdb_scripts section 
(https://sourceware.org/gdb/onlinedocs/gdb/dotdebug_005fgdb_005fscripts-section.html#dotdebug_005fgdb_005fscripts-section),
 but I don't know if $(strip) removes it.

--
messages: 292260
nosy: dilyan.palauzov
priority: normal
severity: normal
status: open
title: gdb autoloading python-gdb.py

___
Python tracker 

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



[issue30158] Deprecation warnings emitted in test_importlib

2017-04-25 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

$ ./python -We -m test.regrtest -v test_importlib
...
==
ERROR: test_find_module 
(test.test_importlib.test_abc.Frozen_MetaPathFinderDefaultsTests)
--
Traceback (most recent call last):
  File "/home/serhiy/py/cpython/Lib/test/test_importlib/test_abc.py", line 160, 
in test_find_module
self.assertIsNone(self.ins.find_module('something', None))
  File "/home/serhiy/py/cpython/Lib/test/test_importlib/test_abc.py", line 151, 
in find_module
return super().find_module(fullname, path)
  File "/home/serhiy/py/cpython/Lib/importlib/abc.py", line 72, in find_module
stacklevel=2)
DeprecationWarning: MetaPathFinder.find_module() is deprecated since Python 3.4 
in favor of MetaPathFinder.find_spec()(available since 3.4)

...

--
components: Tests
messages: 292259
nosy: brett.cannon, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Deprecation warnings emitted in test_importlib
type: behavior
versions: Python 3.5, Python 3.6, Python 3.7

___
Python tracker 

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



[issue30150] raw debug allocators to not return malloc alignment

2017-04-25 Thread STINNER Victor

STINNER Victor added the comment:

Is this issue related to this numpy issue: "ENH: add support for python3.6 
memory tracing"?
https://github.com/numpy/numpy/pull/8885

--

___
Python tracker 

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



[issue30150] raw debug allocators to not return malloc alignment

2017-04-25 Thread STINNER Victor

STINNER Victor added the comment:

> On for example x32 malloc returns 16 byte aligned memory but size_t is 4 
> bytes.

x32 is a strange platform :-( Does numpy support it? I'm not sure that Python 
works on such platform.

I suggest to hardcode 16 or 32 bytes in _PyMem_DebugRawAlloc instead of relying 
on sizeof(size_t). pymalloc aligns memory allocations to 8 bytes if I recall 
correctly.


> How it cause problem?

numpy uses SIMD instructions which require strict memory alignement.

Note: There was also an issue #18835 to "Add aligned memory variants to the 
suite of PyMem functions/macros", but it was rejected.

--
nosy: +haypo

___
Python tracker 

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



[issue30150] raw debug allocators to not return malloc alignment

2017-04-25 Thread INADA Naoki

INADA Naoki added the comment:

How it cause problem?
I think you should use `malloc()` instead of `PyMem_Malloc()` or other Python 
memory allocator when you need strict `malloc()` alignment.

--
nosy: +inada.naoki

___
Python tracker 

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



[issue30132] [Windows] test_distutils leaks a vc140.pdb file

2017-04-25 Thread STINNER Victor

STINNER Victor added the comment:

Reopen, while the warning was fixed on AppVeyor and my Windows VM, I still see 
the warning on Windows buildbots.

http://buildbot.python.org/all/builders/AMD64%20Windows8%203.x/builds/578/steps/test/logs/stdio

Warning -- files was modified by test_distutils
  Before: []
  After:  ['vc140.pdb']

http://buildbot.python.org/all/builders/AMD64%20Windows10%203.x/builds/591/steps/test/logs/stdio

Warning -- files was modified by test_distutils
  Before: []
  After:  ['vc140.pdb']

--
resolution: fixed -> 
status: closed -> open

___
Python tracker 

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



[issue30157] csv.Sniffer.sniff() regex error

2017-04-25 Thread STINNER Victor

STINNER Victor added the comment:

What is the consequence of this change? Does it change the syntax of the 
parser? Which kind of format wasn't parsed correctly?

--
nosy: +haypo

___
Python tracker 

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



[issue30156] PYTHONDUMPREFS segfaults on exit

2017-04-25 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

The previous result was got when use _PyObject_FastCallDict(). Using 
PyObject_Call() is slightly faster:

Mean +- std dev: [python.default] 127 ns +- 4 ns -> [python] 185 ns +- 9 ns: 
1.45x slower (+45%)

--

___
Python tracker 

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



[issue30156] PYTHONDUMPREFS segfaults on exit

2017-04-25 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Removing this micro-optimization makes attribute access in namedtuple more than 
1.5 times slower:

Mean +- std dev: [python.default] 126 ns +- 4 ns -> [python] 200 ns +- 7 ns: 
1.58x slower (+58%)

This would be a significant regression.

--
nosy: +rhettinger

___
Python tracker 

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



[issue26082] functools.lru_cache user specified cachedict support

2017-04-25 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
assignee:  -> rhettinger

___
Python tracker 

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