[New-bugs-announce] [issue38672] Crash on mimetypes.init() if there is no access to one of knownfiles

Michał Szymaniak report at bugs.python.org
Sun Nov 3 07:33:22 EST 2019


New submission from Michał Szymaniak <sc0typl at gmail.com>:

When user lacks rights to read on of the mimetypes.knownfiles, mimetypes init() will throw PermissionError and library becomes unusable.

Reproduction steps:
# mkdir -p /etc/httpd/conf/
# touch /etc/httpd/conf/mime.types
# chmod a-r /etc/httpd/conf/mime.types
$ python
>>> import mimetypes
>>> mimetypes.init()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.7/mimetypes.py", line 355, in init
    db.read(file)
  File "/usr/lib/python3.7/mimetypes.py", line 204, in read
    with open(filename, encoding='utf-8') as fp:
PermissionError: [Errno 13] Permission denied: '/etc/httpd/conf/mime.types'

----------
components: Library (Lib)
messages: 355897
nosy: Michał Szymaniak
priority: normal
severity: normal
status: open
title: Crash on mimetypes.init() if there is no access to one of knownfiles
type: crash
versions: Python 2.7, Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 3.9

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


More information about the New-bugs-announce mailing list