@@ -124,7 +124,7 @@ def __setattr__(self, name, value):
124124 else :
125125 juliapath = remove_prefix (self .__name__ , "julia." )
126126 setter = '''
127- Main. PyCall.pyfunctionret(
127+ PyCall.pyfunctionret(
128128 (x) -> eval({}, :({} = $x)),
129129 Any,
130130 PyCall.PyAny)
@@ -407,9 +407,10 @@ def __init__(self, init_julia=True, jl_runtime_path=None, jl_init_path=None,
407407 self .api .jl_typeof_str .restype = char_p
408408 self .api .jl_call2 .argtypes = [void_p , void_p , void_p ]
409409 self .api .jl_call2 .restype = void_p
410+ self .api .jl_get_field .argtypes = [void_p , char_p ]
410411 self .api .jl_get_field .restype = void_p
411412 self .api .jl_typename_str .restype = char_p
412- self .api .jl_typeof_str . restype = char_p
413+ self .api .jl_unbox_voidpointer . argtypes = [ void_p ]
413414 self .api .jl_unbox_voidpointer .restype = py_object
414415
415416 self .api .jl_exception_clear .restype = None
@@ -420,9 +421,6 @@ def __init__(self, init_julia=True, jl_runtime_path=None, jl_init_path=None,
420421 self .api .jl_printf .restype = ctypes .c_int
421422 self .api .jl_exception_clear ()
422423
423- # We use show() for displaying uncaught exceptions.
424- self .api .show = self ._call ("Base.show" )
425-
426424 if init_julia :
427425 if use_separate_cache :
428426 # First check that this is supported
@@ -460,9 +458,6 @@ def __init__(self, init_julia=True, jl_runtime_path=None, jl_init_path=None,
460458 self .api .PyObject = self ._call ("PyCall.PyObject" )
461459 self .api .convert = self ._call ("convert" )
462460
463- # We use show() for displaying uncaught exceptions.
464- self .api .show = self ._call ("Base.show" )
465-
466461 # Flag process-wide that Julia is initialized and store the actual
467462 # runtime interpreter, so we can reuse it across calls and module
468463 # reloads.
@@ -494,7 +489,7 @@ def _call(self, src):
494489
495490 return ans
496491
497- def check_exception (self , src = None ):
492+ def check_exception (self , src = "<unknown code>" ):
498493 exoc = self .api .jl_exception_occurred ()
499494 self ._debug ("exception occured? " + str (exoc ))
500495 if not exoc :
@@ -511,9 +506,7 @@ def check_exception(self, src=None):
511506 except AttributeError :
512507 res = None
513508 else :
514- res = self .api .jl_call2 (void_p (self .api .convert ),
515- void_p (self .api .PyObject ),
516- void_p (exoc ))
509+ res = self .api .jl_call2 (self .api .convert , self .api .PyObject , exoc )
517510 if res is None :
518511 exception = self .api .jl_typeof_str (exoc ).decode ('utf-8' )
519512 else :
@@ -539,17 +532,17 @@ def eval(self, src):
539532 ans = self ._call (src )
540533 if not ans :
541534 return None
542- res = self .api .jl_call2 (void_p ( self .api .convert ), void_p ( self .api .PyObject ), void_p ( ans ) )
535+ res = self .api .jl_call2 (self .api .convert , self .api .PyObject , ans )
543536
544537 if res is None :
545- self .check_exception (src )
546- return self ._as_pyobj (res , "convert(PyCall.PyObject, {})" . format ( src ) )
538+ self .check_exception ("convert(PyCall.PyObject, {})" . format ( src ) )
539+ return self ._as_pyobj (res )
547540
548- def _as_pyobj (self , res , src = None ):
541+ def _as_pyobj (self , res ):
549542 if res == 0 :
550543 return None
551- boxed_obj = self .api .jl_get_field (void_p ( res ) , b'o' )
552- pyobj = self .api .jl_unbox_voidpointer (void_p ( boxed_obj ) )
544+ boxed_obj = self .api .jl_get_field (res , b'o' )
545+ pyobj = self .api .jl_unbox_voidpointer (boxed_obj )
553546 # make sure we incref it before returning it,
554547 # as this is a borrowed reference
555548 ctypes .pythonapi .Py_IncRef (ctypes .py_object (pyobj ))
0 commit comments