auto-importer doesn't support modules not imported by their parent

Bug #733026 reported by Andrew Wilkins
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Pushy
Fix Released
Medium
Unassigned

Bug Description

You have a package "a", and a module within called "b", i.e.:-
    a/__init__.py
    a/b.py
a/__init__.py does NOT import b.py.

The auto-importer currently is a bit dumb, assuming that the parent imports the child. Based on this assumption, a auto-import of "a.b" works as follows:
    getattr(getattr(conn.modules, "a"), "b")

This will fail if a doesn't import b.

Related branches

Andrew Wilkins (axwalk)
Changed in pushy:
status: New → Incomplete
importance: Undecided → Medium
Revision history for this message
Andrew Wilkins (axwalk) wrote :

It is possible to get around this at the moment, by doing this:
    getattr(conn.modules, "a.b").b
The second getattr is necessary since __import__ is used.

I can think of a couple of options for fixing this:
    - Modify ModuleType proxies to do an import on getattr, if getattr otherwise fails.
    - Add an explicit import function to pushy.Client which handles sub-modules.

I am currently thinking of doing both. If feasible, the first option should only apply to modules returned from the auto-importer.

Changed in pushy:
status: Incomplete → Confirmed
Andrew Wilkins (axwalk)
Changed in pushy:
status: Confirmed → In Progress
Andrew Wilkins (axwalk)
Changed in pushy:
status: In Progress → Fix Committed
Andrew Wilkins (axwalk)
Changed in pushy:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.