File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -308,6 +308,28 @@ builtin_complex(self, args)
308308 "complex() argument can't be converted to complex" );
309309 return NULL ;
310310 }
311+ /* XXX Hack to support classes with __complex__ method */
312+ if (is_instanceobject (r )) {
313+ static object * complexstr ;
314+ object * f ;
315+ if (complexstr == NULL ) {
316+ complexstr = newstringobject ("__complex__" );
317+ if (complexstr == NULL )
318+ return NULL ;
319+ }
320+ f = getattro (r , complexstr );
321+ if (f == NULL )
322+ err_clear ();
323+ else {
324+ object * args = mkvalue ("()" );
325+ if (args == NULL )
326+ return NULL ;
327+ r = call_object (f , args );
328+ DECREF (args );
329+ if (r == NULL )
330+ return NULL ;
331+ }
332+ }
311333 if (is_complexobject (r ))
312334 cr = ((complexobject * )r )-> cval ;
313335 else {
@@ -632,7 +654,7 @@ builtin_map(self, args)
632654
633655 /* XXX Special case map(None, single_list) could be more efficient */
634656 for (i = 0 ; ; ++ i ) {
635- object * alist , * item , * value ;
657+ object * alist , * item = NULL , * value ;
636658 int any = 0 ;
637659
638660 if (func == None && n == 1 )
You can’t perform that action at this time.
0 commit comments