This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: range slicing swallows exceptions from __index__ methods.
Type: behavior Stage: patch review
Components: Interpreter Core Versions: Python 3.2, Python 3.3, Python 3.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: mark.dickinson Nosy List: mark.dickinson, python-dev
Priority: normal Keywords: patch

Created on 2012-11-04 11:27 by mark.dickinson, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue16402.patch mark.dickinson, 2012-11-04 11:28 review
Messages (3)
msg174782 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2012-11-04 11:27
>>> class A(object):
...     def __index__(self): raise ZeroDivisionError
... 
[66062 refs]
>>> a = A()
[66065 refs]
>>> range(10)[0:a]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: slice indices must be integers or None or have an __index__ method
[66105 refs]
msg174783 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2012-11-04 11:28
Here's a patch.
msg174787 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-11-04 11:48
New changeset 94d15358ad6e by Mark Dickinson in branch '3.2':
Issue #16402: In range slicing, fix shadowing of exceptions from __index__ method.
http://hg.python.org/cpython/rev/94d15358ad6e

New changeset 2b656a2cf7ef by Mark Dickinson in branch '3.3':
Issue #16402: Merge fix from 3.2
http://hg.python.org/cpython/rev/2b656a2cf7ef

New changeset f02555353544 by Mark Dickinson in branch 'default':
Issue #16402: Merge fix from 3.3
http://hg.python.org/cpython/rev/f02555353544
History
Date User Action Args
2022-04-11 14:57:38adminsetgithub: 60606
2012-11-04 11:51:01mark.dickinsonsetstatus: open -> closed
resolution: fixed
2012-11-04 11:48:11python-devsetnosy: + python-dev
messages: + msg174787
2012-11-04 11:39:25mark.dickinsonsetcomponents: + Interpreter Core
2012-11-04 11:28:50mark.dickinsonsetfiles: + issue16402.patch
versions: + Python 3.2, Python 3.3, Python 3.4
messages: + msg174783

keywords: + patch
type: behavior
stage: patch review
2012-11-04 11:27:44mark.dickinsoncreate