Author Stanisław Skonieczny (Uosiu)
Recipients Stanisław Skonieczny (Uosiu), Yoichi Nakayama, iritkatriel, michael.foord, pitrou
Date 2021-02-22.10:10:50
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
In-reply-to <>
When you just create a magick mock and then call `__str__` on it, it never
throws an exception and always return a string.
But... when you create a magick mock and then call `__str__` from two
threads concurrently, one of them will raise an exception.

Race is as follows:
1. Thread 1 creates magick mock m.
2. Thread 1 enters `m.__str__` it starts some internal preparations. It
does not exit `__str__` yet.
3. Thread 2 enters `m.__str__`.
In effect one of this threads will try to return `MagickMock` instance
instead of `str` object, which if forbidden by python.
Some low-level python check will raise following exception: `TypeError:
__str__ returned non-string (type MagicMock)`.

Stanisław Skonieczny

On Mon, Feb 22, 2021 at 10:56 AM Irit Katriel <>

> Irit Katriel <> added the comment:
> Why is this only relevant to multiple thread?
> ----------
> _______________________________________
> Python tracker <>
> <>
> _______________________________________
Date User Action Args
2021-02-22 10:10:50Stanisław Skonieczny (Uosiu)setrecipients: + Stanisław Skonieczny (Uosiu), pitrou, michael.foord, Yoichi Nakayama, iritkatriel
2021-02-22 10:10:50Stanisław Skonieczny (Uosiu)linkissue26600 messages
2021-02-22 10:10:50Stanisław Skonieczny (Uosiu)create