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

Added flag to ignore aliases/anchors #104

Open
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
2 participants
@nnadeau

nnadeau commented Nov 30, 2017

@nnadeau

This comment has been minimized.

nnadeau commented Dec 1, 2017

Only Python 2.6 fails, but it's EOL.

@nnadeau

This comment has been minimized.

nnadeau commented Dec 4, 2017

This PR will depend on #105

@perlpunk

This comment has been minimized.

Member

perlpunk commented Mar 17, 2018

I think this can be useful.
However, when using with cyclic references, we run into an endless loop. This is a problem with the existing code, so adding this flag doesn't introduce this problem, but makes it easy to reproduce:

import yaml

string = "&node [ a, b, *node ]"
data = yaml.load(string)
print(data)
out = yaml.dump(data, ignore_aliases=True)
print(out)

...
RecursionError: maximum recursion depth exceeded while calling a Python object

The code in represent_data should remember the nodes it has already visited and output null in that case.

I might have some time to fix this, but not sure when.

@perlpunk

This comment has been minimized.

Member

perlpunk commented Mar 17, 2018

On the other hand, if the desired behaviour is to expand all aliases, then we'd have to live with the possibility of an endless loop. The documentation should warn about this then.

@nnadeau

This comment has been minimized.

nnadeau commented Mar 17, 2018

Yes, my intention is to have no aliases at all, simplifying the YAML markup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment