Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move constructor for object/apply to UnsafeConstructor #347

Merged
merged 1 commit into from Nov 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/yaml/constructor.py
Expand Up @@ -683,10 +683,6 @@ def construct_python_object_new(self, suffix, node):
u'tag:yaml.org,2002:python/object:',
FullConstructor.construct_python_object)

FullConstructor.add_multi_constructor(
u'tag:yaml.org,2002:python/object/apply:',
FullConstructor.construct_python_object_apply)

FullConstructor.add_multi_constructor(
u'tag:yaml.org,2002:python/object/new:',
FullConstructor.construct_python_object_new)
Expand All @@ -703,6 +699,10 @@ def make_python_instance(self, suffix, node, args=None, kwds=None, newobj=False)
return super(UnsafeConstructor, self).make_python_instance(
suffix, node, args, kwds, newobj, unsafe=True)

UnsafeConstructor.add_multi_constructor(
u'tag:yaml.org,2002:python/object/apply:',
UnsafeConstructor.construct_python_object_apply)

# Constructor is same as UnsafeConstructor. Need to leave this in place in case
# people have extended it directly.
class Constructor(UnsafeConstructor):
Expand Down
8 changes: 4 additions & 4 deletions lib3/yaml/constructor.py
Expand Up @@ -694,10 +694,6 @@ def construct_python_object_new(self, suffix, node):
'tag:yaml.org,2002:python/object:',
FullConstructor.construct_python_object)

FullConstructor.add_multi_constructor(
'tag:yaml.org,2002:python/object/apply:',
FullConstructor.construct_python_object_apply)

FullConstructor.add_multi_constructor(
'tag:yaml.org,2002:python/object/new:',
FullConstructor.construct_python_object_new)
Expand All @@ -714,6 +710,10 @@ def make_python_instance(self, suffix, node, args=None, kwds=None, newobj=False)
return super(UnsafeConstructor, self).make_python_instance(
suffix, node, args, kwds, newobj, unsafe=True)

UnsafeConstructor.add_multi_constructor(
'tag:yaml.org,2002:python/object/apply:',
UnsafeConstructor.construct_python_object_apply)

# Constructor is same as UnsafeConstructor. Need to leave this in place in case
# people have extended it directly.
class Constructor(UnsafeConstructor):
Expand Down