[issue26493] Bad formatting in WinError 193 when using subprocess.check_call

2016-03-06 Thread Raúl Núñez de Arenas

Raúl Núñez de Arenas added the comment:

Thanks for the information, Eryk, I've read the blog.

--

___
Python tracker 

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



[issue26496] Exhausted deque iterator should free a reference to a deque

2016-03-06 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

This should be not very hard. It is just reminder to me, I'll write a patch 
after closing related issue26494 and issue26492.

--
dependencies: +Double deallocation on iterator exhausting

___
Python tracker 

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



[issue26496] Exhausted deque iterator should free a reference to a deque

2016-03-06 Thread Raymond Hettinger

Raymond Hettinger added the comment:

I don't think this is even slightly important but will take a look to see if 
there is an easy way to incorporate it that doesn't mess-up previous efforts to 
fine-tune the iterator.

--
assignee:  -> rhettinger
priority: normal -> low

___
Python tracker 

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



[issue11477] Incorrect operand precedence when implementing sequences in C

2016-03-06 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue13298] Result type depends on order of operands for bytes and bytearray

2016-03-06 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

An issue with bytes.join() is already fixed (issue15958).

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue25246] Alternative algorithm for deque_remove()

2016-03-06 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

There is more optimal approach.

Find not just an index in a deque, but a block and an index in a block. After 
that move left or right part of a deque one position right or left. 
__delitem__() could be 2 times faster, remove() could be faster too. Helpers 
proposed in issue17394 allow to do this easily.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue26496] Exhausted deque iterator should free a reference to a deque

2016-03-06 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
title: Exhausted dequeue iterator should free a reference to a deque -> 
Exhausted deque iterator should free a reference to a deque

___
Python tracker 

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



[issue26483] docs unclear on difference between str.isdigit() and str.isdecimal()

2016-03-06 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

AFAIK ‘general category “Nd” ’ is the same as ‘the property value 
Numeric_Type=Decimal’.

Yet one related predicate is str.isnumeric().

https://docs.python.org/3/library/stdtypes.html?#str.isnumeric

Return true if all characters in the string are numeric characters, and there 
is at least one character, false otherwise. Numeric characters include digit 
characters, and all characters that have the Unicode numeric value property, 
e.g. U+2155, VULGAR FRACTION ONE FIFTH. Formally, numeric characters are those 
with the property value Numeric_Type=Digit, Numeric_Type=Decimal or 
Numeric_Type=Numeric.

>>> numerics = ''.join(filter(str.isnumeric, chars))
>>> ''.join(sorted(set(digits) - set(numerics)))
''
>>> ''.join(sorted(set(numerics) - set(digits)))
'¼½¾৴৵৶৷৸৹୲୳୴୵୶୷௰௱௲౸౹౺౻౼౽౾൰൱൲൳൴൵༪༫༬༭༮༯༰༱༲༳፲፳፴፵፶፷፸፹፺፻፼ᛮᛯᛰ៰៱៲៳៴៵៶៷៸៹⅐⅑⅒⅓⅔⅕⅖⅗⅘⅙⅚⅛⅜⅝⅞⅟ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫⅬⅭⅮⅯⅰⅱⅲⅳⅴⅵⅶⅷⅸⅹⅺⅻⅼⅽⅾⅿↀↁↂↅↆↇↈ↉⑩⑪⑫⑬⑭⑮⑯⑰⑱⑲⑳⑽⑾⑿⒀⒁⒂⒃⒄⒅⒆⒇⒑⒒⒓⒔⒕⒖⒗⒘⒙⒚⒛⓫⓬⓭⓮⓯⓰⓱⓲⓳⓴⓾❿➉➓⳽〇〡〢〣〤〥〦〧〨〩〸〹〺㆒㆓㆔㆕㈠㈡㈢㈣㈤㈥㈦㈧㈨㈩㉈㉉㉊㉋㉌㉍㉎㉏㉑㉒㉓㉔㉕㉖㉗㉘㉙㉚㉛㉜㉝㉞㉟㊀㊁㊂㊃㊄㊅㊆㊇㊈㊉㊱㊲㊳㊴㊵㊶㊷㊸㊹㊺㊻㊼㊽㊾㊿㐅㒃㠪㭍一七万三九二五亖亿什仟仨伍佰億兆兩八六十千卄卅卌叁参參叄四壱壹幺廾廿弌弍弎弐拾捌柒漆玖百肆萬貮貳贰阡陆陌陸零ꛦꛧꛨꛩꛪꛫꛬꛭꛮꛯ꠰꠱꠲꠳꠴꠵參拾兩零六陸什ćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİıIJijŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸƊƋˡˢˣˤ˥˦˧˨˩˪˫ˬ˭ˮ˯˰˱˲˳˴˵˶˷˸˹˺˻̡̢̠̣́͊ϑϒϓϔϕࡘ࡙࡚࡛࡜࡝࡞࡟ࡹࡺࡻࡼࡽࡾࡿࢧࢨࢩࢪࢫࢬࢭࢮࢯࣻࣼࣽࣾࣿखगघङचछ়ঽীুূৃৄ৅৆েৈ৉৊োৌ্ৎ৏৒৓৔৕৖ৗ৘৙৚৛ড়ঢ়৞য়ৠৡৢৣ৤৥০১২৩৪৫৬৭৮৯ৰৱ৲৳৴৵৶৷৸৹৺৻ৼ৽৾৿੄੅੆ੇ੽੾ઝઞટ૫૬૭૮૯୘୙୚୛ଡ଼ଢ଼୞ୟ୸୹୺୻୼୽୾୿னப஫஬஭மய೺೻೼೽೾೿๩๪๫๬๭๮๯๰๱๲๳๴๵๶๷๸๹๺๻๼๽๾ၛၜၝၞၟၠၡၢၣၤၥᇡᇢᇣᇤᇥᇦᇧᇨᇩᇪᇫᇬᇭᇮᇯᇰᇱᇲᇳᇴ᜺᜻ᣪᣫᣬᣭᣮᣯᣰᣱᣲ␀␁␂␃␄␅␆␇␈␉␊␋␌␍␎␏␐␑␒␓␔␕␖␗␘␙␚␛␜␝␞␟␠␡␢␣␤␥␦␧␨␩␪␫␬␭␮␯␰␱␲␳␴␵␶␷␸␹␺␻␼␽␾␿⑀⑁⑂⑃⑄⑅⑆⑇⑈⑉⑊⑋⑌⑍⑎⑏⑐⑑⑒⑓⑔⑕⑖⑗⑘⑙⑚⑛⑜⑝⑞⑟①②③④⑤⑥⑦⑧⑨⑩⑪⑫⑬⑭⑮歛歜歝歞歟歠歡퍠퍡퍢퍣퍤퍥퍦퍧퍨퍩퍪퍫퍬퍭퍮퍯퍰퍱dâġपঃঌজ૪૽ଙ⎐⦘㬛扭'

decimals is a subset of digits, and digits is a subset of numerics.

--

___
Python tracker 

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



[issue26498] _io.so flat namespace

2016-03-06 Thread Larry

New submission from Larry:

On OSX El Capitan, Python v2.7.10 and 2.7.11 (standard installer)...

When importing urllib2 it crashes with a flat namespace error then loading 
_io.so.  Shortest test case: "python -c 'import urllib2'"

Traceback (most recent call last):
  File "", line 1, in 
  File 
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", 
line 94, in 
import httplib
  File 
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", 
line 80, in 
import mimetools
  File 
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/mimetools.py", 
line 6, in 
import tempfile
  File 
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/tempfile.py", 
line 32, in 
import io as _io
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/io.py", 
line 51, in 
import _io
ImportError: 
dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so,
 2): Symbol not found: __PyCodecInfo_GetIncrementalDecoder
  Referenced from: 
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so
  Expected in: flat namespace
 in 
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so

This error occurs under both v2.7.10 and v2.7.11.  When I regress to 2.7.9 and 
all is well.

--
components: IO, Library (Lib)
messages: 261278
nosy: bugbee
priority: normal
severity: normal
status: open
title: _io.so flat namespace
type: crash
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



[issue24852] Python 3.5.0rc1 "HOWTO Use Python in the web" needs fix

2016-03-06 Thread Berker Peksag

Berker Peksag added the comment:

See issue 26497 for another report about this. I will remove 
Doc/howto/webservers.rst.

--
versions:  -Python 3.4

___
Python tracker 

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



[issue26497] Documentation - HOWTO Use Python in the web paragraph on TurboGears still mentions it's based on Pylons

2016-03-06 Thread Berker Peksag

Berker Peksag added the comment:

Thanks for the report. Actually, the whole document is outdated. I think we can 
mark this as a duplicate of issue 24852.

--
nosy: +berker.peksag
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> Python 3.5.0rc1 "HOWTO Use Python in the web" needs fix

___
Python tracker 

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



[issue26483] docs unclear on difference between str.isdigit() and str.isdecimal()

2016-03-06 Thread Martin Panter

Martin Panter added the comment:

The documentation could certainly be clarified to say that all decimals, as 
determined by isdecimal(), are also digits as determined by isdigit(). IMO the 
current documentation is confusing or wrong to stay that decimals ‘include 
digit characters’; it is actually the other way around.

I think it could also be clearer about how ‘general category “Nd” ’ and ‘the 
property value Numeric_Type=Digit or Numeric_Type=Decimal’ are related (if they 
are indeed related).

--
nosy: +martin.panter

___
Python tracker 

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



[issue26497] Documentation - HOWTO Use Python in the web paragraph on TurboGears still mentions it's based on Pylons

2016-03-06 Thread Alessandro Molina

New submission from Alessandro Molina:

https://docs.python.org/3.6/howto/webservers.html#turbogears still mentions 
"TurboGears 2 is based on the WSGI stack of another popular component-based web 
framework, Pylons." which is not true anymore since TurboGears 2.3.0.

TurboGears switched to its own micro-framework core since version 2.3.0 as 
Pylons wasn't Python3 compatible.

Also The TGBook is still mentioned even though it's 10 years old and not 
reliable anymore since TurboGears 1.0

--
assignee: docs@python
components: Documentation
messages: 261274
nosy: Alessandro Molina, docs@python
priority: normal
severity: normal
status: open
title: Documentation - HOWTO Use Python in the web paragraph on TurboGears 
still mentions it's based on Pylons
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



[issue25652] collections.UserString.__rmod__() raises NameError

2016-03-06 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

What about such example?

>>> class F:
... def __init__(self, value):
... self.value = value
... def __mod__(self, other):
... if isinstance(other, str):
... return self.value % other
... return NotImplemented
... 
>>> from collections import UserString
>>> F('say %s') % UserString('hello')
'say hello'

--

___
Python tracker 

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



[issue25652] collections.UserString.__rmod__() raises NameError

2016-03-06 Thread Antoine Pitrou

Antoine Pitrou added the comment:

I admit I don't understand what __rmod__ is meant to achieve here, and 
following str's behaviour sounds like a reasonable decision.

--

___
Python tracker 

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



[issue25652] collections.UserString.__rmod__() raises NameError

2016-03-06 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Antoine, do you have any thoughts on this one?   I'm inclined to remove 
__rmod__ entirely.  That would match what str does and it avoids having to 
guess what the user meant when writing "A(s) % UserString(t)" when A does not 
have a __mod__ formatting method.

--
nosy: +pitrou

___
Python tracker 

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



[issue26494] Double deallocation on iterator exhausting

2016-03-06 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Updated patch fixes also set, dict and os.scandir() iterator.

May be sqlite3 cursor needs a fix, but it is too complicated.

--
Added file: http://bugs.python.org/file42081/free_after_iterating_2.patch

___
Python tracker 

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



[issue16113] Add SHA-3 (Keccak) support

2016-03-06 Thread Mark Lawrence

Changes by Mark Lawrence :


--
nosy:  -BreamoreBoy

___
Python tracker 

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



[issue16113] Add SHA-3 (Keccak) support

2016-03-06 Thread Dror Levin

Changes by Dror Levin :


--
nosy: +spatz

___
Python tracker 

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



[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2016-03-06 Thread Roundup Robot

Roundup Robot added the comment:

New changeset eb120f50df4a by Alexander Belopolsky in branch 'default':
Closes #19475: Added timespec to the datetime.isoformat() method.
https://hg.python.org/cpython/rev/eb120f50df4a

--
nosy: +python-dev
resolution:  -> fixed
stage: commit review -> resolved
status: open -> closed

___
Python tracker 

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



[issue26493] Bad formatting in WinError 193 when using subprocess.check_call

2016-03-06 Thread Eryk Sun

Eryk Sun added the comment:

When Python creates an exception generically from a Windows error code, it 
calls WinAPI FormatMessage with the flag FORMAT_MESSAGE_IGNORE_INSERTS. The 
reason for this is explained in a blog post written by Raymond Chen[1]: "when 
you are not in control of the message, you had better pass the 
FORMAT_MESSAGE_IGNORE_INSERTS flag."

[1]: https://blogs.msdn.microsoft.com/oldnewthing/20071128-00/?p=24353

Some extension modules in the code base get this wrong. For example, 
ctypes.FormatError() doesn't use FORMAT_MESSAGE_IGNORE_INSERTS, so it fails to 
get the system error message for ERROR_BAD_EXE_FORMAT (193) and just returns 
its default string "":

>>> ctypes.FormatError(193)
''

--
components: +Windows
nosy: +eryksun, paul.moore, steve.dower, tim.golden, zach.ware
type:  -> behavior

___
Python tracker 

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



[issue26495] super() does not work in nested functions, genexps, listcomps, and gives misleading exceptions

2016-03-06 Thread Antti Haapala

Antti Haapala added the comment:

super() without arguments gives proper "super() without arguments" in 
functions, generator functions nested in methods, if *those* do not have 
arguments. But if you use super() in a nested function that takes an argument, 
or in a generator expression or a comprehension, you'd get 

Got exception: TypeError super(type, obj): obj must be an instance or 
subtype of type

which is really annoying. Furthermore, if a nested function took another 
instance of type(self) as the first argument, then super() could refer 
unexpectedly to wrong instance:

class Bar(Foo):
def calculate(self, other_foos):
def complicated_calculation(other):
super().some_method(other)

for item in other_foos:
complicated_calculation(item)

now the `super()` call would not have implied `self` of `calculate` as the 
first argument, but the `other` argument of the nested function, all without 
warnings.

I believe it is a mistake that these nested functions can see `__class__` at 
all, since it would just mostly lead them misbehaving unexpectedly.

--
components: +Interpreter Core
title: super() does not work nested -> super() does not work in nested 
functions, genexps, listcomps, and gives misleading exceptions

___
Python tracker 

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



[issue26496] Exhausted dequeue iterator should free a reference to a deque

2016-03-06 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

It is common that exhausted iterator frees a reference to iterating sequence. 
All builtin sequences (list, tuple, str, bytes, bytearray), set and dict 
support this. It would be nice if dequeue will support this too.

--
components: Extension Modules
messages: 261265
nosy: rhettinger, serhiy.storchaka
priority: normal
severity: normal
stage: needs patch
status: open
title: Exhausted dequeue iterator should free a reference to a deque
type: enhancement
versions: Python 3.6

___
Python tracker 

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



[issue26495] super() does not work nested

2016-03-06 Thread Antti Haapala

New submission from Antti Haapala:

super() without arguments is

--
messages: 261264
nosy: ztane
priority: normal
severity: normal
status: open
title: super() does not work nested

___
Python tracker 

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



[issue26494] Double deallocation on iterator exhausting

2016-03-06 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

Following example causes double deallocation of a sequence and crashing.

class A(list):
def __del__(self):
next(it)

it = iter(A())
next(it)

The same is for subclass of tuple, str, bytes and bytearray.

Proposed patch fixes this issue.

--
components: Interpreter Core
files: free_after_iterating.patch
keywords: patch
messages: 261263
nosy: rhettinger, serhiy.storchaka
priority: normal
severity: normal
stage: patch review
status: open
title: Double deallocation on iterator exhausting
type: crash
versions: Python 2.7, Python 3.5, Python 3.6
Added file: http://bugs.python.org/file42080/free_after_iterating.patch

___
Python tracker 

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



[issue26493] Bad formatting in WinError 193 when using subprocess.check_call

2016-03-06 Thread Raúl Núñez de Arenas

New submission from Raúl Núñez de Arenas:

Python 3.5.1 x64 @ Windows 10 x64

The error message in the traceback for OSError/WinError 193 has bad formatting 
and the offending file name is not printed.

For example, this code:

import subprocess

testfile = open('testfile.notexecutable', 'wb')
testfile.close()
subprocess.check_call(['testfile.notexecutable'])


produces this output:

Traceback (most recent call last):
  File "test.py", line 6, in 
subprocess.check_call(['testfile.notexecutable'])
  File "C:\Program Files\Python35\lib\subprocess.py", line 579, in check_call
retcode = call(*popenargs, **kwargs)
  File "C:\Program Files\Python35\lib\subprocess.py", line 560, in call
with Popen(*popenargs, **kwargs) as p:
  File "C:\Program Files\Python35\lib\subprocess.py", line 950, in __init__
restore_signals, start_new_session)
  File "C:\Program Files\Python35\lib\subprocess.py", line 1220, in 
_execute_child
startupinfo)
OSError: [WinError 193] %1 is not a valid Win32 application


Please note the "%1 is not a valid..." on the last line. Instead of the "%1" 
placeholder, the filename ("testfile.notexecutable") should appear instead.

Thanks :)

--
messages: 261262
nosy: Raúl Núñez de Arenas
priority: normal
severity: normal
status: open
title: Bad formatting in WinError 193 when using subprocess.check_call
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



[issue15948] Unchecked return value of I/O functions

2016-03-06 Thread Berker Peksag

Changes by Berker Peksag :


--
dependencies: +Missing sanity checks for various C library function calls...

___
Python tracker 

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



[issue19142] Cross-compile fails trying to execute foreign pgen on build host

2016-03-06 Thread Marc Duponcheel

Marc Duponcheel added the comment:

one workaround is to build native in separate directory and to use the native 
build Parser/pgen and Programs/_freeze_importlib for cross compilation host 
build.

--
nosy: +Marc Duponcheel

___
Python tracker 

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



[issue26492] Exhausted array iterator should left exhausted

2016-03-06 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

There is general rule that after raising StopIteration the iterator should 
always raise StopIteration even if new data is added to iterating sequence. 
Array iterators don't obey this rule.

Proposed patch makes array iterator to left in exhausted state since it 
achieved. As a side (or may be primary) effect of this change, iterating 
sequence can be freed just after iterating is finished.

Added tests for other iterators of resizable sequences.

I don't know whether this patch should be applied to maintained releases or 
only to default branch. Note that array pickling tests broken by this patch 
were just added. They just expose current (presumably incorrect) behavior.

--
assignee: rhettinger
components: Extension Modules
files: exhausted_array_iterator.patch
keywords: patch
messages: 261260
nosy: benjamin.peterson, larry, rhettinger, serhiy.storchaka
priority: normal
severity: normal
stage: patch review
status: open
title: Exhausted array iterator should left exhausted
type: behavior
versions: Python 3.6
Added file: http://bugs.python.org/file42079/exhausted_array_iterator.patch

___
Python tracker 

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



[issue21034] Python docs reference the Distribute package which has been deprecated in favor of Setuptools

2016-03-06 Thread Berker Peksag

Berker Peksag added the comment:

I think it would be better to just remove the following part from the 
documentation:

"Of course, you need to install them into the venv first: this could be done by 
running ez_setup.py with the venv activated, followed by running easy_install 
pip. Alternatively, you could download the source tarballs and run python 
setup.py install after unpacking, with the venv activated."

Here is a patch.

--
nosy: +berker.peksag, vinay.sajip
versions: +Python 3.6 -Python 3.4
Added file: http://bugs.python.org/file42078/issue21034.diff

___
Python tracker 

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



[issue25776] More compact pickle of iterators etc

2016-03-06 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

The patch is synchronized with current sources. Added mandatory braces.

--
Added file: http://bugs.python.org/file42077/iterators_pickle_3.patch

___
Python tracker 

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



[issue25776] More compact pickle of iterators etc

2016-03-06 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

There is the extra special case code for bytes and bytearray iterators and 
reversed list iterator. The patch just extends the optimizations to other 
builtin iterators.

In the example with itertools.islice() the overhead of pickling redundant data 
is 20%. If there are a lot of iterators, the overhead can be up to 90%.

>>> import pickle, pickletools, itertools
>>> len(pickletools.optimize(pickle.dumps([itertools.islice('abcdefgh', 4) for 
>>> i in range(1000)], 4)))
Unpatched: 23059
Patched:   12059

Of course this is degenerated case. But if the data contains a lot of initial 
iterators of the same sequence or of short sequences, or exhausted iterators, 
the benefit can be not small.

Yet one benefit from the patch is that it speeds up copying and deepcopying 
initial and exhausted iterators.

$ ./python -m timeit -s "from itertools import islice; from copy import copy; 
it = islice('abcdefgh', 4)" -- "copy(it)"
Unpatched: 7.37 usec per loop
Patched:   6.4 usec per loop

$ ./python -m timeit -s "from itertools import islice; from copy import 
deepcopy; it = islice('abcdefgh', 4)" -- "deepcopy(it)"
Unpatched: 41.7 usec per loop
Patched:   32.6 usec per loop

$ ./python -m timeit -s "from copy import copy; it = iter('abcdefgh')" -- 
"copy(it)"
Unpatched: 10.4 usec per loop
Patched:   9.67 usec per loop

$ ./python -m timeit -s "from copy import deepcopy; it = iter('abcdefgh')" -- 
"deepcopy(it)"
Unpatched: 21.1 usec per loop
Patched:   18.3 usec per loop

$ ./python -m timeit -s "from copy import copy; it = iter(list('abcdefgh'))" -- 
"copy(it)"
Unpatched: 10.3 usec per loop
Patched:   9.54 usec per loop

$ ./python -m timeit -s "from copy import deepcopy; it = 
iter(list('abcdefgh'))" -- "deepcopy(it)"
Unpatched: 39.7 usec per loop
Patched:   36.8 usec per loop

--

___
Python tracker 

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



[issue26489] dictionary unpacking operator in dict expression

2016-03-06 Thread Berker Peksag

Berker Peksag added the comment:

Thanks for the patch! Could you please sign the contributor's agreement at 
https://www.python.org/psf/contrib/contrib-form/ ?

--
nosy: +berker.peksag
resolution:  -> fixed
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



[issue26489] dictionary unpacking operator in dict expression

2016-03-06 Thread Roundup Robot

Roundup Robot added the comment:

New changeset a34428aff42d by Berker Peksag in branch '3.5':
Issue #26489: Add dictionary unpacking support to Tools/parser/unparse.py
https://hg.python.org/cpython/rev/a34428aff42d

New changeset 1b212e366b66 by Berker Peksag in branch 'default':
Issue #26489: Add dictionary unpacking support to Tools/parser/unparse.py
https://hg.python.org/cpython/rev/1b212e366b66

--
nosy: +python-dev

___
Python tracker 

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



[issue2202] urllib2 fails against IIS 6.0 (No support for MD5-sess auth)

2016-03-06 Thread Berker Peksag

Berker Peksag added the comment:

Thanks, Mathieu! I went with a simpler approach to test the code.

--
keywords:  -needs review
nosy: +berker.peksag
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
type: enhancement -> behavior

___
Python tracker 

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



[issue2202] urllib2 fails against IIS 6.0 (No support for MD5-sess auth)

2016-03-06 Thread Roundup Robot

Roundup Robot added the comment:

New changeset d135799e952b by Berker Peksag in branch '2.7':
Issue #2202: Fix UnboundLocalError in 
AbstractDigestAuthHandler.get_algorithm_impls
https://hg.python.org/cpython/rev/d135799e952b

--

___
Python tracker 

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



[issue2202] urllib2 fails against IIS 6.0 (No support for MD5-sess auth)

2016-03-06 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 22eab50cb585 by Berker Peksag in branch '3.5':
Issue #2202: Fix UnboundLocalError in 
AbstractDigestAuthHandler.get_algorithm_impls
https://hg.python.org/cpython/rev/22eab50cb585

New changeset 046c75c9cd33 by Berker Peksag in branch 'default':
Issue #2202: Fix UnboundLocalError in 
AbstractDigestAuthHandler.get_algorithm_impls
https://hg.python.org/cpython/rev/046c75c9cd33

--
nosy: +python-dev

___
Python tracker 

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



[issue25652] collections.UserString.__rmod__() raises NameError

2016-03-06 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

In normal case there is no infinite recursion in collections.UserString1, since 
UserString.__rmod__(S) falls back to S.__mod__(str) or str.__rmod__(S).

>>> S('say %s') % UserString('hello')
Traceback (most recent call last):
  File "", line 1, in 
  File "/home/serhiy/py/cpython/Lib/collections/__init__.py", line 1156, in 
__rmod__
return self.__class__(format % self.data)
TypeError: unsupported operand type(s) for %: 'S' and 'str'

Infinite recursion is possible if we make recursive UserString (us.data = us), 
but in this case we will get infinite recursion in all operations.

collections.UserString1 LGTM at the same degree as UserString.__le__ (it would 
be better to handle NotImplemented correctly).

There is yet one consideration. In 2.x UserString simulates both 8-bit and 
Unicode strings. In 3.x UserString simulates both str and bytes (except 
decode(), bytes formatting, etc). I think it is worth once to make UserString 
to support bytes formatting. In this case it would be incorrect to coerce the 
template to a regular str.

--

___
Python tracker 

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



[issue26167] Improve copy.copy speed for built-in types (list/set/dict)

2016-03-06 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


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

___
Python tracker 

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



[issue25718] itertools.accumulate __reduce__/__setstate__ bug

2016-03-06 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
versions:  -Python 2.7, Python 3.4

___
Python tracker 

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



[issue26015] Add new tests for pickling iterators of mutable sequences

2016-03-06 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

In 2.7 iterators are not pickleable.

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
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



[issue25718] itertools.accumulate __reduce__/__setstate__ bug

2016-03-06 Thread Roundup Robot

Roundup Robot added the comment:

New changeset f3c54cbac3de by Serhiy Storchaka in branch '3.5':
Issue #25718: Fixed pickling and copying the accumulate() iterator with total 
is None.
https://hg.python.org/cpython/rev/f3c54cbac3de

New changeset 49c035b30e18 by Serhiy Storchaka in branch 'default':
Issue #25718: Fixed pickling and copying the accumulate() iterator with total 
is None.
https://hg.python.org/cpython/rev/49c035b30e18

--

___
Python tracker 

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



[issue26491] Defer DECREFs until enum object is in a consistent state for re-entrancy

2016-03-06 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

I don't see possible bug here.

The first item of the tuple is always int or None. It's decrefing don't trigger 
executing user code.

The second item of the tuple is decrefed when the refcount of the tuple is 2 
and we own all references. The code triggered by decrefing the old item can't 
use the tuple (since its refcount is not 1 now), nor free the new index or new 
item (since we take the ownership of them).

I think this patch is not needed.

--

___
Python tracker 

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



[issue26167] Improve copy.copy speed for built-in types (list/set/dict)

2016-03-06 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Then go ahead with the patch as is.

--

___
Python tracker 

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



[issue26015] Add new tests for pickling iterators of mutable sequences

2016-03-06 Thread Raymond Hettinger

Raymond Hettinger added the comment:

These tests look fine.  I won't miss "orgit" ;-)

In test_reversed_pickle, please add the blank line before each section like you 
did for the other tests.

I agree that exhausted array iterator should change to match the others.  Once 
an iterator is exhausted, it is required to remain exhausted even if the 
underlying data mutates.   That rule should survive even after dumping and 
loading.

--
assignee: rhettinger -> serhiy.storchaka

___
Python tracker 

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



[issue26167] Improve copy.copy speed for built-in types (list/set/dict)

2016-03-06 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

> This looks nicer and should run faster by taking advantage of the LIST_APPEND 
> opcode.

The difference is insignificantly (less than 1%) for large lists 
(list(range(1))), but it is 3-4% slower for small lists (list(range(10))) 
and 20-25% slower for empty lists.

On 2.7 your code always has advantage, but on 3.x seems it doesn't have any 
advantage (thanks to overhead of using a generator).

--

___
Python tracker 

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



[issue25718] itertools.accumulate __reduce__/__setstate__ bug

2016-03-06 Thread Raymond Hettinger

Raymond Hettinger added the comment:

+1

--
assignee: rhettinger -> serhiy.storchaka

___
Python tracker 

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



[issue26490] Leading “0” allowed, only for decimal zero

2016-03-06 Thread Berker Peksag

Changes by Berker Peksag :


--
superseder:  -> Deprecate 0 as a synonym for 0

___
Python tracker 

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



[issue26491] Defer DECREFs until enum object is in a consistent state for re-entrancy

2016-03-06 Thread Raymond Hettinger

Changes by Raymond Hettinger :


--
assignee: serhiy.storchaka
components: Interpreter Core
files: enumerate_defer_decref.diff
keywords: patch
nosy: rhettinger, serhiy.storchaka
priority: normal
severity: normal
stage: patch review
status: open
title: Defer DECREFs until enum object is in a consistent state for re-entrancy
type: behavior
versions: Python 2.7, Python 3.5, Python 3.6
Added file: http://bugs.python.org/file42076/enumerate_defer_decref.diff

___
Python tracker 

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



[issue25776] More compact pickle of iterators etc

2016-03-06 Thread Raymond Hettinger

Raymond Hettinger added the comment:

My first impression is that this isn't worth the extra special case code.  The 
savings is very small (only a few bytes) and it isn't common to pickle these 
iterators.

--

___
Python tracker 

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



[issue26167] Improve copy.copy speed for built-in types (list/set/dict)

2016-03-06 Thread Raymond Hettinger

Raymond Hettinger added the comment:

One suggestion:

def _deepcopy_list(x, memo, deepcopy=deepcopy):
y = []
memo[id(x)] = y
y[:] = [deepcopy(a, memo) for a in x]
return y

This looks nicer and should run faster by taking advantage of the LIST_APPEND 
opcode.

It should be noted that the core concept of the patch is all about the 
minimizing the calling overhead of the copying operation (the cost to call 
type(x) and the overhead in the type constructors for parsing the positional 
and keyword arguments).  When it comes to actually copying the data in the 
containers, there underlying code to do the copying is the same for both the 
patched and unpatched version (that is why you see a speed-up for copying empty 
containers and almost no change for containers that have data in them).

--
nosy: +rhettinger

___
Python tracker 

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



[issue25652] collections.UserString.__rmod__() raises NameError

2016-03-06 Thread Raymond Hettinger

Raymond Hettinger added the comment:

The UserString1 patch is incorrect as it leads to infinite recursion because 
the __rmod__ operation only gets called when the other argument doesn't have 
__mod__.

One possible fix is to coerce the template to a regular str: 

def __rmod__(self, template):
return self.__class__(str(template) % self)

That would get the following test to pass:

class S:
'strlike class without a __mod__'
def __init__(self, value):
self.value = value
def __str__(self):
return str(self.value)

assert S('say %s') % UserString('hello') == 'say hello'

That said, the goal of UserString is to parallel what a regular string would 
do.  In this case, a TypeError is raised:

>>> print(S('answer is %s') % 'hello')
Traceback (most recent call last):
  ...
TypeError: unsupported operand type(s) for %: 'S' and 'str'

Serhiy, what do you think should be done, coerce to a str or remove the 
__rmod__ method entirely?

--
assignee: rhettinger -> serhiy.storchaka

___
Python tracker 

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