Commit 696d232
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 2b675f0 commit 696d232
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 | |
|---|---|---|---|
| |||
2715 | 2715 | | |
2716 | 2716 | | |
2717 | 2717 | | |
2718 | | - | |
| 2718 | + | |
2719 | 2719 | | |
2720 | 2720 | | |
2721 | 2721 | | |
| |||
2745 | 2745 | | |
2746 | 2746 | | |
2747 | 2747 | | |
2748 | | - | |
2749 | | - | |
2750 | | - | |
2751 | | - | |
2752 | 2748 | | |
2753 | 2749 | | |
2754 | 2750 | | |
| |||
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
0 commit comments