@@ -438,22 +438,23 @@ def load(self, doc, baseuri, loadingOptions, docRoot=None):
438438 r .append ({"pattern" : d })
439439 elif isinstance (d , dict ):
440440 new_dict : Dict [str , Any ] = {}
441- if "pattern" in d :
442- new_dict ["pattern" ] = d .pop ("pattern" )
441+ dict_copy = copy .deepcopy (d )
442+ if "pattern" in dict_copy :
443+ new_dict ["pattern" ] = dict_copy .pop ("pattern" )
443444 else :
444445 raise ValidationException (
445446 "Missing pattern in secondaryFiles specification entry: {}" .format (
446447 d
447448 )
448449 )
449450 new_dict ["required" ] = (
450- d .pop ("required" ) if "required" in d else None
451+ dict_copy .pop ("required" ) if "required" in dict_copy else None
451452 )
452453
453- if len (d ):
454+ if len (dict_copy ):
454455 raise ValidationException (
455456 "Unallowed values in secondaryFiles specification entry: {}" .format (
456- d
457+ dict_copy
457458 )
458459 )
459460 r .append (new_dict )
@@ -464,20 +465,23 @@ def load(self, doc, baseuri, loadingOptions, docRoot=None):
464465 )
465466 elif isinstance (doc , MutableMapping ):
466467 new_dict = {}
467- if "pattern" in doc :
468- new_dict ["pattern" ] = doc .pop ("pattern" )
468+ doc_copy = copy .deepcopy (doc )
469+ if "pattern" in doc_copy :
470+ new_dict ["pattern" ] = doc_copy .pop ("pattern" )
469471 else :
470472 raise ValidationException (
471473 "Missing pattern in secondaryFiles specification entry: {}" .format (
472474 doc
473475 )
474476 )
475- new_dict ["required" ] = doc .pop ("required" ) if "required" in doc else None
477+ new_dict ["required" ] = (
478+ doc_copy .pop ("required" ) if "required" in doc_copy else None
479+ )
476480
477- if len (doc ):
481+ if len (doc_copy ):
478482 raise ValidationException (
479483 "Unallowed values in secondaryFiles specification entry: {}" .format (
480- doc
484+ doc_copy
481485 )
482486 )
483487 r .append (new_dict )
0 commit comments