Commit cf0645a
Replace check for whether something is a method in the mock module. The
previous version fails on PyPy, because there no method wrappers exist
(everything looks like a regular Python-defined function). Thus the
isinstance(getattr(result, '__get__', None), MethodWrapperTypes) check
returns True for any descriptor, not just methods.
This condition could also return erroneously True in CPython for
C-defined descriptors.
Instead to decide whether something is a method, just check directly
whether it's a function defined on the class. This passes all tests on
CPython and fixes the bug on PyPy.
(cherry picked from commit a327677)
Co-authored-by: Carl Friedrich Bolz-Tereick <[email protected]>
Co-authored-by: Carl Friedrich Bolz-Tereick <[email protected]>
1 parent a6559b4 commit cf0645a
File tree
2 files changed
+4
-5
lines changed- Lib/unittest
- Misc/NEWS.d/next/Library
2 files changed
+4
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2342 | 2342 | | |
2343 | 2343 | | |
2344 | 2344 | | |
2345 | | - | |
| 2345 | + | |
2346 | 2346 | | |
2347 | 2347 | | |
2348 | 2348 | | |
| |||
2381 | 2381 | | |
2382 | 2382 | | |
2383 | 2383 | | |
2384 | | - | |
2385 | | - | |
2386 | | - | |
2387 | | - | |
2388 | 2384 | | |
2389 | 2385 | | |
2390 | 2386 | | |
| |||
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
0 commit comments