Skip to content
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

[\?] fails to parse in Loader but works in CLoader #753

Open
silverwind opened this issue Sep 8, 2023 · 3 comments
Open

[\?] fails to parse in Loader but works in CLoader #753

silverwind opened this issue Sep 8, 2023 · 3 comments

Comments

@silverwind
Copy link

silverwind commented Sep 8, 2023

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:
    [\?]
      ^
@silverwind silverwind changed the title [\?] fails to parse in Loader but not CLoader [\?] fails to parse in Loader but works in CLoader Sep 8, 2023
@perlpunk
Copy link
Member

perlpunk commented Sep 8, 2023

duplicate of #128

@silverwind
Copy link
Author

silverwind commented Sep 8, 2023

Okay, but shouldn't both loaders either fail or succeed in tandem?

@perlpunk
Copy link
Member

perlpunk commented Sep 8, 2023

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

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

No branches or pull requests

2 participants