[Python-checkins] python/dist/src/Objects complexobject.c,2.63,2.64
rhettinger@users.sourceforge.net
rhettinger@users.sourceforge.net
Thu, 29 Aug 2002 07:22:53 -0700
Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv26220/Objects
Modified Files:
complexobject.c
Log Message:
complex() was the only numeric constructor that created a new instance
when given its own type as an argument.
Index: complexobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/complexobject.c,v
retrieving revision 2.63
retrieving revision 2.64
diff -C2 -d -r2.63 -r2.64
*** complexobject.c 19 Aug 2002 19:26:42 -0000 2.63
--- complexobject.c 29 Aug 2002 14:22:50 -0000 2.64
***************
*** 824,827 ****
--- 824,836 ----
&r, &i))
return NULL;
+
+ /* Special-case for single argumet that is already complex */
+ if (PyComplex_CheckExact(r) && i == NULL) {
+ /* Note that we can't know whether it's safe to return
+ a complex *subclass* instance as-is, hence the restriction
+ to exact complexes here. */
+ Py_INCREF(r);
+ return r;
+ }
if (PyString_Check(r) || PyUnicode_Check(r)) {
if (i != NULL) {