[Python-projects] Pylint: W0212 (access to protected member) false negative

Paul `Satoshi' Hachmann satoshi.harada at gmail.com
Wed Jan 21 19:42:31 CET 2009


In the following code, the '_secret' protected member of SomeClass
is accessed twice; once to set it and another to print it:

--------------
class SomeClass(object):
    def __init__(self):
        self._secret = 3


obj = SomeClass()
obj._secret = 1                      # Doesn't catch this!
print "I am accessing", obj._secret  # Produces W0212, as expected
--------------

However, the assignment statement by itself doesn't generate a W0212.

Using version:
 pylint 0.15.2,
 astng 0.17.2, common 0.34.0
 Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52)
 [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)]


-- 
Fare thee well,
Paul `Satoshi' Hachmann


More information about the Python-Projects mailing list