discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Discuss-gnuradio] gr-modtool produces incorrect swig.i


From: Tom Rondeau
Subject: Re: [Discuss-gnuradio] gr-modtool produces incorrect swig.i
Date: Wed, 13 Feb 2013 16:44:19 -0500

On Wed, Feb 13, 2013 at 4:10 PM, Eric B <address@hidden> wrote:
I'm using the gr-modtool that is now included with gnuradio to add a block to an existing module that was created with an earlier version of gr-modtool.py. The swig.i file originally looks like:

%include "gnuradio.i"
%include "testmod_swig_doc.i"

{
#include "testmod_testblock.h"
}

GR_SWIG_BLOCK_MAGIC(testmod,testblock);
%include "testmod_testblock.h"


After adding my new block the swig.i looks like:


%include "gnuradio.i"
%include "testmod_swig_doc.i"

{
#include "testmod_testblock.h"
#include "testmod_testblock2.h"
}

GR_SWIG_BLOCK_MAGIC(testmod,testblock);
%include "testmod_testblock.h"

%include "testmod_testblock2.h"
GR_SWIG_BLOCK_MAGIC(testmod, testblock2);

I can build and install the module just fine but when I got to execute a flowgraph with testblock2 in it I get these errors:

Traceback (most recent call last):
  File "/home/user/top_block.py", line 52, in <module>
    tb = top_block()
  File "/home/user/top_block.py", line 34, in __init__
    self.testmod_testblock2_0 = testmod.testblock2()
AttributeError: 'module' object has no attribute 'testblock2'
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/apport_python_hook.py", line 64, in apport_excepthook
    from apport.fileutils import likely_packaged, get_recent_crashes
  File "/usr/lib/python2.7/dist-packages/apport/__init__.py", line 4, in <module>
    from apport.report import Report
  File "/usr/lib/python2.7/dist-packages/apport/report.py", line 28, in <module>
    import problem_report
  File "/usr/lib/python2.7/dist-packages/problem_report.py", line 14, in <module>
    import zlib, base64, time, sys, gzip, struct, os
  File "/usr/lib/python2.7/gzip.py", line 10, in <module>
    import io
  File "/usr/lib/python2.7/io.py", line 51, in <module>
    import _io
TypeError: type '_io._IOBase' participates in gc and is a base type but has inappropriate tp_free slot

Original exception was:
Traceback (most recent call last):
  File "/home/user/top_block.py", line 52, in <module>
    tb = top_block()
  File "/home/user/top_block.py", line 34, in __init__
    self.testmod_testblock2_0 = testmod.testblock2()
AttributeError: 'module' object has no attribute 'testblock2'


Simply reversing the order of the last two lines (ie. GR_SWIG_BLOCK_MAGIC comes BEFORE %include) fixes this and allows it to run correctly. This isn't very intuitive from the error and it would be great if gr-modtool could be updated to correct this.

Is this for the v3.6 or v3.7 API? I'm assuming this is for 3.6 (based off master). And this might finally clear up some confusion we've been having regarding this.

In the new 3.7, the ordering should absolutely be:

%import <thing's header>
GR_SWIG_BLOCK_MAGIC2(thing)

It sounds like this is the opposite for the 3.6 way of doing things (which we normally don't do this way and instead create a .i file for each block and handle things that way). But I guess this is why we named it MAGIC...

Tom


reply via email to

[Prev in Thread] Current Thread [Next in Thread]