Skip to content

Breaking change in jsonschema==3.1.0 for Python 2.7 #611

@logachev

Description

@logachev

Recent update 3.1.0 introduces a breaking change for Python 2.7.

Here is a code sample that works with 3.0.0 but is broken with 3.1.0 because of the switch from re to js_regex: #609

from jsonschema import Draft4Validator as Validator
schema = {'type': 'string', 'pattern': r'\d+'}
validator = Validator(schema)
list(validator.iter_errors('123'))

Thrown exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/site-packages/jsonschema/validators.py", line 328, in iter_errors
    for error in errors:
  File "/usr/local/lib/python2.7/site-packages/jsonschema/_validators.py", line 200, in pattern
    not js_regex.compile(patrn).search(instance)
  File "/usr/local/lib/python2.7/site-packages/js_regex/_impl.py", line 39, in compile
    raise TypeError("pattern={!r} must be a unicode string".format(pattern))
TypeError: pattern='\\d+' must be a unicode string

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