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 uosiu
Recipients uosiu
Date 2016-03-21.08:13:06
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1458547986.83.0.630762686391.issue26600@psf.upfronthosting.co.za>
In-reply-to
Content
This bug results in raising TypeError: __str__ returned non-string (type MagicMock)
Following program can reproduce it:

```
from threading import Thread
from mock.mock import MagicMock


def main():
    mocks = [MagicMock() for _ in range(1000)]

    def in_thread():
        for m in mocks:
            str(m)

    threads = [Thread(target=in_thread) for _ in range(10)]
    for thread in threads:
        thread.start()
    for thread in threads:
        thread.join()


if __name__ == '__main__':
    main()
```

For me it rasies few times:

```
Exception in thread Thread-6:
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/threading.py", line 923, in _bootstrap_inner
    self.run()
  File "/usr/local/lib/python3.5/threading.py", line 871, in run
    self._target(*self._args, **self._kwargs)
  File "../misc/magic_mock_str_bug.py", line 11, in in_thread
    str(m)
TypeError: __str__ returned non-string (type MagicMock)
```
History
Date User Action Args
2016-03-21 08:13:06uosiusetrecipients: + uosiu
2016-03-21 08:13:06uosiusetmessageid: <1458547986.83.0.630762686391.issue26600@psf.upfronthosting.co.za>
2016-03-21 08:13:06uosiulinkissue26600 messages
2016-03-21 08:13:06uosiucreate