Skip to content

fix: replace import urllib with import urllib.parse - #2807

Open
dajiaohuang wants to merge 1 commit into
googleapis:mainfrom
dajiaohuang:fix/2803-urllib-parse-import
Open

fix: replace import urllib with import urllib.parse#2807
dajiaohuang wants to merge 1 commit into
googleapis:mainfrom
dajiaohuang:fix/2803-urllib-parse-import

Conversation

@dajiaohuang

Copy link
Copy Markdown

Description

The modules import urllib but call urllib.parse.* functions. In Python, importing urllib does not import its submodules - urllib.parse only becomes accessible after import urllib.parse is executed.

This change fixes AttributeError: module 'urllib' has no attribute 'parse' when using these modules directly without any prior import of urllib.parse.

Files Changed

  • googleapiclient/_helpers.py
  • googleapiclient/discovery.py
  • googleapiclient/http.py
  • googleapiclient/model.py

Fixes

Fixes #2803

The modules import urllib but call urllib.parse.* functions.
In Python, importing urllib does not import its submodules.
This change fixes AttributeError when using these modules directly
without any prior import of urllib.parse.

Fixes googleapis#2803
@dajiaohuang
dajiaohuang requested a review from a team as a code owner September 2, 2026 10:52
@product-auto-label product-auto-label Bot added the size: xs Pull request size is extra small. label Sep 2, 2026
@google-cla

google-cla Bot commented Sep 2, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates several files in the googleapiclient library to import urllib.parse instead of the top-level urllib module. I have no feedback to provide as there are no review comments.

@skippdot

skippdot commented Sep 2, 2026

Copy link
Copy Markdown

@dajiaohuang is it just duplicate of #2804 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: xs Pull request size is extra small.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

googleapiclient modules use urllib.parse but only import urllib, crashing when urllib.parse was not imported elsewhere

2 participants