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 aviso
Recipients Darragh Bailey, anthonypjshaw, aviso, cjw296, lisroach, mariocj89, michael.foord, pconnell, r.david.murray, rbcollins, xtreak
Date 2020-03-15.06:39:43
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
This bug was introduced with Issue25597

Here's some code that demonstrates the error:

    import sys
    from unittest.mock import patch

    with patch.object(sys, 'stdout', wraps=sys.stdout) as mockstdout:

This works fine in 3.8 and earlier, but fails in 3.9

It seems the goal was to be able to access dunder methods for wrapped objects. Before this change __bool__ wasn't actually being checked, but was forced to True, which works for basic existence tests. The new code method._mock_wraps = getattr(mock._mock_wraps, name) has no fallthrough in case the attribute isn't there such as the case with __bool__ on sys.stdout.
Date User Action Args
2020-03-15 06:39:44avisosetrecipients: + aviso, rbcollins, cjw296, r.david.murray, michael.foord, pconnell, Darragh Bailey, lisroach, anthonypjshaw, mariocj89, xtreak
2020-03-15 06:39:44avisosetmessageid: <>
2020-03-15 06:39:44avisolinkissue39966 messages
2020-03-15 06:39:43avisocreate