Sorry in advance for this long message. I've been trying to get Python 3.3
working (under a venv, a 3.3 specific feature). I've ran into a number of
problems beyond my ability to fix, and I'm wondering if it's an
environment specific issue because it seems that Python 3.3.
Problem #1
----------
pylint crashes when importing a built-in module. Apparently
imp.find_module() returns None for mp_filename if the module is built-in.
Attached is the patch I used to fix this. Ignore the "for filepath,
importer in list(pic.items()):" line, as it's part of the 2to3 automatic
conversion.
The fix in _search_zip is just to fix some error handling code that
probably was never tested. I don't think "file"... actually now that I
look at that patch, removing the file parameter was wrong, it should be
filepath instead of file. Oops, I can fix that.
Problem #2
----------
I don't have a solution to this one. Given files: t.py, tmp/u.py and
tmp/v.py (and tmp/__init__.py)
t.py
----
import tmp.u
tmp.u.obfuscate()
tmp/u.py
--------
from .v import *
__all__ = [ "obfuscate" ]
tmp/v.py
-------
def obfuscate():
print("hello world")
I will always get a E1101 error under Python 3.3 for t.py
************* Module t
C0111: 1,0: Missing docstring
E1101: 4,0: Module 'tmp.u' has no 'obfuscate' member
This works fine using Pylint under 2.6.
Problem #3
----------
I will always get an exception when parsing any python code with a finally
block.
e.g.::
def main():
fp = None
try:
fp = open('/tmp/foo.dat')
data = fp.read()
print(data)
except OSError as exc:
print("Oops no file")
finally:
if fp:
fp.close()
if __name__ == '__main__':
main()
This fails with the backtrace::
************* Module t2
C0111: 1,0: Missing docstring
C0111: 2,0:main: Missing docstring
C0103: 3,4:main: Invalid name "fp" for type variable (should match
[a-z_][a-z0-9_]{2,30}$)
Traceback (most recent call last):
File "/work/fwk-trunk/framework/lumberjack/virtualenv/bin/pylint", line 9, in
<module>
load_entry_point('pylint==0.28.0', 'console_scripts', 'pylint')()
File
"/work/fwk-trunk/framework/lumberjack/virtualenv/lib/python3.3/site-packages/pylint/__init__.py",
line 21, in run_pylint
Run(sys.argv[1:])
File
"/work/fwk-trunk/framework/lumberjack/virtualenv/lib/python3.3/site-packages/pylint/lint.py",
line 995, in __init__
linter.check(args)
File
"/work/fwk-trunk/framework/lumberjack/virtualenv/lib/python3.3/site-packages/pylint/lint.py",
line 592, in check
self.check_astng_module(astng, walker, rawcheckers)
File
"/work/fwk-trunk/framework/lumberjack/virtualenv/lib/python3.3/site-packages/pylint/lint.py",
line 670, in check_astng_module
walker.walk(astng)
File
"/work/fwk-trunk/framework/lumberjack/virtualenv/lib/python3.3/site-packages/pylint/utils.py",
line 630, in walk
self.walk(child)
File
"/work/fwk-trunk/framework/lumberjack/virtualenv/lib/python3.3/site-packages/pylint/utils.py",
line 630, in walk
self.walk(child)
File
"/work/fwk-trunk/framework/lumberjack/virtualenv/lib/python3.3/site-packages/pylint/utils.py",
line 630, in walk
self.walk(child)
File
"/work/fwk-trunk/framework/lumberjack/virtualenv/lib/python3.3/site-packages/pylint/utils.py",
line 627, in walk
cb(astng)
File
"/work/fwk-trunk/framework/lumberjack/virtualenv/lib/python3.3/site-packages/pylint/checkers/format.py",
line 296, in visit_default
prev_sibl = node.previous_sibling()
File
"/work/fwk-trunk/framework/lumberjack/virtualenv/lib/python3.3/site-packages/logilab/astng/bases.py",
line 592, in previous_sibling
stmts = self.parent.child_sequence(self)
File
"/work/fwk-trunk/framework/lumberjack/virtualenv/lib/python3.3/site-packages/logilab/astng/bases.py",
line 445, in child_sequence
raise ASTNGError(msg % (repr(child), repr(self)))
logilab.astng.exceptions.ASTNGError: Could not found <TryExcept() l.None [t2] at
Ox7fa5c95c9f10> in <Function(main) l.2 [t2] at Ox7fa5c95c9c10>'s children
If these are a setup issue, can someone point me in the correct direction
to fix this? I did a pip install from a tarball of 0.28 along with the
related dependencies.
diff -r -U 5 logilab-common-0.59.1/modutils.py logilab-common-0.59.1.py3/modutils.py
--- logilab-common-0.59.1/modutils.py 2013-04-17 02:48:51.000000000 -0700
+++ logilab-common-0.59.1.py3/modutils.py 2013-04-30 13:18:40.379335351 -0700
@@ -563,16 +563,16 @@
elif mtype == PKG_DIRECTORY:
mp_filename = _has_init(mp_filename)
return mp_filename
def _search_zip(modpath, pic):
- for filepath, importer in pic.items():
+ for filepath, importer in list(pic.items()):
if importer is not None:
if importer.find_module(modpath[0]):
if not importer.find_module('/'.join(modpath)):
- raise ImportError('No module named %s in %s/%s' % (
- '.'.join(modpath[1:]), file, modpath))
+ raise ImportError('No module named %s in %s' % (
+ '.'.join(modpath[1:]), modpath))
return ZIPFILE, abspath(filepath) + '/' + '/'.join(modpath), filepath
raise ImportError('No module named %s' % '.'.join(modpath))
def _module_file(modpath, path=None):
"""get a module type / file path
@@ -611,11 +611,11 @@
except ImportError:
if checkeggs:
return _search_zip(modpath, pic)[:2]
raise
else:
- if checkeggs:
+ if checkeggs and mp_filename:
fullabspath = [abspath(x) for x in _path]
try:
pathindex = fullabspath.index(dirname(abspath(mp_filename)))
emtype, emp_filename, zippath = _search_zip(modpath, pic)
if pathindex > _path.index(zippath):
_______________________________________________
Python-Projects mailing list
Python-Projects@lists.logilab.org
http://lists.logilab.org/mailman/listinfo/python-projects