Custom Query (132 matches)

Filters
 
Or
 
  
 
Columns

Show under each result:


Results (49 - 51 of 132)

Ticket Resolution Summary Owner Reporter
#59 worksforme Load yaml data as utf-8 strings into a dictionary xi dukebody@…

Reported by dukebody@…, 7 years ago.

Description

Hello, I'm looking for support, but I don't know if this is the right place to ask.

I'm using PyYAML to load some nested data from an utf-8 encoded file in Python with:

import yaml
stream=file('data.yaml','r')
data=yaml.load(stream)

The data variable becomes a dictionary with unicode values where is needed. What I want is to put utf-8 strings instead of unicode values to use this data with another library: Cheetah. If I try to use the unicode-type dictionary generated by default with PyYAML I get an UnicodeDecodeError, because de Cheetah strings are in iso-8859-15 and Python tries to decode them to Unicode using ASCII charset tables, so it obiously fails.

Is there any way to get an utf-8 coded dictionary?

#60 fixed Error loading timestamps xi miki@…

Reported by miki@…, 7 years ago.

Description

Try the following script:

#!/usr/bin/env python

import syck
from datetime import datetime

for i in range(10000):
    now = datetime.now()
    dumped = syck.dump(now)
    loaded = syck.load(dumped)
    if now != loaded:
        print "original:", now
        print "result:", loaded
        print "dump:", dumped
        break

I get:

original: 2007-09-17 11:04:08.091612
result: 2007-09-17 11:04:08.916120
dump: --- !timestamp 2007-09-17T11:04:08.091612

The YAML looks OK, so the parsing is wrong.

#62 fixed value token of single period ('.') is parsed incorrectly, throws wrong exception xi sproaticus

Reported by sproaticus, 7 years ago.

Description

A scalar value token consisting of just a period ('.') is interpreted as a float value. When construct_yaml_float() creates a float using this value, it throws an uncaught ValueError instead of yaml.YAMLError

(Also, what's PIL doing in the stack? I didn't import it.)

>>> yaml.load('yaml: .')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.5/site-packages/PIL/__init__.py", line 66, in load
    
  File "build/bdist.linux-i686/egg/yaml/constructor.py", line 38, in get_data
  File "build/bdist.linux-i686/egg/yaml/constructor.py", line 46, in construct_document
  File "build/bdist.linux-i686/egg/yaml/constructor.py", line 394, in construct_yaml_map
  File "build/bdist.linux-i686/egg/yaml/constructor.py", line 207, in construct_mapping
  File "build/bdist.linux-i686/egg/yaml/constructor.py", line 132, in construct_mapping
  File "build/bdist.linux-i686/egg/yaml/constructor.py", line 87, in construct_object
  File "build/bdist.linux-i686/egg/yaml/constructor.py", line 281, in construct_yaml_float
ValueError: invalid literal for float(): .

Environment:

  • Python 2.5.1 (r251:54863, May 2 2007, 16:56:35) [GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2
  • PyYAML-3.05-py2.5.egg
Note: See TracQuery for help on using queries.