phobos icon indicating copy to clipboard operation
phobos copied to clipboard

Bug in phobos/core/multiple.py

Open m0rsch1 opened this issue 1 year ago • 7 comments

https://github.com/dfki-ric/phobos/blob/e359008a2302cb7307e6ce9e0dc7e80feb5b3c4f/phobos/core/multiple.py#L173

The inputfile can be None but is not checked before calling os.path.abspath(inputfile)

m0rsch1 avatar May 31 '24 09:05 m0rsch1

Can you give me the python traceback to this error?

AlpenAalAlex avatar Jun 06 '24 06:06 AlpenAalAlex

Well, i dont have a trace right now. But i think its not needed here: If i pass no inputfile to the __init__ function of the Arrangement class, then it is set to None per default. In that case the line i have highlighted will fail, because os.path.abspath(None) is an invalid call.

m0rsch1 avatar Jun 07 '24 12:06 m0rsch1

So, either the inputfile argument is needed, then it should not be set to None per default or (which i think has been intended) the self.inputfile attribute has to be initialized to None as well and overwritten only if the argument inputfile is not None (there is an if statement for that already later in the __init__ constructor).

m0rsch1 avatar Jun 07 '24 12:06 m0rsch1

Please check with pre_v2.1.0 ;)

hwiedPro avatar Jun 13 '24 08:06 hwiedPro

After a quick look into the affected file i dont see this bug fixed there.

m0rsch1 avatar Jun 14 '24 05:06 m0rsch1

But now it is;)

hwiedPro avatar Jun 20 '24 11:06 hwiedPro

Found another similar issue here:

--- a/phobos/core/multiple.py
+++ b/phobos/core/multiple.py
@@ -22,7 +22,7 @@ class Entity(Representation, SmurfBase):
         assert world is not None
         self.model = _singular(model)
         self.origin = _singular(origin) if origin is not None else representation.Pose()
-        self._file = os.path.normpath(os.path.join(os.path.dirname(world.inputfile), file)) if not os.path.isabs(file) else file
+        self._file = os.path.normpath(os.path.join(os.path.dirname(world.inputfile), file)) if file is not None and not os.path.isabs(file) else file
         if model is None and file is not None:
             if self._file.lower().rsplit(".", 1)[-1] in ["smurfs", "smurfa"]:
                 try:

m0rsch1 avatar Aug 22 '24 12:08 m0rsch1

Has been fixed, thank you :)

m0rsch1 avatar Sep 02 '24 07:09 m0rsch1