[issue21507] set and frozenset constructor should use operator.length_hint to guess the size of the iterator

2014-05-15 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

I agree with Josh's arguments. Similar idea was already proposed and rejected 
(issue17338).

--

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



[issue21509] json.load fails to read UTF-8 file with (BOM) Byte Order Marks

2014-05-15 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Currently json.load/loads don't support binary input. See issue17909 and 
issue19837.

--

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



[issue21507] set and frozenset constructor should use operator.length_hint to guess the size of the iterator

2014-05-15 Thread STINNER Victor

STINNER Victor added the comment:

I think the argument against using PyObject_LengthHint for the general 
iterable case is that for inputs other than sets or dicts, the assumption is 
that significant deduplication will occur.

Oh... I'm dumb :) Sorry.

Another option for frozenset only: we may adjust the internal size when the 
frozenset is created from an iterator.

--

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



[issue21027] difflib new cli interface

2014-05-15 Thread STINNER Victor

STINNER Victor added the comment:

 After more thought, I think this should remain in tools as a demo.

I disagree, I like the command line interface. It's very useful on Windows for 
example. It's also useful on UNIX embedded devices where Python is installed, 
but only a few UNIX tools.

If you are not convinced, please see this amazing talk of David Beazley at 
Pycon 2014:
http://pyvideo.org/video/2645/discovering-python

The patch only adds a few lines to difflib.py.

IMO difflib CLI is even more useful than tarfile CLI ;-)

It's not like no other Python module has a CLI. Modules with a CLI of Python 
3.5:

aifc
base64
calendar
cgi
code
compileall
cProfile
dis
doctest
filecmp
fileinput
formatter
ftplib
getopt
gzip
imaplib
imghdr
inspect
locale
mailcap
mimetypes
modulefinder
netrc
nntplib
pdb
pickle
pickletools
platform
poplib
pprint
profile
pstats
pyclbr
py_compile
pydoc
quopri
random
runpy
shlex
site
smtpd
smtplib
sndhdr
sre_constants
symbol
symtable
sysconfig
tabnanny
tarfile
telnetlib
textwrap
timeit
tokenize
token
trace
turtle
uu
webbrowser
zipfile

--

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



[issue19837] Wire protocol encoding for the JSON module

2014-05-15 Thread STINNER Victor

Changes by STINNER Victor victor.stin...@gmail.com:


--
nosy: +haypo

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



[issue17909] Autodetecting JSON encoding

2014-05-15 Thread STINNER Victor

Changes by STINNER Victor victor.stin...@gmail.com:


--
nosy: +haypo

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



[issue13916] disallow the surrogatepass handler for non utf-* encodings

2014-05-15 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

This issue was mainly resolved in issue12892. The surrogatepass error handler 
now works with UTF-16* and UTF-32* encodings. But for other encodings it 
behaves as for UTF-8 (preserve old behavior). Should we change the behavior for 
non-UTF encodings end raise an exception (as for strict)?

--

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



[issue19186] expat symbols should be namespaced in pyexpat again

2014-05-15 Thread Peter Kruse

Peter Kruse added the comment:

Fascinating, you are right, very good, thanks for your time and looking into 
this.

Peter

--

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



[issue15809] 2.7 IDLE console uses incorrect encoding.

2014-05-15 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Alternative solution is to force UTF-8 in IDLE console. But I think this will 
be more surprising, especially for Windows users.

--

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



[issue13916] disallow the surrogatepass handler for non utf-* encodings

2014-05-15 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Here is a patch which disallows the surrogatepass handler for non-utf 
encodings. Please test it on Windows.

--
type: behavior - enhancement
versions: +Python 3.5 -Python 3.1, Python 3.2, Python 3.3

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



[issue13916] disallow the surrogatepass handler for non utf-* encodings

2014-05-15 Thread STINNER Victor

STINNER Victor added the comment:

Serhiy Storchaka wrote:
 Here is a patch

I don't see your patch.

--

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



[issue13916] disallow the surrogatepass handler for non utf-* encodings

2014-05-15 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Oh, sorry.

--
keywords: +patch
Added file: http://bugs.python.org/file35257/surrogatepass_non_utf.patch

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



[issue13916] disallow the surrogatepass handler for non utf-* encodings

2014-05-15 Thread Martin v . Löwis

Martin v. Löwis added the comment:

LGTM

--

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



[issue21510] fma documentation should provide better example.

2014-05-15 Thread Mark Dickinson

Changes by Mark Dickinson dicki...@gmail.com:


--
nosy: +mark.dickinson, skrah

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



[issue21510] fma documentation should provide better example.

2014-05-15 Thread Mark Dickinson

Mark Dickinson added the comment:

I wouldn't want to drop the simple example: I suspect that many of those 
looking at fma won't have the first idea what it does, and that first example 
shows clearly that it's a fused multiply-add.

But +1 for an example that demonstrates the single rounding, either in the 
online docs or the docstring (or both).

--

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



[issue13916] disallow the surrogatepass handler for non utf-* encodings

2014-05-15 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 5e98a50e0f55 by Serhiy Storchaka in branch 'default':
Issue #13916: Disallowed the surrogatepass error handler for non UTF-*
http://hg.python.org/cpython/rev/5e98a50e0f55

--
nosy: +python-dev

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



[issue21510] fma documentation should provide better example.

2014-05-15 Thread Jayanth Koushik

Jayanth Koushik added the comment:

@Mark: I agree. And perhaps it is also worth mentioning (on an unrelated note), 
that the decimal fma is not based on the internal cmath fma (it could not be) 
and unlike the cmath fma, it is no faster than an unfused multiply-add.

--

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



[issue13916] disallow the surrogatepass handler for non utf-* encodings

2014-05-15 Thread Serhiy Storchaka

Changes by Serhiy Storchaka storch...@gmail.com:


--
assignee:  - serhiy.storchaka
resolution:  - fixed
stage:  - resolved
status: open - closed

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



[issue17909] Autodetecting JSON encoding

2014-05-15 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

All dependencies for this issue are resolved now.

Here is updated patch, synchronized with tip.

--
Added file: http://bugs.python.org/file35258/json_detect_encoding_2.patch

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



[issue21487] Assorted ipaddress performance improvements

2014-05-15 Thread Antoine Pitrou

Antoine Pitrou added the comment:

I find logical operations on negative numbers confusing in Python, so I'd 
rather stick with the first implementation.

--

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



[issue17909] Autodetecting JSON encoding

2014-05-15 Thread Serhiy Storchaka

Changes by Serhiy Storchaka storch...@gmail.com:


Removed file: http://bugs.python.org/file30133/json_detect_encoding.patch

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



[issue21486] optimize v4 v6 netmask parsing

2014-05-15 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

What I want to say, the patch LGTM, but after committing issue14373 we should 
simplify the code by using functools.lru_cache().

--

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



[issue21486] optimize v4 v6 netmask parsing

2014-05-15 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Actually, using lru_cache(maxsize=None) would enable a simple infinite cache 
like in the patch. But it's not like a lot of code would be saved.

--

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



[issue13916] disallow the surrogatepass handler for non utf-* encodings

2014-05-15 Thread STINNER Victor

STINNER Victor added the comment:

It makes sense to restrict surrogatepass to UTF-* encodings. UTF-8, UTF-16 and 
UTF-32 encoders reject surrogate characters, but not UTF-7. Is it a bug? I'm 
asking because PyCodec_SurrogatePassErrors() doesn't support UTF-7.

IMO your change is important enough to be mentionned in What's new Python 3.5 
document, and maybe also in the documentation of the codecs module.

--

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



[issue13916] disallow the surrogatepass handler for non utf-* encodings

2014-05-15 Thread STINNER Victor

STINNER Victor added the comment:

Windows buildbots are unhappy.

http://buildbot.python.org/all/builders/x86%20Windows7%203.x/builds/8355/steps/test/logs/stdio

==
ERROR: test_surrogatepass_handler (test.test_codecs.CP65001Test)
--
Traceback (most recent call last):
  File 
D:\cygwin\home\db3l\buildarea\3.x.bolen-windows7\build\lib\test\test_codecs.py,
 line 883, in test_surrogatepass_handler
self.assertEqual(abc\ud800def.encode(cp65001, surrogatepass),
UnicodeEncodeError: 'CP_UTF8' codec can't encode character '\ud800' in position 
3: invalid character

==
FAIL: test_encode (test.test_codecs.CP65001Test)
--
Traceback (most recent call last):
  File 
D:\cygwin\home\db3l\buildarea\3.x.bolen-windows7\build\lib\test\test_codecs.py,
 line 818, in test_encode
encoded = text.encode('cp65001', errors)
UnicodeEncodeError: 'CP_UTF8' codec can't encode character '\udc80' in position 
0: invalid character

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File 
D:\cygwin\home\db3l\buildarea\3.x.bolen-windows7\build\lib\test\test_codecs.py,
 line 821, in test_encode
'errors=%r: %s' % (text, errors, err))
AssertionError: Unable to encode '\udc80' to cp65001 with 
errors='surrogatepass': 'CP_UTF8' codec can't encode character '\udc80' in 
position 0: invalid character

==
FAIL: test_cp1252 (test.test_codecs.CodePageTest)
--
Traceback (most recent call last):
  File 
D:\cygwin\home\db3l\buildarea\3.x.bolen-windows7\build\lib\test\test_codecs.py,
 line 2849, in test_cp1252
(b'[\x98]', 'surrogatepass', None),
  File 
D:\cygwin\home\db3l\buildarea\3.x.bolen-windows7\build\lib\test\test_codecs.py,
 line 2781, in check_decode
codecs.code_page_decode, cp, raw, errors, True)
AssertionError: UnicodeDecodeError not raised by code_page_decode

--
resolution: fixed - 
status: closed - open

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



[issue13916] disallow the surrogatepass handler for non utf-* encodings

2014-05-15 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Here is a patch, which adds support for cp65001 and fixes test_cp1252. Please 
test it on Windows Vista.

Lone surrogates are not illegal in UTF-7 (see RFC 1642), so error handler is 
not called and explicit support of UTF-7 is not needed.

Could you please help with documenting this change in What's new Python 3.5 
document? I don't think this change is worth special mentioning in codecs 
documentation, it is already documented that surrogatepass is supported only 
for utf-8, utf-16* and utf-32*.

--
Added file: http://bugs.python.org/file35259/surrogatepass_cp_utf8.patch

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



[issue21508] C API PyArg_ParseTuple doc is innacurate

2014-05-15 Thread Steve

Steve added the comment:

I would prefer the function to return bool.  But what I prefer is irrelevant, 
what counts is accuracy and clarity.  And to this end, the return type and the 
comment have to match.

For a int return value, the document should mention a condition relative to an 
integer value (e.g.: ==0, !=0, ==-1, 0, ==42, etc).

In this particular case, to minimize the changes, success should be defined as 
!=0 and failure ==0.

Although there is a bigger problem that I mentioned in that the Python C API 
uses two different return value standards: in most places, ==0 is success, in 
this case (and some other places) ==0 is a failure.

As for implementation constraints I don't see how making the documentation 
accurate affects that in any way.  If ever the implementation is expanded, the 
documentation will need to change.  The only alternative is to make the doc 
vague or simply wrong.

--

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



[issue13916] disallow the surrogatepass handler for non utf-* encodings

2014-05-15 Thread STINNER Victor

STINNER Victor added the comment:

 Here is a patch, which adds support for cp65001

The name of the encoding is cp65001, not something like cp-utf8.

And there is no alias like cp_65001, there is only cp65001.

--

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



[issue17909] Autodetecting JSON encoding

2014-05-15 Thread Chris Rebert

Chris Rebert added the comment:

You'll need to also update the Character Encodings subsection of the json 
docs.

--

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



[issue13916] disallow the surrogatepass handler for non utf-* encodings

2014-05-15 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

But an exception reports about CP_UTF8.

--
title: disallow the surrogatepass handler for non  utf-* encodings - 
disallow the surrogatepass handler for non utf-* encodings

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



[issue21511] Thinko in Lib/quopri.py

2014-05-15 Thread Paul Sokolovsky

New submission from Paul Sokolovsky:

Lib/quopri.py for version 3.3..3.5-tip contains following code:

ESCAPE = b'='
...
line = input.readline()
if not line: break
i, n = 0, len(line)
if n  0 and line[n-1:n] == b'\n':
...
elif i+1  n and line[i+1] == ESCAPE:


So, ESCAPE is defined as bytes, we see that line is read as bytes, and 
characters are accessed using idiom like line[n-1:n], but then it uses 
line[i+1], which returns int and thus will never be equal to ESCAPE.

I'm not sure what exact semantic condition that branch represents, for me it 
looks like == sequence to be decoded as =. But I don't see such encoding 
variant in http://en.wikipedia.org/wiki/Quoted-printable . Either way, 
replacing that condition with and False, still passes test_quopri.py

--
components: Library (Lib)
messages: 218618
nosy: pfalcon
priority: normal
severity: normal
status: open
title: Thinko in Lib/quopri.py
type: behavior
versions: Python 3.5

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



[issue21512] time module becomes None after raise SystemExit

2014-05-15 Thread Ryder Lewis

New submission from Ryder Lewis:

I'm not sure if this is a bug or expected behavior, but basically what I want 
to do is log the timestamp when an application exits. Sample script to 
illustrate the issue:

 try.py 
import time

class A():
def __init__(self):
print(Initializing A. The time is {}.format(time.time()))

def __del__(self):
if time is None:
print(time is None!)
else:
print(Deleting A. The time is {}.format(time.time()))

a = A()
raise SystemExit()

=

When running this script multiple times, there are 3 possible outcomes:

 outcome #1 (happens about 25% of my trial runs, what I would expect is 
correct behavior) 
Initializing A. The time is 1400175810.4806361
Deleting A. The time is 1400175810.483156

 outcome #2 (happens about 50% of my trial runs) 
Initializing A. The time is 1400175814.1646852
time is None!

 outcome #3 (happens about 25% of my trial runs) 
Initializing A. The time is 1400175809.6802816
Exception ignored in: bound method A.__del__ of __main__.A object at 
0x7fb125eab5f8
Traceback (most recent call last):
  File ./try.py, line 12, in __del__
TypeError: 'NoneType' object is not callable

--
components: Interpreter Core
messages: 218619
nosy: ryder.lewis
priority: normal
severity: normal
status: open
title: time module becomes None after raise SystemExit
type: behavior
versions: Python 3.4

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



[issue21512] time module becomes None after raise SystemExit

2014-05-15 Thread Ezio Melotti

Changes by Ezio Melotti ezio.melo...@gmail.com:


--
nosy: +benjamin.peterson, pitrou
resolution:  - not a bug
status: open - pending

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



[issue21512] time module becomes None after raise SystemExit

2014-05-15 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Well, let's call it a limitation rather than a bug.
When creating a global variable (such as a in your example), that variable is 
kept alive at least as long as the module containing it. However, modules 
usually live until very late in the interpreter shutdown process, *especially* 
the __main__ module. So, by the time a gets garbage-collected, other globals 
or modules may already have been wiped.

Unfortunately, I don't think there's much we can do to improve this. The answer 
to your specific problem is to use the atexit module instead, since an atexit 
callback is guaranteed to be called with a normal execution environment, before 
it starts being garbage-collected.

--
status: pending - open

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



[issue21512] time module becomes None after raise SystemExit

2014-05-15 Thread Antoine Pitrou

Changes by Antoine Pitrou pit...@free.fr:


--
resolution: not a bug - wont fix
status: open - closed

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



[issue21486] optimize v4 v6 netmask parsing

2014-05-15 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 2158614e1607 by Antoine Pitrou in branch 'default':
Issue #21486: Optimize parsing of netmasks in ipaddress.IPv4Network and 
ipaddress.IPv6Network.
http://hg.python.org/cpython/rev/2158614e1607

--
nosy: +python-dev

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



[issue21487] Assorted ipaddress performance improvements

2014-05-15 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 2711677cf874 by Antoine Pitrou in branch 'default':
Issue #21487: Optimize ipaddress.summarize_address_range() and 
ipaddress.{IPv4Network,IPv6Network}.subnets().
http://hg.python.org/cpython/rev/2711677cf874

--
nosy: +python-dev

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



[issue15809] 2.7 IDLE console uses incorrect encoding.

2014-05-15 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Idle 3.x has Martin's patch, except that the 'if' clause is merely commented 
out rather than removed. (Perhaps someone wanted to test the removal first.  It 
should now be deleted.)

My 2.7 Idle has Default Source Encoding ... [x] None. Since there is nothing 
for this in either config-main.def, I presume it is the default -- at least for 
Windows. But Martin says it is not relevant.

'Surprising' suggests that you think or know that doing the same in 2.7 might 
introduce other discrepancies from console behavior. I am reluctant to do that, 
though it is possible that it might make Idle *better* than the console.

I would definitely be reluctant to do something more wide-ranging than your 
patch without extensive tests, and even that patch should have some tests, some 
of which pass now and continue to pass, and other that fail now and pass with 
the patch.

Irdb said As a Windows user, currently I can't print u'йцук' in interactive 
mode and get an Unsupported characters in input error because my default 
system encoding (cp1256) can't encode Russian.)

Idle 2.7
 u'йцук'
Unsupported characters in input

Console 2.7
 u''
u''
 u''[0] == '?'
True

--

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



[issue20826] Faster implementation to collapse consecutive ip-networks

2014-05-15 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 8867874a2b7d by Antoine Pitrou in branch 'default':
Issue #20826: Optimize ipaddress.collapse_addresses().
http://hg.python.org/cpython/rev/8867874a2b7d

--
nosy: +python-dev

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



[issue20826] Faster implementation to collapse consecutive ip-networks

2014-05-15 Thread Antoine Pitrou

Antoine Pitrou added the comment:

I've now committed this. exhuma, if you have any further observations or 
results, don't hesitate to post them!

--
resolution:  - fixed
stage: patch review - commit review
status: open - closed

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



[issue21487] Assorted ipaddress performance improvements

2014-05-15 Thread Antoine Pitrou

Changes by Antoine Pitrou pit...@free.fr:


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

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



[issue21486] optimize v4 v6 netmask parsing

2014-05-15 Thread Antoine Pitrou

Changes by Antoine Pitrou pit...@free.fr:


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

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



[issue15809] 2.7 IDLE console uses incorrect encoding.

2014-05-15 Thread Martin v . Löwis

Changes by Martin v. Löwis mar...@v.loewis.de:


--
nosy:  -loewis

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



[issue21364] Documentation Recommends Broken Pattern

2014-05-15 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 4621bb82ceec by Antoine Pitrou in branch '3.4':
Issue #21364: remove recommendation of broken pattern.
http://hg.python.org/cpython/rev/4621bb82ceec

New changeset dbf728f9a2f0 by Antoine Pitrou in branch 'default':
Issue #21364: remove recommendation of broken pattern.
http://hg.python.org/cpython/rev/dbf728f9a2f0

--
nosy: +python-dev

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



[issue21364] Documentation Recommends Broken Pattern

2014-05-15 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Thanks for the report, Armin. I've removed that recommendation and changed the 
surrounding wording to insist that standard streams are always text streams.

--
resolution:  - fixed
stage:  - resolved
status: open - closed

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



[issue21364] Documentation Recommends Broken Pattern

2014-05-15 Thread Armin Ronacher

Armin Ronacher added the comment:

To avoid further problems may I also recommend documenting how exactly people 
are supposed to wrap sys.stdout and so forth.  Clearly putting a StringIO there 
is insufficient as StringIO does not have a buffer.

Something like this maybe?

import io
buf = io.BytesIO()
sys.stdout = io.TextIOWrapper(buf,
encoding='utf-8',
errors='strict', # or surrogate-escape as this is the default for stdout 
now? not sure
line_buffering=True
)

--

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



[issue21364] Documentation Recommends Broken Pattern

2014-05-15 Thread Antoine Pitrou

Antoine Pitrou added the comment:

 To avoid further problems may I also recommend documenting how exactly
 people are supposed to wrap sys.stdout and so forth.  Clearly putting
 a StringIO there is insufficient as StringIO does not have a buffer.

I would like to know of some situations where you want to write some
code that accesses standard streams as binary *and* don't control the
application setup (i.e. library code rather than application code). It
seems to me that a library should take the binary streams as parameters
rather than force the use of stdin/stdout.

--

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



[issue21513] speed up some ipaddress properties

2014-05-15 Thread Antoine Pitrou

New submission from Antoine Pitrou:

Some properties on IPv4Address and IPv6Address instantiate one or several 
network objects each time they are computed. Instead these characteristic 
networks can be computed once and for all at module import. Patch attached.

(note: the lru_cache() decorator seems to mitigate this in micro-benchmarks, 
but the common pattern is not to call .is_private on always the same address 
:-))

--
components: Library (Lib)
files: ipaddr_props.patch
keywords: patch
messages: 218630
nosy: ncoghlan, pitrou, pmoody, serhiy.storchaka
priority: normal
severity: normal
stage: patch review
status: open
title: speed up some ipaddress properties
type: performance
versions: Python 3.5
Added file: http://bugs.python.org/file35260/ipaddr_props.patch

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



[issue21364] Documentation Recommends Broken Pattern

2014-05-15 Thread Armin Ronacher

Armin Ronacher added the comment:

 I would like to know of some situations where you want to write some
 code that accesses standard streams as binary *and* don't control the
 application setup (i.e. library code rather than application code). It
 seems to me that a library should take the binary streams as parameters
 rather than force the use of stdin/stdout.

The same situations people wrapped streams before on python 2:

* code.py users.  Werkzeug's traceback system implements a remote python 
  shell through it.
* any system that wants to unittest shell scripts on a high level.
* any system that wants to execute arbitrary python code and then
  capture whatever output it did.  This is for instance what I see
  Sphinx users frequently do (or doctests)

In fact, the reasons people wrap sys.stdout/sys.stderr on 2.x are the same 
reasons why people would do it on 3.x: they have arbitrary code they did not 
write and they want to capture what it does.

Since you do not know if that is binary or text you need a stream object that 
behaves the same way as the default one.

--

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



[issue21364] Documentation Recommends Broken Pattern

2014-05-15 Thread Armin Ronacher

Armin Ronacher added the comment:

Pretty much, yes.  Just that you probably want 'replace' instead.  
surrogate-escape does not do anything useful here I think.

--

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



[issue21364] Documentation Recommends Broken Pattern

2014-05-15 Thread Antoine Pitrou

Antoine Pitrou added the comment:

 The same situations people wrapped streams before on python 2:
 
 * code.py users.  Werkzeug's traceback system implements a remote python 
   shell through it.
 * any system that wants to unittest shell scripts on a high level.
 * any system that wants to execute arbitrary python code and then
   capture whatever output it did.  This is for instance what I see
   Sphinx users frequently do (or doctests)

I see, I misunderstood you. You actually want to get back the bytes
output of e.g. stdout, right?
You could indeed use a TextIOWrapper wrapping a BytesIO object. Or of
course another possibility is to do the encoding yourself, e.g.
sys.stdout.getvalue().encode('utf-8', 'surrogateescape').

--

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



[issue21364] Documentation Recommends Broken Pattern

2014-05-15 Thread R. David Murray

R. David Murray added the comment:

Note that in 3.4 we have contextlib.replace_stdout, but it doesn't give any 
examples of how to construct file-like objects that will work well with it.

--

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



[issue21364] Documentation Recommends Broken Pattern

2014-05-15 Thread R. David Murray

R. David Murray added the comment:

I mean redirect_stdout.

--

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



[issue21513] speed up some ipaddress properties

2014-05-15 Thread Josh Rosenberg

Changes by Josh Rosenberg shadowranger+pyt...@gmail.com:


--
nosy: +josh.rosenberg

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



[issue21508] C API PyArg_ParseTuple doc is innacurate

2014-05-15 Thread Josh Rosenberg

Josh Rosenberg added the comment:

Changing the docs isn't the main hurdle; the problem is that if we told people 
they could test == 1, rather than != 0, then new success return codes couldn't 
be added without a long period of warning.

I don't think the convention is consistently 0 means success BTW. Frankly, 0 
means success is just confusing in general (since it reverses the normal C 
convention, even if it agrees with the errno convention).

bool is sadly out, since Python is forever stuck in 1990, and will never know 
the joys of C99.

--

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



[issue18104] Idle: make human-mediated GUI tests usable

2014-05-15 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 0a6d51ccff54 by Terry Jan Reedy in branch '2.7':
Issue #18104: revise docstrings, remove obsolete comments.
http://hg.python.org/cpython/rev/0a6d51ccff54

New changeset 6d2982ff441f by Terry Jan Reedy in branch '3.4':
Issue #18104: revise docstrings, remove obsolete comments.
http://hg.python.org/cpython/rev/6d2982ff441f

--

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



[issue21507] set and frozenset constructor should use operator.length_hint to guess the size of the iterator

2014-05-15 Thread Josh Rosenberg

Josh Rosenberg added the comment:

Not sure how much that really helps. If I understand you correctly, it would be 
a memory optimization that would require a round of rehashing to use?

If you wanted to make a change that got guaranteed better performance, you 
might add support for dict's dict_keys and dict_items objects (since those have 
the same uniqueness guarantees as a set or dict, and I could easily see someone 
creating sets from them to remove the link to the original dict).

If you wanted to get crazy, you might add preallocation support for 
collections.abc abstract classes equivalent to the built-ins, specifically, 
Set, Mapping, KeysView and ItemsView. That's probably not a good idea though, 
since it ends up calling out to Python code more (slowing you down for the 
general case) and it's probably not as safe, since a user-defined 
implementation of those abstract classes might not strictly adhere to the same 
uniqueness or hashability contracts the built-ins provide.

--

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



[issue21046] Document formulas used in statistics

2014-05-15 Thread Alextp

Alextp added the comment:

@Ezio:
of course, much of these funcs CANNOT be expressed as simple formulas. Only 
with some text. I shown example descriptions for almost all- above.

--

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



[issue17909] Autodetecting JSON encoding

2014-05-15 Thread akira

akira added the comment:

Both json standard (ECMA-404) [1] and the new json rfc 7159 [2] do not mention
the encoding detection.

[1] http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf
[2] https://tools.ietf.org/html/rfc7159#section-8.1

From the rfc:

 JSON text SHALL be encoded in UTF-8, UTF-16, or UTF-32.  The default
  encoding is UTF-8, and JSON texts that are encoded in UTF-8 are
  interoperable in the sense that they will be read successfully by the
  maximum number of implementations; there are many implementations
  that cannot successfully read texts in other encodings (such as
  UTF-16 and UTF-32).

  Implementations MUST NOT add a byte order mark to the beginning of a
  JSON text.  In the interests of interoperability, implementations
  that parse JSON texts MAY ignore the presence of a byte order mark
  rather than treating it as an error.

--
nosy: +akira

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



[issue17909] Autodetecting JSON encoding

2014-05-15 Thread Chris Rebert

Chris Rebert added the comment:

I agree that the state of encoding detection in the new RFC seems unclear, 
given that the old RFC prefaced the part about the encoding detection with:
 Since the first two characters of a JSON text will always be ASCII
 characters

But in the new RFC:
 Appendix A.  Changes from RFC 4627
[...]
o  Changed the definition of JSON text so that it can be any JSON
   value, removing the constraint that it be an object or array.

Thus,
 ಠ_ಠ
whose 2nd character is decidedly non-ASCII, is now a valid JSON text (i.e. 
standalone JSON document).

There seems to have been a thread about encoding detection in the RFC 7159 
working group, but I don't have the time to read through it all:

 Re: [Json] JSON: remove gap between Ecma-404 and IETF draft
 http://www.ietf.org/mail-archive/web/json/current/msg01936.html

It eventually leads to a dedicated sub-thread:

 [Json] Encoding detection (Was: Re: JSON: remove gap between Ecma-404 and 
 IETF draft)
 http://www.ietf.org/mail-archive/web/json/current/msg01959.html

--

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



[issue18820] json.dump() ignores its 'default' option when serializing dictionary keys

2014-05-15 Thread Chris Rebert

Changes by Chris Rebert pyb...@rebertia.com:


--
nosy: +cvrebert

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



[issue19361] Specialize exceptions thrown by JSON parser

2014-05-15 Thread Chris Rebert

Changes by Chris Rebert pyb...@rebertia.com:


--
nosy: +cvrebert

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



[issue13212] json library is decoding/encoding when it should not

2014-05-15 Thread Chris Rebert

Chris Rebert added the comment:

Note that, per the new JSON RFC 7159 (https://tools.ietf.org/html/rfc7159 ), 
top-level non-collection values are now de-jure permissible in JSON:

 Appendix A.  Changes from RFC 4627
o  Changed the definition of JSON text so that it can be any JSON
   value, removing the constraint that it be an object or array.

--

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



[issue21509] json.load fails to read UTF-8 file with (BOM) Byte Order Marks

2014-05-15 Thread Chris Rebert

Chris Rebert added the comment:

The new JSON RFC now at least mentions BOM handling:
https://tools.ietf.org/html/rfc7159#section-8.1 :
 Implementations MUST NOT add a byte order mark to the beginning of a
 JSON text.  In the interests of interoperability, implementations
 that parse JSON texts MAY ignore the presence of a byte order mark
 rather than treating it as an error.

--
nosy: +cvrebert

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



[issue21514] update json module docs in light of RFC 7159 ECMA-404

2014-05-15 Thread Chris Rebert

New submission from Chris Rebert:

json module docs: https://docs.python.org/3/library/json.html

New superseding JSON RFC: https://tools.ietf.org/html/rfc7159
Errata to the new RFC: http://www.rfc-editor.org/errata_search.php?rfc=7159
ECMA-404: http://www.ecma-international.org/publications/standards/Ecma-404.htm

These updated specs are of particular relevance to the Standard Compliance 
section of the json module docs. There are also a bunch of new interoperability 
notes in the RFC that could probably bear repeating in the module's docs.

--
assignee: docs@python
components: Documentation
messages: 218644
nosy: cvrebert, docs@python
priority: normal
severity: normal
status: open
title: update json module docs in light of RFC 7159  ECMA-404
versions: Python 2.7, Python 3.5

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



[issue21401] python2 -3 does not warn about str/unicode to bytes conversions and comparisons

2014-05-15 Thread Chris Rebert

Changes by Chris Rebert pyb...@rebertia.com:


--
nosy: +cvrebert

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



[issue1043134] Add preferred extensions for MIME types

2014-05-15 Thread Chris Rebert

Changes by Chris Rebert pyb...@rebertia.com:


--
nosy: +cvrebert

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



[issue1521950] shlex.split() does not tokenize like the shell

2014-05-15 Thread Chris Rebert

Changes by Chris Rebert pyb...@rebertia.com:


--
nosy: +cvrebert

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



[issue13826] Having a shlex example in the subprocess.Popen docs is confusing

2014-05-15 Thread Chris Rebert

Changes by Chris Rebert pyb...@rebertia.com:


--
nosy: +cvrebert

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



[issue13197] subprocess: move shell arguments to a separate keyword param

2014-05-15 Thread Chris Rebert

Changes by Chris Rebert pyb...@rebertia.com:


--
nosy: +cvrebert

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