Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita001f27

Browse files
committed
Per suggestion#420 (comment)move a few constructors from full_load to unsafe_load.
1 parentfe15062 commita001f27

File tree

4 files changed

+26
-26
lines changed

4 files changed

+26
-26
lines changed

‎lib/yaml/constructor.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -722,18 +722,6 @@ def construct_python_object_new(self, suffix, node):
722722
u'tag:yaml.org,2002:python/name:',
723723
FullConstructor.construct_python_name)
724724

725-
FullConstructor.add_multi_constructor(
726-
u'tag:yaml.org,2002:python/module:',
727-
FullConstructor.construct_python_module)
728-
729-
FullConstructor.add_multi_constructor(
730-
u'tag:yaml.org,2002:python/object:',
731-
FullConstructor.construct_python_object)
732-
733-
FullConstructor.add_multi_constructor(
734-
u'tag:yaml.org,2002:python/object/new:',
735-
FullConstructor.construct_python_object_new)
736-
737725
classUnsafeConstructor(FullConstructor):
738726

739727
deffind_python_module(self,name,mark):
@@ -750,6 +738,18 @@ def set_python_instance_state(self, instance, state):
750738
returnsuper(UnsafeConstructor,self).set_python_instance_state(
751739
instance,state,unsafe=True)
752740

741+
UnsafeConstructor.add_multi_constructor(
742+
u'tag:yaml.org,2002:python/module:',
743+
UnsafeConstructor.construct_python_module)
744+
745+
UnsafeConstructor.add_multi_constructor(
746+
u'tag:yaml.org,2002:python/object:',
747+
UnsafeConstructor.construct_python_object)
748+
749+
UnsafeConstructor.add_multi_constructor(
750+
u'tag:yaml.org,2002:python/object/new:',
751+
UnsafeConstructor.construct_python_object_new)
752+
753753
UnsafeConstructor.add_multi_constructor(
754754
u'tag:yaml.org,2002:python/object/apply:',
755755
UnsafeConstructor.construct_python_object_apply)

‎lib3/yaml/constructor.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -710,18 +710,6 @@ def construct_python_object_new(self, suffix, node):
710710
'tag:yaml.org,2002:python/name:',
711711
FullConstructor.construct_python_name)
712712

713-
FullConstructor.add_multi_constructor(
714-
'tag:yaml.org,2002:python/module:',
715-
FullConstructor.construct_python_module)
716-
717-
FullConstructor.add_multi_constructor(
718-
'tag:yaml.org,2002:python/object:',
719-
FullConstructor.construct_python_object)
720-
721-
FullConstructor.add_multi_constructor(
722-
'tag:yaml.org,2002:python/object/new:',
723-
FullConstructor.construct_python_object_new)
724-
725713
classUnsafeConstructor(FullConstructor):
726714

727715
deffind_python_module(self,name,mark):
@@ -738,6 +726,18 @@ def set_python_instance_state(self, instance, state):
738726
returnsuper(UnsafeConstructor,self).set_python_instance_state(
739727
instance,state,unsafe=True)
740728

729+
UnsafeConstructor.add_multi_constructor(
730+
'tag:yaml.org,2002:python/module:',
731+
UnsafeConstructor.construct_python_module)
732+
733+
UnsafeConstructor.add_multi_constructor(
734+
'tag:yaml.org,2002:python/object:',
735+
UnsafeConstructor.construct_python_object)
736+
737+
UnsafeConstructor.add_multi_constructor(
738+
'tag:yaml.org,2002:python/object/new:',
739+
UnsafeConstructor.construct_python_object_new)
740+
741741
UnsafeConstructor.add_multi_constructor(
742742
'tag:yaml.org,2002:python/object/apply:',
743743
UnsafeConstructor.construct_python_object_apply)

‎tests/lib/test_recursive.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def test_recursive(recursive_filename, verbose=False):
3030
output2=None
3131
try:
3232
output1=yaml.dump(value1)
33-
value2=yaml.load(output1,yaml.FullLoader)
33+
value2=yaml.load(output1,yaml.UnsafeLoader)
3434
output2=yaml.dump(value2)
3535
assertoutput1==output2, (output1,output2)
3636
finally:

‎tests/lib3/test_recursive.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def test_recursive(recursive_filename, verbose=False):
3131
output2=None
3232
try:
3333
output1=yaml.dump(value1)
34-
value2=yaml.full_load(output1)
34+
value2=yaml.unsafe_load(output1)
3535
output2=yaml.dump(value2)
3636
assertoutput1==output2, (output1,output2)
3737
finally:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp