TypeError raised from ord() call in yaml.emit
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 66/100
Research direction
Read emitter.py at prepare_tag_prefix around line 575, then run the supplied BytesIO reproducer through yaml.parse and yaml.emit. Done means this input emits without the TypeError, with a regression check covering the reported case.
Written by the indexing model from the issue text.
Description
The below code results in a TypeError: ord() expected string of length 1, but int found when yaml.emit is called. This occurs in the function prepare_tag_prefix at line 575 in emitter.py.
Minimized Reproducer:
import io
import yaml
text = io.BytesIO( b"%TAG ! tag:%002:\n---")
events = list(yaml.parse(text))
output = yaml.emit(events)
Version Information:
7.0.0.dev0
also occurs in the current release: 6.0.2
Exception Trace:
File "/rep.py", line 6, in <module>
output = yaml.emit(events)
File "lib/python3.9/site-packages/yaml/__init__.py", line 172, in emit
dumper.emit(event)
File "lib/python3.9/site-packages/yaml/emitter.py", line 115, in emit
self.state()
File "lib/python3.9/site-packages/yaml/emitter.py", line 176, in expect_first_document_start
return self.expect_document_start(first=True)
File "lib/python3.9/site-packages/yaml/emitter.py", line 193, in expect_document_start
prefix_text = self.prepare_tag_prefix(prefix)
File "lib/python3.9/site-packages/yaml/emitter.py", line 575, in prepare_tag_prefix
chunks.append('%%%02X' % ord(ch))
TypeError: ord() expected string of length 1, but int found
- Dominant language
- Python
- Stars
- 2.9k
- Forks
- 607
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from yaml/pyyaml
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
-
Cannot output integer-like strings as strings unless they pass the overly-restrictive integer regex Open
Difficulty 3/5 1-2 days Newbie friendliness 68/100
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100