Commit a327677
authored
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.
1 parent 3cb49b6 commit a327677
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 | |
|---|---|---|---|
| |||
2748 | 2748 | | |
2749 | 2749 | | |
2750 | 2750 | | |
2751 | | - | |
| 2751 | + | |
2752 | 2752 | | |
2753 | 2753 | | |
2754 | 2754 | | |
| |||
2778 | 2778 | | |
2779 | 2779 | | |
2780 | 2780 | | |
2781 | | - | |
2782 | | - | |
2783 | | - | |
2784 | | - | |
2785 | 2781 | | |
2786 | 2782 | | |
2787 | 2783 | | |
| |||
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
0 commit comments