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

Implicit Resolvers do not appear to work with PyYAML 5.1 #294

Closed
cfeenstra67 opened this issue Apr 21, 2019 · 7 comments
Closed

Implicit Resolvers do not appear to work with PyYAML 5.1 #294

cfeenstra67 opened this issue Apr 21, 2019 · 7 comments

Comments

@cfeenstra67
Copy link

I've noticed that with PyYAML 5.1 implicit resolvers do not seem to work at all. Using this example script:

import re
import uuid
import yaml

regex = re.compile(r'^UUID\((.+)\)$')
yaml.add_implicit_resolver('!uuid', regex)

def convert_uuid(loader, node):
    value = loader.construct_scalar(node)
    str_value = regex.match(value).group(1)
    return uuid.UUID(str_value)

yaml.add_constructor('!uuid', convert_uuid)

print(yaml.load('''
    config:
        abc: UUID(6a02171e-6482-11e9-ab43-f2189845f1cc)
        def: abc
'''))

I confirmed that w/ 3.13 we correctly get the uuid.UUID object, while it is a string with 5.1 is it just the string 'UUID(6a02171e-6482-11e9-ab43-f2189845f1cc)'. The way I found this was that it broke the environment variable interpolation that elasticsearch-curator provides.

Sorry if this is a duplicate, I searched around and could not find an equivalent issue.

@cfeenstra67
Copy link
Author

After looking around this appears to be the same issue as #266 , I confirmed it does work with Loader set. It does seem to be a bug, but I'll close this issue as it's covered there

@perlpunk
Copy link
Member

@ingydotnet I suggest to reopen because add_implicit_resolver is not yet covered by the fixes.
(also add_path_resolver btw)

@perlpunk
Copy link
Member

I'm reopening this for @ingydotnet

@perlpunk perlpunk reopened this May 27, 2019
@perlpunk
Copy link
Member

I created #305 to fix this

@perlpunk
Copy link
Member

We just released 5.2b1 https://pypi.org/project/PyYAML/5.2b1/ which should fix this.

@perlpunk
Copy link
Member

perlpunk commented Dec 2, 2019

We released 5.2: https://pypi.org/project/PyYAML/5.2/

@perlpunk
Copy link
Member

perlpunk commented Dec 2, 2019

Closing. Please reopen if necessary. Thanks!

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