Skip to content

Commit

Permalink
Raise the correct exception from AnyMsg.serialize (#1311)
Browse files Browse the repository at this point in the history
Previously, this was causing `TypeError: 'module' object is not
callable`, which was not noticed due to the bare `except:` in the test.
  • Loading branch information
drigz authored and dirk-thomas committed Feb 9, 2018
1 parent 4d4774b commit a3a06d4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion clients/rospy/src/rospy/msg.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def __init__(self, *args):
def serialize(self, buff):
"""AnyMsg provides an implementation so that a node can forward messages w/o (de)serialization"""
if self._buff is None:
raise rospy.exceptions("AnyMsg is not initialized")
raise rospy.exceptions.ROSException("AnyMsg is not initialized")
else:
buff.write(self._buff)

Expand Down
3 changes: 2 additions & 1 deletion test/test_rospy/test/unit/test_rospy_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,13 @@ def test_anymsg(self):
except ImportError:
from io import StringIO
import rospy
import rospy.exceptions
#trip wires against AnyMsg API
m = rospy.AnyMsg()
try:
m.serialize(StringIO())
self.fail("AnyMsg should not allow serialization")
except:
except rospy.exceptions.ROSException:
pass

teststr = 'foostr-%s'%time.time()
Expand Down

0 comments on commit a3a06d4

Please sign in to comment.