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

rdflib/plugins/shared/jsonld/context.py UnboundLocalError: local variable 'new_base' referenced before assignment #2303

Closed
crisely09 opened this issue Mar 21, 2023 · 5 comments · Fixed by #2306
Assignees
Labels
6.3.x Things that should be fixed in 6.3.x or later. bug Something isn't working confirmation needed The issue raises a potential bug that needs to be confirmed. regression Something stopped working

Comments

@crisely09
Copy link

We migrated from rdflib 6.2.0 to 6.3.1 and now we are getting a completely new error initializing a Context instance.

See error below:

Screenshot 2023-03-21 at 14 04 46

I believe the variable new_base was named just base in the previous version.

@aucampia
Copy link
Member

Thanks for the report @crisely09 - I will try have it fixed in 6.3.2.

@aucampia aucampia added bug Something isn't working confirmation needed The issue raises a potential bug that needs to be confirmed. regression Something stopped working 6.3.x Things that should be fixed in 6.3.x or later. labels Mar 21, 2023
@aucampia aucampia self-assigned this Mar 21, 2023
@aucampia
Copy link
Member

@crisely09 could you share some more details of the code that triggered this?

aucampia added a commit to aucampia/rdflib that referenced this issue Mar 22, 2023
A variable was only being initialized for string-valued inputs, but if a `dict`
input was passed the variable would still be accessed, resulting in a
`UnboundLocalError`.

This change initializes the variable always, instead of only when string-valued
input is used to construct a JSON-LD context.

- Closes <RDFLib#2303>.
aucampia added a commit to aucampia/rdflib that referenced this issue Mar 22, 2023
A variable was only being initialized for string-valued inputs, but if a `dict`
input was passed the variable would still be accessed, resulting in a
`UnboundLocalError`.

This change initializes the variable always, instead of only when string-valued
input is used to construct a JSON-LD context.

- Closes <RDFLib#2303>.
@crisely09
Copy link
Author

@crisely09 could you share some more details of the code that triggered this?

We inherit the class, we use it mainly to resolve documents. See https://github.com/BlueBrain/nexus-forge/blob/master/kgforge/core/commons/context.py

@aucampia
Copy link
Member

@crisely09 Okay, I think I managed to fix it in #2306, maybe try running with that branch, but otherwise it will be releases in 6.3.2 before Monday.

aucampia added a commit to aucampia/rdflib that referenced this issue Mar 23, 2023
A variable was only being initialized for string-valued inputs, but if a `dict`
input was passed the variable would still be accessed, resulting in a
`UnboundLocalError`.

This change initializes the variable always, instead of only when string-valued
input is used to construct a JSON-LD context.

- Closes <RDFLib#2303>.
@crisely09
Copy link
Author

Great, I will try again on Monday after the release.
Thanks!

aucampia added a commit that referenced this issue Mar 24, 2023
A variable was only being initialized for string-valued inputs, but if a `dict`
input was passed the variable would still be accessed, resulting in a
`UnboundLocalError`.

This change initializes the variable always, instead of only when string-valued
input is used to construct a JSON-LD context.

- Closes <#2303>.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.3.x Things that should be fixed in 6.3.x or later. bug Something isn't working confirmation needed The issue raises a potential bug that needs to be confirmed. regression Something stopped working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants