-
Notifications
You must be signed in to change notification settings - Fork 281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
syntax
: valid yaml [\?]
raises syntax error
#594
Comments
PyYAML doesn't view it as valid $ cat << 'EOF' | python3 -c 'import sys, yaml, json; y=yaml.safe_load(sys.stdin.read()); print(json.dumps(y))'
[\?]
EOF
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/andrewimeson/Documents/Code/personal/yamllint/issue_594/.venv/lib/python3.11/site-packages/yaml/__init__.py", line 125, in safe_load
return load(stream, SafeLoader)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/andrewimeson/Documents/Code/personal/yamllint/issue_594/.venv/lib/python3.11/site-packages/yaml/__init__.py", line 81, in load
return loader.get_single_data()
^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/andrewimeson/Documents/Code/personal/yamllint/issue_594/.venv/lib/python3.11/site-packages/yaml/constructor.py", line 49, in get_single_data
node = self.get_single_node()
^^^^^^^^^^^^^^^^^^^^^^
File "/Users/andrewimeson/Documents/Code/personal/yamllint/issue_594/.venv/lib/python3.11/site-packages/yaml/composer.py", line 36, in get_single_node
document = self.compose_document()
^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/andrewimeson/Documents/Code/personal/yamllint/issue_594/.venv/lib/python3.11/site-packages/yaml/composer.py", line 55, in compose_document
node = self.compose_node(None, None)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/andrewimeson/Documents/Code/personal/yamllint/issue_594/.venv/lib/python3.11/site-packages/yaml/composer.py", line 82, in compose_node
node = self.compose_sequence_node(anchor)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/andrewimeson/Documents/Code/personal/yamllint/issue_594/.venv/lib/python3.11/site-packages/yaml/composer.py", line 110, in compose_sequence_node
while not self.check_event(SequenceEndEvent):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/andrewimeson/Documents/Code/personal/yamllint/issue_594/.venv/lib/python3.11/site-packages/yaml/parser.py", line 98, in check_event
self.current_event = self.state()
^^^^^^^^^^^^
File "/Users/andrewimeson/Documents/Code/personal/yamllint/issue_594/.venv/lib/python3.11/site-packages/yaml/parser.py", line 483, in parse_flow_sequence_entry
raise ParserError("while parsing a flow sequence", self.marks[-1],
yaml.parser.ParserError: while parsing a flow sequence
in "<unicode string>", line 1, column 1:
[\?]
^
expected ',' or ']', but got '?'
in "<unicode string>", line 1, column 3:
[\?]
^ Nor does YAML is a superset of JSON, so the output you produced is valid JSON and YAML This is equivalent to your JSON as well, and yamllint and other tools can parse it without issue. - \? |
Hmm, it does work for me in pyyaml:
Edit: It works with |
Opened yaml/pyyaml#753 |
Bug is not in this repo, so let's close it. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
[\?]
is valid according to various other parsers, but this one rejects it:It should decode to JSON
["\\?"]
.The text was updated successfully, but these errors were encountered: