Skip to content

Docs for urllib.request.urlcleanup does not mention that it will uninstall openers installed with urllib.request.install_opener #102591

Description

@aucampia

Documentation

urllib.request.install_opener sets urllib.request._opener to the supplied value:

def install_opener(opener):
global _opener
_opener = opener

And urllib.request.urlcleanup sets urllib.requests._opener to None, thus essentially uninstalling any previously installed global opener:

def urlcleanup():
"""Clean up temporary files from urlretrieve calls."""
for temp_file in _url_tempfiles:
try:
os.unlink(temp_file)
except OSError:
pass
del _url_tempfiles[:]
global _opener
if _opener:
_opener = None

However, this uninstallation of a previously installed global opener is not documented.

If the uninstallation of openers installed with install_opener is intended, then it would be best to document it in urlcleanup, and if it is not intended this should be a bug instead of a doc issue.

Linked PRs

Metadata

Metadata

Assignees

Labels

docsDocumentation in the Doc dir

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions