From 9d45055a028d83b5614121cf2152af1ab7056d68 Mon Sep 17 00:00:00 2001 From: jcorgan Date: Sat, 25 Apr 2009 02:57:27 +0000 Subject: [PATCH] Generate more informative error message than recursion error git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@10908 221aa14e-8319-0410-a670-987f0aec2ac5 --- gnuradio-core/src/python/gnuradio/gr/hier_block2.py | 2 ++ gnuradio-core/src/python/gnuradio/gr/top_block.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/gnuradio-core/src/python/gnuradio/gr/hier_block2.py b/gnuradio-core/src/python/gnuradio/gr/hier_block2.py index 3d3545a2..b43c5fed 100644 --- a/gnuradio-core/src/python/gnuradio/gr/hier_block2.py +++ b/gnuradio-core/src/python/gnuradio/gr/hier_block2.py @@ -45,6 +45,8 @@ class hier_block2(object): """ Pass-through member requests to the C++ object. """ + if not hasattr(self, "_hb"): + raise RuntimeError("hier_block2: invalid state--did you forget to call gr.hier_block2.__init__ in a derived class?") return getattr(self._hb, name) def connect(self, *points): diff --git a/gnuradio-core/src/python/gnuradio/gr/top_block.py b/gnuradio-core/src/python/gnuradio/gr/top_block.py index b9c436a0..71e40142 100644 --- a/gnuradio-core/src/python/gnuradio/gr/top_block.py +++ b/gnuradio-core/src/python/gnuradio/gr/top_block.py @@ -89,6 +89,8 @@ class top_block(object): self._tb = top_block_swig(name) def __getattr__(self, name): + if not hasattr(self, "_tb"): + raise RuntimeError("top_block: invalid state--did you forget to call gr.top_block.__init__ in a derived class?") return getattr(self._tb, name) def start(self): -- 2.47.2