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: Negative __len__ provokes SystemError
Type: Stage:
Components: Interpreter Core Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: jhylton Nosy List: jhylton, tonylownds
Priority: normal Keywords:

Created on 2002-06-30 22:27 by tonylownds, last changed 2022-04-10 16:05 by admin. This issue is now closed.

Messages (2)
msg11412 - (view) Author: Tony Lownds (tonylownds) Date: 2002-06-30 22:27
class A(object):
  def __len__(self): 
    return -2  # anything < 0

  def __getslice__(self, x, y):  
    pass

A()[-1:]   # anything < 0

... results in....

Traceback (most recent call last):
  File "cause_system_error.py", line 8, in ?
    A()[-1:]   # anything < 0
SystemError: error return without exception set


msg11413 - (view) Author: Jeremy Hylton (jhylton) (Python triager) Date: 2002-07-25 16:06
Logged In: YES 
user_id=31392

Fixed in rev 2.162 of typeobject.c.
History
Date User Action Args
2022-04-10 16:05:28adminsetgithub: 36830
2002-06-30 22:27:39tonylowndscreate