Skip to content

Commit

Permalink
Merge pull request #1121 from kartikmohta/fix/roslogging-python3
Browse files Browse the repository at this point in the history
Make RospyLogger.findCaller compatible with Python3 (also, unbreak ROS on Python3)
  • Loading branch information
dirk-thomas authored Aug 11, 2017
2 parents c7c1b19 + 3fa3960 commit 548cf9e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tools/rosgraph/src/rosgraph/roslogging.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@
class LoggingException(Exception): pass

class RospyLogger(logging.getLoggerClass()):
def findCaller(self):
def findCaller(self, dummy=False): # Dummy second arg to match Python3 function declaration
"""
Find the stack frame of the caller so that we can note the source
file name, line number, and function name with class name if possible.
"""
file_name, lineno, func_name = super(RospyLogger, self).findCaller()
file_name, lineno, func_name = super(RospyLogger, self).findCaller()[:3]

f = inspect.currentframe()
if f is not None:
Expand All @@ -74,7 +74,10 @@ def findCaller(self):
except KeyError: # if the function is unbound, there is no self.
pass
break
return file_name, lineno, func_name
if sys.version_info > (3, 2):
return file_name, lineno, func_name, None # Dummy last argument to match Python3 return type
else:
return file_name, lineno, func_name

logging.setLoggerClass(RospyLogger)

Expand Down

0 comments on commit 548cf9e

Please sign in to comment.