[Python-bugs-list] [ python-Bugs-575773 ] Negative __len__ provokes SystemError

noreply@sourceforge.net noreply@sourceforge.net
Sun, 30 Jun 2002 15:27:40 -0700


Bugs item #575773, was opened at 2002-06-30 22:27
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=575773&group_id=5470

Category: Python Interpreter Core
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Tony Lownds (tonylownds)
Assigned to: Nobody/Anonymous (nobody)
Summary: Negative __len__ provokes SystemError

Initial Comment:
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




----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=575773&group_id=5470