Better YAML error introspection (#23767)
Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
This commit is contained in:
parent
c35484bbf6
commit
ee4dcb4cae
@ -619,10 +619,15 @@ class YAML:
|
||||
# Try loading YAML with fallback for problematic characters
|
||||
try:
|
||||
data = instance.yaml.load(s, Loader=instance.SafeLoader) or {}
|
||||
except Exception:
|
||||
except Exception as e:
|
||||
# Remove problematic characters and retry
|
||||
s = re.sub(r"[^\x09\x0A\x0D\x20-\x7E\x85\xA0-\uD7FF\uE000-\uFFFD\U00010000-\U0010ffff]+", "", s)
|
||||
data = instance.yaml.load(s, Loader=instance.SafeLoader) or {}
|
||||
try:
|
||||
data = instance.yaml.load(s, Loader=instance.SafeLoader) or {}
|
||||
except Exception:
|
||||
raise ValueError(
|
||||
f"YAML syntax error in '{file}': {e}\nVerify YAML with https://ray.run/tools/yaml-formatter"
|
||||
) from None
|
||||
|
||||
# Check for accidental user-error None strings (should be 'null' in YAML)
|
||||
if "None" in data.values():
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user