Hi all,

A little while ago some of us bumped into an issue with swig 2.0.9 which
was dubbed "buggy", but the bottom line is that the fully qualified module
names are probably here to stay (it is required in py3 and should work
fine in py2).

Rather than just staying away from anything beyond swig 2.0.9 I'd like to
find a solution to this problem.

As Andreas already mentioned, I think it is due to a circular dependency
between the modules, but I am not familiar with the technique used in
m5/__init__.py and my first attempts at fixing this were unsuccessful.
Would it be as easy as importing serialize at the right place?

Is there some python/scons ninja out there (Nate perhaps? :-) that could
have a look?

Thanks,

Andreas


On 14/03/2013 15:10, "Andreas Sandberg" <[email protected]> wrote:

>changeset ef864175dcc0 in /z/repo/gem5
>details: http://repo.gem5.org/gem5?cmd=changeset;node=ef864175dcc0
>description:
>       scons: Check for known buggy version of SWIG (2.0.9)
>
>       SWIG version 2.0.9 uses fully qualified module names despite of the
>       importing module being in the same package as the imported
>       module. This has the unfortunate consequence of causing the following
>       error when importing m5.internal.event:
>
>       Traceback (most recent call last):
>         File "<string>", line 1, in <module>
>         File "src/python/importer.py", line 75, in load_module
>           exec code in mod.__dict__
>         File "src/python/m5/__init__.py", line 35, in <module>
>           import internal
>         File "src/python/importer.py", line 75, in load_module
>           exec code in mod.__dict__
>         File "src/python/m5/internal/__init__.py", line 32, in <module>
>           import event
>         File "src/python/importer.py", line 75, in load_module
>           exec code in mod.__dict__
>         File "build/X86/python/swig/event.py", line 107, in <module>
>           class Event(m5.internal.serialize.Serializable):
>       AttributeError: 'module' object has no attribute 'internal'
>
>       When 'event' is loaded, it triggers 'serialize' to be loaded. However,
>       it seems like the dictionary of 'm5' isn't updated until after
>       __init__.py terminates, which means that 'event' never sees the
>       'internal' attribute on 'm5'. Older versions of SWIG didn't include
>       the fully qualified module name if the modules were in the same
>       package.
>
>diffstat:
>
> SConstruct |  9 +++++++++
> 1 files changed, 9 insertions(+), 0 deletions(-)
>
>diffs (19 lines):
>
>diff -r 1a21964b7227 -r ef864175dcc0 SConstruct
>--- a/SConstruct       Tue Mar 12 18:41:29 2013 +0100
>+++ b/SConstruct       Thu Mar 14 16:08:55 2013 +0100
>@@ -713,6 +713,15 @@
>     print '       Installed version:', swig_version[2]
>     Exit(1)
>
>+if swig_version[2] == "2.0.9":
>+    print '\n' + termcap.Yellow + termcap.Bold + \
>+        'Warning: SWIG version 2.0.9 sometimes generates broken code.\n'
>+ \
>+        termcap.Normal + \
>+        'This problem only affects some platforms and some Python\n' + \
>+        'versions. See the following SWIG bug report for details:\n' + \
>+        'http://sourceforge.net/p/swig/bugs/1297/\n'
>+
>+
> # Set up SWIG flags & scanner
> swig_flags=Split('-c++ -python -modern -templatereduce $_CPPINCFLAGS')
> main.Append(SWIGFLAGS=swig_flags)
>_______________________________________________
>gem5-dev mailing list
>[email protected]
>http://m5sim.org/mailman/listinfo/gem5-dev
>


-- IMPORTANT NOTICE: The contents of this email and any attachments are 
confidential and may also be privileged. If you are not the intended recipient, 
please notify the sender immediately and do not disclose the contents to any 
other person, use it for any purpose, or store or copy the information in any 
medium.  Thank you.

_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to