@@ -134,12 +134,22 @@ def serialize_tzinfo(
134134 def _serialize_external_object (self , o ):
135135
136136 yield "System" , "Python"
137- yield "Type" , "PythonFunction"
137+
138+ if callable (o ):
139+ yield "Type" , "PythonFunction"
140+ try :
141+ # force tuple to avoid calling this method again on `map`.
142+ yield "Arguments" , tuple (map (force_text , first (inspect .getfullargspec (o ))))
143+ except TypeError :
144+ # this function can fail with TypeError unsupported callable
145+ pass
146+ else :
147+ yield "Type" , "PythonObject"
138148
139149 if hasattr (o , "__name__" ):
140- yield "Name " , force_text (o .__name__ )
150+ yield "Command " , force_text (o .__name__ )
141151 else :
142- yield "Name " , force_text (o .__class__ .__name__ )
152+ yield "Command " , force_text (o .__class__ .__name__ )
143153
144154 is_module = inspect .ismodule (o )
145155
@@ -155,13 +165,7 @@ def _serialize_external_object(self, o):
155165 yield "IsMethod" , inspect .ismethod (o ),
156166 yield "IsCallable" , callable (o ),
157167
158- if callable (o ):
159- try :
160- # force tuple to avoid calling this method again on `map`.
161- yield "Arguments" , tuple (map (force_text , first (inspect .getfullargspec (o ))))
162- except TypeError :
163- # this function can fail with TypeError unsupported callable
164- pass
168+
165169
166170 def serialize_external_object (self , obj ):
167171 return self .serialize_function (
0 commit comments