This is an automated email from the ASF dual-hosted git repository.

akitouni pushed a commit to branch abderrahim/ruamel-yaml-malformed
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 5323c39341acb461513e07a1e160cf4147b29d78
Author: Abderrahim Kitouni <[email protected]>
AuthorDate: Mon Nov 10 12:18:02 2025 +0100

    _yaml: fix confusing error message
    
    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
---
 src/buildstream/_yaml.pyx | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/buildstream/_yaml.pyx b/src/buildstream/_yaml.pyx
index c962bb881..dc2bc95ce 100644
--- a/src/buildstream/_yaml.pyx
+++ b/src/buildstream/_yaml.pyx
@@ -293,10 +293,10 @@ cpdef MappingNode load(str filename, str shortname, bint 
copy_tree=False, object
 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:
-        rep = Representer(file_index)
-        parser = yaml.CParser(data)
+    rep = Representer(file_index)
+    parser = yaml.CParser(data)
 
+    try:
         try:
             while parser.check_event():
                 rep.handle_event(parser.get_event())

Reply via email to