You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
assignee='https://github.com/ncoghlan'closed_at=<Date2018-10-25.14:10:34.470>created_at=<Date2017-12-14.13:26:34.576>labels= ['easy', '3.8', 'library']
title='Add pure Python fallback for functools.reduce'updated_at=<Date2018-10-25.15:01:16.818>user='https://github.com/stevendaprano'
Reviewing the code and the CI test failures on the PR, the trick here is that functools isn't actually *using* functools.reduce, it's just re-exporting it if it's defined.
So if you block importing of "_functools" (which the test suite does in order to test the pure Python fallbacks), then the *only* consequence is that "functools.reduce" will be missing - the module will otherwise be fine.
This isn't at all clear when reading the code though, so I think the simplest resolution here would be to add a comment to the fallback path that says "If _functools.reduce is missing, then functools.reduce will also be missing, but the module will otherwise work".
However, the documentation says nothing about reduce being optional, and it is unconditionally included in the module __all__.
Oh, about this specific issue: maybe test___all__ should be fixed to test functools.py with _functools blocked? As done by test_functools.py? But this is a wider change and I'm not sure that it's doable :-( (especially in a generic way!) The PEP-399 requires the same API for the C and the Python implementations.