Skip to content

RefResolutionError on PyPy only #828

@jpmckinney

Description

@jpmckinney

To reproduce:

$ python --version
Python 3.7.10 (51efa818fd9b, Apr 04 2021, 12:03:51)
[PyPy 7.3.4 with GCC Apple LLVM 12.0.0 (clang-1200.0.32.29)]
pip install jsonschema requests
import jsonschema

instance = [[{}], [{}]]
schema = {
    "items": {"$ref": "#/definitions/record"},
    "definitions": {
        "record": {
            "oneOf": [
                {},
                {"$ref": "https://standard.open-contracting.org/schema/1__1__5/release-schema.json"}
            ]
        }
    }
}

Causes:

jsonschema.exceptions.RefResolutionError: Unresolvable JSON pointer: 'definitions/record'

The error does not occur on CPython.

The underlying cause is likely here, where we're improperly relying on the pop_scope call to run immediately on the suspended generator, whereas it really can run anytime afterwards (and does on PyPy), causing the current resolution scope to be incorrect when resolving the ref.

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