Skip to content

Problems with the example in docs/faq.rst #367

Closed
@mpnowacki

Description

@mpnowacki

I've encountered three issues when using the example supporting defaults (on python 3.5.3).

  • the method check_schema crashes in a most peculiar way. Calling DefaultValidatingDraft4Validator.check_schema(schema) causes a RecursionError: maximum recursion depth exceeded while calling a Python object
  • this code may work in an unexpected way when the default value is a mutable object. For example, let's say you validate an object and the default value gets injected. If you then manipulate this object, and modify the injected default value, the next time this schema injects the default value it shall be modified. Changing instance.setdefault(property, subschema["default"]) to instance.setdefault(property, copy.deepcopy(subschema["default"])) solves this completely, maybe it's worth to include it in the example?
  • This code doesn't work with python 3 because of the .iteritems() call, but that's just a cosmetic detail.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething doesn't work the way it should.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions