@@ -444,7 +444,10 @@ def loads(data, conf=True):
444
444
kname , kval = re .match (key_regex , to_eval ).group (1 , 2 )
445
445
if "#" not in kname :
446
446
k = Key (kname , kval )
447
- lopen [0 ].add (k )
447
+ if lopen and isinstance (lopen [0 ], (Container , Server )):
448
+ lopen [0 ].add (k )
449
+ else :
450
+ f .add (k ) if conf else f .append (k )
448
451
if re .match (r'(^(?!#)([^#]*[}]{1}\s*)$)|(\s*{$)' , line_outside_quotes ):
449
452
closenum = len (re .findall ('}' , line_outside_quotes ))
450
453
while closenum > 0 :
@@ -454,7 +457,7 @@ def loads(data, conf=True):
454
457
elif isinstance (lopen [0 ], Container ):
455
458
c = lopen [0 ]
456
459
lopen .pop (0 )
457
- if lopen :
460
+ if lopen and isinstance ( lopen [ 0 ], ( Container , Server )) :
458
461
lopen [0 ].add (c )
459
462
else :
460
463
f .add (c ) if conf else f .append (c )
@@ -463,7 +466,7 @@ def loads(data, conf=True):
463
466
cmt_regex = r'.*#\s*(.*)(?![^\'\"]*[\'\"])'
464
467
c = Comment (re .match (cmt_regex , line ).group (1 ),
465
468
inline = not re .match (r'^\s*#.*' , line ))
466
- if len (lopen ):
469
+ if lopen and isinstance (lopen [ 0 ], ( Container , Server ) ):
467
470
lopen [0 ].add (c )
468
471
else :
469
472
f .add (c ) if conf else f .append (c )
0 commit comments