Steve Dower <steve.do...@python.org> added the comment:

We should at least have consistent error messages:

>>> class O:
...  def __len__(self):
...   return 2**100
...
>>> o=O()
>>> len(o)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OverflowError: cannot fit 'int' into an index-sized integer

I'd argue for replacing 'int' here with the rendered value, but I think 
OverflowError is the right type. Mentioning "C ssize_t" is the problem.

As for the list constructor, I'd be okay with chaining a MemoryError here, 
provided the OverflowError sticks around. But in this context a MemoryError is 
"recoverable" while an OverflowError very likely indicates a programming error, 
so we shouldn't hide it from the user.

----------
nosy: +steve.dower

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue36552>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to