[New-bugs-announce] [issue31040] mimetypes.add_type should complain when you give it an undotted ext

Daniel Watkins report at bugs.python.org
Tue Jul 25 15:25:41 EDT 2017


New submission from Daniel Watkins:

```
import mimetypes

print(mimetypes.guess_type('foo.manifest'))
mimetypes.add_type('text/plain', 'manifest')
print(mimetypes.guess_type('foo.manifest'))
```

results in:

```
('application/x-ms-manifest', None)
('application/x-ms-manifest', None)
```

I (mistakenly) expected the latter print to give me "('text/plain', None)".  It doesn't because I should have prepended a . to the second add_type argument.

I think add_type should error out when given an extension without a dot-prefix, because it's extremely unlikely that code that does so is behaving as intended with the current implementation.

(At the very least, documentation should be updated to make this expectation clearer.)

----------
components: Library (Lib)
messages: 299135
nosy: odd_bloke
priority: normal
severity: normal
status: open
title: mimetypes.add_type should complain when you give it an undotted ext

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue31040>
_______________________________________


More information about the New-bugs-announce mailing list