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

pyyaml can't parse the character = in some places #846

Open
thatch opened this issue Feb 13, 2025 · 0 comments
Open

pyyaml can't parse the character = in some places #846

thatch opened this issue Feb 13, 2025 · 0 comments

Comments

@thatch
Copy link

thatch commented Feb 13, 2025

The special value tag appears to be unhandled in several locations. For example,

>>> from yaml import load, Loader
>>> load("=:", Loader=Loader)
{'=': None}
>>> load("=", Loader=Loader)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/timhatch/code/codemod-yaml/.venv/lib/python3.12/site-packages/yaml/__init__.py", line 81, in load
    return loader.get_single_data()
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/timhatch/code/codemod-yaml/.venv/lib/python3.12/site-packages/yaml/constructor.py", line 51, in get_single_data
    return self.construct_document(node)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/timhatch/code/codemod-yaml/.venv/lib/python3.12/site-packages/yaml/constructor.py", line 55, in construct_document
    data = self.construct_object(node)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/timhatch/code/codemod-yaml/.venv/lib/python3.12/site-packages/yaml/constructor.py", line 100, in construct_object
    data = constructor(self, node)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/timhatch/code/codemod-yaml/.venv/lib/python3.12/site-packages/yaml/constructor.py", line 427, in construct_undefined
    raise ConstructorError(None, None,
yaml.constructor.ConstructorError: could not determine a constructor for the tag 'tag:yaml.org,2002:value'
  in "<unicode string>", line 1, column 1:
    =
    ^

but it's not just a bug at the root of document, see

>>> load("=: =", Loader=Loader)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/timhatch/code/codemod-yaml/.venv/lib/python3.12/site-packages/yaml/__init__.py", line 81, in load
    return loader.get_single_data()
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/timhatch/code/codemod-yaml/.venv/lib/python3.12/site-packages/yaml/constructor.py", line 51, in get_single_data
    return self.construct_document(node)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/timhatch/code/codemod-yaml/.venv/lib/python3.12/site-packages/yaml/constructor.py", line 60, in construct_document
    for dummy in generator:
                 ^^^^^^^^^
  File "/Users/timhatch/code/codemod-yaml/.venv/lib/python3.12/site-packages/yaml/constructor.py", line 413, in construct_yaml_map
    value = self.construct_mapping(node)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/timhatch/code/codemod-yaml/.venv/lib/python3.12/site-packages/yaml/constructor.py", line 218, in construct_mapping
    return super().construct_mapping(node, deep=deep)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/timhatch/code/codemod-yaml/.venv/lib/python3.12/site-packages/yaml/constructor.py", line 143, in construct_mapping
    value = self.construct_object(value_node, deep=deep)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/timhatch/code/codemod-yaml/.venv/lib/python3.12/site-packages/yaml/constructor.py", line 100, in construct_object
    data = constructor(self, node)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/timhatch/code/codemod-yaml/.venv/lib/python3.12/site-packages/yaml/constructor.py", line 427, in construct_undefined
    raise ConstructorError(None, None,
yaml.constructor.ConstructorError: could not determine a constructor for the tag 'tag:yaml.org,2002:value'
  in "<unicode string>", line 1, column 4:
    =: =
       ^
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

1 participant