pyyaml
pyyaml copied to clipboard
`[\?]` fails to parse in `Loader` but works in `CLoader`
The string [\?]
parses fine in CLoader
while Loader
fails to do so. Is it expected?
$ python3
Python 3.11.5 (main, Aug 24 2023, 15:18:16) [Clang 14.0.3 (clang-1403.0.22.14.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from yaml import load, CLoader, Loader
>>> load('[\?]', CLoader)
['\\?']
>>> load('[\?]', Loader)
...
File "/usr/local/lib/python3.11/site-packages/yaml/parser.py", line 98, in check_event
self.current_event = self.state()
^^^^^^^^^^^^
File "/usr/local/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:
[\?]
^
duplicate of #128
Okay, but shouldn't both loaders either fail or succeed in tandem?
Ideally, yes, but it has to be implemented in both libyaml and pyyaml. First, the maintainers of pyyaml should be clear if they want that fix or not