Skip to content

Added flag to ignore aliases/anchors#104

Closed
engnadeau wants to merge 1 commit into
yaml:masterfrom
engnadeau:no-aa
Closed

Added flag to ignore aliases/anchors#104
engnadeau wants to merge 1 commit into
yaml:masterfrom
engnadeau:no-aa

Conversation

@engnadeau
Copy link
Copy Markdown

@engnadeau
Copy link
Copy Markdown
Author

Only Python 2.6 fails, but it's EOL.

@engnadeau
Copy link
Copy Markdown
Author

This PR will depend on #105

@perlpunk
Copy link
Copy Markdown
Member

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
Copy link
Copy Markdown
Member

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.

@engnadeau
Copy link
Copy Markdown
Author

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

@jonasw234 jonasw234 mentioned this pull request Nov 23, 2018
@engnadeau
Copy link
Copy Markdown
Author

closing stale PR

@engnadeau engnadeau closed this Aug 23, 2019
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

Successfully merging this pull request may close these issues.

Disable Aliases/Anchors

2 participants