[issue18162] Add index attribute to IndexError

2015-04-15 Thread Ofer Schwarz

Ofer Schwarz added the comment:

I'm working on this now (patch hopefully coming soon), and I've hit an 
interesting issue:
PySequence methods take care of negative indexes by adding +len before calling 
the subclass method (s.t. -1 becomes len-1 etc.). This means that if the 
subclass raises an exception with the index, it might be the wrong index.

This case only happens when index  -len, so when I talked it out with Larry he 
suggested just passing the original index to the subclass in this case. So for 
index = 0 or index  -len the subclass will receive the actual index, and for 
-len = index  0 the subclass will get index+len.
That's a change in behavior, but I actually think it's a good one. The 
negative-index use case in PySequence is exactly intended for this [-len, 0) 
use case, and if some subclass wants to do something weird with negative 
indexes it'd probably want the actual argument anyway.

I'm writing my patch with this in it, but it might be worth discussing here if 
someone disagrees.

--
nosy: +blackfawn

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



[issue18162] Add index attribute to IndexError

2015-04-15 Thread Ofer Schwarz

Changes by Ofer Schwarz os.uran...@gmail.com:


--
keywords: +patch
Added file: http://bugs.python.org/file39055/indexerror.patch

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



[issue18162] Add index attribute to IndexError

2015-04-15 Thread Ofer Schwarz

Changes by Ofer Schwarz os.uran...@gmail.com:


Added file: http://bugs.python.org/file39056/indexerror.tests

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



[issue18162] Add index attribute to IndexError

2015-04-15 Thread Ofer Schwarz

Changes by Ofer Schwarz os.uran...@gmail.com:


Added file: http://bugs.python.org/file39060/indexerror_all.patch

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



[issue18166] 'value' attribute for ValueError

2015-04-14 Thread Ofer Schwarz

Ofer Schwarz added the comment:

There's actually no advantage for a weakref here, since the exception object 
already holds an indirect reference to all the raising frame's locals through 
__traceback__.

--
nosy: +blackfawn

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



[issue18166] 'value' attribute for ValueError

2015-04-14 Thread Ofer Schwarz

Ofer Schwarz added the comment:

So, this is actually impossible to do.
Since exceptions are c-level classes, adding members to ValueError means 
anything that multiple-inherits from ValueError and any other complex exception 
gets a multiple bases layout conflict. There's already one such class - 
_pyio.UnsupportedOperation inherits both ValueError and OSError - but the 
bigger issue is that this would break compatibility.

After discussing it (face-to-face) with a bunch of core devs, I think the only 
reasonable course of action is to close the issue and never speak of this again.

--

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



[issue23960] PyErr_SetImportError doesn't clean up on some errors

2015-04-14 Thread Ofer Schwarz

New submission from Ofer Schwarz:

When creating kwargs to construct the ImportError, if PyDict_SetItemString 
fails the function returns without decref'ing the already-created locals.

--
components: Interpreter Core
files: importerrorcleanup.patch
keywords: patch
messages: 241052
nosy: blackfawn, gregory.p.smith
priority: normal
severity: normal
status: open
title: PyErr_SetImportError doesn't clean up on some errors
type: behavior
versions: Python 3.5
Added file: http://bugs.python.org/file39023/importerrorcleanup.patch

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



[issue21345] multiprocessing.Pool._handle_workers sleeps too long

2015-04-13 Thread Ofer Schwarz

Ofer Schwarz added the comment:

I couldn't reproduce this on my machine, but I have no idea if I'm using the 
wrong sequence of operations, or type of pool, or if my machine is just faster 
or something else entirely.
Johannes, can you upload a repro code for this?

--
nosy: +blackfawn

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