id,summary,reporter,owner,description,type,status,priority,component,severity,resolution,keywords,cc
8,Comparison operations fail with floats (NaN and +/- Inf) in PyYAML3000 on WinXP (SP2),Peter Murphy (pkmurphy@…,xi,"This is what happens when you run the test suite under WinXP (SP2) and Python 2.4:

{{{
C:\pyyaml\trunk>python tests/test_build.py 
..............................................................................................................................................................................................................................................................................F..........................E........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................E..........................E............................................................................................................................................................
======================================================================
ERROR: testTypes_float_representer_2_3_bug (test_constructor.TestConstructorTypes)
----------------------------------------------------------------------
Traceback (most recent call last):
  File ""C:\pyyaml\trunk\tests\test_appliance.py"", line 28, in test_method
    getattr(self, '_'+method_name)(test, *filenames)
  File ""C:\pyyaml\trunk\tests\test_constructor.py"", line 249, in _testTypes
    data1 = list(load_all(file(data_filename, 'rb'), Loader=MyLoader))
  File ""build/lib\yaml\__init__.py"", line 52, in load_all
    yield loader.get_data()
  File ""build/lib\yaml\constructor.py"", line 41, in get_data
    return self.construct_document(self.get_node())
  File ""build/lib\yaml\constructor.py"", line 49, in construct_document
    data = self.construct_object(node)
  File ""build/lib\yaml\constructor.py"", line 86, in construct_object
    data = constructor(node)
  File ""build/lib\yaml\constructor.py"", line 63, in <lambda>
    constructor = lambda node: self.yaml_constructors[node.tag](self, node)
  File ""build/lib\yaml\constructor.py"", line 358, in construct_yaml_map
    return self.construct_mapping(node)
  File ""build/lib\yaml\constructor.py"", line 153, in construct_mapping
    ""found duplicate key"", key_node.start_mark)
ConstructorError: while constructing a mapping
  in ""tests/data\float-representer-2.3-bug.data"", line 2, column 1
found duplicate key
  in ""tests/data\float-representer-2.3-bug.data"", line 3, column 1

======================================================================
ERROR: testTypes_construct_float (test_representer.TestRepresenterTypes)
----------------------------------------------------------------------
Traceback (most recent call last):
  File ""C:\pyyaml\trunk\tests\test_appliance.py"", line 28, in test_method
    getattr(self, '_'+method_name)(test, *filenames)
  File ""C:\pyyaml\trunk\tests\test_representer.py"", line 15, in _testTypes
    data2 = load(output, Loader=MyLoader)
  File ""build/lib\yaml\__init__.py"", line 61, in load
    return loader.get_data()
  File ""build/lib\yaml\constructor.py"", line 41, in get_data
    return self.construct_document(self.get_node())
  File ""build/lib\yaml\constructor.py"", line 49, in construct_document
    data = self.construct_object(node)
  File ""build/lib\yaml\constructor.py"", line 86, in construct_object
    data = constructor(node)
  File ""build/lib\yaml\constructor.py"", line 63, in <lambda>
    constructor = lambda node: self.yaml_constructors[node.tag](self, node)
  File ""build/lib\yaml\constructor.py"", line 358, in construct_yaml_map
    return self.construct_mapping(node)
  File ""build/lib\yaml\constructor.py"", line 154, in construct_mapping
    value = self.construct_object(node.value[key_node])
  File ""build/lib\yaml\constructor.py"", line 86, in construct_object
    data = constructor(node)
  File ""build/lib\yaml\constructor.py"", line 63, in <lambda>
    constructor = lam
DATA:
canonical: 6.8523015e+5
exponential: 685.230_15e+03
fixed: 685_230.15
sexagesimal: 190:20:30.15
negative infinity: -.inf
not a number: .NaN

CODE:
{
    ""canonical"": 685230.15,
    ""exponential"": 685230.15,
    ""fixed"": 685230.15,
    ""sexagesimal"": 685230.15,
    ""negative infinity"": -1e300000,
    ""not a number"": 1e300000/1e300000,
}

NATIVES1: [(""'canonical'"", 685230.15000000002), (""'exponential'"", 685230.15000000002), (""'fixed'"", 685230.15000000002), (""'negative infinity'"", -1.0), (""'not a number'"", 1.0), (""'sexagesimal'"", 685230.15000000002)]
NATIVES2: [(""'canonical'"", 685230.15000000002), (""'exponential'"", 685230.15000000002), (""'fixed'"", 685230.15000000002), (""'negative infinity'"", -1.#INF), (""'not a number'"", -1.#IND), (""'sexagesimal'"", 685230.15000000002)]

DATA:
#0.0:   # hash(0) == hash(nan) and 0 == nan in Python 2.3
1.0: 1
+.inf: 10
-.inf: -10
.nan: 100

CODE:
{
#    0.0: 0,
    1.0: 1,
    1e300000: +10,
    -1e300000: -10,
    1e300000/1e300000: 100,
}

NATIVES1: None
NATIVES2: None

OUTPUT:
{negative infinity: !!float '-1.#INF', not a number: !!float '-1.#IND', sexagesimal: 685230.15000000002,
  fixed: 685230.15000000002, canonical: 685230.15000000002, exponential: 685230.15000000002}

NATIVES1: {'exponential': 685230.15000000002, 'negative infinity': -1.#INF, 'sexagesimal': 685230.15000000002, 'not a number': -1.#IND, 'fixed': 685230.15000000002, 'canonical': 685230.15000000002}
NATIVES2: None

OUTPUT:
{!!float '-1.#IND': 100, .inf: 1, !!float '-1.#INF': -10, !!float '1.#INF': 10}

NATIVES1: {-1.#IND: 100, 1.0: 1, -1.#INF: -10, 1.#INF: 10}
NATIVES2: None
bda node: self.yaml_constructors[node.tag](self, node)
  File ""build/lib\yaml\constructor.py"", line 259, in construct_yaml_float
    return float(value)
ValueError: invalid literal for float(): 1.#IND

======================================================================
ERROR: testTypes_float_representer_2_3_bug (test_representer.TestRepresenterTypes)
----------------------------------------------------------------------
Traceback (most recent call last):
  File ""C:\pyyaml\trunk\tests\test_appliance.py"", line 28, in test_method
    getattr(self, '_'+method_name)(test, *filenames)
  File ""C:\pyyaml\trunk\tests\test_representer.py"", line 15, in _testTypes
    data2 = load(output, Loader=MyLoader)
  File ""build/lib\yaml\__init__.py"", line 61, in load
    return loader.get_data()
  File ""build/lib\yaml\constructor.py"", line 41, in get_data
    return self.construct_document(self.get_node())
  File ""build/lib\yaml\constructor.py"", line 49, in construct_document
    data = self.construct_object(node)
  File ""build/lib\yaml\constructor.py"", line 86, in construct_object
    data = constructor(node)
  File ""build/lib\yaml\constructor.py"", line 63, in <lambda>
    constructor = lambda node: self.yaml_constructors[node.tag](self, node)
  File ""build/lib\yaml\constructor.py"", line 358, in construct_yaml_map
    return self.construct_mapping(node)
  File ""build/lib\yaml\constructor.py"", line 145, in construct_mapping
    key = self.construct_object(key_node)
  File ""build/lib\yaml\constructor.py"", line 86, in construct_object
    data = constructor(node)
  File ""build/lib\yaml\constructor.py"", line 63, in <lambda>
    constructor = lambda node: self.yaml_constructors[node.tag](self, node)
  File ""build/lib\yaml\constructor.py"", line 259, in construct_yaml_float
    return float(value)
ValueError: invalid literal for float(): 1.#IND

======================================================================
FAIL: testTypes_construct_float (test_constructor.TestConstructorTypes)
----------------------------------------------------------------------
Traceback (most recent call last):
  File ""C:\pyyaml\trunk\tests\test_appliance.py"", line 28, in test_method
    getattr(self, '_'+method_name)(test, *filenames)
  File ""C:\pyyaml\trunk\tests\test_constructor.py"", line 255, in _testTypes
    self.failUnlessEqual(data1, data2)
AssertionError: {'exponential': 685230.15000000002, 'negative infinity': -1.0, 'sexagesimal': 685230.15000000002, 'not a number': 1.0, 'fixed': 685230.15000000002, 'canonical': 685230.15000000002} != {'exponential': 685230.15000000002, 'negative infinity': -1.#INF, 'sexagesimal': 685230.15000000002, 'not a number': -1.#IND, 'fixed': 685230.15000000002, 'canonical': 685230.15000000002}

----------------------------------------------------------------------
Ran 1130 tests in 7.781s

FAILED (failures=1, errors=3)
>Exit code: 1
}}}",defect,closed,normal,pyyaml,normal,fixed,,
