This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author sjmachin
Recipients sjmachin
Date 2008-12-25.00:42:04
SpamBayes Score 8.495778e-08
Marked as misclassified No
Message-id <1230165726.07.0.804126540628.issue4743@psf.upfronthosting.co.za>
In-reply-to
Content
In a package, "import local1, local2" is not fixed. Here's some real
live 2to3 output showing the problem and the workaround:
  
 import ExcelFormulaParser, ExcelFormulaLexer
-import ExcelFormulaParser
-import ExcelFormulaLexer
+from . import ExcelFormulaParser
+from . import ExcelFormulaLexer
 import sys, struct
-from antlr import ANTLRException
+from .antlr import ANTLRException

As a solution that covers cases like "import sys, local1, local2" is
possibly difficult, I suggest putting out a warning that a manual fix
(one import per line) may be required. I've put this kludge in my copy
of fix_import.py:

 def probably_a_local_import(imp_name, file_path):
+    if "," in imp_name:
+        print("*** Can't handle import %r in %s" % (imp_name, file_path))
     # Must be stripped because the right space is included by the parser
     imp_name = imp_name.split('.', 1)[0].strip()
     base_path = dirname(file_path)
     base_path = join(base_path, imp_name)

[Aside: "right space"? Possibly should be "left space"]

and it produces:

*** Can't handle import ' ExcelFormulaParser, ExcelFormulaLexer' in
\2to3\xlwt\py3\xlwt\ExcelFormula.py
*** Can't handle import ' sys, struct' in
\2to3\xlwt\py3\xlwt\ExcelFormula.py
History
Date User Action Args
2008-12-25 00:42:06sjmachinsetrecipients: + sjmachin
2008-12-25 00:42:06sjmachinsetmessageid: <1230165726.07.0.804126540628.issue4743@psf.upfronthosting.co.za>
2008-12-25 00:42:04sjmachinlinkissue4743 messages
2008-12-25 00:42:04sjmachincreate