Stanisław Skonieczny (Uosiu) <stanislaw.skoniec...@gmail.com> added the comment:
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 <rep...@bugs.python.org> wrote: > > Irit Katriel <iritkatr...@yahoo.com> added the comment: > > Why is this only relevant to multiple thread? > > ---------- > > _______________________________________ > Python tracker <rep...@bugs.python.org> > <https://bugs.python.org/issue26600> > _______________________________________ > ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue26600> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com