This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author AWhetter
Recipients AWhetter, YoSTEALTH, barry, brandtbucher, maxking, r.david.murray, steve.dower, xtreak
Date 2019-10-28.18:00:37
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1572285637.29.0.702469430805.issue34938@roundup.psfhosted.org>
In-reply-to
Content
Maybe updating the dictionaries isn't right at all.
I think if you were experienced enough you would have the intuition that mutable attributes like this are not going to change in your local scope if you import them into it. But relying on this knowledge makes it difficult for newer users. Plus we all make mistakes ;) So a note in the docs sounds like a good idea to me.

I think `init` does rebuild when `files` is `None` (https://github.com/python/cpython/blob/edb172a87296d9359593a23cd9a09f5867ea1f0e/Lib/mimetypes.py#L350) but it's not clear to me whether rebuilding should include any additional types registered with `add_type`. At the moment it says `the mapping will be added to the official MIME types`, but I think an additional note that this means that it will persist after subsequent calls to `init` would make that clear.

As for importing `init` into the local scope, I think ideally we wouldn't use `global` at all. We should be able to make `init` import `mimetypes` locally and explicitly access attributes on the module?
Another option is we make the module attributes accessible through a module level `__getattr__` which gets the attributes off of the global `Mimetypes` object stored in `mimetypes._db`. But that would still require usage of a `global _db`.
History
Date User Action Args
2019-10-28 18:00:37AWhettersetrecipients: + AWhetter, barry, r.david.murray, steve.dower, maxking, YoSTEALTH, xtreak, brandtbucher
2019-10-28 18:00:37AWhettersetmessageid: <1572285637.29.0.702469430805.issue34938@roundup.psfhosted.org>
2019-10-28 18:00:37AWhetterlinkissue34938 messages
2019-10-28 18:00:37AWhettercreate