PageRenderTime 17ms CodeModel.GetById 10ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/logilab-astng-0.23.1/test/regrtest_data/package/import_package_subpackage_module.py

#
Python | 68 lines | 44 code | 0 blank | 24 comment | 0 complexity | 0201d38fc6dba22547ee0a32e7ed233b MD5 | raw file
 1# pylint: disable-msg=I0011,C0301,W0611
 2# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 3# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
 4# copyright 2003-2010 Sylvain Thenault, all rights reserved.
 5# contact mailto:thenault@gmail.com
 6#
 7# This file is part of logilab-astng.
 8#
 9# logilab-astng is free software: you can redistribute it and/or modify it
10# under the terms of the GNU Lesser General Public License as published by the
11# Free Software Foundation, either version 2.1 of the License, or (at your
12# option) any later version.
13#
14# logilab-astng is distributed in the hope that it will be useful, but
15# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
17# for more details.
18#
19# You should have received a copy of the GNU Lesser General Public License along
20# with logilab-astng. If not, see <http://www.gnu.org/licenses/>.
21"""I found some of my scripts trigger off an AttributeError in pylint
220.8.1 (with common 0.12.0 and astng 0.13.1).
23
24Traceback (most recent call last):
25  File "/usr/bin/pylint", line 4, in ?
26    lint.Run(sys.argv[1:])
27  File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 729, in __init__
28    linter.check(args)
29  File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 412, in check
30    self.check_file(filepath, modname, checkers)
31  File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 426, in check_file
32    astng = self._check_file(filepath, modname, checkers)
33  File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 450, in _check_file
34    self.check_astng_module(astng, checkers)
35  File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 494, in check_astng_module
36    self.astng_events(astng, [checker for checker in checkers
37  File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 511, in astng_events
38    self.astng_events(child, checkers, _reversed_checkers)
39  File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 511, in astng_events
40    self.astng_events(child, checkers, _reversed_checkers)
41  File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 508, in astng_events
42    checker.visit(astng)
43  File "/usr/lib/python2.4/site-packages/logilab/astng/utils.py", line 84, in visit
44    method(node)
45  File "/usr/lib/python2.4/site-packages/pylint/checkers/variables.py", line 295, in visit_import
46    self._check_module_attrs(node, module, name_parts[1:])
47  File "/usr/lib/python2.4/site-packages/pylint/checkers/variables.py", line 357, in _check_module_attrs
48    self.add_message('E0611', args=(name, module.name),
49AttributeError: Import instance has no attribute 'name'
50
51
52You can reproduce it by:
53(1) create package structure like the following:
54
55package/
56        __init__.py
57        subpackage/
58                   __init__.py
59                   module.py
60
61(2) in package/__init__.py write:
62
63import subpackage
64
65(3) run pylint with a script importing package.subpackage.module.
66"""
67__revision__ = '$Id: import_package_subpackage_module.py,v 1.1 2005-11-10 15:59:32 syt Exp $'
68import package.subpackage.module