New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix TypeError when processing relative imports #61
Conversation
Note that I also have another approach that is narrower in what it fixes (i.e. not fixing the error messages for relative star imports), but it also adds a |
@@ -1128,6 +1133,8 @@ def IMPORTFROM(self, node): | |||
else: | |||
self.futuresAllowed = False | |||
|
|||
module = ('.' * node.level) + (node.module or '') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alternatively this could be
if node.level:
module = ('.' * node.level) + (node.module or '')
else:
module = node.module
If someone else could review this and give it a 👍 I'd really appreciate it. I'm pressed for time today and this is an important bugfix. I'll do the release as soon as the review is good. |
It is a bit late here; I'll be up again in a few hours and can do some more testing and address any additional review comments arising. |
Fixes lp:1560134 aec68a7 added module names to error messages, however it caused a TypeError for relative imports that do not specify a module such as: from . import x This fixes the TypeError, and also adds the necessary leading dots for relative import error messages. Add tests for various types of relative imports.
I don't really have an opinion on the patch, but would like to see this fixed of course. I've subscribed to this thread so once the patch lands, I can cherry pick it into the Debian/Ubuntu packages, or if a new upstream release will happen soon after, I'll be happy to upload it. |
As Barry i also hit the problem now and would like to see it addressed. If i may, what about merging and releasing and seeing if anyone gets problems? As it currently stands 1.2 produces the traceback (i have flakes failing for 7 files in one project) where 1.1 was fine. |
Certainly, if a new upstream was released with this patch, I'd just upload it to Debian/Ubuntu and that would solve it. I'll end up doing it that way anyway for a new upstream, when we can drop this patch. Okay, let me see about importing this patch into the Debian package instead of the previous quick hack. |
just released 1.2.3 to fix this |
We should do a 1.2.3 hotfix with the version 1.2.3.4 so we don't miss out on this opportunity ;) |
Looks like the 1.2.3 tag is missing from the repo... |
whoops, forgot to push. Fixed now, thanks. |
Fixes lp:1560134
aec68a7 added module names to error messages,
however it caused a TypeError for relative imports
that do not specify a module such as:
from . import x
This fixes the TypeError, and also adds the necessary
leading dots for relative import error messages.
Add tests for various types of relative imports.