summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--checkers/classes.py7
-rw-r--r--test/input/func_noerror_super_protected.py22
3 files changed, 32 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 8fd3249..e5e3e49 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,7 +2,10 @@ ChangeLog for PyLint
====================
--
- * #110853: Fix a crash when an __init__ method in a base class has been
+ * #115580: fix erroneous W0212 (access to protected member) on super call
+ (patch by Martin Pool)
+
+ * #110853: fix a crash when an __init__ method in a base class has been
created by assignment rather than direct function definition. (patch by
Torsten Marek)
diff --git a/checkers/classes.py b/checkers/classes.py
index 1259d18..f2c2913 100644
--- a/checkers/classes.py
+++ b/checkers/classes.py
@@ -386,10 +386,15 @@ a metaclass class method.'}
self.add_message('W0212', node=node, args=attrname)
return
+ # If the expression begins with a call to super, that's ok.
+ if isinstance(node.expr, astng.CallFunc) and \
+ isinstance(node.expr.func, astng.Name) and \
+ node.expr.func.name == 'super':
+ return
+
# We are in a class, one remaining valid cases, Klass._attr inside
# Klass
if not (callee == klass.name or callee in klass.basenames):
-
self.add_message('W0212', node=node, args=attrname)
def visit_name(self, node):
diff --git a/test/input/func_noerror_super_protected.py b/test/input/func_noerror_super_protected.py
new file mode 100644
index 0000000..5e78eea
--- /dev/null
+++ b/test/input/func_noerror_super_protected.py
@@ -0,0 +1,22 @@
+"""Accessing a protected method through super() is ok."""
+
+# pylint: disable=missing-docstring,too-few-public-methods
+
+__revision__ = None
+
+class Alpha(object):
+
+ _secret = 2
+
+ def test(self):
+ print "test %s" % self
+
+
+class Beta(Alpha):
+
+ def test(self):
+ print super(Beta, self)._secret
+ super(Beta, self).test()
+
+
+Beta().test()