|
From: Robert W. B. <rb...@di...> - 2001-03-31 20:13:52
|
Hello all,
I was curious about the builtin "coerce" and what it should do
with non-numeric types.
Currently in CPython
>>> coerce(1,"a")
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: number coercion failed
>>>
Currently in Jython
>>> coerce(1, "a")
(1, 'a') <-- note: not the same type
>>>
It seems the typeerror should be raised, but as always, it's likely
there's something I've missed or misunderstood (maybe in PEP208 or
elsewhere). Sorry if I'm off yet again, but I was wondering if the
fall-through return of __builtin__.java::coerce should instead raise the
TypeError("number coercion failed").
If so...
=========================================================================
--- __builtin__.java Sun Mar 4 12:12:34 2001
+++ __builtin__.java Sat Mar 31 13:41:42 2001
@@ -205,7 +205,7 @@
return new PyTuple(new PyObject[] {(PyObject)ctmp, o2});
}
}
- return new PyTuple(new PyObject[] {o1, o2});
+ throw Py.TypeError("number coercion failed");
}
public static PyCode compile(String data, String filename, String
type) {
==========================================================================
or...
Index: __builtin__.java
===================================================================
RCS file: /cvsroot/jython/jython/org/python/core/__builtin__.java,v
retrieving revision 2.31
diff -r2.31 __builtin__.java
208c208
< return new PyTuple(new PyObject[] {o1, o2});
---
> throw Py.TypeError("number coercion failed");
Tnx,
Robert
|