[issue20752] Difflib should provide the option of overriding the SequenceMatcher

2014-09-10 Thread Claudiu Popa

Changes by Claudiu Popa :


--
nosy:  -Claudiu.Popa

___
Python tracker 

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



[issue15955] gzip, bz2, lzma: add option to limit output size

2014-09-10 Thread Martin Panter

Martin Panter added the comment:

If people are worried about the best low-level decompressor API, maybe leave 
that as a future enhancement, and just rely on using the existing file reader 
APIs. I would expect them to have a sensible decompressed buffer size limit, 
however “bzip2” and LZMA look susceptible to zip bombing:

>>> GzipFile(fileobj=gzip_bomb).read(1)
b'\x00'
>>> BZ2File(bzip_bomb).read(1)
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python3.4/bz2.py", line 293, in read
return self._read_block(size)
  File "/usr/lib/python3.4/bz2.py", line 254, in _read_block
while n > 0 and self._fill_buffer():
  File "/usr/lib/python3.4/bz2.py", line 218, in _fill_buffer
self._buffer = self._decompressor.decompress(rawblock)
MemoryError
>>> z = LZMAFile(lzma_bomb)
>>> z.read(1)
b'\x00'  # Slight delay before returning
>>> len(z._buffer)
55675075  # Decompressed much more data than I asked for

--

___
Python tracker 

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



[issue22374] Replace contextmanager example and improve explanation

2014-09-10 Thread Martin Panter

Martin Panter added the comment:

You should probably use try / finally in your context manager to always restore 
the attribute. Having said that, I recently wrote a similar context manager, 
and then later discovered there is already “unittest.mock.patch” and/or 
“unittest.mock.patch.object” via Issue 11664, which apparently can do this job.

--
nosy: +vadmium

___
Python tracker 

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



[issue16830] Add skip_host and skip_accept_encoding to httplib/http.client

2014-09-10 Thread Martin Panter

Changes by Martin Panter :


--
nosy: +vadmium

___
Python tracker 

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



[issue9951] introduce bytes.hex method

2014-09-10 Thread Chris Lasher

Changes by Chris Lasher :


--
nosy: +gotgenes

___
Python tracker 

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



[issue22373] PyArray_FromAny tries to deallocate double: 12 (d)

2014-09-10 Thread Riccardo

Riccardo added the comment:

Great, i solved trying to avoid calls to python code in parallel regions.
Thanks for pointing me in right direction, i wasn’t thinking at all to the GIL, 
i was convinced i had tryed everything and that it was a bug..

Regards

On 10 Sep 2014, at 05:50, Stefan Behnel  wrote:

> 
> Stefan Behnel added the comment:
> 
> Agreed that it's not a bug in CPython, but my guess is that it's not a bug in 
> NumPy either. The C function you call (which IIRC creates a new NumPy array) 
> almost certainly needs the GIL to protect it against race conditions, and 
> since you mentioned OpenMP, you most likely released the GIL. So, just 
> re-acquire the GIL around the call (and make sure you don't have any other 
> threading problems in your code).
> 
> --
> nosy: +scoder
> 
> ___
> Python tracker 
> 
> ___

--

___
Python tracker 

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



[issue22381] update zlib in 2.7 to 1.2.8

2014-09-10 Thread Matthias Klose

New submission from Matthias Klose:

I'd like to update zlib in 2.7 to 1.2.8. zlib isn't used at all for posix 
builds, because it requires a system installed zlib. However I don't know what 
is is used for Windows and MacOSX.  Please could somebody check?

My rationale for the update is that the .exe files require a zlib, and I'd like 
to build these on Linux with a mingw cross compiler.

The patch brings zlib to the status as found on the 3.4 branch.

--
assignee: ronaldoussoren
components: Build, Macintosh, Windows
files: zlib-update.diff
keywords: patch
messages: 226688
nosy: doko, hynek, ned.deily, ronaldoussoren, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: update zlib in 2.7 to 1.2.8
versions: Python 2.7
Added file: http://bugs.python.org/file36591/zlib-update.diff

___
Python tracker 

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



[issue22376] urllib2.urlopen().read().splitlines() opening a directory in a FTP server randomly returns incorrect result

2014-09-10 Thread Alan Evangelista

Alan Evangelista added the comment:

duplicate of #22375. I closed that one because I wanted to edit the original 
bug description and I could not, preferred to create a new bug.

R. David Murray's comment in #22375: "I think this was already fixed in issue 
15002"

--

___
Python tracker 

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



[issue17442] code.InteractiveInterpreter doesn't display the exception cause

2014-09-10 Thread Berker Peksag

Berker Peksag added the comment:

Claudiu, did you see Jim Jewett's review on Rietveld?

--
nosy: +berker.peksag

___
Python tracker 

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



[issue9951] introduce bytes.hex method

2014-09-10 Thread STINNER Victor

STINNER Victor added the comment:

New features cannot be added to Python 2 anymore, only to the current 
development version which is now Python 3.5.

If new methods are added to bytes, they should be added to bytearray too. Maybe 
we should also consider add them to memoryview? memoryview has already a 
.bytes() method and can be casted to type "B" (array of integers in range 
0..255).

The float type has .hex() and .fromhex() methods. We should kepe these names to 
stay consistent. Which kind of output do you prefer? "0xHH 0xHH ...", "HH HH HH 
..." or "HH..."? Do you want to add parameters to choose the format?

Current binascii format:

>>> binascii.hexlify('abc')
'616263'

--
nosy: +haypo

___
Python tracker 

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



[issue17442] code.InteractiveInterpreter doesn't display the exception cause

2014-09-10 Thread Claudiu Popa

Claudiu Popa added the comment:

Actually, no, it seems that I didn't receive any mail regarding them. I'll 
update the patch accordingly.

--

___
Python tracker 

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



[issue19746] No introspective way to detect ModuleImportFailure in unittest

2014-09-10 Thread R. David Murray

R. David Murray added the comment:

Yeah, I figured out it was loader only errors after I read the code :)

"load_tests not called" is very different from "load_tests produced an 
exception", so the text of the error message should be changed accordingly.

I understood your use case more-or-less, my question was, why is the error 
*string* the thing returned?  Given that the synthetic test encapsulates and 
re-raises the error, might it be more useful to store the exception object in 
the errors attribute rather than the message strings?  That would seem to 
provide more introspectability.

--

___
Python tracker 

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



[issue17442] code.InteractiveInterpreter doesn't display the exception cause

2014-09-10 Thread Claudiu Popa

Claudiu Popa added the comment:

Here's the new version which fixes the comments from the review.

--
Added file: http://bugs.python.org/file36592/issue17442_2.patch

___
Python tracker 

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



[issue22379] Empty exception message of str.join

2014-09-10 Thread R. David Murray

R. David Murray added the comment:

Thanks for the report and patch.

The test doesn't fail before your patch.  I think checkraises should be changed 
to make sure the message isn't empty.

And yes, the tests should be added to 3.5.

--
components: +Interpreter Core -ctypes
nosy: +r.david.murray
stage:  -> needs patch
type: enhancement -> behavior

___
Python tracker 

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



[issue7744] Allow site.addsitedir insert to beginning of sys.path

2014-09-10 Thread Michael R. Bernstein

Michael R. Bernstein added the comment:

And in case it isn't clear how such a method would help, here is what the 
earlier code would look like:

import os
import site

dirname = 'lib'
dirpath = os.path.join(os.path.dirname(__file__), dirname)

site.insertsitedir(1, dirpath)

But (other than the imports) it could even be reduced to a one-liner:

site.insertsitedir(1, os.path.join(os.path.dirname(__file__), 'lib'))

--

___
Python tracker 

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



[issue16104] Compileall script: add option to use multiple cores

2014-09-10 Thread Brett Cannon

Changes by Brett Cannon :


--
assignee:  -> brett.cannon

___
Python tracker 

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



[issue22240] argparse support for "python -m module" in help

2014-09-10 Thread Miki Tebeka

Miki Tebeka added the comment:

Thanks Paul, will work on that.

--

___
Python tracker 

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



[issue22381] update zlib in 2.7 to 1.2.8

2014-09-10 Thread Steve Dower

Changes by Steve Dower :


--
nosy: +benjamin.peterson

___
Python tracker 

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



[issue22087] _UnixDefaultEventLoopPolicy should either create a new loop or explicilty fail when get_event_loop() is called from a multiprocessing child process

2014-09-10 Thread Dan O'Reilly

Dan O'Reilly added the comment:

Are any other changes needed here? I'm still not completely clear on what 
Victor meant with his last comment.

--

___
Python tracker 

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



[issue9205] Parent process hanging in multiprocessing if children terminate unexpectedly

2014-09-10 Thread Dan O'Reilly

Dan O'Reilly added the comment:

Is it possible to have this issue re-opened, so that the new patch is more 
likely to get attention? Or should I create a new issue for the multiprocessing 
patch?

--

___
Python tracker 

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



[issue19232] Speed up _decimal import

2014-09-10 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 8bf51cf94405 by Stefan Krah in branch 'default':
Issue #19232: Speed up decimal import.  Additionally, since _decimal is
http://hg.python.org/cpython/rev/8bf51cf94405

--
nosy: +python-dev

___
Python tracker 

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



[issue19232] Speed up _decimal import

2014-09-10 Thread Stefan Krah

Stefan Krah added the comment:

We could speed up the import further by not importing collections
in _decimal.  That could be done once structseq fully implements
the namedtuple protocol (for DecimalTuple).

--

___
Python tracker 

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



[issue22381] update zlib in 2.7 to 1.2.8

2014-09-10 Thread Ned Deily

Ned Deily added the comment:

OS X builds are posix builds so, by default, they dynamically link with the 
system-supplied zlib.  The particular version varies by release: the most 
recent (10.9) supplies zlib 1.2.5.  So updating the zlib in Modules should have 
no effect on OS X.  Does that answer your question?

--
assignee: ronaldoussoren -> 

___
Python tracker 

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



[issue9951] introduce bytes.hex method

2014-09-10 Thread Terry J. Reedy

Terry J. Reedy added the comment:

To answer Serhiy, the goal is to have a bytes method that represents bytes as 
bytes rather than as a mixture of bytes and encoded ascii characters. This 
would aid people who work with bytes that are not encoded ascii and that do not 
embed encoded ascii. It should not be necessary to import anything.  

>>> hex(int.from_bytes(b'abc', 'big'))
'0x616263'
is a bit baroque and produces a hex representation of an int, not of multiple 
bytes.

I think following the float precedent is a good idea.
>>> float.fromhex(1.5.hex())
1.5
>>> float.fromhex('0x1.8p+0').hex()
'0x1.8p+0'

The output of bytes.hex should be one that is accepted by bytes.fromhex, which 
is to say, hex 'digit' pairs. Spaces are optionally allowed between pairs. I 
would add a 'spaces' parameter, defaulting to False. to output spaces when set 
to true.  (Or possible reverse the default  -- what do potential users think?)

A possible altermative for the parameter could be form='' (default), form=' ' 
(add spaces), and form='x' to add '\x' prefixes.  I don't know that adding '\x' 
would be useful. The prefixes are not accepted by .fromhex.

--
versions: +Python 3.5 -Python 3.4

___
Python tracker 

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



[issue22382] sqlite3 connection built from apsw connection should raise IntegrityError, not DatabaseError

2014-09-10 Thread william tonkin

New submission from william tonkin:

python
Python 2.7.6 (default, Dec 23 2013, 13:16:30)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-54)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>


-
test script
-
import apsw
import sqlite3

print 'sqlite3.version:', sqlite3.version
print 'sqlite3.sqlite_version:', sqlite3.sqlite_version
print 'apsw.apswversion:', apsw.apswversion()

sqlite3_not_from_apsw = sqlite3.connect(':memory:')
apsw_conn = apsw.Connection(':memory:')
sqlite3_from_apsw = sqlite3.connect(apsw_conn)
cursor_not_from_apsw = sqlite3_not_from_apsw.cursor()
cursor_from_apsw = sqlite3_from_apsw.cursor()

sqlite3_not_from_apsw.execute(
"create table foo ( a timestamp check(datetime(a) is not null))")

try:
sqlite3_not_from_apsw.execute(
"insert into foo values (?)", ('',))
except sqlite3.DatabaseError as foo:
print 'not from apsw, repr(foo)', repr(foo)

sqlite3_from_apsw.execute(
"create table foo ( a timestamp check(datetime(a) is not null))")

try:
sqlite3_from_apsw.execute(
"insert into foo values (?)", ('',))
except sqlite3.DatabaseError as foo:
print 'from apsw, repr(foo)', repr(foo)

-
output:

sqlite3.version: 2.6.0
sqlite3.sqlite_version: 3.8.2
apsw.apswversion: 3.8.2-r1
not from apsw, repr(foo) IntegrityError('CHECK constraint failed: foo',)
from apsw, repr(foo) DatabaseError('CHECK constraint failed: foo',)


Note that when the sqlite3 connection is built from an apsw connection the 
insert statement that violates the check constraint raises 'DatabaseError' and 
not 'IntegrityError'.

--
messages: 226704
nosy: wtonkin
priority: normal
severity: normal
status: open
title: sqlite3 connection built from apsw connection should raise 
IntegrityError, not DatabaseError
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



[issue22382] sqlite3 connection built from apsw connection should raise IntegrityError, not DatabaseError

2014-09-10 Thread Ned Deily

Ned Deily added the comment:

If you are reporting an issue with how apsw behaves, be aware that it is a 
third-party project, not in the Python standard library.  As such, you should 
report the issue to its bug tracker (https://github.com/rogerbinns/apsw/issues) 
as listed in its PyPI entry:  https://pypi.python.org/pypi/apsw/

If not about apsw, feel free to elaborate and reopen this issue.

--
nosy: +ned.deily
resolution:  -> third party
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



[issue22240] argparse support for "python -m module" in help

2014-09-10 Thread paul j3

paul j3 added the comment:

One way to reduce the testing burden, and to be extra safe regarding backward 
compatibility is to make this action optional, rather than the default.

For example, make `_prog_name` importable (i.e. change the name), and then 
expect the user to use it explicitly with:

parser = argparse.ArgumentParser(prog=argparse.prog_name(), ...)

and leave the `parse_args` stack unchanged.

This would require an addition to the documentation.  The user can then check 
for themselves whether `prog_name` gets the right name, given their packaging 
and calling method.  It's a little more work for a package creator, but 
arguably it's a good thing to aware of.  

The added tests, if any, can focus on the output of this function, rather than 
the output of the 'print_help'.

--

___
Python tracker 

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



[issue22240] argparse support for "python -m module" in help

2014-09-10 Thread Miki Tebeka

Miki Tebeka added the comment:

I don't like changing code just to accommodate testing. Will try to think of a 
way to solve this.

--

___
Python tracker 

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



[issue22383] Crazy unicode : How g and ɡ look the same but are two different characters

2014-09-10 Thread Christian Kleineidam

New submission from Christian Kleineidam:

g = 2
i = 2
ɡ = 1
a = g + i
a
>>> 4

Given the font on which this bug tracker runs it's possible to see why a is 4 
and not 3. On the other hand there are plenty of fonts (such as Arial, Tahoma 
or Courier New) that display chr(103) and chr(609) the same way. If a 
programmer is not aware of the issue it will make it nearly impossible to spot 
bugs that come up when someone names variables or functions via using chr(609). 

Python should either forbid people from using chr(609) to name functions and 
variables or treat it as a synonym of chr(103).

--
components: Unicode
messages: 226708
nosy: Christian.Kleineidam, ezio.melotti, haypo
priority: normal
severity: normal
status: open
title: Crazy unicode : How g and ɡ look the same but are two different 
characters
type: behavior
versions: Python 3.1, Python 3.2, Python 3.3, Python 3.4, Python 3.5

___
Python tracker 

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



[issue22383] Crazy unicode : How g and ɡ look the same but are two different characters

2014-09-10 Thread Ezio Melotti

Ezio Melotti added the comment:

The same happens with 'l' and 'I' on some fonts.
Forbid those chars or treat them as synonyms is not an option.

--
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed
versions:  -Python 3.1, Python 3.2, Python 3.3, Python 3.4

___
Python tracker 

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



[issue21739] Add hint about expression in list comprehensions (https://docs.python.org/2/tutorial/datastructures.html#list-comprehensions)

2014-09-10 Thread Rose Ames

Rose Ames added the comment:

Fwiw, I've seen a beginner be confused by this.  Patch attached.

--
keywords: +patch
nosy: +superluser
Added file: http://bugs.python.org/file36593/reword.patch

___
Python tracker 

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



[issue21228] Missing enumeration of HTTPResponse Objects methods of urllib.request.urlopen's http.client.HTTPResponse?

2014-09-10 Thread Evens Fortuné

Evens Fortuné added the comment:

Well, there wasn't any indication before that the returned object was 
implementing the "addinfourl" interface. So I don't think we have lost 
anything. In what situation this interface is useful ? The following comment 
(that you had highlighted in your comment) gives the impression that theses 
methods are there only to provide compatibility with clients using old-styles 
responses. 

http://hg.python.org/cpython/file/c499cc2c4a06/Lib/http/client.py#l772

That would imply that newer clients would usually not use these methods. If you 
want to document this, I think the "addinfourl" interface should then be better 
described somewhere else where it would include the fact that the HTTPResponse 
class implements it.

Anyway, I don't see the advantage of using a getter method (like geturl()) 
instead of accessing directly the attribute. For me, this is less pythonic. If 
you ever have to attach a behaviour to the access of this attribute, a property 
could then be defined.

--

___
Python tracker 

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



[issue22384] Tk.report_callback_exception kills process when run with pythonw.exe

2014-09-10 Thread Aivar Annamaa

New submission from Aivar Annamaa:

Seems that the statement 'sys.stderr.write("Exception in Tkinter callback\n")' 
in Tk.report_callback_exception fails when the program is run with pythonw.exe, 
and brings down the whole process.

A simple sample is attached.

--
files: demo.py
messages: 226712
nosy: Aivar.Annamaa
priority: normal
severity: normal
status: open
title: Tk.report_callback_exception kills process when run with pythonw.exe
Added file: http://bugs.python.org/file36594/demo.py

___
Python tracker 

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



[issue22384] Tk.report_callback_exception kills process when run with pythonw.exe

2014-09-10 Thread Aivar Annamaa

Changes by Aivar Annamaa :


--
components: +Tkinter
type:  -> crash
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



[issue22380] Y2K compliance section in FAQ is 14 years too old

2014-09-10 Thread Georg Brandl

Georg Brandl added the comment:

+1

--
nosy: +georg.brandl
versions:  -Python 3.1, Python 3.2, Python 3.3

___
Python tracker 

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



[issue22369] "context management protocol" vs "context manager protocol"

2014-09-10 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
assignee: docs@python -> serhiy.storchaka

___
Python tracker 

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



[issue22380] Y2K compliance section in FAQ is 14 years too old

2014-09-10 Thread Ezio Melotti

Changes by Ezio Melotti :


--
keywords: +easy
nosy: +ezio.melotti
stage:  -> needs patch

___
Python tracker 

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



[issue21739] Add hint about expression in list comprehensions (https://docs.python.org/2/tutorial/datastructures.html#list-comprehensions)

2014-09-10 Thread R. David Murray

R. David Murray added the comment:

Thanks!

While this patch does sort-of go into a detail, it seems to me like it does it 
in a tutorial-appropriate fashion.  I'm +1 on applying this.

--
stage: needs patch -> commit review

___
Python tracker 

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



[issue22369] "context management protocol" vs "context manager protocol"

2014-09-10 Thread Roundup Robot

Roundup Robot added the comment:

New changeset cc5b183a2ad4 by Serhiy Storchaka in branch '3.4':
Issue #22369: Change "context manager protocol" to "context management 
protocol".
http://hg.python.org/cpython/rev/cc5b183a2ad4

New changeset ad568d52af4b by Serhiy Storchaka in branch 'default':
Issue #22369: Change "context manager protocol" to "context management 
protocol".
http://hg.python.org/cpython/rev/ad568d52af4b

New changeset e62082a70b6b by Serhiy Storchaka in branch '2.7':
Issue #22369: Change "context manager protocol" to "context management 
protocol".
http://hg.python.org/cpython/rev/e62082a70b6b

--
nosy: +python-dev

___
Python tracker 

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



[issue21228] Missing enumeration of HTTPResponse Objects methods of urllib.request.urlopen's http.client.HTTPResponse?

2014-09-10 Thread R. David Murray

R. David Murray added the comment:

Indeed, geturl is deprecated.  I'm not sure where you see it documented, I 
don't see it.

--

___
Python tracker 

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



[issue19494] urllib2.HTTPBasicAuthHandler (or urllib.request.HTTPBasicAuthHandler) doesn't work with GitHub API v3 and similar

2014-09-10 Thread Matej Cepl

Matej Cepl added the comment:

New version of the HTTPBasicPriorAuthHandler patch

--
Added file: 
http://bugs.python.org/file36595/0001-Alternative-handler-adding-Authorization-header-even.patch

___
Python tracker 

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



[issue22380] Y2K compliance section in FAQ is 14 years too old

2014-09-10 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 071a2620917f by Benjamin Peterson in branch '3.4':
y2k compliance, lol (closes #22380)
http://hg.python.org/cpython/rev/071a2620917f

New changeset 02c94b9451f8 by Benjamin Peterson in branch '2.7':
y2k compliance, lol (closes #22380)
http://hg.python.org/cpython/rev/02c94b9451f8

New changeset e3a3c8809d09 by Benjamin Peterson in branch 'default':
merge 3.4 (#22380)
http://hg.python.org/cpython/rev/e3a3c8809d09

--
nosy: +python-dev
resolution:  -> fixed
stage: needs patch -> resolved
status: open -> closed

___
Python tracker 

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



[issue22383] Crazy unicode : How g and ɡ look the same but are two different characters

2014-09-10 Thread STINNER Victor

STINNER Victor added the comment:

Just avoid using such symbols in your application.

--

___
Python tracker 

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



[issue21147] sqlite3 doesn't complain if the request contains a null character

2014-09-10 Thread STINNER Victor

STINNER Victor added the comment:

sqlite_null_2.patch looks good to me.

--

___
Python tracker 

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



[issue21951] tcl test change crashes AIX

2014-09-10 Thread STINNER Victor

STINNER Victor added the comment:

I'm not sure that tkinter_ckallock.patch is correct. Extract of 
attemptckalloc() manual page:
"If the allocation fails, these functions will return NULL. Note that on some 
platforms, but not all, attempting to allocate a zero-sized block of memory 
will also cause these functions to return NULL."

http://linux.die.net/man/3/attemptckalloc

It looks like you are fixing two different issues in the same patch: fix AIX 
and enhance handling of memory allocation failure.

Can you please split your patch in two parts? For AIX, adding these two lines 
for list/tuple should be enough:

if (size == 0)
return Tcl_NewListObj(0, NULL);

--

___
Python tracker 

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



[issue22369] "context management protocol" vs "context manager protocol"

2014-09-10 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Thank you David.

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



[issue21951] tcl test change crashes AIX

2014-09-10 Thread STINNER Victor

STINNER Victor added the comment:

"I'm not sure that tkinter_ckallock.patch is correct."

Oh, when I read my message, I realized that I was not explicit enough. It looks 
like attemptckalloc() can be called with 0 at some places with  
tkinter_ckallock.patch. But I didn't check carefully, the patch is maybe 
correct.

--

___
Python tracker 

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



[issue22338] test_json crash on memory allocation failure

2014-09-10 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 3ac9f9576ce6 by Victor Stinner in branch '3.4':
Issue #22338: Fix a crash in the json module on memory allocation failure.
http://hg.python.org/cpython/rev/3ac9f9576ce6

New changeset 135fc23e475c by Victor Stinner in branch 'default':
(Merge 3.4) Issue #22338: Fix a crash in the json module on memory allocation
http://hg.python.org/cpython/rev/135fc23e475c

--
nosy: +python-dev

___
Python tracker 

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



[issue19494] urllib2.HTTPBasicAuthHandler (or urllib.request.HTTPBasicAuthHandler) doesn't work with GitHub API v3 and similar

2014-09-10 Thread Matej Cepl

Matej Cepl added the comment:

BTW, should I add anything for https://docs.python.org/3.5/whatsnew/3.5.html ?

--

___
Python tracker 

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



[issue22338] test_json crash on memory allocation failure

2014-09-10 Thread STINNER Victor

STINNER Victor added the comment:

> Modules/_json.c:1558: item = NULL;
> You can move it outside of the loop.

I prefer to set item to NULL just after PyList_SET_ITEM() to make it explicit 
that the list now owns the reference.

> But may be it will be better to make this "item" variable local.

"item" is also used below, and I don't want to have two "item" variables.

I commited my to Python 3.4 & 3.5.

Python 2.7 doesn't look to be affected, chunk and item are not cleared 
(Py_DECREF) in the error handler ("bail:" label).

Thanks for the review.

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



[issue22326] tempfile.TemporaryFile fails on NFS v4 filesystems

2014-09-10 Thread STINNER Victor

STINNER Victor added the comment:

> It becomes then still a Python problem, as tempfile.TemporaryFile is not 
> generally usable any more.

Well, it looks like you are the first one to complain, whereas the module is at 
least 10 years old. So it looks more like an issue in your setup (as you 
wrote), than a bug in Python.

Which syscalls fails with errno 5? Can you run your example with strace to 
identify the syscall?

*If* a patch should be written, we need to identify which Python line should be 
modified.

--

___
Python tracker 

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



[issue21228] Missing enumeration of HTTPResponse Objects methods of urllib.request.urlopen's http.client.HTTPResponse?

2014-09-10 Thread Evens Fortuné

Evens Fortuné added the comment:

To be honest, it may be inspired by what's written a few lines lower, for ftp, 
files dans data urls even though the return object is not the same as the 
http(s) urls

http://hg.python.org/cpython/file/c499cc2c4a06/Doc/library/urllib.request.rst#l75

--

___
Python tracker 

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



[issue21228] Missing enumeration of HTTPResponse Objects methods of urllib.request.urlopen's http.client.HTTPResponse?

2014-09-10 Thread R. David Murray

R. David Murray added the comment:

Ah, I was looking at the http docs.  I wonder if we just missed the urllib docs 
when we made the changes.  Either that, or I'm misremembering things.

--

___
Python tracker 

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



[issue9951] introduce bytes.hex method

2014-09-10 Thread HCT

HCT added the comment:

@Victor

binascii.hexlify('abc') doesn't work in 3.4. I assume this is a new thing for 
3.5

>>> import binascii
>>> binascii.hexlify('abc')
Traceback (most recent call last):
  File "", line 1, in 
TypeError: 'str' does not support the buffer interface
>>>
>>> binascii.hexlify(b'abc')
b'616263'


@Terry
I think that space shouldn't be done by the hex function. if you allow space 
between each hex, then what do you do if the bytes are actually from array of 
64-bit ints? getting into support separating space for every X bytes is 
probably not the scope of this.


I propose the hex functions for bytes/memoryview/bytearray should be as follow. 
I prefer to not have the '0x' prefix at all, but I understand all other hex 
functions adds it. would be good to have the option to not have the prefix.

bytes.hex( byte_order = sys.byteorder ) returns a hex string in small letter. 
ex. c0ffee

bytes.HEX( byte_order = sys.byteorder ) returns a hex string in capital 
letters. ex. DEADBEEF

bytes.from_hex( hex_str, byte_order = sys.byteorder ) returns a bytes object. 
ex. b'\xFE\xFF'


another more flexible way is to have hex function accept a format similar to 
how sscanf works, but this will probably bring lots of trouble for all kinds of 
variants to support and the required error checks.

--

___
Python tracker 

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



[issue9951] introduce bytes.hex method

2014-09-10 Thread Nick Coghlan

Nick Coghlan added the comment:

Just as a recap of at least some of the *current* ways to do a bytes -> hex 
conversion:

>>> import codecs
>>> codecs.encode(b"abc", "hex")
b'616263'
>>> import binascii
>>> binascii.hexlify(b"abc")
b'616263'
>>> import base64
>>> base64.b16encode(b"abc")
b'616263'
>>> hex(int.from_bytes(b"abc", "big"))
'0x616263'
>>> hex(int.from_bytes(b"abc", "little"))
'0x636261'

Thus, the underlying purpose of this proposal is to provide a single "more 
obvious way to do it". As per the recent discussion on python-ideas, the point 
where that is most useful is in debugging output.

However, rather than a new method on bytes/bytearray/memoryview for this, I 
instead suggest it would be appropriate to extend the default handling of the 
"x" and "X" format characters to accept arbitrary bytes-like objects. The 
processing of these characters would be as follows:

"x": display a-f as lowercase digits
"X": display A-F as uppercase digits
"#": includes 0x prefix
".precision": chunks output, placing a space after every  bytes
",": uses a comma as the separator, rather than a space

Output order would match binascii.hexlify()

Examples:

format(b"xyz", "x") -> '78797a'
format(b"xyz", "X") -> '78797A'
format(b"xyz", "#x") -> '0x78797a'

format(b"xyz", ".1x") -> '78 79 7a'
format(b"abcdwxyz", ".4x") -> '61626364 7778797a'
format(b"abcdwxyz", "#.4x") -> '0x61626364 0x7778797a'

format(b"xyz", ",.1x") -> '78,79,7a'
format(b"abcdwxyz", ",.4x") -> '61626364,7778797a'
format(b"abcdwxyz", "#,.4x") -> '0x61626364,0x7778797a'

This approach makes it easy to inspect binary data, with the ability to inject 
regular spaces or commas to improved readability. Those are the basic features 
needed to support debugging.

Anything more complicated than that, and we're starting to want something more 
like the struct module.

--

___
Python tracker 

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



[issue9951] introduce bytes.hex method

2014-09-10 Thread Terry J. Reedy

Terry J. Reedy added the comment:

The proposal is to add a .hex method (similar to binascii.hexlify) that is the 
inverse of .fromhex (similar to binascii.unhexlify), as originally specified in 
PEP 358.
http://legacy.python.org/dev/peps/pep-0358/
"The object has a .hex() method that does the reverse [of .frombytes]
   >> bytes([92, 83, 80, 255]).hex()
   '5c5350ff'
"
If we add .hex, I think we should stick with this: no 0x or \x prefix. 

To aid debugging, I would change spaces to be None or a positive int n to 
insert a space every n bytes.  So .hex(8) for an array of 64 bit ints.

--

___
Python tracker 

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



[issue22385] Allow 'x' and 'X' to accept bytes objects in string formatting

2014-09-10 Thread Nick Coghlan

New submission from Nick Coghlan:

Inspired by the discussion in issue 9951, I believe it would be appropriate to 
extend the default handling of the "x" and "X" format characters to accept 
arbitrary bytes-like objects. The processing of these characters would be as 
follows:

"x": display a-f as lowercase digits
"X": display A-F as uppercase digits
"#": includes 0x prefix
".precision": chunks output, placing a space after every  bytes
",": uses a comma as the separator, rather than a space

Output order would match binascii.hexlify()

Examples:

format(b"xyz", "x") -> '78797a'
format(b"xyz", "X") -> '78797A'
format(b"xyz", "#x") -> '0x78797a'

format(b"xyz", ".1x") -> '78 79 7a'
format(b"abcdwxyz", ".4x") -> '61626364 7778797a'
format(b"abcdwxyz", "#.4x") -> '0x61626364 0x7778797a'

format(b"xyz", ",.1x") -> '78,79,7a'
format(b"abcdwxyz", ",.4x") -> '61626364,7778797a'
format(b"abcdwxyz", "#,.4x") -> '0x61626364,0x7778797a'

This approach makes it easy to inspect binary data, with the ability to inject 
regular spaces or commas to improved readability. Those are the basic features 
needed to support debugging.

Anything more complicated than that, and we're starting to want something more 
like the struct module.

--
components: Interpreter Core
messages: 226733
nosy: ncoghlan
priority: normal
severity: normal
status: open
title: Allow 'x' and 'X' to accept bytes objects in string formatting
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



[issue9951] introduce bytes.hex method

2014-09-10 Thread HCT

HCT added the comment:

@Terry

natural bytes do not have space between them. I would think adding space is for 
typesetting situation which should be done by user's post-processing.

I agree to not have any prefix to make .hex and from_hex uniform. the \x is the 
str representation of bytes when you print a bytes object directly in Python. 
the actual bytes object doesn't have that \x prefix.

--

___
Python tracker 

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



[issue9951] introduce bytes.hex method

2014-09-10 Thread Nick Coghlan

Nick Coghlan added the comment:

Good point Terry - I split the proposal to support bytes-like objects for 'x' 
and 'X' in string formatting out to issue 22385.

For bytes.hex, I'm inclined to stick with the dirt simple option described in 
PEP 358: the exact behaviour of the current binascii.hexlify().

--

___
Python tracker 

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



[issue22385] Allow 'x' and 'X' to accept bytes-like objects in string formatting

2014-09-10 Thread Nick Coghlan

Changes by Nick Coghlan :


--
title: Allow 'x' and 'X' to accept bytes objects in string formatting -> Allow 
'x' and 'X' to accept bytes-like objects in string formatting

___
Python tracker 

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



[issue21228] Missing enumeration of HTTPResponse Objects methods of urllib.request.urlopen's http.client.HTTPResponse?

2014-09-10 Thread Martin Panter

Martin Panter added the comment:

By removing the “addinfourl” methods for HTTP responses, you are making it 
unnecessarily hard to handle header fields and metadata from the response. I do 
not know of any other documented way of getting the eventual redirect target, 
other than geturl(). And code to parse the Content-Type, which I understand is 
also returned for file: URLs, would start to get ugly (untested):

info = getattr(response, "info", None)
if info:
type = info().get_content_type()  # Easy!
else:
import cgi
type = cgi.parse_header(response.getheader("Content-Type))[0]

Since a HTTP status code only seems to be returned for HTTP responses, 
deprecating or removing getcode() in favour of “HTTPResponse.status” might be 
okay, but I think info() and geturl() should stay.

Maybe a “url” attribute is more Pythonic, but as far as I am aware that has 
never been documented for Python 2 or 3 for any URL type. I would not expect 
much existing code to be using it, and deprecating geturl() seems like a 
needless annoyance.

--

___
Python tracker 

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



[issue9951] introduce bytes.hex method

2014-09-10 Thread Nick Coghlan

Nick Coghlan added the comment:

Open question: the current patch adds bytes.hex() and bytearray.hex(). Should 
we also add memoryview.hex(), or split that suggestion out to a separate 
proposal?

--

___
Python tracker 

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



[issue9951] introduce bytes.hex method

2014-09-10 Thread Mark Lawrence

Mark Lawrence added the comment:

I'd say add memoryview.hex() here as everything seems related.  Victor has also 
mentioned memoryview in msg226692.

--
nosy: +BreamoreBoy

___
Python tracker 

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



[issue22386] Python 3.4 logging.getLevelName() no longer maps string to level.

2014-09-10 Thread Clark Boylan

New submission from Clark Boylan:

Prior to http://hg.python.org/cpython/rev/5629bf4c6bba?revcount=60 
logging.getLevelName(lvl) would map string lvl args like 'INFO' to the integer 
level value 20. After this change the string to int level mapping is removed 
and you can only map level to string. This removes the only public method for 
doing this mapping in the logging module.

Old Behavior:
>>> logging.getLevelName('INFO')
20
>>> logging.getLevelName(20)
'INFO'
>>> 

New Behavior:
>>> logging.getLevelName('INFO')
'Level INFO'
>>> logging.getLevelName(20)
'INFO'
>>> logging.getLevelName(logging.INFO)
'INFO'
>>> 

The old behavior is valuable because it allows you to sanity check log levels 
provided as strings before attempting to use them. It seems that without this 
public mapping you have to rely on Logger.setLevel(lvl) throwing a ValueError 
which it seems to do only in 2.7 and greater.

--
components: Library (Lib)
messages: 226739
nosy: cboylan
priority: normal
severity: normal
status: open
title: Python 3.4 logging.getLevelName() no longer maps string to level.
type: behavior
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



[issue22386] Python 3.4 logging.getLevelName() no longer maps string to level.

2014-09-10 Thread Alex Gaynor

Alex Gaynor added the comment:

I believe something like the following diff restores the previous behavior 
(untested!):

diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py
index a61c2b0..4a8f83e 100644
--- a/Lib/logging/__init__.py
+++ b/Lib/logging/__init__.py
@@ -129,7 +129,7 @@ def getLevelName(level):

 Otherwise, the string "Level %s" % level is returned.
 """
-return _levelToName.get(level, ("Level %s" % level))
+return _levelToName.get(level, _nameToLevel.get(level, ("Level %s" % 
level)))

 def addLevelName(level, levelName):
 """

--
nosy: +alex

___
Python tracker 

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



[issue21228] Missing enumeration of HTTPResponse Objects methods of urllib.request.urlopen's http.client.HTTPResponse?

2014-09-10 Thread R. David Murray

R. David Murray added the comment:

I think I'm thinking of the Request API, and not the Response API.  So ignore 
my comments about deprecation, I'm not sure what the status is.

--

___
Python tracker 

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



[issue21228] Missing enumeration of HTTPResponse Objects methods of urllib.request.urlopen's http.client.HTTPResponse?

2014-09-10 Thread Evens Fortuné

Evens Fortuné added the comment:

Look, the subject of this issue is to clarify the methods of the 
urllib.request.urlopen()'s return value for http(s) URLs. Nobody seemed to work 
on this for 4 months. That's why I tried to submit a patch after looking into 
the code to try to do my part to help.

If you think that my patch is not clear enough and would need to be more 
precise or maybe even that it is plain wrong, please submit a new patch with 
your ideas so that we can close eventually this issue.

I really didn't think that it would get this complicated…

--

___
Python tracker 

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



[issue22381] update zlib in 2.7 to 1.2.8

2014-09-10 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 3c343588f6a6 by doko in branch '2.7':
- Issue #22381: Update zlib to 1.2.8.
http://hg.python.org/cpython/rev/3c343588f6a6

--
nosy: +python-dev

___
Python tracker 

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