Close #14857: fix regression in references to PEP 3135 implicit __class__ closure variable. Reopens issue #12370, but also updates unittest.mock to workaround that issue
diff --git a/NEWS b/NEWS
index f9a71ef..7ad0da6 100644
--- a/NEWS
+++ b/NEWS
@@ -1 +1,4 @@
+- Issue #14857: fix regression in references to PEP 3135 implicit __class__
+ closure variable (Reopens issue #12370)
+
- Issue #14295: Add unittest.mock
diff --git a/mock.py b/mock.py
index 389a9cb..e47f3b1 100644
--- a/mock.py
+++ b/mock.py
@@ -116,10 +116,6 @@
inPy3k = sys.version_info[0] == 3
-# Needed to work around Python 3 bug where use of "super" interferes with
-# defining __class__ as a descriptor
-_super = super
-
self = 'im_self'
builtin = '__builtin__'
if inPy3k:
@@ -128,6 +124,9 @@
FILTER_DIR = True
+# Workaround for Python issue #12370
+# Without this, the __class__ properties wouldn't be set correctly
+_safe_super = super
def _is_instance_mock(obj):
# can't use isinstance on Mock objects because they override __class__
@@ -531,7 +530,7 @@
if kwargs:
self.configure_mock(**kwargs)
- _super(NonCallableMock, self).__init__(
+ _safe_super(NonCallableMock, self).__init__(
spec, wraps, name, spec_set, parent,
_spec_state
)
@@ -960,7 +959,7 @@
_spec_state=None, _new_name='', _new_parent=None, **kwargs):
self.__dict__['_mock_return_value'] = return_value
- _super(CallableMixin, self).__init__(
+ _safe_super(CallableMixin, self).__init__(
spec, wraps, name, spec_set, parent,
_spec_state, _new_name, _new_parent, **kwargs
)
@@ -1858,7 +1857,7 @@
class MagicMixin(object):
def __init__(self, *args, **kw):
- _super(MagicMixin, self).__init__(*args, **kw)
+ _safe_super(MagicMixin, self).__init__(*args, **kw)
self._mock_set_magics()