Custom Query (132 matches)

Filters
 
Or
 
  
 
Columns

Show under each result:


Results (13 - 15 of 132)

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Ticket Resolution Summary Owner Reporter
#15 fixed pyyaml discards '-' sign on negative floats xi alex_(a)_alexmole_(o)_co_(o)_uk

Reported by alex_(a)_alexmole_(o)_co_(o)_uk, 8 years ago.

Description

yaml.load( 'foo: -3.1' ) returns {'foo': 3.10000}

The same technique preserves the sign of integers though, so I presume it must be a bug rather than a yaml feature.

#17 fixed Single quote character can break emitter output xi apopheniac.reply.pyyaml@…

Reported by apopheniac.reply.pyyaml@…, 8 years ago.

Description

If a string contains a space followed by a single quote character, PyYaml?'s emitter fails to duplicate the single quote. The resulting YAML output yields a parse error:

>>> map = {'key': " 'single quoted text'"}
>>> yaml.dump(map)
"{key: ' 'single quoted text'''}\n"
>>> yaml.load(yaml.dump(map))
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/home/apopheniac/lib/python/yaml/__init__.py", line 61, in load
    return loader.get_data()
  File "/home/apopheniac/lib/python/yaml/constructor.py", line 41, in get_data
    return self.construct_document(self.get_node())
  File "/home/apopheniac/lib/python/yaml/composer.py", line 23, in get_node
    return self.compose_document()
  File "/home/apopheniac/lib/python/yaml/composer.py", line 40, in compose_document
    node = self.compose_node(None, None)
  File "/home/apopheniac/lib/python/yaml/composer.py", line 69, in compose_node
    node = self.compose_mapping_node(anchor)
  File "/home/apopheniac/lib/python/yaml/composer.py", line 112, in compose_mapping_node
    while not self.check_event(MappingEndEvent):
  File "/home/apopheniac/lib/python/yaml/parser.py", line 78, in check_event
    self.current_event = self.event_generator.next()
  File "/home/apopheniac/lib/python/yaml/parser.py", line 129, in parse_stream
    for event in self.parse_block_node():
  File "/home/apopheniac/lib/python/yaml/parser.py", line 323, in parse_node
    for event in collection_events:
  File "/home/apopheniac/lib/python/yaml/parser.py", line 472, in parse_flow_mapping
    "expected ',' or '}', but got %r" % token.id, token.start_mark)
yaml.parser.ParserError: while scanning a flow mapping
  in "<string>", line 1, column 1:
    {key: ' 'single quoted text'''}
    ^
expected ',' or '}', but got '<scalar>'
  in "<string>", line 1, column 10:
    {key: ' 'single quoted text'''}
             ^

If each single quote is preceded by a non-space character, then the error disappears:

>>> map = {"key": " foo'single quoted text'"}
>>> yaml.dump(map)
"{key: ' foo''single quoted text'''}\n"
>>> yaml.load(yaml.dump(map))
{'key': " foo'single quoted text'"}

The error seems to lie in the write_single_quoted function of module emitter.py. I've only encountered this problem with scalars represented in single quoted style.

#22 fixed Aliases break if there are temporary objects xi tim.hochberg@…

Reported by tim.hochberg@…, 8 years ago.

Description

If an object being passed to represet_data has a shorter lifespan than the representer, the results are unpredictable, but generally bad. In my case, I'm trying to represent a custom omap class. I register a representer like so:

def omap_representer(dumper, data):
    items = [[x, y] for (x, y) in data.iteritems()] 
    return dumper.represent_sequence(u'!omap', items)
    
yaml.add_representer(omap, omap_representer)

If I then dump something that contains multiple omaps, such as [one_omap,another_omap], the representer get's confused because it sees distinct objects that have the same id. Here's an actual example:

>>> a # Note that these are omaps not dictionaries, despite appearances.
[{1: 2, 2: 4}, {1: 99, 2: 88}]

>>> print yaml.dump(a)
- !omap
  - &id001 [1, 2]
  - &id002 [2, 4]
- !omap
  - *id001
  - *id002

Two approaches come to mind to fix this.

  1. Hold onto a reference to the original object as well as to the serialized object in represented_objects. This is what I did as a temporary fix.
  2. Do some sort of weak reference magic to track if an object dies and then delete it from represented_objects. This is more complicated and I'm not entirely sure it would work well. The upside is it's possibly more frugal with memory.

-tim

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