@@ -329,22 +329,32 @@ def add_path_resolver(tag, path, kind=None, Loader=Loader, Dumper=Dumper):
329
329
Loader .add_path_resolver (tag , path , kind )
330
330
Dumper .add_path_resolver (tag , path , kind )
331
331
332
- def add_constructor (tag , constructor , Loader = Loader ):
332
+ def add_constructor (tag , constructor , Loader = None ):
333
333
"""
334
334
Add a constructor for the given tag.
335
335
Constructor is a function that accepts a Loader instance
336
336
and a node object and produces the corresponding Python object.
337
337
"""
338
- Loader .add_constructor (tag , constructor )
338
+ if Loader == None :
339
+ loader .Loader .add_constructor (tag , constructor )
340
+ loader .FullLoader .add_constructor (tag , constructor )
341
+ loader .UnsafeLoader .add_constructor (tag , constructor )
342
+ else :
343
+ Loader .add_constructor (tag , constructor )
339
344
340
- def add_multi_constructor (tag_prefix , multi_constructor , Loader = Loader ):
345
+ def add_multi_constructor (tag_prefix , multi_constructor , Loader = None ):
341
346
"""
342
347
Add a multi-constructor for the given tag prefix.
343
348
Multi-constructor is called for a node if its tag starts with tag_prefix.
344
349
Multi-constructor accepts a Loader instance, a tag suffix,
345
350
and a node object and produces the corresponding Python object.
346
351
"""
347
- Loader .add_multi_constructor (tag_prefix , multi_constructor )
352
+ if Loader == None :
353
+ loader .Loader .add_multi_constructor (tag_prefix , multi_constructor )
354
+ loader .FullLoader .add_multi_constructor (tag_prefix , multi_constructor )
355
+ loader .UnsafeLoader .add_multi_constructor (tag_prefix , multi_constructor )
356
+ else :
357
+ Loader .add_multi_constructor (tag_prefix , multi_constructor )
348
358
349
359
def add_representer (data_type , representer , Dumper = Dumper ):
350
360
"""
0 commit comments