Skip to content

Remove call to ord in lib3 emitter code#129

Closed
scauligi wants to merge 1 commit into
yaml:masterfrom
scauligi:master
Closed

Remove call to ord in lib3 emitter code#129
scauligi wants to merge 1 commit into
yaml:masterfrom
scauligi:master

Conversation

@scauligi
Copy link
Copy Markdown

@scauligi scauligi commented Feb 4, 2018

Fixes issue #118
encode produces a bytestring, and iterating over a bytestring in python 3 produces ints instead of chars

@perlpunk
Copy link
Copy Markdown
Member

I vote for merging. @ingydotnet @sigmavirus24 or anyone else, thoughts?

@ingydotnet
Copy link
Copy Markdown
Member

Can we get a test to support this change?

@perlpunk
Copy link
Copy Markdown
Member

Here's a test reproducing it:

import yaml

l = lambda: None
d = yaml.dump({ 'l': l }, default_flow_style=False)

print(d)
assert(d == "l: !!python/name:__main__.%3Clambda%3E ''\n")

Currently it produces an exception in python3:

...
  File "lib3/yaml/emitter.py", line 607, in prepare_tag
    chunks.append('%%%02X' % ord(ch))
TypeError: ord() expected string of length 1, but int found

@perlpunk
Copy link
Copy Markdown
Member

merged in d13a3d0

@perlpunk perlpunk closed this Mar 14, 2019
@perlpunk perlpunk mentioned this pull request Mar 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants