[New-bugs-announce] [issue9574] complex does not parse strings containing decimals

Jervis Whitley report at bugs.python.org
Thu Aug 12 09:12:42 CEST 2010


New submission from Jervis Whitley <jervisau at gmail.com>:

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.

----------
components: Interpreter Core
messages: 113661
nosy: jdwhitley
priority: normal
severity: normal
status: open
title: complex does not parse strings containing decimals
type: behavior
versions: Python 2.5, Python 2.6, Python 2.7, Python 3.1

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9574>
_______________________________________


More information about the New-bugs-announce mailing list