From: SourceForge.net <no...@so...> - 2012-12-20 19:12:26
|
Bugs item #3597554, was opened at 2012-12-19 13:25 Message generated for change (Settings changed) made by ptomulik You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=101645&aid=3597554&group_id=1645 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: python Group: None Status: Open Resolution: None >Priority: 4 Private: No Submitted By: Paweł Tomulik (ptomulik) >Assigned to: William Fulton (wsfulton) Summary: Problem with same module names in different packages Initial Comment: Hi, I have following minimal example: P1 P1/Foo_Mod.i P1/__init__.py P2 P2/Foo_Mod.i P2/__init__.py with python modules P1.Foo_Mod and P2.Foo_Mod. For such cases, the generated python code is often incorrect and it's impoossible to import generated modules. One of such cases is, if we define: struct Foo1 {} in P1.Foo_Mod and do something like %import <P1/Foo_Mod.i> struct Foo2 : public Foo1 {} in P2/Foo_Mod.i. For such code, the modules get generated but import of P2.Foo_Mod yields: >>> import P2.Foo_Mod Traceback (most recent call last): File "<stdin>", line 1, in <module> File "P2/Foo_Mod.py", line 71, in <module> class P2Foo2(P1Foo1): NameError: name 'P1Foo1' is not defined This is, because the generated proxy(?) python module P2.Foo_Mod contains something like: # P2.Foo_Mod ... import P1.Foo_Mod class P2Foo2(P1Foo1): ... but it should have: # P2.Foo_Mod ... import P1.Foo_Mod class P2Foo2(P1.Foo_Mod.P1Foo1): ... I attach a simple example that allows to replicate the bug and patch for your consideration. The patch was created in hurry, so I don't know if it doesn't break other things in swig. Regards! ---------------------------------------------------------------------- Comment By: Paweł Tomulik (ptomulik) Date: 2012-12-19 13:41 Message: struct P1Foo1{}; and struct P2Foo2 : public P1Foo1 {}; ---------------------------------------------------------------------- Comment By: Paweł Tomulik (ptomulik) Date: 2012-12-19 13:40 Message: Sorry, should be struct P1Foo2{}; and struct P2Foo2 : public P1Foo1 {}; in the description above. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=101645&aid=3597554&group_id=1645 |