[Patches] [ python-Patches-479551 ] fix complex() with 2 string args

noreply@sourceforge.net noreply@sourceforge.net
Thu, 08 Nov 2001 07:31:52 -0800


Patches item #479551, was opened at 2001-11-08 05:21
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=479551&group_id=5470

Category: Core (C code)
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Michael Hudson (mwh)
Assigned to: Fred L. Drake, Jr. (fdrake)
Summary: fix complex() with 2 string args

Initial Comment:
reported on c.l.py

>>> complex ("1", "1")
(1+0j)

>From my reading of the docs, this should fail.  Patch
does this, adds test case.

Assigned to Fred, largely at random.

----------------------------------------------------------------------

>Comment By: Skip Montanaro (montanaro)
Date: 2001-11-08 07:31

Message:
Logged In: YES 
user_id=44345

I have a slightly different patch.  If the first arg is not
a string, the second arg can't be a string.  The current
implementation raises a TypeError with a not entirely
comprehensible message, so I added a special case to catch
that.  Also, my test cases are in test_complex.py instead of
test_b1.py and I have some doc changes.  (God, I just
*loooove* the new diff-mode in XEmacs 21.4.  Ya gotta try it
-- if you're not a vi-head, that is!)


----------------------------------------------------------------------

Comment By: Grant Griffin (dspguru)
Date: 2001-11-08 07:13

Message:
Logged In: YES 
user_id=70844

I agree with the discussion on c.l.py as to the 
interpretation of the docs, so it sounds like Michael's 
patch is a good thing.  However, along with the patch, I'd 
like to see the docs clarified a little.  Specifically, it 
would be nice if the docs stated that the imaginary part 
(if any) can be specified as part of the string using the 
standard "j" suffix:

   ActivePython 2.1.1, build 212 (ActiveState)
   >>> complex('1+1j')
   (1+1j)

This feature appears to be the reason that a separate 
imaginary argument was disallowed in the string case, so 
spelling that aspect out will help people understand (and 
therefore remember) the rules on this.

=g2

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=479551&group_id=5470