Fix Mypy error
This commit is contained in:
parent
3779d749cd
commit
523960bc9f
@ -72,17 +72,16 @@ if sys.platform == "win32":
|
|||||||
elif os.name == "posix":
|
elif os.name == "posix":
|
||||||
import fcntl
|
import fcntl
|
||||||
|
|
||||||
HAVE_RENAMEAT2: bool = False
|
|
||||||
if sys.platform == "linux":
|
if sys.platform == "linux":
|
||||||
import ctypes
|
import ctypes
|
||||||
|
|
||||||
RENAME_EXCHANGE: int = 2
|
RENAME_EXCHANGE: int = 2
|
||||||
|
renameat2 = None
|
||||||
try:
|
try:
|
||||||
renameat2 = ctypes.CDLL(None, use_errno=True).renameat2
|
renameat2 = ctypes.CDLL(None, use_errno=True).renameat2
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
HAVE_RENAMEAT2 = True
|
|
||||||
renameat2.argtypes = [
|
renameat2.argtypes = [
|
||||||
ctypes.c_int, ctypes.c_char_p,
|
ctypes.c_int, ctypes.c_char_p,
|
||||||
ctypes.c_int, ctypes.c_char_p,
|
ctypes.c_int, ctypes.c_char_p,
|
||||||
@ -170,7 +169,7 @@ def rename_exchange(src: str, dst: str) -> None:
|
|||||||
dst_dir = dst_dir or os.curdir
|
dst_dir = dst_dir or os.curdir
|
||||||
if not src_base or not dst_base:
|
if not src_base or not dst_base:
|
||||||
raise ValueError("Invalid arguments: %r -> %r" % (src, dst))
|
raise ValueError("Invalid arguments: %r -> %r" % (src, dst))
|
||||||
if HAVE_RENAMEAT2:
|
if sys.platform == "linux" and renameat2:
|
||||||
src_base_bytes = os.fsencode(src_base)
|
src_base_bytes = os.fsencode(src_base)
|
||||||
dst_base_bytes = os.fsencode(dst_base)
|
dst_base_bytes = os.fsencode(dst_base)
|
||||||
src_dir_fd = os.open(src_dir, 0)
|
src_dir_fd = os.open(src_dir, 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user