[issue15806] Add context manager for the try: ... except: pass pattern

2012-08-29 Thread Raymond Hettinger
Raymond Hettinger added the comment: Yes, something along those lines would be *much* better: class Ignore: ''' Context manager to ignore particular exceptions''' def __init__(self, *ignored_exceptions): self.ignored_exceptions = ignored_exceptions def __enter__(self):

[issue15806] Add context manager for the try: ... except: pass pattern

2012-08-29 Thread Nick Coghlan
Nick Coghlan added the comment: I'd just write it with @contextmanager. Making it easier to cleanly factor out exception handling is one of the main reasons that exists. @contextmanager def ignored(*exceptions): Context manager to ignore particular exceptions try: yield

[issue15806] Add context manager for the try: ... except: pass pattern

2012-08-29 Thread Chris Jerdonek
Changes by Chris Jerdonek chris.jerdo...@gmail.com: -- nosy: +cjerdonek ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15806 ___ ___

[issue15804] Feature request, implicit except : pass

2012-08-29 Thread Ezio Melotti
Changes by Ezio Melotti ezio.melo...@gmail.com: -- stage: - committed/rejected ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15804 ___ ___

[issue15798] subprocess.Popen() fails if 0, 1 or 2 descriptor is closed

2012-08-29 Thread Ross Lagerwall
Ross Lagerwall added the comment: It's caused by the following check in _posixsubprocess.c: if (close_fds errpipe_write 3) { /* precondition */ PyErr_SetString(PyExc_ValueError, errpipe_write must be = 3); return NULL; } which was written by Gregory P. Smith in 2010

[issue13405] Add DTrace probes

2012-08-29 Thread Ronald Oussoren
Ronald Oussoren added the comment: The obvious workaround w.r.t. dtrace not finding the preprocessor is to install the command-line tools for xcode, which you can do from Xcode's preferences. something else to try (before installing the commandline tools): add $(dirname $(xcrun -find cpp)) to

[issue15806] Add context manager for the try: ... except: pass pattern

2012-08-29 Thread Ezio Melotti
Ezio Melotti added the comment: I think I'm -1 on this. This saves two lines, but makes the code less explicit, it can't be used for try/except/else or try/except/except, it requires an extra import, the implementation is simple enough that it doesn't necessary need to be in the stdlib, it

[issue15573] Support unknown formats in memoryview comparisons

2012-08-29 Thread Stefan Krah
Stefan Krah added the comment: We overlooked one thing. Since hashing is defined in terms of tobytes(), the equality-hash invariant is now broken: from _testbuffer import ndarray x = ndarray([1,2,3], shape=[3], format='f') y = ndarray([1,2,3], shape=[3], format='B') a = memoryview(x) b =

[issue15806] Add context manager for the try: ... except: pass pattern

2012-08-29 Thread Martin v . Löwis
Martin v. Löwis added the comment: I think the zipfile example is really a bad example. IMO, it would best be written as try: return bool(EndRecData(fp)) except IOError: return False i.e. there shouldn't be a pass statement at all in this code, and the if can be dropped whether you use

[issue15802] Illegal test for mailbox

2012-08-29 Thread Ezio Melotti
Ezio Melotti added the comment: +if int(groups[0]) == int(previous_groups[0]): +self.assertGreaterEqual(int(groups[1]), int(previous_groups[1]), This checks that int(groups[1]) = int(previous_groups[1]) if int(groups[0]) == int(previous_groups[0]) whereas

[issue15798] subprocess.Popen() fails if 0, 1 or 2 descriptor is closed

2012-08-29 Thread Chris Rebert
Changes by Chris Rebert pyb...@rebertia.com: -- nosy: +cvrebert ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15798 ___ ___ Python-bugs-list

[issue15806] Add context manager for the try: ... except: pass pattern

2012-08-29 Thread Chris Rebert
Changes by Chris Rebert pyb...@rebertia.com: -- nosy: +cvrebert ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15806 ___ ___ Python-bugs-list

[issue15798] subprocess.Popen() fails if 0, 1 or 2 descriptor is closed

2012-08-29 Thread Gregory P. Smith
Gregory P. Smith added the comment: easy enough to reproduce... $ ./python.exe -c 'import os, subprocess as s; os.close(0); os.close(1); s.Popen([/bin/true])' Traceback (most recent call last): File string, line 1, in module File /Users/gps/python/hg/default/Lib/subprocess.py, line 818, in

[issue15802] Nonsensical test for mailbox

2012-08-29 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Yes, the previous check nonsensical in two cases -- comparing strings and comparing with wrong value. groups[0] -- current seconds (str), groups[1] -- current milliseconds (str), previous_groups[0] -- previous seconds (str), previous_groups[1] -- previous

[issue15751] Support subinterpreters in the GIL state API

2012-08-29 Thread Antoine Pitrou
Antoine Pitrou added the comment: Le mercredi 29 août 2012 à 02:19 +, Nick Coghlan a écrit : However, it *doesn't* work (at least, not easily) if the extension itself wants to call back into an interpreter other than the one already associated with the current thread: /* Embedding

[issue15798] subprocess.Popen() fails if 0, 1 or 2 descriptor is closed

2012-08-29 Thread Ross Lagerwall
Ross Lagerwall added the comment: The attached patch + test seems to fix the issue. It's not very elegant. -- keywords: +patch Added file: http://bugs.python.org/file27042/issue15798.patch ___ Python tracker rep...@bugs.python.org

[issue15751] Support subinterpreters in the GIL state API

2012-08-29 Thread Nick Coghlan
Nick Coghlan added the comment: Yeah, I eventually came around to agreeing that it's better to stick with the Ensure/Release model. SwitchInterpreter gets messy when it comes to managing the lifecycle of temporary thread states. So an EnsureEx/ReleaseEx pair with a new struct that includes

[issue13370] test_ctypes fails when building python with clang

2012-08-29 Thread Ronald Oussoren
Changes by Ronald Oussoren ronaldousso...@mac.com: -- status: pending - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13370 ___ ___

[issue14329] proxy_bypass_macosx_sysconf does not handle singel ip addresses correctly

2012-08-29 Thread Ronald Oussoren
Changes by Ronald Oussoren ronaldousso...@mac.com: -- status: open - pending type: - behavior ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14329 ___

[issue15573] Support unknown formats in memoryview comparisons

2012-08-29 Thread Nick Coghlan
Nick Coghlan added the comment: Perhaps the hash could just be based on a subset of the items? For example, hash the format, shape and the first and last items? Yes, such an approach means you're more likely to get collisions if you do start hashing these, but that seems better than making

[issue13405] Add DTrace probes

2012-08-29 Thread Samuel John
Samuel John added the comment: dtrace ignores PATH and CC and CPP. I tried that already :/ Of course I could just install the command line tools. But still it's a shame since all the tools are already there. -- ___ Python tracker

[issue15806] Add context manager for the try: ... except: pass pattern

2012-08-29 Thread Nick Coghlan
Nick Coghlan added the comment: (Note: I'm not yet convinced this is a good idea. I'm definitely considering it, though) As with many context managers, a key benefit here is in the priming effect for readers. In this code: try: # Whatever except (A, B, C): pass the

[issue15806] Add context manager for the try: ... except: pass pattern

2012-08-29 Thread Ezio Melotti
Ezio Melotti added the comment: As with many context managers, a key benefit here is in the priming effect for readers. The focus is mostly on what it's being executed rather than what it's being ignored though. Do this operation and ignore these exceptions if they occur vs. Ignore these

[issue15751] Support subinterpreters in the GIL state API

2012-08-29 Thread Graham Dumpleton
Graham Dumpleton added the comment: If PyGILState_STATE is a struct, what happens if someone naively does: PyGILState_Release(PyGILState_UNLOCKED) I know they shouldn't, but I actually do this in mod_wsgi in one spot as it is otherwise a pain to carry around the state when I know for sure if

[issue15807] Bogus versionchanged note in logging.handlers.MemoryHandler doc

2012-08-29 Thread Gunnlaugur Thor Briem
New submission from Gunnlaugur Thor Briem: In logging.handlers.MemoryHandler documentation: “Changed in version 2.6: credentials was added.” There's no `credentials` anywhere nearby, and at first glance I can't see anything new in `MemoryHandler` when this was introduced. Presumably the `..

[issue15807] Bogus versionchanged note in logging.handlers.MemoryHandler doc

2012-08-29 Thread Ezio Melotti
Changes by Ezio Melotti ezio.melo...@gmail.com: -- nosy: +vinay.sajip stage: - needs patch versions: -Python 2.6 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15807 ___

[issue13405] Add DTrace probes

2012-08-29 Thread Ronald Oussoren
Ronald Oussoren added the comment: It's rather annoying that dtrace doesn't honor the PATH variable, and when you run the strings command on /usr/lib/libdtrace.dylib you'll see that it hardcodes the use of gcc (not even cpp or clang). I've filed radar 12196604 in Apple's tracker, although it

[issue13405] Add DTrace probes

2012-08-29 Thread Robert Kern
Changes by Robert Kern robert.k...@gmail.com: -- nosy: -robert.kern ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13405 ___ ___ Python-bugs-list

[issue15802] Nonsensical test for mailbox

2012-08-29 Thread Chris Jerdonek
Chris Jerdonek added the comment: In other words, (int(groups[0]), int(groups[1])) = (int(previous_groups[0]), int(previous_groups[1])). Why not use a single self.assertGreaterEqual() on the pairs (with an appropriate change in the message)? It currently hand-codes the lexicographic

[issue15806] Add context manager for the try: ... except: pass pattern

2012-08-29 Thread Antoine Pitrou
Antoine Pitrou added the comment: If this is desirable then I think it would be better as a classmethod of Exception: with KeyError.trap(): do_something() -- nosy: +pitrou ___ Python tracker rep...@bugs.python.org

[issue15806] Add context manager for the try: ... except: pass pattern

2012-08-29 Thread Eric V. Smith
Eric V. Smith added the comment: While the classmethod version has some appeal, it doesn't extend well to handling multiple exception types. I'm -0 on this, in any event. I think the original code is more clear. Why force people to learn (or recognize) a second idiom for something so simple?

[issue15808] Possibility of setting custom key bindings for Additional help sources menu items

2012-08-29 Thread Rostyslav Dzinko
New submission from Rostyslav Dzinko: There's a possibility to add additional help sources in IDLE via Options - Configure IDLE... - General - Additional Help Sources Use case: If someone wants to download certain version of Python documentation in HTML and specify local index.html to

[issue15808] Possibility of setting custom key bindings for Additional help sources menu items

2012-08-29 Thread Rostyslav Dzinko
Changes by Rostyslav Dzinko rostislav.dzi...@gmail.com: -- versions: -3rd party ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15808 ___ ___

[issue15784] OSError.__str__() should distinguish between errno and winerror

2012-08-29 Thread Richard Oudkerk
Richard Oudkerk added the comment: The changeset is 2e587b9bae35. Georg, could you copy it to your release branch please. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15784 ___

[issue15800] Closing of sys.std* files in gzip test.

2012-08-29 Thread Jesús Cea Avión
Jesús Cea Avión added the comment: Test? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15800 ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue15475] Correct __sizeof__ support for itertools

2012-08-29 Thread Aaron Iles
Changes by Aaron Iles aaron.i...@gmail.com: -- nosy: +aliles ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15475 ___ ___ Python-bugs-list mailing

[issue15806] Add context manager for the try: ... except: pass pattern

2012-08-29 Thread Jesús Cea Avión
Changes by Jesús Cea Avión j...@jcea.es: -- nosy: +jcea ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15806 ___ ___ Python-bugs-list mailing list

[issue13266] Add inspect.unwrap(f) to easily unravel __wrapped__ chains

2012-08-29 Thread Aaron Iles
Changes by Aaron Iles aaron.i...@gmail.com: -- nosy: +aliles ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13266 ___ ___ Python-bugs-list mailing

[issue15510] textwrap.wrap('') returns empty list

2012-08-29 Thread Chris Jerdonek
Chris Jerdonek added the comment: Attaching an updated patch that improves the organization of the new test cases (test ordering, test names, and test comments, etc). -- Added file: http://bugs.python.org/file27043/issue-15510-4.patch ___ Python

[issue15490] Correct __sizeof__ support for StringIO

2012-08-29 Thread Aaron Iles
Changes by Aaron Iles aaron.i...@gmail.com: -- nosy: +aliles ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15490 ___ ___ Python-bugs-list mailing

[issue15436] __sizeof__ is not documented

2012-08-29 Thread Aaron Iles
Changes by Aaron Iles aaron.i...@gmail.com: -- nosy: +aliles ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15436 ___ ___ Python-bugs-list mailing

[issue15696] Correct __sizeof__ support for mmap

2012-08-29 Thread Aaron Iles
Changes by Aaron Iles aaron.i...@gmail.com: -- nosy: +aliles ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15696 ___ ___ Python-bugs-list mailing

[issue15695] Correct __sizeof__ support for StgDict

2012-08-29 Thread Aaron Iles
Changes by Aaron Iles aaron.i...@gmail.com: -- nosy: +aliles ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15695 ___ ___ Python-bugs-list mailing

[issue15513] Correct __sizeof__ support for pickle

2012-08-29 Thread Aaron Iles
Changes by Aaron Iles aaron.i...@gmail.com: -- nosy: +aliles ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15513 ___ ___ Python-bugs-list mailing

[issue15809] Строки из IDLE поступают в неверной кодировке.

2012-08-29 Thread alex hartwig
New submission from alex hartwig: Это из IDLE: Python 2.7.2+ (default, Oct 4 2011, 20:03:08) [GCC 4.6.1] on linux2 Type copyright, credits or license() for more information. import sys import locale sys.getdefaultencoding() 'ascii' locale.getpreferredencoding() 'UTF-8' s = u'Русский

[issue15809] Строки из IDLE поступают в неверной кодировке.

2012-08-29 Thread Ezio Melotti
Ezio Melotti added the comment: Looks like your IDLE is set to use latin-1, but s.encode('latin1') should have failed with an UnicodeEncodeError. Are you sure you copied the snippet correctly? The default source encoding refers to the .py files you open with IDLE, and doesn't affect the

[issue15809] IDLE console uses incorrect encoding.

2012-08-29 Thread Andrew Svetlov
Changes by Andrew Svetlov andrew.svet...@gmail.com: -- title: Строки из IDLE поступают в неверной кодировке. - IDLE console uses incorrect encoding. ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15809

[issue15809] IDLE console uses incorrect encoding.

2012-08-29 Thread alex hartwig
alex hartwig added the comment: Text is correct. See attachment. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15809 ___ ___ Python-bugs-list

[issue15810] assertSequenceEqual should be fired when comparing sequences

2012-08-29 Thread Florent Xicluna
New submission from Florent Xicluna: When writing unittest, I noticed that I need to uses assertSequenceEqual explicitly when comparing sequences of different kinds. If I only use the plain assertEqual, it does not generate pretty diffs. On second thought, I think it could be fixed in

[issue15811] ElementTree.write() raises TypeError when xml_declaration = True and encoding is a unicode string

2012-08-29 Thread David Buxton
New submission from David Buxton: The problem is an inconsistency between the ElementTree.write() method on Python 2 and 3 when xml_declaration is True. For Python 2.7 the encoding argument MUST NOT be a unicode string. For Python 3.2 the encoding argument MUST be a unicode string. On Python

[issue15810] assertSequenceEqual should be fired when comparing sequences

2012-08-29 Thread R. David Murray
R. David Murray added the comment: I think it works as it should (you shouldn't be asserting that a sequence and a tuple are equal, after all). Once you fix your test, you'll get the pretty print if there are still differences. -- nosy: +michael.foord, r.david.murray

[issue15765] test_getcwd_long_pathnames (in test_posix) kills NetBSD

2012-08-29 Thread Roundup Robot
Roundup Robot added the comment: New changeset bfa5d0ddfbeb by Trent Nelson in branch '2.7': Issue #15765: Fix quirky NetBSD getcwd() behaviour. http://hg.python.org/cpython/rev/bfa5d0ddfbeb -- nosy: +python-dev ___ Python tracker

[issue9185] os.getcwd causes infinite loop on solaris

2012-08-29 Thread Roundup Robot
Roundup Robot added the comment: New changeset bfa5d0ddfbeb by Trent Nelson in branch '2.7': Issue #15765: Fix quirky NetBSD getcwd() behaviour. http://hg.python.org/cpython/rev/bfa5d0ddfbeb -- nosy: +python-dev ___ Python tracker

[issue15811] ElementTree.write() raises TypeError when xml_declaration = True and encoding is a unicode string

2012-08-29 Thread Florent Xicluna
Changes by Florent Xicluna florent.xicl...@gmail.com: -- components: +Library (Lib) nosy: +eli.bendersky, flox ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15811 ___

[issue15807] Bogus versionchanged note in logging.handlers.MemoryHandler doc

2012-08-29 Thread Roundup Robot
Roundup Robot added the comment: New changeset 48f54b6bf0ef by Vinay Sajip in branch '2.7': Closes #15807: Removed incorrect directive from help. http://hg.python.org/cpython/rev/48f54b6bf0ef -- nosy: +python-dev resolution: - fixed stage: needs patch - committed/rejected status: open

[issue15710] logging module crashes in Python 2.7.3 for handler.setLevel(long)

2012-08-29 Thread Roundup Robot
Roundup Robot added the comment: New changeset 8ba6d8fc9740 by Vinay Sajip in branch '2.7': Closes #15710: accept long in _checkLevel. http://hg.python.org/cpython/rev/8ba6d8fc9740 -- nosy: +python-dev resolution: invalid - fixed stage: - committed/rejected status: open - closed

[issue15810] assertSequenceEqual should be fired when comparing sequences

2012-08-29 Thread Florent Xicluna
Florent Xicluna added the comment: you're probably right. I will continue to use assertSequenceEqual for my use cases. Actually, what confused me is that these assertions are True: class T(tuple): pass class L(list): pass assertEqual(T('ab'), tuple('ab')) assertEqual(L('ab'), list('ab')) And

[issue15810] assertSequenceEqual should be fired when comparing sequence subclasses

2012-08-29 Thread R. David Murray
R. David Murray added the comment: That sounds like a bug. -- title: assertSequenceEqual should be fired when comparing sequences - assertSequenceEqual should be fired when comparing sequence subclasses ___ Python tracker rep...@bugs.python.org

[issue15803] Incorrect docstring on ConfigParser.items()

2012-08-29 Thread R. David Murray
Changes by R. David Murray rdmur...@bitdance.com: -- nosy: +lukasz.langa ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15803 ___ ___

[issue15803] Incorrect docstring on ConfigParser.items()

2012-08-29 Thread R. David Murray
Changes by R. David Murray rdmur...@bitdance.com: -- stage: - patch review type: enhancement - behavior ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15803 ___

[issue15803] Incorrect docstring on ConfigParser.items()

2012-08-29 Thread Chris Jerdonek
Chris Jerdonek added the comment: This is a nit, but there should be two spaces after the period: +each option in the section. Otherwise, return a list of tuples with -- nosy: +cjerdonek ___ Python tracker rep...@bugs.python.org

[issue15810] assertSequenceEqual should be fired when comparing sequence subclasses

2012-08-29 Thread Ezio Melotti
Ezio Melotti added the comment: The assertSequenceEqual docs[0] say: This method is not called directly by assertEqual(), but it’s used to implement assertListEqual() and assertTupleEqual(). The asserEqual docs[1] say: In addition, if first and second are the exact same type and one of

[issue15803] Incorrect docstring on ConfigParser.items()

2012-08-29 Thread Ezio Melotti
Ezio Melotti added the comment: While I like to have two spaces after the period, this convenction is not enforced, and it usually depends on the style used in the file. If the double space is used elsewhere in the same document, then it should be preserved, otherwise using a single space is

[issue15803] Incorrect docstring on ConfigParser.items()

2012-08-29 Thread Chris Jerdonek
Chris Jerdonek added the comment: If the double space is used elsewhere in the same document, You can see one above the change in the patch file. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15803

[issue15809] IDLE console uses incorrect encoding.

2012-08-29 Thread Martin v . Löwis
Martin v. Löwis added the comment: The problem is that IDLE passes an UTF-8 encoded source string to compile, and compile, in the absence of a source encoding, uses the PEP 263 default source encoding, i.e. Latin-1. As the consequence, the variable s has the value

[issue15803] Incorrect docstring on ConfigParser.items()

2012-08-29 Thread Nathan Trapuzzano
Nathan Trapuzzano added the comment: Looks like the file has about an equal number of single- and double-spaces after periods. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15803 ___

[issue15812] inspect.getframeinfo() cannot show first line

2012-08-29 Thread Richard Oudkerk
New submission from Richard Oudkerk: When inspect.getframeinfo() tries to collect lines of context it never shows the first line (unless context is as big as the number of lines in the file). The relevant code is start = lineno - 1 - context//2 try: lines, lnum =

[issue9860] Building python outside of source directory fails

2012-08-29 Thread Trent Nelson
Changes by Trent Nelson tr...@snakebite.org: -- nosy: +trent ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9860 ___ ___ Python-bugs-list mailing

[issue15573] Support unknown formats in memoryview comparisons

2012-08-29 Thread Stefan Krah
Stefan Krah added the comment: I'm trying to think of an optimization for the native types. It should be possible to cast any native type element to unsigned char and use the truncated value for the bytes hash. Well, for double probably it's required to go from double - int64_t - unsigned

[issue15591] when building the extensions, stdout is lost when stdout is redirected

2012-08-29 Thread Barry A. Warsaw
Changes by Barry A. Warsaw ba...@python.org: -- nosy: +barry ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15591 ___ ___ Python-bugs-list mailing

[issue15813] Python function decorator scope losing variable

2012-08-29 Thread V.E.O
New submission from V.E.O: I just learned python @ decorator, it's cool, but soon I found my modified code coming out weird problems. def with_wrapper(param1): def dummy_wrapper(fn): print param1 param1 = 'new' fn(param1) return dummy_wrapper def dummy():

[issue15813] Python function decorator scope losing variable

2012-08-29 Thread R. David Murray
R. David Murray added the comment: When you assign a value to param1 it becomes a local variable, thus the error. You should ask for help on your scoping questions from the python-tutor list or the general python-list. -- nosy: +r.david.murray resolution: - invalid stage: -

[issue15811] ElementTree.write() raises TypeError when xml_declaration = True and encoding is a unicode string

2012-08-29 Thread David Buxton
David Buxton added the comment: A patch against the current default branch to add tests for the xml_declaration keyword argument. This passes when applied to the 2.7 branch too. This does NOT test whether one can use both bytes/unicode for the encoding argument. It just uses the native string

[issue15811] ElementTree.write() raises TypeError when xml_declaration = True and encoding is a unicode string

2012-08-29 Thread Eli Bendersky
Eli Bendersky added the comment: Thanks for the patch, David. Alas, due to personal reasons I will not be able to work on core Python in the next 2-3 months. I may throw in a review here and there, but that's not a promise ;-) -- ___ Python

[issue15798] subprocess.Popen() fails if 0, 1 or 2 descriptor is closed

2012-08-29 Thread Gregory P. Smith
Gregory P. Smith added the comment: Yes, something along the lines of that patch is what I was thinking. BTW, this is only necessary for the errpipe_write fd. errpipe_read is for the parent process. I'm going to do it within _create_pipe so that the optimal _posixsubprocess.cloexec_pipe

[issue15573] Support unknown formats in memoryview comparisons

2012-08-29 Thread Martin v . Löwis
Martin v. Löwis added the comment: 1. I STRONGLY request to take hashing out of this issue. The only further action that this issue can have is complete reversal of the patch, starting over. Now that the issue has been resolved, a NEW issue arises, namely that hashing is inconsistent with

[issue15811] ElementTree.write() raises TypeError when xml_declaration = True and encoding is a unicode string

2012-08-29 Thread Amaury Forgeot d'Arc
Amaury Forgeot d'Arc added the comment: Why is it a problem? Encoding must be a text string: encoding='utf-8' works with both Python 2 and 3. Or if you used from __future__ import unicode_literals, str('utf-8') works as well. -- nosy: +amaury.forgeotdarc

[issue15811] ElementTree.write() raises TypeError when xml_declaration = True and encoding is a unicode string

2012-08-29 Thread David Buxton
David Buxton added the comment: Only a problem because I am using unicode_literals and it didn't occur to me to use `str('utf-8')` to get a native string on both 2+3. Much the best solution, thank you. But that is still a little smelly - I think what I want ideally is for ElementTree to

[issue11776] Constructor signatures missing in types module documentation

2012-08-29 Thread Mike Hoy
Mike Hoy added the comment: This should be all the requested changes. I've gone over the table entries (at least the first one, CodeType, with bitdancer on IRC). I've removed the descriptive language from below the table and added it to the table. Leaving the text below the table to deal with

[issue15814] memoryview: equality-hash invariant

2012-08-29 Thread Stefan Krah
New submission from Stefan Krah: The new PEP-3118 equality definition from #15573 that is based on element-wise comparisons breaks the equality-hash invariant: from _testbuffer import ndarray x = ndarray([1,2,3], shape=[3], format='f') y = ndarray([1,2,3], shape=[3], format='B') a =

[issue15573] Support unknown formats in memoryview comparisons

2012-08-29 Thread Stefan Krah
Stefan Krah added the comment: I agree that this isn't a blocker due to the limited use of memoryview hashing. Tracking this in #15814. -- status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15573

[issue15805] Add stdout redirection tool to contextlib

2012-08-29 Thread Brett Cannon
Brett Cannon added the comment: So Alex's point is valid: the examples in the unittest.mock.patch docs shows how to do this (http://docs.python.org/dev/py3k/library/unittest.mock.html#patch). So this could be simplified to: def redirect_stdout(replacement=None): return

[issue15798] subprocess.Popen() fails if 0, 1 or 2 descriptor is closed

2012-08-29 Thread Aleksey Filippov
Aleksey Filippov added the comment: It may be implemented simplier. fcntl(fd, F_DUPFD_CLOEXEC, min_fd_number) will allocate new fd at least min_fd_number. So, it is not necessary to do a lot of dup() calls. -- ___ Python tracker

[issue15573] Support unknown formats in memoryview comparisons

2012-08-29 Thread Arfrever Frehtes Taifersar Arahesis
Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com: -- resolution: - fixed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15573 ___

[issue15798] subprocess.Popen() fails if 0, 1 or 2 descriptor is closed

2012-08-29 Thread Gregory P. Smith
Gregory P. Smith added the comment: F_DUPFD_CLOEXEC appears exclusive to modern Linux kernels. Any idea how wide spread support for plain F_DUPFD is? If that is everywhere the code I've just whipped up could lose a lot of loops... -- ___ Python

[issue15814] memoryview: equality-hash invariant

2012-08-29 Thread Martin v . Löwis
Martin v. Löwis added the comment: I think the proper solution is to make memoryview objects unhashable. Any other approach will have flaws of some kind. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15814

[issue15814] memoryview: equality-hash invariant

2012-08-29 Thread Antoine Pitrou
Antoine Pitrou added the comment: I think the proper solution is to make memoryview objects unhashable. Disagreed. If memoryviews are to be bytes-like objects they should be hashable (at least when readonly). Any other approach will have flaws of some kind. Not more so than equality between

[issue15798] subprocess.Popen() fails if 0, 1 or 2 descriptor is closed

2012-08-29 Thread Gregory P. Smith
Gregory P. Smith added the comment: Here's my initial fix. If fcntl(errpipe_write, F_DUPFD, 3) is widely available this could be shrunk a bit to avoid the for loop potentially calling dup a few times and tracking the wasted fds to close later. Otherwise if it isn't I'd rather not bother with

[issue13769] json.dump(ensure_ascii=False) return str instead of unicode

2012-08-29 Thread Petri Lehtinen
Petri Lehtinen added the comment: Attached an updated patch, which is more explicit on what ensure_ascii actually does. -- Added file: http://bugs.python.org/file27049/issue13769_v2.patch ___ Python tracker rep...@bugs.python.org

[issue15800] Closing of sys.std* files in gzip test.

2012-08-29 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I can not imagine how it can be tested. Correction does not affect the current behavior. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15800 ___

[issue15814] memoryview: equality-hash invariant

2012-08-29 Thread Martin v . Löwis
Martin v. Löwis added the comment: Am 29.08.12 20:01, schrieb Antoine Pitrou: I think the proper solution is to make memoryview objects unhashable. Disagreed. If memoryviews are to be bytes-like objects they should be hashable (at least when readonly). So what specific hash algorithm do you

[issue15814] memoryview: equality-hash invariant

2012-08-29 Thread Antoine Pitrou
Antoine Pitrou added the comment: Am 29.08.12 20:01, schrieb Antoine Pitrou: I think the proper solution is to make memoryview objects unhashable. Disagreed. If memoryviews are to be bytes-like objects they should be hashable (at least when readonly). So what specific hash algorithm

[issue15815] Add numerator to ZeroDivisionError messages

2012-08-29 Thread Terry J. Reedy
New submission from Terry J. Reedy: I propose that we add 'of ' to all ZeroDivisionError messagesso it is less necessary to use a debugger to add print statements to recover the information currently tossed away. (I also propose to change denominator from 'zero' to '0', '0.0', '0+0j', as

[issue15814] memoryview: equality-hash invariant

2012-08-29 Thread Martin v . Löwis
Martin v. Löwis added the comment: Am 29.08.12 21:06, schrieb Antoine Pitrou: So what specific hash algorithm do you propose? The current algorithm works well in conjunction with bytes objects. That's about the only type if works for. My claim is that any hash definition for memoryviews

[issue15816] pydoc.py uses a hack that depends on implementation details and breaks help() when __builtin__.__import__ is overwritten.

2012-08-29 Thread David Kreuter
New submission from David Kreuter: help(compile) # this works import __builtin__ real_import = __import__ __builtin__.__import__ = lambda *a: real_import(*a) help(compile) # this fails The line responsible for this is in pydoc.py around line 300: ... elif exc is ImportError and

[issue15816] pydoc.py uses a hack that depends on implementation details and breaks help() when __builtin__.__import__ is overwritten.

2012-08-29 Thread R. David Murray
R. David Murray added the comment: Replacing __import__ is not supported. That said, this is fixed in 3.3. -- nosy: +r.david.murray resolution: - out of date stage: - committed/rejected status: open - closed type: - behavior versions: +Python 3.3 -Python 2.7, Python 3.1, Python 3.2

[issue14803] Add feature to allow code execution prior to __main__ invocation

2012-08-29 Thread Andrew Svetlov
Changes by Andrew Svetlov andrew.svet...@gmail.com: -- nosy: +asvetlov ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14803 ___ ___

[issue15808] Possibility of setting custom key bindings for Additional help sources menu items

2012-08-29 Thread Ned Deily
Ned Deily added the comment: Actually, IDLE does have code to look for an on-disk copy of the html-formatted Python documentation set but the paths are platform-specific and, in the Linux case, are out-of-date for some distributions at least. For Linux platforms it looks for `index.html` in

[issue15814] memoryview: equality-hash invariant

2012-08-29 Thread Stefan Krah
Stefan Krah added the comment: Martin v. L??wis rep...@bugs.python.org wrote: In general, since memoryview(obj)==obj, it would be necessary that hash(memoryview(obj))==hash(obj). However, since memoryview cannot know what hashing algorithm obj uses, it cannot compute the hash value with the

[issue15814] memoryview: equality-hash invariant

2012-08-29 Thread Stefan Krah
Stefan Krah added the comment: And since memory_richcompare() and any potentially compatible hash function are quite tricky to implement by now, perhaps the generally useful parts could be exposed as PyBuffer_RichCompareBool() and PyBuffer_Hash(). --

  1   2   >