Skip to content

Conversation

@abderrahim
Copy link
Contributor

This moves the ruamel-yaml CParser import instantiation outside of try-catch. The catch reports 'Severely malformed YAML', which isn't the case if you you cant't import CParser

This moves the ruamel-yaml CParser import instantiation outside of try-catch.
The catch reports 'Severely malformed YAML', which isn't the case if you you
cant't import CParser
cpdef MappingNode load_data(str data, int file_index=node._SYNTHETIC_FILE_INDEX, str file_name=None, bint copy_tree=False):
cdef Representer rep

try:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, we would have the precise exception below instead of the blind except Exception statement.

Given that determining what exception specifically is raised there may be quite difficult, I think I'd still be more comfortable with an additional except ImportError block, so that anything else happening inside the yaml.CParser(data) constructor is still in the try block.

E.g. just adding the following before the blind except may be preferrable:

try:
   ...
except ImportError as e:
    raise e
except Exception:
   ... keeping the same blind except...
``

@juergbi
Copy link
Contributor

juergbi commented Nov 14, 2025

Link to relevant issue: #1833

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.

3 participants