Share

PyChecker

Tracker: Bugs

5 New pcmodules.py module, modulePath code causes import error - ID: 2209631
Last Update: Settings changed ( thomasvs )

Hi,

When using pychecker 0.8.18 on our code base it gives various import
errors, without a backtrace as the error happens within pychecker itself.

The error can be made visible by changing line 516 from:
for filename, line, func, text in tbinfo[1:]:
To:
for filename, line, func, text in tbinfo:

This shows the error is at line 628 of checker.py:
if not pcmodules.getPCModule(self.moduleName).module :

The problem is that "pcmodules.getPCModule(self.moduleName)"

Returns None.

After this I lost track of what is happening.

To reproduce do:

git clone http://git.fedorahosted.org/git/anaconda.git
cd anaconda
export PYTHONPATH="isys:textw:iw:installclasses:/usr/lib/booty"
pychecker anaconda *.py textw/*.py iw/*.py installclasses/*.py isys/*.py

You will then also see quite a few errors about missing (native) modules,
but those can be ignored (or fixed by first doing make if you've all the
necessary libs installed).

Then you will see an error importing constants:
Processing module constants (constants.py)...
Caught exception importing module constants:
File "/usr/lib/python2.5/site-packages/pychecker/checker.py", line 628,
in load()
if not pcmodules.getPCModule(self.moduleName).module :
AttributeError: 'NoneType' object has no attribute 'module'

And more errors like these for other modules. Building the native modules
does not help here. Note that doing the same with pychecker-0.8.17 works
fine.


Hans de Goede ( jwrdegoede ) - 2008-10-30 12:02

5

Closed

Fixed

Nobody/Anonymous

None

0.8.19

Public


Comments ( 5 )




Date: 2009-06-27 18:47
Sender: thomasvsProject Admin

My mistake, not properly distinguishing between '' and None as moduleDir,
which happens when you test modules in the current working directory.

Fixed in CVS just now:

Checking in ChangeLog;
/cvsroot/pychecker/pychecker/ChangeLog,v <-- ChangeLog
new revision: 1.46; previous revision: 1.45
done
Mailing pychecker-checkins@lists.sourceforge.net,
nnorwitz@users.sourceforge.net, johnshue@users.sourceforge.net,
thomas@apestaart.org...
Generating notification message...
Generating notification message... done.
Checking in pychecker/checker.py;
/cvsroot/pychecker/pychecker/pychecker/checker.py,v <-- checker.py
new revision: 1.116; previous revision: 1.115
done
Mailing pychecker-checkins@lists.sourceforge.net,
nnorwitz@users.sourceforge.net, johnshue@users.sourceforge.net,
thomas@apestaart.org...
Generating notification message...
Generating notification message... done.

Please try with CVS from pychecker.


Date: 2009-06-27 18:26
Sender: thomasvsProject Admin

After implementing bisection in moap, I ran it to find where it broke:

moap vcs bisect reset; moap vcs bisect start; cvs up -rv0_8_17; moap vcs
bisect good; cvs up -A; moap vcs bisect bad; moap vcs bisect run ./test.sh

(with test.sh:
#!/bin/sh
cd /home/thomas/dev/ext/anaconda
output=`PYTHONPATH=/home/thomas/dev/ext/pychecker python
/home/thomas/dev/ext/pychecker/pychecker/checker.py backend.py constants.py
2>&1`
echo $output | grep NoneType > /dev/null 2>&1
if test $? -eq 1
then
# not found, so good
echo version good.
exit 0
else
echo version bad.
exit 1
fi
)

As I suspected, I was the one who introduced the change:

[pychecker-head] [moap-trunk] [thomas@ana pychecker]$ moap vcs bisect
diff
Index: ChangeLog
===================================================================
RCS file: /cvsroot/pychecker/pychecker/ChangeLog,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -p -u -3 -r1.21 -r1.22
--- ChangeLog 13 Jul 2008 22:56:12 -0000 1.21
+++ ChangeLog 13 Jul 2008 23:00:31 -0000 1.22
@@ -1,5 +1,16 @@
2008-07-14 Thomas Vander Stichele <thomas at apestaart dot org>

+ * pychecker/checker.py:
+ Make sure args passed for checking now create PyCheckerModule
+ instances with moduleDir set properly. This triggers the new
+ code behaviour where modules are stored as a moduleName, moduleDir
+ tuple in pcmodules.py, making sure same-named modules get treated
+ separately.
+ New test suite now passes again.
+ Fixes #1563572.
+
+2008-07-14 Thomas Vander Stichele <thomas at apestaart dot org>
+
* test/input/getmodule/A/C.py:
* test/input/getmodule/A/__init__.py:
* test/input/getmodule/B/C.py:
Index: pychecker/checker.py
===================================================================
RCS file: /cvsroot/pychecker/pychecker/pychecker/checker.py,v
retrieving revision 1.110
retrieving revision 1.111
diff -u -p -u -3 -r1.110 -r1.111
--- pychecker/checker.py 13 Jul 2008 22:39:29 -0000 1.110
+++ pychecker/checker.py 13 Jul 2008 23:00:31 -0000 1.111
@@ -815,7 +815,7 @@ def processFiles(files, cfg = None, pre_
for file, (moduleName, moduleDir) in zip(files, getModules(files)) :
if callable(pre_process_cb) :
pre_process_cb("module %s (%s)" % (moduleName, file))
- module = PyCheckerModule(moduleName)
+ module = PyCheckerModule(moduleName, moduleDir=moduleDir)
if not module.load() :
w = Warning(module.filename(), 1,
msgs.Internal("NOT PROCESSED UNABLE TO IMPORT"))



Date: 2009-06-26 11:50
Sender: thomasvsProject Admin

Interestingly enough, this doesn't fail:
pychecker python /home/thomas/dev/ext/pychecker/pychecker/checker.py
`pwd`/backend.py `pwd`/constants.py



Date: 2009-06-25 13:32
Sender: thomasvsProject Admin

minimum trigger: pychecker backend.py constants.py


Removing backend.py doesn't trigger the bug.


Date: 2009-06-25 13:28
Sender: thomasvsProject Admin

You also need pykickstart installed, I think.

With that installed, using pychecker 0.8.18, I get as the first error:


[thomas@ana anaconda]$ pychecker anaconda *.py textw/*.py iw/*.py
installclasses/*.py isys/*.py
Processing module anaconda (anaconda)...
ImportError: No module named anaconda
Processing module anaconda_log (anaconda_log.py)...
warning: couldn't find real module for class <class 'ssl.SSLError'>
(module name: ssl)
warning: couldn't find real module for class <type 'ssl.SSLContext'>
(module name: ssl)
warning: couldn't find real module for class <class 'ssl.SSLError'>
(module name: ssl)
Processing module backend (backend.py)...
ImportError: No module named _isys
Processing module bootloader (bootloader.py)...
ImportError: No module named _isys
Processing module cmdline (cmdline.py)...
ImportError: No module named parted
Processing module compssort (compssort.py)...
Processing module constants (constants.py)...
Caught exception importing module constants:
AttributeError: 'NoneType' object has no attribute 'module'
Processing module desktop (desktop.py)...


Running it only on constants.py doesn't trigger it.


Log in to comment.




Attached File

No Files Currently Attached

Changes ( 6 )

Field Old Value Date By
artifact_group_id None 2009-06-27 18:47 thomasvs
allow_comments 0 2009-06-27 18:47 thomasvs
status_id Open 2009-06-27 18:47 thomasvs
resolution_id None 2009-06-27 18:47 thomasvs
allow_comments 1 2009-06-27 18:47 thomasvs
close_date - 2009-06-27 18:47 thomasvs