Message364222
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. |
|
Date |
User |
Action |
Args |
2020-03-15 06:39:44 | aviso | set | recipients:
+ aviso, rbcollins, cjw296, r.david.murray, michael.foord, pconnell, Darragh Bailey, lisroach, anthonypjshaw, mariocj89, xtreak |
2020-03-15 06:39:44 | aviso | set | messageid: <1584254384.28.0.0187140133308.issue39966@roundup.psfhosted.org> |
2020-03-15 06:39:44 | aviso | link | issue39966 messages |
2020-03-15 06:39:43 | aviso | create | |
|