classification
Title: Filename http.py breaks calls to urllib
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Agrim Sachdeva2, eric.smith
Priority: normal Keywords:

Created on 2019-06-11 22:47 by Agrim Sachdeva2, last changed 2019-06-11 23:40 by eric.smith. This issue is now closed.

Messages (2)
msg345282 - (view) Author: Agrim Sachdeva (Agrim Sachdeva2) Date: 2019-06-11 22:47
If a script that uses urllib is named http.py, the following error occurs:

Traceback (most recent call last):
  File ".\http.py", line 1, in <module>
    import urllib.request, urllib.parse, urllib.error
  File "C:\Users\grim\AppData\Local\Programs\Python\Python37\lib\urllib\request.py", line 88, in <module>
    import http.client
  File "C:\Python\http.py", line 11, in <module>
    html = urllib.request.urlopen(url).read()
AttributeError: module 'urllib' has no attribute 'request'
msg345289 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2019-06-11 23:40
Closing as not a bug. This is how python works: you do not want to name a file the same as any standard library module. Use a file name other than http.py.
History
Date User Action Args
2019-06-11 23:40:47eric.smithsetstatus: open -> closed

type: compile error -> behavior
components: + Library (Lib), - Windows

nosy: + eric.smith, - paul.moore, tim.golden, zach.ware, steve.dower
messages: + msg345289
resolution: not a bug
stage: resolved
2019-06-11 22:47:11Agrim Sachdeva2create