This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jdwhitley
Recipients jdwhitley
Date 2010-08-12.07:12:40
SpamBayes Score 3.607447e-07
Marked as misclassified No
Message-id <1281597162.74.0.823446392009.issue9574@psf.upfronthosting.co.za>
In-reply-to
Content
complex() raises ValueError when parsing a string argument containing both real and imaginary where one of the real or imaginary is a decimal.

To reproduce:

>>> complex("1.1 + 2.1j")
ValueError: complex() arg is a malformed string

>>> complex("2.1j")
2.1j

>>> complex("1.1 + 2j")
ValueError: complex() arg is a malformed string

>>> complex("1 + 2.1j")
ValueError: complex() arg is a malformed string 

Expected results:

>>> complex("1.1 + 2.1j")
(1.1 + 2.1j)

>>> complex("2.1j")
2.1j

>>> complex("1.1 + 2j")
(1.1 + 2j)

>>> complex("1 + 2.1j")
(1 + 2.1j)

This affects all versions up to Python 3.1.2. I haven't tested any of the development builds.

Tests were conducted on a Windows XP 32 bit machine.
History
Date User Action Args
2010-08-12 07:12:42jdwhitleysetrecipients: + jdwhitley
2010-08-12 07:12:42jdwhitleysetmessageid: <1281597162.74.0.823446392009.issue9574@psf.upfronthosting.co.za>
2010-08-12 07:12:41jdwhitleylinkissue9574 messages
2010-08-12 07:12:40jdwhitleycreate