[New-bugs-announce] [issue34702] urlopen doesn't handle query strings with "file" scheme

Guillaume Ayoub report at bugs.python.org
Sun Sep 16 04:18:19 EDT 2018


New submission from Guillaume Ayoub <xovni at wanadoo.fr>:

urlopen includes query strings in the filename with "file"-scheme URLs.

>>> from urllib.request import urlopen
>>> urlopen('file:///tmp/test')
<addinfourl at 140059890562888 whose fp = <_io.BufferedReader name='/tmp/test'>>
>>> urlopen('file:///tmp/test?q')
Traceback (most recent call last):
  File "/usr/lib/python3.7/urllib/request.py", line 1473, in open_local_file
    stats = os.stat(localfile)
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/test?q'

This behavior seems to be OK with what RFC 8089 tells, but many other implementations (including browsers and curl) remove query strings from the filename.

----------
messages: 325475
nosy: liZe
priority: normal
severity: normal
status: open
title: urlopen doesn't handle query strings with "file" scheme
type: behavior

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


More information about the New-bugs-announce mailing list