[New-bugs-announce] [issue36948] NameError in urllib.request.URLopener.retrieve

Karthikeyan Singaravelan report at bugs.python.org
Fri May 17 12:09:52 EDT 2019


New submission from Karthikeyan Singaravelan <tir.karthi at gmail.com>:

In issue27485 the deprecated functions were replaced with underscore prefixed ones due to which imports where modified. Some of the places where not changed causing NameError in using urllib.request.URLopener.retrieve for local files and non-local files which is deprecated. I found these undefined names while running flake8 on Lib folder. I will raise a PR with tests for the same.

Sample Error : 

./python.exe
Python 3.8.0a4+ (heads/master:870b035bc6, May 17 2019, 16:28:23)
[Clang 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from urllib.request import URLopener
>>> URLopener().retrieve('file:///tmp/a.txt')
sys:1: DeprecationWarning: URLopener style of invoking requests is deprecated. Use newer urlopen functions/methods
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/urllib/request.py", line 1786, in retrieve
    return url2pathname(splithost(url1)[1]), hdrs
NameError: name 'splithost' is not defined

----------
components: Library (Lib)
messages: 342733
nosy: cheryl.sabella, xtreak
priority: normal
severity: normal
status: open
title: NameError in urllib.request.URLopener.retrieve
type: behavior
versions: Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue36948>
_______________________________________


More information about the New-bugs-announce mailing list