[issue37529] Mimetype module duplicates

2022-03-12 Thread Andrew Svetlov


Change by Andrew Svetlov :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
versions: +Python 3.11 -Python 2.7, Python 3.5, Python 3.6, Python 3.7, Python 
3.8, Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37529] Mimetype module duplicates

2022-03-12 Thread Andrew Svetlov


Andrew Svetlov  added the comment:


New changeset d9db07a3100105768ba83ffd67991e78452bb22e by andrei kulakov in 
branch 'main':
bpo-37529: Add test for guessing extensions (GH-28243)
https://github.com/python/cpython/commit/d9db07a3100105768ba83ffd67991e78452bb22e


--
nosy: +asvetlov

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37529] Mimetype module duplicates

2021-09-08 Thread Andrei Kulakov


Change by Andrei Kulakov :


--
pull_requests: +26663
pull_request: https://github.com/python/cpython/pull/28244

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37529] Mimetype module duplicates

2021-09-08 Thread Andrei Kulakov


Change by Andrei Kulakov :


--
keywords: +patch
pull_requests: +26662
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/28243

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37529] Mimetype module duplicates

2021-08-06 Thread Andrei Kulakov


Andrei Kulakov  added the comment:

This was fixed in https://github.com/python/cpython/pull/26300 but wasn't 
backported.

--
nosy: +andrei.avk

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37529] Mimetype module duplicates

2020-09-17 Thread Danny Lin


Danny Lin  added the comment:

It doesn't seem so... In Python 3.8.5 this code is still seen in mimetypes.py 
(line 492-504):

'.bmp': 'image/bmp',
'.gif': 'image/gif',
'.ief': 'image/ief',
'.jpg': 'image/jpeg',
'.jpe': 'image/jpeg',
'.jpeg'   : 'image/jpeg',
'.png': 'image/png',
'.svg': 'image/svg+xml',
'.tiff'   : 'image/tiff',
'.tif': 'image/tiff',
'.ico': 'image/vnd.microsoft.icon',
'.ras': 'image/x-cmu-raster',
'.bmp': 'image/x-ms-bmp',

--
nosy: +danny87105

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37529] Mimetype module duplicates

2019-07-16 Thread Jeffrey Kintscher


Jeffrey Kintscher  added the comment:

This appears to have been fixed by issue #4963 and backported to the 3.7 and 
3.8 branches:

Python 3.7.4+ (heads/3.7-dirty:e7bec26937, Jul 16 2019, 12:53:26) 
[Clang 10.0.1 (clang-1001.0.46.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import mimetypes
>>> mimetypes.guess_extension('image/bmp')
'.bmp'
>>> mimetypes.guess_extension('image/x-ms-bmp')
'.bmp'

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37529] Mimetype module duplicates

2019-07-11 Thread Jeffrey Kintscher


Change by Jeffrey Kintscher :


--
nosy: +Jeffrey.Kintscher

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37529] Mimetype module duplicates

2019-07-09 Thread disconnect3d


disconnect3d  added the comment:

To be more specific and to keep this information historically, the .bmp 
registers two mimetypes - 'image/bmp' and 'image/x-ms-bmp'.

Below a part of the relevant code.
```
types_map = _types_map_default = {
# (...)
'.bmp': 'image/bmp',
'.gif': 'image/gif',
'.ief': 'image/ief',
'.jpg': 'image/jpeg',
'.jpe': 'image/jpeg',
'.jpeg'   : 'image/jpeg',
'.png': 'image/png',
'.svg': 'image/svg+xml',
'.tiff'   : 'image/tiff',
'.tif': 'image/tiff',
'.ico': 'image/vnd.microsoft.icon',
'.ras': 'image/x-cmu-raster',
'.bmp': 'image/x-ms-bmp',
```

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37529] Mimetype module duplicates

2019-07-09 Thread disconnect3d


New submission from disconnect3d :

The mimetype builtin module allows users to guess extension for a given 
mimetype through the `mimetypes.guess_extension` function.

Default mimetypes are stored in `types_map` and `_types_map_default` 
dictionaries that maps extensions to mimetypes. Those dictionaries are created 
by `_default_mime_types` function in `cpython/Lib/mimetypes.py`.

If a given extension have more than one mimetype, this information is lost.
This happens currently for ".bmp" extension in CPython's codebase.

This can be seen in the linked code below:
https://github.com/python/cpython/blob/110a47c4f42cf4db88edc1876899fff8f05190fb/Lib/mimetypes.py#L490-L502

Here is an example in an interactive IPython session:
```
In [1]: import mimetypes

In [2]: mimetypes.guess_extension('image/bmp')
Out[2]: '.bmp'

In [3]: mimetypes.guess_extension('image/x-ms-bmp')

In [4]:
```

The issue has been found by using Semmle's LGTM: 
https://lgtm.com/projects/g/python/cpython/snapshot/d099f261c762ac81042e47b530d279f932d89e09/files/Lib/mimetypes.py?sort=name=ASC=heatmap


PS / offtopic / loud thinking: Maybe there should be a debug build of CPython 
that would detect such key overwrites during dicts initialisation and warn 
about them?

--
components: Library (Lib)
messages: 347562
nosy: Dominik Czarnota
priority: normal
severity: normal
status: open
title: Mimetype module duplicates
type: behavior
versions: Python 2.7, Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com