diff --git a/PythonAPI/carla/source/carla/__init__.py b/PythonAPI/carla/source/carla/__init__.py index 6a213c86b27..99f3ecc70a8 100644 --- a/PythonAPI/carla/source/carla/__init__.py +++ b/PythonAPI/carla/source/carla/__init__.py @@ -39,14 +39,14 @@ def get_submodules(mod, parent): # this should be fine for the current rss versions. # NOTE: Check when updating RSS version if v.__name__ != "map": - print(v, "already imported. This might create a carla.ad import hierarchy") + print(v, "already imported. This might create a wrong carla.ad import hierarchy") continue correct_path = parent+"."+v.__name__ ad_submodules[v] = correct_path get_submodules(v, correct_path) - get_submodules(ad, "carla.ad") # type: ignore - if ad is sys.modules["ad"]: # type: ignore - sys.modules["carla.ad"] = sys.modules.pop("ad") + get_submodules(ad, "carla.libcarla.ad") # type: ignore + if ad.__name__ != "carla.libcarla.ad" and "ad" in sys.modules and ad is sys.modules["ad"] and "carla.libcarla.ad" not in sys.modules: # type: ignore + sys.modules["carla.libcarla.ad"] = sys.modules.pop("ad") for mod, correct_name in ad_submodules.items(): # NOTE: Check when updating RSS version #print("Correcting", mod.__name__, "to", correct_name) @@ -59,6 +59,5 @@ def get_submodules(mod, parent): __fix_ad_namespaces() except Exception as e: print("Could not clean ad_rss namespace due to", e, "Please report this bug") - pass del __fix_ad_namespaces diff --git a/PythonAPI/carla/source/libcarla/AdRss.cpp b/PythonAPI/carla/source/libcarla/AdRss.cpp index 405fefaed9e..cb9822257fd 100644 --- a/PythonAPI/carla/source/libcarla/AdRss.cpp +++ b/PythonAPI/carla/source/libcarla/AdRss.cpp @@ -103,7 +103,7 @@ void export_ad() { using namespace boost::python; // create/import the ad module scope - object ad_module(handle<>(borrowed(PyImport_AddModule("ad")))); + object ad_module(handle<>(borrowed(PyImport_AddModule("carla.libcarla.ad")))); scope().attr("ad") = ad_module; scope submodule_scope = ad_module; scope().attr("__doc__") = "Python binding of ad namespace C++ code";