Skip to content

Commit a5f6491

Browse files
committed
Change some eval tests to isdefined
Suggested by @tkelman
1 parent 8943e7b commit a5f6491

File tree

1 file changed

+4
-17
lines changed

1 file changed

+4
-17
lines changed

src/gentypes.jl

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -245,13 +245,7 @@ function _import_rospy_pkg(package::String)
245245
throw(ArgumentError("Improper import call for package: $package"))
246246
end
247247
pypkg = symbol(string("py_",pkg,"_",ptype))
248-
newimport = try
249-
eval(pypkg)
250-
false
251-
catch
252-
true
253-
end
254-
if newimport
248+
if ! isdefined(RobotOS, pypkg)
255249
@debug("Importing python package: ", package)
256250
pkgsym, mssym = symbol(pkg), symbol(ptype)
257251
try
@@ -421,7 +415,7 @@ end
421415
#Create the core generated expressions for a native Julia message type that has
422416
#data fields and interchanges with a python counterpart:
423417
# (1) the 'type ... end' block
424-
# (2) No param outer constructer
418+
# (2) Default outer constructer with no arguments
425419
# (3) convert(PyObject, ...)
426420
# (4) convert(..., o::PyObject)
427421
function typecode(rosname::String, super::Symbol, members::Vector)
@@ -606,7 +600,7 @@ function _check_array_type(typ::String)
606600
btype, arraylen
607601
end
608602

609-
#Get the ROS name string corresponding to a generated type
603+
#Get the rospy PyObject corresponding to a generated type
610604
function _get_rospy_class(typ::DataType)
611605
global _rospy_objects
612606
rospycls =
@@ -624,14 +618,7 @@ end
624618

625619
#Check if the type name conflicts with a Julia builtin. Currently this is only
626620
#some of the messages from the std_msgs.msg package
627-
function _nameconflicts(typename::String)
628-
try
629-
eval(Base, symbol(typename))
630-
true
631-
catch
632-
false
633-
end
634-
end
621+
_nameconflicts(typename::String) = isdefined(Base, symbol(typename))
635622

636623
#Get a default value for any builtin ROS type
637624
_typedefault{T<:Real}(::Type{T}) = zero(T)

0 commit comments

Comments
 (0)