Updates:
Status: NeedsDecision
Cc: asmeurer
Labels: Documentation
Comment #4 on issue 2612 by vlada.pe...@gmail.com: Error in
quantum/__init__.py under Python 3
http://code.google.com/p/sympy/issues/detail?id=2612
Well, the thing is that the advertised behavior works in Python 3 too
(showing that I don't understand really well how __all__ works, not that
the documentation was really helpful). I remembered then that this occurs
only in doctests. And, rightly enough, the __init__.py file actually has no
doctests, this is what the doctester says for it:
sympy/physics/quantum/__init__.py[?] Failed to import
[FAIL]
Why is the doctester trying to import it? Beats me. I actually have
another "Failed to import" error, which looks something like this:
sympy/parsing/ast_parser_python25.py[?] Failed to import
[FAIL]
...
________ /home/vperic/devel/sympy/sympy/parsing/ast_parser_python25.py
_________
File "/usr/local/lib/python3.2/doctest.py", line 200, in _normalize_module
return __import__(module, globals(), locals(), ["*"])
File "/home/vperic/devel/sympy/sympy/parsing/ast_parser_python25.py",
line 1, in <module>
import compiler
ImportError: No module named compiler
Now, I didn't pay much attention to this because I intended to just not
copy over the file (since we need it just under python 2.5) and avoid this,
but it's obviously the same issue.
I'm completely clueless what to do about this. On one hand, the errors are
perfectly harmless. On the other, they are errors and might confuse users
unnecessarily; I also don't see an easy way to just skip them. The function
raising the error doesn't seem to have changed since 2004.
Of course, I could refactor the code not to use this construct exactly.
This would imply the following changes to code:
-import qapply as qapmod
+from qapply import __all__ as qap_all
from qapply import *
-__all__.extend(qapmod.__all__)
+__all__.extend(qap_all)
As far as I can see, this works fine in both Python versions (but I will
test again very carefully if we decide to take this approach). I would then
solve the issue with the ast_parser file the way I originally intended, by
not copying it over in the script. This basically just silences the errors
but I see no other solution.
Aaron, Ronan, anyone else, thoughts?
--
You received this message because you are subscribed to the Google Groups
"sympy-issues" group.
To post to this group, send email to sympy-issues@googlegroups.com.
To unsubscribe from this group, send email to
sympy-issues+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/sympy-issues?hl=en.