Title: Possible to construct long(None)
Type: behaviour Severity: normal
Components: Core Versions: 2.5alpha1
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: nriley, pjenvey
Priority: Keywords:

Created on 2008-06-15.21:41:13 by nriley, last changed 2008-06-22.21:17:20 by pjenvey.

msg3289 (view) Author: Nicholas Riley (nriley) Date: 2008-06-15.21:41:11

>>> x = long(None)
>>> x
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
	at org.python.core.PyLong.long_toString(
	at org.python.core.PyLong.toString(
	at org.python.core.PyObject.__repr__(


>>> long(None)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: long() argument must be a string or a number, not 'NoneType'

int(None) fails as expected.
msg3297 (view) Author: Nicholas Riley (nriley) Date: 2008-06-22.04:43:10
With r4699 long(None) now generates an AttributeError, which is quite a 
bit better.  Would it make sense to change long___new__ to trap this 
AttributeError and throw a TypeError, or is there a better way to do this?
msg3300 (view) Author: Philip Jenvey (pjenvey) Date: 2008-06-22.21:17:19
i made it translate the AttributeError to TypeError in r4713

technically this will swallow any user created AttributedErrors in a 
__long__ definition, but that's just kind of how Jython does things right 
now. We do a similar translation for e.g. __complex__
Date User Action Args
2008-06-22 21:17:20pjenveysetstatus: open -> closed
resolution: fixed
messages: + msg3300
2008-06-22 04:43:13nrileysetnosy: + pjenvey
messages: + msg3297
2008-06-15 21:41:13nrileycreate