New submission from STINNER Victor <vstin...@redhat.com>:

While working on bpo-37421 "Some tests leak temporary files", I had to write PR 
14529 fix: test_urllib urlretrieve() tests now explicitly call urlcleanup() to 
remove temporary files.

If urlretrieve() caller forgets to remove the temporary file, the "temporary" 
file is left in the temporary directory, until this directory is cleared which 
may happen soon (next reboot?) or not.

When ContentTooShortError is raised, the temporary file is left in the 
temporary directory: the caller must call urlcleanup() explicitly. It sounds 
like a bug to me.

Is it really a good API if urlcleanup() must be called explicitly? I dislike 
having a "separated" function for the cleanup, whereas Python could rely on 
object lifetime to do the cleanup.

Should we deprecate this API in favor of a better urllib API?

----------
components: Library (Lib)
messages: 347056
nosy: vstinner, xtreak
priority: normal
severity: normal
status: open
title: What is urllib.request.urlcleanup() function?
versions: Python 3.9

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue37475>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to