Staging
v0.5.1
https://github.com/python/cpython
Revision cf0645a17acbc0c4dbbf82434e37637965748bbb authored by Miss Islington (bot) on 29 January 2020, 16:10:24 UTC, committed by GitHub on 29 January 2020, 16:10:24 UTC
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 a327677905956ae0b239ff430a1346dfe265709e)

Co-authored-by: Carl Friedrich Bolz-Tereick <cfbolz@gmx.de>

Co-authored-by: Carl Friedrich Bolz-Tereick <cfbolz@gmx.de>
1 parent a6559b4
History
Tip revision: cf0645a17acbc0c4dbbf82434e37637965748bbb authored by Miss Islington (bot) on 29 January 2020, 16:10:24 UTC
bpo-39485: fix corner-case in method-detection of mock (GH-18256)
Tip revision: cf0645a
File Mode Size
.azure-pipelines
.github
Doc
Grammar
Include
Lib
Mac
Misc
Modules
Objects
PC
PCbuild
Parser
Programs
Python
Tools
m4
.gitattributes -rw-r--r-- 1.6 KB
.gitignore -rw-r--r-- 1.5 KB
.travis.yml -rw-r--r-- 6.1 KB
CODE_OF_CONDUCT.rst -rw-r--r-- 631 bytes
LICENSE -rw-r--r-- 12.5 KB
Makefile.pre.in -rw-r--r-- 62.9 KB
README.rst -rw-r--r-- 9.6 KB
aclocal.m4 -rw-r--r-- 10.7 KB
config.guess -rwxr-xr-x 43.1 KB
config.sub -rwxr-xr-x 35.4 KB
configure -rwxr-xr-x 491.3 KB
configure.ac -rw-r--r-- 164.2 KB
install-sh -rwxr-xr-x 7.0 KB
pyconfig.h.in -rw-r--r-- 42.2 KB
setup.py -rw-r--r-- 101.3 KB

README.rst

back to top