Skip to content

Conversation

@warren-bank
Copy link
Contributor

@warren-bank warren-bank commented Jan 24, 2025

Though not directly relevant.. this is also an issue with cpython, and there is an open pull request.

Pyodide uses Javascript XHR to perform the network request, and constructs an 'HTTPResponse' object from the XHR response. When doing so, a 'url' attribute should be added.

Though not directly relevant,
this is also an issue with cpython:
  python/cpython#86228
and there is an open pull request:
  https://github.com/python/cpython/pull/22738/files

Pyodide uses Javascript XHR to perform the network request,
and constructs an 'HTTPResponse' object from the XHR response.
When doing so, a 'url' attribute should be added.
@warren-bank
Copy link
Contributor Author

note to @koenvo

  • it would really be appreciated if you could please push a minor release, so this can be added to Pyodide

note to self/others:

  • until this is included in Pyodide, the following is a monkey patch to workaround the issue:
    import pyodide_http
    
    original_urlopen = pyodide_http._urllib.urlopen
    
    def modified_urlopen(url, *args, **kwargs):
        response = original_urlopen(url, *args, **kwargs)
        if isinstance(url, pyodide_http._urllib.urllib.request.Request):
            response.url = url.full_url
        else:
            response.url = url
        return response
    
    pyodide_http._urllib.urlopen = modified_urlopen

warren-bank added a commit to warren-bank/single-page-apps that referenced this pull request Jan 24, 2025
Add monkey patch workaround for open pull request:
  koenvo/pyodide-http#43
@koenvo
Copy link
Owner

koenvo commented Jan 31, 2025

Thanks for the PR Warren. The release script is kind of outdated. Let me solve that and push out a minor release.

@koenvo koenvo merged commit 09ce9e5 into koenvo:main Feb 5, 2025
1 check failed
@koenvo
Copy link
Owner

koenvo commented Feb 5, 2025

@warren-bank just released a new patch version: 0.2.2

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