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

fix: UnboundLocalError: cannot access local variable netloc where it … #465

Merged
merged 1 commit into from
Jul 27, 2024

Conversation

bukzor
Copy link
Contributor

@bukzor bukzor commented Jul 25, 2024

…is not associated with a value

@sirosen
Copy link
Member

sirosen commented Jul 27, 2024

Thanks for this!

The fix looks good, but could you share how you encountered this? I can't think of a way to test this behavior. It seems like you would need some kind of crafted URI which I'm not able to imagine at present.

@sirosen sirosen merged commit 0b580cc into python-jsonschema:main Jul 27, 2024
23 checks passed
@sirosen
Copy link
Member

sirosen commented Jul 27, 2024

I've gone ahead with a merge, since I'd rather include this fix than leave it unpatched, but I still don't see how this scenario is reachable. Without that, I can't add a regression test and this could break in the future without warning.

If you're able to share the scenario which triggered this, that would be a tremendous help!
Either way, thanks for the contribution. 🙂

@bukzor
Copy link
Contributor Author

bukzor commented Jul 31, 2024

A uri like file: x hits this path. Such a url reveals several other bugs as well though which I'm working on intermittently.

@sirosen
Copy link
Member

sirosen commented Aug 2, 2024

I'm not sure how such a URL could get past the earlier check for if not filename.startswith("file://"): (this block of code is in the else branch).

I'm pretty sure that file: x is not a valid file URI, though it might not be all that relevant. (My understanding is that file URIs are specified as requiring absolute paths, even though many applications support the use of relative paths.)

I'll try to reproduce the behavior, but I am somewhat concerned by the fact that it still isn't clear to me how this could happen.

@bukzor
Copy link
Contributor Author

bukzor commented Aug 6, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants