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 rmccampbell7
Recipients rmccampbell7
Date 2018-12-12.19:06:57
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1544641617.77.0.788709270274.issue35474@psf.upfronthosting.co.za>
In-reply-to
Content
The mimetypes.guess_all_extensions function is defined as:

def guess_all_extensions(self, type, strict=True):
    type = type.lower()
    extensions = self.types_map_inv[True].get(type, [])
    if not strict:
        for ext in self.types_map_inv[False].get(type, []):
            if ext not in extensions:
                extensions.append(ext)
    return extensions

If any mime type exists in both the strict and non-strict types_map_inv and it is called with strict=False, then it will modify the strict list in-place which effects future calls even with strict=True. While this doesn't manifest as an error for me because the dictionaries are non-overlapping, it is a potential error; it is also vulnerable to people accidentally modifying the returned list. The list should be copied after the first lookup.
History
Date User Action Args
2018-12-12 19:06:57rmccampbell7setrecipients: + rmccampbell7
2018-12-12 19:06:57rmccampbell7setmessageid: <1544641617.77.0.788709270274.issue35474@psf.upfronthosting.co.za>
2018-12-12 19:06:57rmccampbell7linkissue35474 messages
2018-12-12 19:06:57rmccampbell7create