convert : fix Norway problem when parsing YAML#12114
Merged
ngxson merged 3 commits intoggml-org:masterfrom Feb 28, 2025
Merged
Conversation
Contributor
Author
|
The problem seems to be fixed on yaml 1.2 specs, but |
compilade
reviewed
Feb 28, 2025
compilade
reviewed
Feb 28, 2025
Comment on lines
+146
to
+149
| yaml_content += "\n" | ||
| yaml_content = yaml_content.replace("- no\n", "- \"no\"\n") | ||
|
|
||
| if yaml_content: |
Collaborator
There was a problem hiding this comment.
Now this if is always true, because of the extra new line.
Maybe the extra \n should be added only when joining the lines?
diff --git a/gguf-py/gguf/metadata.py b/gguf-py/gguf/metadata.py
index 0629306bb..e807f4346 100644
--- a/gguf-py/gguf/metadata.py
+++ b/gguf-py/gguf/metadata.py
@@ -139,11 +139,10 @@ class Metadata:
break # End of frontmatter
else:
lines_yaml.append(line)
- yaml_content = "\n".join(lines_yaml)
+ yaml_content = "\n".join(lines_yaml) + "\n"
# Quick hack to fix the Norway problem
# https://hitchdev.com/strictyaml/why/implicit-typing-removed/
- yaml_content += "\n"
yaml_content = yaml_content.replace("- no\n", "- \"no\"\n")
if yaml_content:
compilade
approved these changes
Feb 28, 2025
arthw
pushed a commit
to arthw/llama.cpp
that referenced
this pull request
Mar 19, 2025
* convert : fix Norway problem when parsing YAML * Update gguf-py/gguf/metadata.py * add newline at correct place
Seunghhon
pushed a commit
to Seunghhon/llama.cpp
that referenced
this pull request
Apr 26, 2026
* convert : fix Norway problem when parsing YAML * Update gguf-py/gguf/metadata.py * add newline at correct place
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related to #12091 (comment)
The problem is:
- noThe YAML above will be interpreted as "yes/no", which is translated into true/false boolean value.
The fix? Do a replace
no-->"no"CC @mofosyne @compilade if you have a better solution