Custom Query (121 matches)

Filters
 
Or
 
  
 
Columns

Show under each result:


Results (7 - 9 of 121)

1 2 3 4 5 6 7 8 9 10 11 12 13
Ticket Resolution Summary Owner Reporter
#8 fixed Comparison operations fail with floats (NaN and +/- Inf) in PyYAML3000 on WinXP (SP2) xi Peter Murphy (pkmurphy@…

Reported by Peter Murphy (pkmurphy@…, 8 years ago.

Description

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
#9 fixed Forcing block style xi edemaine@…

Reported by edemaine@…, 8 years ago.

Description

Is there an easy way to force the emitter to use block style instead of flow style? I have one particular case in mind where it would be particularly desirable: ordered dictionaries. For example:

>>> yaml.load('[hello: world, goodbye: world]')
[{'hello': 'world'}, {'goodbye': 'world'}]
>>> print yaml.dump(_)
- {hello: world}
- {goodbye: world}

In my opinion, the output would look much nicer as

- hello: world
- goodbye: world

Even if you don't agree with this opinion, there should be a way to force block style in all output. I did not see an easy way to do this, even with subclassing. Suggestions?

#11 fixed Unicode support xi edemaine@…

Reported by edemaine@…, 8 years ago.

Description

I would like to bring up two issues with Unicode support in PyYAML's emitter. First, it emits a type annotation of !!python/unicode whenever emitting a unicode string that can be encoded in ASCII:

>>> print yaml.dump(u'Fran\xe7ais')
"Fran\xE7ais"

>>> print yaml.dump(u'hello')
!!python/unicode 'hello'

I assume this is to force the value to be a unicode string when read back in. However, it makes for rather ugly files. In my case, and I imagine many others, I really don't care whether a string is stored as a 'str' or as a 'unicode' object in Python. And in YAML, the native string type is Unicode anyway. So it seems strange to have this distinction at the level of the YAML file. On the other hand, I understand the desire to have yaml.load(yaml.dump(x)) == x. Perhaps this should be another configuration option? (Of course, I could just convert my ASCII-encodable unicode objects to str objects...)

The second issue is that the emitter escapes non-ASCII characters even when all characters are printable (according to 'c-printable' in the YAML spec) when using an encoding (UTF8) that supports such characters. I don't find this as elegant as could be. Instead of the "Fran\xE7ais" output above, I would have hoped for the UTF8-encoded byte string Fran\xc3\xa7ais\n.

I guess this is as stylistic an issue as the previous one. It makes me wonder again whether there should be a Style object that can specify various emitting options, instead of many keyword arguments...

1 2 3 4 5 6 7 8 9 10 11 12 13
Note: See TracQuery for help on using queries.