@@ -347,6 +347,19 @@ def __init__(self, name, mode=DEFAULT_MODE, handle=None,
347347 use_errno = False ,
348348 use_last_error = False ,
349349 winmode = None ):
350+ if name :
351+ name = _os .fspath (name )
352+
353+ # If the filename that has been provided is an iOS/tvOS/watchOS
354+ # .fwork file, dereference the location to the true origin of the
355+ # binary.
356+ if name .endswith (".fwork" ):
357+ with open (name ) as f :
358+ name = _os .path .join (
359+ _os .path .dirname (_sys .executable ),
360+ f .read ().strip ()
361+ )
362+
350363 self ._name = name
351364 flags = self ._func_flags_
352365 if use_errno :
@@ -467,6 +480,8 @@ def LoadLibrary(self, name):
467480
468481if _os .name == "nt" :
469482 pythonapi = PyDLL ("python dll" , None , _sys .dllhandle )
483+ elif _sys .platform == "android" :
484+ pythonapi = PyDLL ("libpython%d.%d.so" % _sys .version_info [:2 ])
470485elif _sys .platform == "cygwin" :
471486 pythonapi = PyDLL ("libpython%d.%d.dll" % _sys .version_info [:2 ])
472487else :
@@ -498,15 +513,14 @@ def WinError(code=None, descr=None):
498513 c_ssize_t = c_longlong
499514
500515# functions
516+
501517from _ctypes import _memmove_addr , _memset_addr , _string_at_addr , _cast_addr
502518
503519## void *memmove(void *, const void *, size_t);
504- # XXX: RUSTPYTHON
505- # memmove = CFUNCTYPE(c_void_p, c_void_p, c_void_p, c_size_t)(_memmove_addr)
520+ memmove = CFUNCTYPE (c_void_p , c_void_p , c_void_p , c_size_t )(_memmove_addr )
506521
507522## void *memset(void *, int, size_t)
508- # XXX: RUSTPYTHON
509- # memset = CFUNCTYPE(c_void_p, c_void_p, c_int, c_size_t)(_memset_addr)
523+ memset = CFUNCTYPE (c_void_p , c_void_p , c_int , c_size_t )(_memset_addr )
510524
511525def PYFUNCTYPE (restype , * argtypes ):
512526 class CFunctionType (_CFuncPtr ):
@@ -515,30 +529,27 @@ class CFunctionType(_CFuncPtr):
515529 _flags_ = _FUNCFLAG_CDECL | _FUNCFLAG_PYTHONAPI
516530 return CFunctionType
517531
518- # XXX: RUSTPYTHON
519- # _cast = PYFUNCTYPE(py_object, c_void_p, py_object, py_object)(_cast_addr)
532+ _cast = PYFUNCTYPE (py_object , c_void_p , py_object , py_object )(_cast_addr )
520533def cast (obj , typ ):
521534 return _cast (obj , obj , typ )
522535
523- # XXX: RUSTPYTHON
524- # _string_at = PYFUNCTYPE(py_object, c_void_p, c_int)(_string_at_addr)
536+ _string_at = PYFUNCTYPE (py_object , c_void_p , c_int )(_string_at_addr )
525537def string_at (ptr , size = - 1 ):
526- """string_at(addr [, size]) -> string
538+ """string_at(ptr [, size]) -> string
527539
528- Return the string at addr ."""
540+ Return the byte string at void *ptr ."""
529541 return _string_at (ptr , size )
530542
531543try :
532544 from _ctypes import _wstring_at_addr
533545except ImportError :
534546 pass
535547else :
536- # XXX: RUSTPYTHON
537- # _wstring_at = PYFUNCTYPE(py_object, c_void_p, c_int)(_wstring_at_addr)
548+ _wstring_at = PYFUNCTYPE (py_object , c_void_p , c_int )(_wstring_at_addr )
538549 def wstring_at (ptr , size = - 1 ):
539- """wstring_at(addr [, size]) -> string
550+ """wstring_at(ptr [, size]) -> string
540551
541- Return the string at addr ."""
552+ Return the wide-character string at void *ptr ."""
542553 return _wstring_at (ptr , size )
543554
544555
0 commit comments