[PATCH] rtems_waf: moved "import os.path" to the beginning of "bsp_configure" func def to avoid UnboundLocalError.

Saeed Ehteshamifar salpha.2004 at gmail.com
Thu Sep 8 17:27:01 UTC 2016

In function 'bsp_configure' of rtems_bsd.py, when conf.options.rtems_libbsd
is None, os.path is not imported, which leads to "UnboundLocalError: local
variable 'os' referenced before assignment" error.

This patch tries to avoid that error.

diff --git a/rtems_bsd.py b/rtems_bsd.py
index eaff438..6074f4d 100644
--- a/rtems_bsd.py
+++ b/rtems_bsd.py
@@ -48,6 +48,7 @@ def options(opt):
                    help = 'Path to install RTEMS LibBSD (defauls to

 def bsp_configure(conf, arch_bsp):
+    import os.path
     conf.check(header_name = 'dlfcn.h', features = 'c')
     if not rtems.check_posix(conf):
         conf.fatal("RTEMS kernel POSIX support is disabled; configure
RTEMS with --enable-posix")
@@ -56,7 +57,6 @@ def bsp_configure(conf, arch_bsp):
     if conf.options.rtems_libbsd is None:
         rtems_libbsd_path = conf.env.PREFIX
-        import os.path
         if not os.path.exists(conf.options.rtems_libbsd):
             conf.fatal('RTEMS LibBSD not found')
         rtems_libbsd_path = conf.options.rtems_libbsd
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20160908/a5aab479/attachment.html>

More information about the devel mailing list