Skip to content

Commit e5ef722

Browse files
committed
Stop using aliases void_p/char_p
This is in preparation for using isort which currently has a bug that it cannot handle import mixing aliases and non-aliases.
1 parent d2a88af commit e5ef722

File tree

1 file changed

+22
-24
lines changed

1 file changed

+22
-24
lines changed

src/julia/core.py

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@
2727
import textwrap
2828
import warnings
2929

30-
from ctypes import c_void_p as void_p
31-
from ctypes import c_char_p as char_p
32-
from ctypes import py_object, c_int, c_char_p, POINTER, pointer
30+
from ctypes import py_object, c_char_p, c_int, c_void_p, POINTER, pointer
3331

3432
try:
3533
from shutil import which
@@ -510,40 +508,40 @@ def is_compatible_exe(jl_libpython):
510508

511509
def setup_libjulia(libjulia):
512510
# Store the running interpreter reference so we can start using it via self.call
513-
libjulia.jl_.argtypes = [void_p]
511+
libjulia.jl_.argtypes = [c_void_p]
514512
libjulia.jl_.restype = None
515513

516514
# Set the return types of some of the bridge functions in ctypes terminology
517-
libjulia.jl_eval_string.argtypes = [char_p]
518-
libjulia.jl_eval_string.restype = void_p
519-
520-
libjulia.jl_exception_occurred.restype = void_p
521-
libjulia.jl_typeof_str.argtypes = [void_p]
522-
libjulia.jl_typeof_str.restype = char_p
523-
libjulia.jl_call2.argtypes = [void_p, void_p, void_p]
524-
libjulia.jl_call2.restype = void_p
525-
libjulia.jl_get_field.argtypes = [void_p, char_p]
526-
libjulia.jl_get_field.restype = void_p
527-
libjulia.jl_typename_str.restype = char_p
528-
libjulia.jl_unbox_voidpointer.argtypes = [void_p]
515+
libjulia.jl_eval_string.argtypes = [c_char_p]
516+
libjulia.jl_eval_string.restype = c_void_p
517+
518+
libjulia.jl_exception_occurred.restype = c_void_p
519+
libjulia.jl_typeof_str.argtypes = [c_void_p]
520+
libjulia.jl_typeof_str.restype = c_char_p
521+
libjulia.jl_call2.argtypes = [c_void_p, c_void_p, c_void_p]
522+
libjulia.jl_call2.restype = c_void_p
523+
libjulia.jl_get_field.argtypes = [c_void_p, c_char_p]
524+
libjulia.jl_get_field.restype = c_void_p
525+
libjulia.jl_typename_str.restype = c_char_p
526+
libjulia.jl_unbox_voidpointer.argtypes = [c_void_p]
529527
libjulia.jl_unbox_voidpointer.restype = py_object
530528

531529
for c_type in UNBOXABLE_TYPES:
532530
jl_unbox = getattr(libjulia, "jl_unbox_{}".format(c_type))
533-
jl_unbox.argtypes = [void_p]
531+
jl_unbox.argtypes = [c_void_p]
534532
jl_unbox.restype = getattr(ctypes, "c_{}".format({
535533
"float32": "float",
536534
"float64": "double",
537535
}.get(c_type, c_type)))
538536

539-
libjulia.jl_typeof.argtypes = [void_p]
540-
libjulia.jl_typeof.restype = void_p
537+
libjulia.jl_typeof.argtypes = [c_void_p]
538+
libjulia.jl_typeof.restype = c_void_p
541539

542540
libjulia.jl_exception_clear.restype = None
543541
libjulia.jl_stderr_obj.argtypes = []
544-
libjulia.jl_stderr_obj.restype = void_p
542+
libjulia.jl_stderr_obj.restype = c_void_p
545543
libjulia.jl_stderr_stream.argtypes = []
546-
libjulia.jl_stderr_stream.restype = void_p
544+
libjulia.jl_stderr_stream.restype = c_void_p
547545
libjulia.jl_printf.restype = ctypes.c_int
548546

549547
libjulia.jl_parse_opts.argtypes = [POINTER(c_int),
@@ -759,7 +757,7 @@ def init_julia(self, options=None):
759757
argv_list = [s.encode('utf-8') for s in argv_list]
760758

761759
argc = c_int(len(argv_list))
762-
argv = POINTER(char_p)((char_p * len(argv_list))(*argv_list))
760+
argv = POINTER(c_char_p)((c_char_p * len(argv_list))(*argv_list))
763761

764762
logger.debug("argv_list = %r", argv_list)
765763
logger.debug("argc = %r", argc)
@@ -1139,9 +1137,9 @@ def check_exception(self, src="<unknown code>"):
11391137
.format(exception, src))
11401138

11411139
def _typeof_julia_exception_in_transit(self):
1142-
exception = void_p.in_dll(self.api, 'jl_exception_in_transit')
1140+
exception = c_void_p.in_dll(self.api, 'jl_exception_in_transit')
11431141
msg = self.api.jl_typeof_str(exception)
1144-
return char_p(msg).value
1142+
return c_char_p(msg).value
11451143

11461144
def help(self, name):
11471145
""" Return help string for function by name. """

0 commit comments

Comments
 (0)