fix crash when using set in regexp for --generated-members option. Closes #88914

authorSylvain Th?nault <sylvain.thenault@logilab.fr>
changeset8752260a4f41
branchdefault
phasepublic
hiddenno
parent revision#b68f274aaab7 fix gui reporter broken by addition of coloffset information. Closes #92584
child revision#085dad997b71 Doesn't check that overriden method signature match if it's a private method, closes #18772
files modified by this revision
ChangeLog
checkers/typecheck.py
test/smoketest.py
# HG changeset patch
# User Sylvain Thénault <sylvain.thenault@logilab.fr>
# Date 1337602147 -7200
# Mon May 21 14:09:07 2012 +0200
# Node ID 8752260a4f4183cfe7b068ce39f8a50ad9b26f75
# Parent b68f274aaab72edcb4cced3d8f4d60bd9d1f0353
fix crash when using set in regexp for --generated-members option. Closes #88914

diff --git a/ChangeLog b/ChangeLog
@@ -9,15 +9,18 @@
1      * #77982: do not emit E0602 for loop variables of comprehensions
2        used as argument values inside a decorator (patch by tmarek@google.com)
3 
4      * #89092: don't emit E0202 (attribute hiding a method) on @property methods
5 
6 -    * #92584 fix pylint-gui crash due to internal API change
7 +    * #92584: fix pylint-gui crash due to internal API change
8 
9 -    * #87192 fix crash when decorators are accessed through more than one dot
10 +    * #87192: fix crash when decorators are accessed through more than one dot
11        (for instance @a.b is fine, @a.b.c crash)
12 
13 +    * #88914: fix parsing of --generated-members options, leading to crash
14 +      when using a regexp value set
15 +
16      * fix potential crashes with utils.safe_infer raising InferenceError
17 
18 
19  2011-12-08  --  0.25.1
20      * #81078: Warn if names in  exception handlers clobber overwrite
diff --git a/checkers/typecheck.py b/checkers/typecheck.py
@@ -130,10 +130,11 @@
21          # REQUEST,aq_parent,"[a-zA-Z]+_set{1,2}"' =>
22          # ('REQUEST', 'aq_parent', '[a-zA-Z]+_set{1,2}')
23          if isinstance(self.config.generated_members, str):
24              gen = shlex.shlex(self.config.generated_members)
25              gen.whitespace += ','
26 +            gen.wordchars += '[]-+'
27              self.config.generated_members = tuple(tok.strip('"') for tok in gen)
28          for pattern in self.config.generated_members:
29              # attribute is marked as generated, stop here
30              if re.match(pattern, node.attrname):
31                  return
diff --git a/test/smoketest.py b/test/smoketest.py
@@ -80,10 +80,15 @@
32      @tag('smoke')
33      def test_no_ext_file(self):
34          self._runtest([join(HERE, 'input', 'noext')], code=0)
35 
36      @tag('smoke')
37 +    def test_generated_members(self):
38 +        # XXX dual end quotation since optparse buggily remove one...
39 +        self._runtest(['--generated-members=objects,DoesNotExist,delay,retry,"[a-zA-Z]+_set{1,2}""', 'pylint.lint'])
40 +
41 +    @tag('smoke')
42      def test_w0704_ignored(self):
43          self._runtest([join(HERE, 'input', 'ignore_except_pass_by_default.py')], code=0)
44 
45      @tag('smoke', 'help', 'config')
46      def test_generate_config_option(self):