Skip to content

Commit

Permalink
Fix importing of nested modules.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Salz committed Apr 19, 2012
1 parent e3a3cde commit 865a813
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions jsonrpclib/jsonclass.py
Expand Up @@ -129,6 +129,13 @@ def load(obj):
except ImportError:
raise TranslationError('Could not import %s from module %s.' %
(json_class_name, json_module_tree))

# The returned class is the top-level module, not the one we really
# want. (E.g., if we import a.b.c, we now have a.) Walk through other
# path components to get to b and c.
for i in json_module_parts[1:]:
temp_module = getattr(temp_module, i)

json_class = getattr(temp_module, json_class_name)
# Creating the object...
new_obj = None
Expand Down

1 comment on commit 865a813

@tonybarbieri
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We ran into this issue today as well. I was going to put a pull request in for the fix but you beat me too it. Thanks for sharing!

Please sign in to comment.