[issue13824] argparse.FileType opens a file and never closes it

2013-09-25 Thread paul j3

paul j3 added the comment:

An alternative way to delay the file opening, is to return an instance that has 
a `filename` attribute, and has an `open` method.  This can be compactly added 
to the `FileContext` that I defined in the previous patch.  The `FileContext` 
provides the `_ostest` function (testing using os.access), and wrapper for 
stdin/out.


class FileOpener(argparse.FileContext):
# delayed FileType; alt to use of partial()
# sample use:
# with args.input.open() as f: f.read()
def __call__(self, string):
string = self._ostest(string)
self.filename = string
return self
def open(self):
return self.__delay_call__(self.filename)()
file =  property(open, None, None, 'open file property')

--

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



[issue1185124] pydoc doesn't find all module doc strings

2013-09-25 Thread Sunny

Sunny added the comment:

I've updated my patch with the review changes and tests.

tokenize.detect_encoding throws a TypeError if the file object passed to it is 
in text mode. However, i've realized catching this is not necessary as i now 
check for TextIOBase instead of just StringIO before.

--
Added file: http://bugs.python.org/file31864/myfirst_2.patch

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



[issue1185124] pydoc doesn't find all module doc strings

2013-09-25 Thread Manuel Pégourié-Gonnard

Changes by Manuel Pégourié-Gonnard m...@elzevir.fr:


--
nosy:  -mpg

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



[issue19084] No way to use TLS-PSK from python ssl

2013-09-25 Thread Roger Light

Roger Light added the comment:

This is not TLS-SRP, but TLS-PSK as described by RFC 4279[1]

There is a very small amount of overlap - the unknown_psk_identity error 
defined by PSK is also used in SRP.

[1] http://tools.ietf.org/html/rfc4279

--

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



[issue19058] test_sys.test_ioencoding_nonascii() fails with ASCII locale encoding

2013-09-25 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Indeed.

Here is a patch. It uses same algorithm to obtain encodable non-ASCII string as 
for FS_NONASCII, but with locale encoding. It also adds new tests and 
simplifies existing tests.

--
keywords: +patch
stage: needs patch - patch review
Added file: http://bugs.python.org/file31865/sys_test_ioencoding_locale.patch

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



[issue16038] ftplib: unlimited readline() from connection

2013-09-25 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Please apply it yourself.

--

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



[issue19086] Make fsum usable incrementally.

2013-09-25 Thread Oscar Benjamin

New submission from Oscar Benjamin:

I would like to be able use fsum incrementally however it is not currently 
possible.

With sum() you can do:

subtotal = sum(nums)
subtotal = sum(othernums, subtotal)

This wouldn't work for fsum() because the returned float is not the same as the 
state maintained internally which is a list of floats. I propose instead that a 
fsum() could take an optional second argument which is a list of floats and in 
this case return the updated list of floats.

I have modified Raymond Hettinger's msum() recipe to do what I want:

def fsum(iterable, carry=None):
Full precision summation using multiple floats for intermediate values
partials = list(carry) if carry else []
for x in iterable:
i = 0
for y in partials:
if abs(x)  abs(y):
x, y = y, x
hi = x + y
lo = y - (hi - x)
if lo:
partials[i] = lo
i += 1
x = hi
partials[i:] = [x]
if carry is None:
return sum(partials, 0.0)
else:
return partials


Here's an interactive session showing how you might use it:

 from fsum import fsum
 fsum([1e20, 1, -1e20])
1.0
 fsum([1e20, 1, -1e20], [])
[1.0, 0.0]
 fsum([1e20, 1, -1e20], [])
[1.0, 0.0]
 fsum([1e20, 1, -1e20], [])
[1.0, 0.0]
 fsum([1e20, 1], [])
[1.0, 1e+20]
 carry = fsum([1e20, 1], [])
 fsum([-1e20], carry)
[1.0, 0.0]
 nums = [7, 1e100, -7, -1e100, -9e-20, 8e-20] * 10
 subtotal = []
 for n in nums:
... subtotal = fsum([n], subtotal)
...
 subtotal
[-1.0007e-19]
 fsum(subtotal)
-1.0007e-19


My motivation for this is that I want to be able to write an efficient sum 
function that is accurate for a mix of ints and floats while being as fast as 
possible in the case that I have a list of only floats (or only ints). What I 
have so far looks a bit like:

def sum(numbers):
exact_total = 0
float_total = 0.0
for T, nums in groupby(numbers):
if T is int:
exact_total = sum(nums, exact_total)
elif T is float:
# This doesn't really work:
float_total += fsum(float_total)
# ...


However fsum is only exact if it adds all the numbers in a single pass. The 
above would have order-dependent results given a mixed list of ints and floats 
e.g.:

[1e20, -1e20, 1, -1, 1.0, -1.0]
  vs
[1e20, 1.0, -1e20, 1, -1, -1.0]

Although fsum is internally very accurate it always discards information on 
output. Even if I build a list of all floats and fsum those at the end it can 
still be inaccurate if the exact_total cannot be exactly coerced to float and 
passed to fsum.

If I could get fsum to return the exact float expansion then I could use that 
in a number of different ways. Given the partials list I can combine all of the 
different subtotals with Fraction arithmetic and coerce to float only at the 
very end. If I can also get fsum to accept a float expansion on input then I 
can use it incrementally and there is no need to build a list of all floats.

I am prepared to write a patch for this if the idea is deemed acceptable.

--
components: Library (Lib)
messages: 198381
nosy: mark.dickinson, oscarbenjamin, rhettinger
priority: normal
severity: normal
status: open
title: Make fsum usable incrementally.
type: enhancement
versions: Python 3.4, Python 3.5

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



[issue19083] IDNA prefix should be case insensitive

2013-09-25 Thread Berker Peksag

Changes by Berker Peksag berker.pek...@gmail.com:


--
versions: +Python 3.4 -Python 3.5

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



[issue18596] enable usage of AddressSanitizer in CPython [PATCH]

2013-09-25 Thread halfie

halfie added the comment:

I am attaching the latest tested patch against tip.

--
Added file: http://bugs.python.org/file31866/ASAN-compat-35da5d848ffd-v3.patch

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



[issue19078] Allow reversed(memoryview), like memoryview

2013-09-25 Thread Claudiu.Popa

Claudiu.Popa added the comment:

So, in the following case, len shouldn't return 4, but the number of items? 
Also, is it ok to assume that the number of items is
((*shape)[0] * ... * (*shape)[ndims-1])?

 x = np.array([[1, 2, 3], [4, 5, 6], [4,5,6], [4,4,4]], np.int32)
 x.shape
(4, 3)
 x.shape[0] * x.shape[1]
12
 len(x)
4
 memoryview(x)
memory at 0x0217C378
 len(memoryview(x))
4
 memoryview(x).shape
(4, 3)


--

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



[issue19078] Allow reversed(memoryview), like memoryview

2013-09-25 Thread Antoine Pitrou

Antoine Pitrou added the comment:

No, you're right, it should probably return 4.

--

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



[issue19087] bytearray front-slicing not optimized

2013-09-25 Thread Antoine Pitrou

New submission from Antoine Pitrou:

If you delete a slice at the end of a bytearray, it is naturally optimized 
(thanks to the resizing strategy). However, if you delete a slice at the front 
of a bytearray, it is not: a memmove() gets done every time.

$ ./python -m timeit b=bytearray(1) while b: b[-1:] = b''
100 loops, best of 3: 5.67 msec per loop
$ ./python -m timeit b=bytearray(1) while b: b[:1] = b''
100 loops, best of 3: 6.67 msec per loop

$ ./python -m timeit b=bytearray(5) while b: b[-1:] = b''
10 loops, best of 3: 28.3 msec per loop
$ ./python -m timeit b=bytearray(5) while b: b[:1] = b''
10 loops, best of 3: 61.1 msec per loop

$ ./python -m timeit b=bytearray(10) while b: b[-1:] = b''
10 loops, best of 3: 59.4 msec per loop
$ ./python -m timeit b=bytearray(10) while b: b[:1] = b''
10 loops, best of 3: 198 msec per loop

This makes implementing a fifo using bytearray a bit suboptimal. It shouldn't 
be very hard to improve.

--
components: Interpreter Core
messages: 198385
nosy: pitrou
priority: normal
severity: normal
stage: needs patch
status: open
title: bytearray front-slicing not optimized
type: performance
versions: Python 3.4

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



[issue19088] TypeError with pickle in embedded python3.3 when starting multiple Interpreters.

2013-09-25 Thread Larry Pete

New submission from Larry Pete:

Hexchat (fork of XChat IRC Client) switched with version 2.9.6 to Python 3.3 
for their Python plugins.
Hexchat loads plugins in a similar fashion like the attached C file (not 
entirely sure I used the C-API right though). For every plugin a new 
interpreter is started and Py_EndInterpreter is used to unload the plugin.
When using pickle in such a python plugin, it raises the Exception (in the 
attached example):

Traceback (most recent call last):
  File string, line 7, in module
TypeError: attribute of type 'NoneType' is not callable

when trying to pickle an object (using pickle.dump or pickle.dumps).
The Exception happens on the line where pickle.dumps is called, though 
pickle.dumps is not None.

It happens:
- with python3.3.2 (I also tested it with python3.4.0a2 since I happened to 
have it installed, same issue). No issue with python2.7. I did not test it with 
3.x versions prior to 3.3.2
- when trying to pickle a user defined class. Python objects like dictionaries 
and lists work fine.
- only with the second (and any additional) interpreter.
- when destroying the interpreter and starting a new one, in that order. When 
two interpreters are started and execute the code before any of them is 
destroyed, it works fine.

The full output of the attached file when executed is btw:

First output:
Pickle dumps:
b'\x80\x03c__main__\nSomeClass\nq\x00)\x81q\x01}q\x02X\x08\x00\x00\x00some_varq\x03K{sb.'

Second output:
Pickle dumps:
Traceback (most recent call last):
  File string, line 7, in module
TypeError: attribute of type 'NoneType' is not callable

--
components: Extension Modules
files: fail.c
messages: 198386
nosy: Larry.Pete, alexandre.vassalotti, pitrou
priority: normal
severity: normal
status: open
title: TypeError with pickle in embedded python3.3 when starting multiple 
Interpreters.
type: behavior
versions: Python 3.3
Added file: http://bugs.python.org/file31867/fail.c

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



[issue19030] inspect.getmembers and inspect.classify_class_attrs mishandle descriptors

2013-09-25 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 436b606ecfe8 by Ethan Furman in branch 'default':
Close #19030: improvements to inspect and Enum.
http://hg.python.org/cpython/rev/436b606ecfe8

--
nosy: +python-dev
resolution:  - fixed
stage: patch review - committed/rejected
status: open - closed

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



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2013-09-25 Thread Arfrever Frehtes Taifersar Arahesis

Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com:


--
nosy: +Arfrever

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



[issue5907] repr of time.struct_time type does not eval

2013-09-25 Thread Arfrever Frehtes Taifersar Arahesis

Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com:


--
nosy: +Arfrever

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



[issue16038] ftplib: unlimited readline() from connection

2013-09-25 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 8b19e7d0be45 by Barry Warsaw in branch '2.6':
- Issue #16038: CVE-2013-1752: ftplib: Limit amount of data read by
http://hg.python.org/cpython/rev/8b19e7d0be45

--
nosy: +python-dev

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



[issue16038] ftplib: unlimited readline() from connection

2013-09-25 Thread Barry A. Warsaw

Changes by Barry A. Warsaw ba...@python.org:


--
versions:  -Python 2.6

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



[issue19021] AttributeError in Popen.__del__

2013-09-25 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

I'm wondering too. While the code in Popen.__del__() is almost same, I can't 
reproduce the issue in 3.3. Perhaps it relates to some 3.4 changes? Import 
machinery, weak references, the shutdown process?

Before applying the patch which fixes Popen.__del__() I want understand what 
happens.

--

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



[issue19087] bytearray front-slicing not optimized

2013-09-25 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

And the same is for a list. List and bytearray are wrong types for front 
deleting. I don't think we should increase the size of bytearray, and 
complicate and slowdown it for such special purpose.

If you want to implement a fifo using bytearray more optimal, defer the 
deleting until used size less than a half of allocated size. See for example 
XMLPullParser.read_events() in Lib/xml/etree/ElementTree.py.

--
nosy: +serhiy.storchaka

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



[issue19087] bytearray front-slicing not optimized

2013-09-25 Thread Antoine Pitrou

Antoine Pitrou added the comment:

 And the same is for a list. List and bytearray are wrong types for
 front deleting.

There is no bytedeque().

 I don't think we should increase the size of
 bytearray, and complicate and slowdown it for such special purpose.

I don't think it would really slow it down. It should be a simple
optimization. And FIFO buffers are quite common when writing parsers
for network applications.

 If you want to implement a fifo using bytearray more optimal, defer
 the deleting until used size less than a half of allocated size. See
 for example XMLPullParser.read_events() in
 Lib/xml/etree/ElementTree.py.

Of course, I wrote that code. Still, doing it manually is suboptimal
and cumbersome when it could be done transparently.

--

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



[issue19021] AttributeError in Popen.__del__

2013-09-25 Thread Richard Oudkerk

Richard Oudkerk added the comment:

The clearing of modules at shutdown has been substantially changed in 3.4.  Now 
a best effort is made to let the module go away purely by gc.  Those modules 
which survive get purged in random order.

In 3.3 all modules were purged, but builtins was special cased to be purged 
last.  (See Python/import.c:PyImport_Cleanup().)

I would favour setting a flag before the purging stage which prevents __del__ 
methods (and weakrefs?) from running.

--
nosy: +pitrou, sbt

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



[issue19089] Windows: Broken Ctrl-D shortcut on Python 3

2013-09-25 Thread anatoly techtonik

New submission from anatoly techtonik:

Ctrl-D shortcut works to terminate session in Python 2 on Windows, and doesn't 
work with Python 3.

--
components: Windows
messages: 198393
nosy: techtonik
priority: normal
severity: normal
status: open
title: Windows: Broken Ctrl-D shortcut on Python 3
versions: Python 3.1, Python 3.2, Python 3.3, Python 3.4, Python 3.5

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



[issue19089] Windows: Broken Ctrl-D shortcut on Python 3

2013-09-25 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc added the comment:

It never worked for me.
Are you using a custom shell or cygwin or something?

--
nosy: +amaury.forgeotdarc

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



[issue19089] Windows: Broken Ctrl-D shortcut on Python 3

2013-09-25 Thread Ethan Furman

Ethan Furman added the comment:

Ctrl-D has never work for me on Windows either.

--
nosy: +ethan.furman

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



[issue19089] Windows: Broken Ctrl-D shortcut on Python 3

2013-09-25 Thread Tim Golden

Tim Golden added the comment:

It doesn't work on Python 2.x either as delivered. Usually means you 
have an external readline module installed.

--
nosy: +tim.golden

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



[issue19089] Windows: Broken Ctrl-D shortcut on Python 3

2013-09-25 Thread anatoly techtonik

anatoly techtonik added the comment:

Well, it appears that installed IPython brought pyreadline, but I execute it in 
standard Python shell.

I'd vote for this feature by default. Is that possible without readline?

--

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



[issue19089] Windows: Broken Ctrl-D shortcut on Python 3

2013-09-25 Thread anatoly techtonik

anatoly techtonik added the comment:

Here is the output of py -v.

--
Added file: http://bugs.python.org/file31868/py_-v.stderr.txt

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



[issue19089] Windows: Broken Ctrl-D shortcut on Python 3

2013-09-25 Thread Eric V. Smith

Eric V. Smith added the comment:

The Windows (and before it MS-DOS) EOF character is Ctrl-Z. Try that.

Depending on the toolset you use, it might use Ctrl-D as EOF. Cygwin's python 
uses Ctrl-D.

--
nosy: +eric.smith

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



[issue19089] Windows: Broken Ctrl-D shortcut on Python 3

2013-09-25 Thread anatoly techtonik

anatoly techtonik added the comment:

It would be nice if Python supported some cross-platform standard for user 
interfaces. It is rather annoying to use Ctrl-Z for Python in local window and 
Ctrl-D for Python in remote console session (which is *nix of course).

It becomes even more annoying, because Ctrl-Z in *nix session sends Python 
process to background.

--

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



[issue19089] Windows: Make Ctrl-D exit key combination cross-platform

2013-09-25 Thread anatoly techtonik

Changes by anatoly techtonik techto...@gmail.com:


--
title: Windows: Broken Ctrl-D shortcut on Python 3 - Windows: Make Ctrl-D exit 
key combination cross-platform
versions: +Python 2.7

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



[issue19089] Windows: Make Ctrl-D exit key combination cross-platform

2013-09-25 Thread Eric V. Smith

Eric V. Smith added the comment:

It's trying to be consistent on whatever platform it's on. I'd rather 
python.exe match all other text-based .exe's on Windows. We can't have it both 
ways.

But I agree it's a hassle. Cross-platform is a problem that Cygwin is trying to 
solve, so I suggest you use it. I usually use the Cygwin python for this reason.

--

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



[issue19089] Windows: Make Ctrl-D exit key combination cross-platform

2013-09-25 Thread Brian Curtin

Brian Curtin added the comment:

I'm unable to find the previous issue, but you asked for this in the past. 
Ctrl-Z and Ctrl-D simply have different meanings on the different platforms, 
outside of what Python does. We already can't make Ctrl-Z on Windows do what it 
does on Linux, and Ctrl-D is not natural to Windows users.

--
nosy: +brian.curtin

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



[issue19089] Windows: Make Ctrl-D exit key combination cross-platform

2013-09-25 Thread Tim Golden

Tim Golden added the comment:

I'm at best +0.25, but I don't have a problem with Ctrl-D exiting on 
Windows, as it doesn't do anything else!

The thing is, though, that this is all handled within 
myreadline.c:my_fgets which is a call into the system fgets which errors 
out with Ctrl-Z but returns Ctrl-D. Which means that the two would 
behave differently even if we special-cased Ctrl-D.

(Sorry: was that explanation a bit involved?)

--

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



[issue19021] AttributeError in Popen.__del__

2013-09-25 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Could we instead restore the builtins module to it's initial state before the 
purging stage? I believe all builtins are immutable and can't create reference 
loops.

--

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



[issue19081] zipimport behaves badly when the zip file changes while the process is running

2013-09-25 Thread Gregory P. Smith

Changes by Gregory P. Smith g...@krypto.org:


Added file: http://bugs.python.org/file31869/issue19081-gps02.patch

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



[issue19091] ast.parse gives wrong position for some Names when non-ascii characters occur before

2013-09-25 Thread Aivar Annamaa

New submission from Aivar Annamaa:

ast.parse gives col_offset=4 for Name x when given program a + x vs. 
col_offset=5 for x when Name a is replaced with a-umlaut (I can't write that 
character here, because it seems that the issue system doesn't handle non-ascii 
characters either).

See the attached Python shell transcript for explanation (it's in UTF-8).

--
components: Interpreter Core
files: bug.txt
messages: 198406
nosy: Aivar.Annamaa
priority: normal
severity: normal
status: open
title: ast.parse gives wrong position for some Names when non-ascii characters 
occur before
type: behavior
versions: Python 3.3
Added file: http://bugs.python.org/file31870/bug.txt

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



[issue19081] zipimport behaves badly when the zip file changes while the process is running

2013-09-25 Thread Gregory P. Smith

Changes by Gregory P. Smith g...@krypto.org:


Added file: http://bugs.python.org/file31871/issue19081-gps03.patch

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



[issue19091] ast.parse gives wrong position for some Names when non-ascii characters occur before

2013-09-25 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

This looks similar to issue2382 and issue10382.

--
nosy: +serhiy.storchaka

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



[issue19091] ast.parse gives wrong position for some Names when non-ascii characters occur before

2013-09-25 Thread Aivar Annamaa

Aivar Annamaa added the comment:

Serhiy, it's similar in that it has to do with encodings, but I think it's 
caused by different bug.

I suspect it has something to do with the fact that tokenizer gives positions 
as offsets of characters and ast as offsets of UTF-8 bytes.

--

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



[issue19091] ast.parse gives wrong position for some Names when non-ascii characters occur before

2013-09-25 Thread Aivar Annamaa

Aivar Annamaa added the comment:

I should explain more -- the string containing the program is read in 
correctly, the trouble occurs during parse.

--

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



[issue19091] ast.parse gives wrong position for some Names when non-ascii characters occur before

2013-09-25 Thread Aivar Annamaa

Aivar Annamaa added the comment:

 ast [gives positions as] offsets of UTF-8 bytes

Oops, I'm sorry, I realized only now that this is the explanation of this 
behaviour. So, after all it seems to be a feature (albeit very weird), not a 
bug.

--
resolution:  - invalid

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



[issue19092] ExitStack.__exit__ incorrectly suppresses exceptions in __exit__ callbacks of inner context managers

2013-09-25 Thread Hrvoje Nikšić

New submission from Hrvoje Nikšić:

While using contextlib.ExitStack in our project, we noticed that its __exit__ 
method of contextlib.ExitStack suppresses the exception raised in any 
contextmanager's __exit__ except the outermost one. Here is a test case to 
reproduce the problem:

class Err:
  def __enter__(self): pass
  def __exit__(self, *exc): 1/0

class Ok:
  def __enter__(self): pass
  def __exit__(self, *exc): pass


import contextlib
s = contextlib.ExitStack()
s.push(Ok())
s.push(Err())
with s:
  pass

Since the inner context manager raises in __exit__ and neither context manager 
requests suppression, I would expect to see a ZeroDivisionError raised. What 
actually happens is that the exception is suppressed. This behavior caused us 
quite a few headaches before we figured out why we the exceptions raised in 
during __exit__ went silently undetected in production.

The problem is in ExitStack.__exit__, which explicitly propagates the exception 
only if it occurs in the outermost exit callback. The idea behind it appears to 
be to simply record the raised exception in order to allow exit callbacks of 
the outer context managers to see the it -- and get a chance to suppress it. 
The only exception that is directly re-raised is the one occurring in the 
outermost exit callback, because it certainly cannot be seen nor suppressed by 
anyone else.

But this reasoning is flawed because if an exception happens in an inner cm and 
none of the outer cm's chooses to suppress it, then there will be no one left 
to raise it. Simply returning True from ExitStack.__exit__ is of no help, as 
that only has an effect when an exception was passed into the function in the 
first place, and even then, the caller can only re-raise the earlier exception, 
not the exception that occurred in the exit callback. And if no exception was 
sent to ExitStack.__exit__, as is the case in the above code, then no exception 
will be re-raised at all, effectively suppressing it.

I believe the correct way to handle this is by keeping track of whether an 
exception actually occurred in one of the _exit_callbacks. As before, the 
exception is forwarded to next cm's exit callbacks, but if none of them 
suppresses it, then the exception is re-raised instead of returning from the 
function. I am attaching a patch to contextlib.py that implements this change.

The patch also makes sure that True is returned from ExitStack.__exit__ only if 
an exception was actually passed into it.

--
components: Library (Lib)
files: exitstack.diff
keywords: patch
messages: 198411
nosy: hniksic
priority: normal
severity: normal
status: open
title: ExitStack.__exit__ incorrectly suppresses exceptions in __exit__ 
callbacks of inner context managers
type: behavior
versions: Python 3.4
Added file: http://bugs.python.org/file31872/exitstack.diff

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



[issue19092] ExitStack.__exit__ incorrectly suppresses exceptions in __exit__ callbacks of inner context managers

2013-09-25 Thread Eric Snow

Changes by Eric Snow ericsnowcurren...@gmail.com:


--
nosy: +ncoghlan

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



[issue19092] ExitStack.__exit__ incorrectly suppresses exceptions in __exit__ callbacks of inner context managers

2013-09-25 Thread Barry A. Warsaw

Changes by Barry A. Warsaw ba...@python.org:


--
nosy: +barry

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



[issue19093] RE

2013-09-25 Thread Roman

New submission from Roman:

complete my registration

--
messages: 198412
nosy: bjimnen
priority: normal
severity: normal
status: open
title: RE

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



[issue19093] Spam

2013-09-25 Thread Berker Peksag

Changes by Berker Peksag berker.pek...@gmail.com:


--
nosy:  -bjimnen
resolution:  - invalid
stage:  - committed/rejected
status: open - closed
title: RE - Spam

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



[issue19093] Spam

2013-09-25 Thread Berker Peksag

Changes by Berker Peksag berker.pek...@gmail.com:


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

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



[issue19021] AttributeError in Popen.__del__

2013-09-25 Thread Terry J. Reedy

Terry J. Reedy added the comment:

 Before applying the patch which fixes Popen.__del__()

I think your #12085 patch should be applied and that issue closed. It is not 
specifically about shutdown. Tweaking shutdown further would be a new issue.

--

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



[issue19077] More robust TemporaryDirectory cleanup

2013-09-25 Thread Richard Oudkerk

Richard Oudkerk added the comment:

An alternative would be to use weakref.finalize() which would guarantee that 
cleanup happens before any purging occurs.  That would allow the use of shutil:

class TemporaryDirectory(object):
def __init__(self, suffix=, prefix=template, dir=None):
self.name = mkdtemp(suffix, prefix, dir)
self._cleanup = weakref.finalize(self, shutil.rmtree, self.name)

def __enter__(self):
return self.name

def __exit__(self, exc, value, tb):
self._cleanup()

def cleanup(self):
self._cleanup()

--
nosy: +sbt

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



[issue11638] python setup.py sdist --formats tar* crashes if version is unicode

2013-09-25 Thread Doug Hellmann

Changes by Doug Hellmann doug.hellm...@gmail.com:


--
nosy: +doughellmann

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



[issue18314] Have os.unlink remove junction points

2013-09-25 Thread Terry J. Reedy

Changes by Terry J. Reedy tjre...@udel.edu:


--
nosy: +brian.curtin, tim.golden

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



[issue19087] bytearray front-slicing not optimized

2013-09-25 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Here is a patch. Benchmarks (under Linux where realloc is fast; the gap may be 
wider under Windows):

$ ./python -m timeit b=bytearray(10) while b: b[:1] = b''
- before: 225 msec per loop
- after: 60.4 msec per loop

$ ./python -m timeit b=bytearray(10) while b: b[:200] = b''
- before: 1.17 msec per loop
- after: 350 usec per loop

--
keywords: +patch
nosy: +haypo
Added file: http://bugs.python.org/file31873/bytea_slice.patch

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



[issue19087] bytearray front-slicing not optimized

2013-09-25 Thread Antoine Pitrou

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


--
stage: needs patch - patch review

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



[issue18314] Have os.unlink remove junction points

2013-09-25 Thread Terry J. Reedy

Terry J. Reedy added the comment:

I am not sure if this is a bug or enhancement. It is a moot point until there 
is a patch to apply.

A patch would need a test that fails now and passes with the patch. From the 
Wikipedia article, it appears that a test using mklink /J would not run on XP 
and would have to be skipped. I would not expect an XP buildbot to necessarily 
have the Server 2003 Resource Kit needed for an XP test.

Does _delete_junction_point(link_path) work on XP or should the feature be 
restricted to Vista+?

--
nosy: +terry.reedy
stage:  - test needed
type: behavior - enhancement
versions: +Python 3.4 -Python 3.3

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



[issue19088] TypeError with pickle in embedded python3.3 when starting multiple Interpreters.

2013-09-25 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc added the comment:

The NoneType that fails is in typeobject.c:
   _PyObject_CallMethodId(copyreg, PyId__slotnames, O, cls);

The error here is that copyreg comes from a cached reference to the module, 
stored in a static variable (cached_copyreg_module).  When the interpreter 
shuts down the first time, all the module members are set to None... but the 
reference is kept forever.

This variable should be reset, and reloaded (with a fresh module from the new 
interpreter) the next time it's used.
I added a call to _PyType_Fini() in Py_EndInterpreter, this fixes the given 
example.

Two sets of questions though:

- There are many of these _Fini functions, called in Py_Finalize. Which ones 
should we call in Py_EndInterpreter? and why? Maybe this PyType_Fini() is not a 
_Fini, but should be renamed PyType_EndInterpreter?

- one copyreg for multiple interpreters... this looks wrong: each interpreter 
has its own list of modules, but copyreg.__globals__ belongs to only one...
  A good solution would be to cache the copyreg module in the 
PyInterpreterState (it already has codec_search_cache). Or use 
PyImport_GetModuleDict()

--
nosy: +amaury.forgeotdarc

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



[issue19094] urljoin should raise a TypeError if URL is not a string

2013-09-25 Thread Jason R. Coombs

New submission from Jason R. Coombs:

 import urllib.parse
 urllib.parse.urljoin('foo', [])
'foo'

That should raise a TypeError, not succeed quietly as if an empty string were 
passed.

--
components: Library (Lib)
messages: 198418
nosy: jason.coombs
priority: normal
severity: normal
status: open
title: urljoin should raise a TypeError if URL is not a string
versions: Python 2.7, Python 3.3, Python 3.4

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



[issue2382] [Py3k] SyntaxError cursor shifted if multibyte character is in line.

2013-09-25 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Added tests. I think it will be worth apply this patch which fixes the issue 
for most Europeans and than continue working on the issue of wide characters.

--
Added file: http://bugs.python.org/file31874/adjust_offset_2.patch

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



[issue19088] TypeError with pickle in embedded python3.3 when starting multiple Interpreters.

2013-09-25 Thread Antoine Pitrou

Antoine Pitrou added the comment:

 one copyreg for multiple interpreters... this looks wrong: each interpreter 
 has its own list of modules, but copyreg.__globals__ belongs to only one...
 A good solution would be to cache the copyreg module in the 
 PyInterpreterState (it already has codec_search_cache).

Yes, this is a reasonable solution.

--
stage:  - needs patch
versions: +Python 3.4

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



[issue19092] ExitStack.__exit__ incorrectly suppresses exceptions in __exit__ callbacks of inner context managers

2013-09-25 Thread Nick Coghlan

Nick Coghlan added the comment:

Yep, as indicated by the patch, looks like just a bug with the location of the 
raise in the stack emulation.

The contextlib tests will also need a new test case to cover this, as well as 
one to cover such an exception being suppressed by an outer manager.

--
versions: +Python 3.3

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



[issue2382] [Py3k] SyntaxError cursor shifted if multibyte character is in line.

2013-09-25 Thread Serhiy Storchaka

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


Removed file: http://bugs.python.org/file27506/adjust_offset-3.3.patch

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



[issue19077] More robust TemporaryDirectory cleanup

2013-09-25 Thread Nick Coghlan

Nick Coghlan added the comment:

Sounds good to me!

--

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



[issue19087] bytearray front-slicing not optimized

2013-09-25 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Could you please provide an example which uses this feature?

--

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



[issue19087] bytearray front-slicing not optimized

2013-09-25 Thread Antoine Pitrou

Antoine Pitrou added the comment:

 Could you please provide an example which uses this feature?

A generic example is to parse messages out of a TCP stream. Basically
any protocol transported on TCP needs such a facility, or has to find
workarounds (which are either suboptimal or complicated).

Mercurial has another implementation strategy for a similar thing:
http://selenic.com/repo/hg/file/50d721553198/mercurial/util.py#l935

--

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



[issue19095] Document SSLSocket.getpeercert always returns None without do_handshake

2013-09-25 Thread Dariusz Suchojad

New submission from Dariusz Suchojad:

Hello,

I'd like to suggest adding a simple note to SSLSocket.getpeercert stating that 
it will always return None if do_handshake has never been called.

This is not the default behaviour, by default SSLSocket.__init__'s 
do_handshake_on_connect is True so .getpeercert nicely returns a cert (assuming 
the usual caveats - the other side offers a certificate and cert_reqs is not 
CERT_NONE).

However, I've just been debugging a someone else's server and I spent some time 
figuring out why client certificates weren't available - turned out this was 
because do_handshake was never called (PySSL_SSLdo_handshake in _ssl.c).

Adding a single-sentence line will certainly be very helpful.

Many thanks!

--
assignee: docs@python
components: Documentation
messages: 198425
nosy: docs@python, dsuch
priority: normal
severity: normal
status: open
title: Document SSLSocket.getpeercert always returns None without do_handshake
type: enhancement

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



[issue1185124] pydoc doesn't find all module doc strings

2013-09-25 Thread Akira Kitada

Akira Kitada added the comment:

Do you have any plan to work on patch for 2.7?
Apparently your patch is only for 3.x.

--

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