Modify ↓
Ticket #96 (new defect)
Added note about UnicodeError instead of the tuple of multiple classes. Also, bumping this ;-)
| Reported by: | mike@… | Owned by: | xi |
|---|---|---|---|
| Priority: | normal | Component: | pysyck |
| Severity: | normal | Keywords: | |
| Cc: |
Description
>>> import syck
>>> syck.dump({'blah' : '\xea\xd3'})
Traceback (most recent call last):
File "C:\workspace\Digsby\syck_test.py", line 2, in <module>
syck.dump({'blah' : '\xea\xd3'})
File "C:\workspace\dpython\lib\site-packages\syck\dumpers.py", line 295, in dump
dumper.dump(object)
File "C:\workspace\dpython\lib\site-packages\syck\dumpers.py", line 23, in dump
self.emit(self._convert(object, {}))
File "C:\workspace\dpython\lib\site-packages\syck\dumpers.py", line 40, in _convert
self._convert(value, object_to_node)
File "C:\workspace\dpython\lib\site-packages\syck\dumpers.py", line 28, in _convert
node = self.represent(object)
File "C:\workspace\dpython\lib\site-packages\syck\dumpers.py", line 97, in represent
return representer(object)
File "C:\workspace\dpython\lib\site-packages\syck\dumpers.py", line 112, in represent_str
return _syck.Scalar(object.encode('ascii'), tag="tag:yaml.org,2002:str")
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: ordinal not in range(128)
This can be fixed by changing line 115 of dumpers.py from
except UnicodeDecodeError:
to
except (UnicodeDecodeError, UnicodeEncodeError):
I left the UnicodeDecodeError? in the except clause, but I don't think catching it is necessary unless _syck.Scalar(...) can raise a UnicodeDecodeError? (I wasn't certain of this, nor am I sure how to find out).
Feel free to contact me for more info.
Attachments
Change History
Note: See
TracTickets for help on using
tickets.

Alternatively instead of
the equivalent
can be used.