[issue5868] mimetypes.MAGIC_FUNCTION initialization not thread-safe in Python 2.6.2

Alain Poirier report at bugs.python.org
Tue Apr 28 16:51:57 CEST 2009


New submission from Alain Poirier <alain.poirier at net-ng.com>:

In Python 2.6.2, the fix for the issue 5401 changed the way the
mimetypes module is initialized.

But now the initialization is not thread-safe : a thread can set
``inited`` to ``True`` and then be preempted before to overwrite the
functions guess_type(), guess_extension() ...

With such a partial initialization, the next thread will raise an 
excessive recursion exception when calling one of this functions.

A fix could be to wrap ``mimetypes.init()`` with a thread lock.

----------
components: Library (Lib)
messages: 86747
nosy: apoirier, benjamin.peterson
severity: normal
status: open
title: mimetypes.MAGIC_FUNCTION initialization not thread-safe in Python 2.6.2
type: behavior
versions: Python 2.6

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


More information about the Python-bugs-list mailing list