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):
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
Changes by Chris Jerdonek chris.jerdo...@gmail.com:
--
nosy: +cjerdonek
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15806
___
___
Changes by Ezio Melotti ezio.melo...@gmail.com:
--
stage: - committed/rejected
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15804
___
___
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
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
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
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 =
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
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
Changes by Chris Rebert pyb...@rebertia.com:
--
nosy: +cvrebert
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15798
___
___
Python-bugs-list
Changes by Chris Rebert pyb...@rebertia.com:
--
nosy: +cvrebert
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15806
___
___
Python-bugs-list
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
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
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
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
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
Changes by Ronald Oussoren ronaldousso...@mac.com:
--
status: pending - closed
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13370
___
___
Changes by Ronald Oussoren ronaldousso...@mac.com:
--
status: open - pending
type: - behavior
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14329
___
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
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
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
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
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
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 `..
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
___
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
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
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
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
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?
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
Changes by Rostyslav Dzinko rostislav.dzi...@gmail.com:
--
versions: -3rd party
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15808
___
___
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
___
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:
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
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
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
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
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
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
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
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
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
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'Русский
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
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
alex hartwig added the comment:
Text is correct. See attachment.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15809
___
___
Python-bugs-list
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
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
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
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
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
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
___
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
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
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
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
Changes by R. David Murray rdmur...@bitdance.com:
--
nosy: +lukasz.langa
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15803
___
___
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
___
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
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
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
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
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
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
___
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 =
Changes by Trent Nelson tr...@snakebite.org:
--
nosy: +trent
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9860
___
___
Python-bugs-list mailing
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
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
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():
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: -
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
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
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
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
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
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
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
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 =
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
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
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
Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com:
--
resolution: - fixed
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15573
___
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
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
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
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
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
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
___
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
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
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
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
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
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
Changes by Andrew Svetlov andrew.svet...@gmail.com:
--
nosy: +asvetlov
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14803
___
___
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
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
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 - 100 of 117 matches
Mail list logo