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
c-api
data
distributing
distutils
extending
faq
howto
includes
install
installing
library
reference
tools
tutorial
using
whatsnew
Makefile -rw-r--r-- 7.4 KB
README.rst -rw-r--r-- 4.5 KB
about.rst -rw-r--r-- 1.5 KB
bugs.rst -rw-r--r-- 4.3 KB
conf.py -rw-r--r-- 6.4 KB
contents.rst -rw-r--r-- 538 bytes
copyright.rst -rw-r--r-- 451 bytes
glossary.rst -rw-r--r-- 52.0 KB
license.rst -rw-r--r-- 43.4 KB
make.bat -rw-r--r-- 5.5 KB

README.rst

back to top