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 <1584254384.28.0.0187140133308.issue39966@roundup.psfhosted.org>
In-reply-to
Content
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:
        bool(sys.stdout)

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.
History
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: <1584254384.28.0.0187140133308.issue39966@roundup.psfhosted.org>
2020-03-15 06:39:44avisolinkissue39966 messages
2020-03-15 06:39:43avisocreate