From: Avery Pennarun Date: Sun, 22 Aug 2010 06:44:49 +0000 (-0700) Subject: cmd/ftp: don't die if we can't import the ctypes module. X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=bacd2e74363df800a8b72ab24f12175bc98b55fb;p=packages%2Fb%2Fbup.git cmd/ftp: don't die if we can't import the ctypes module. It's only needed on some rare broken versions of readline anyway. If we can't find the module, chances are the system doesn't have that broken version of readline. Based on suggestions by Gabriel Filion and Aaron Ucko. Signed-off-by: Avery Pennarun --- diff --git a/cmd/ftp-cmd.py b/cmd/ftp-cmd.py index f61b1ee..f103a61 100755 --- a/cmd/ftp-cmd.py +++ b/cmd/ftp-cmd.py @@ -97,7 +97,13 @@ def find_readline_lib(): def init_readline_vars(): """Work around trailing space automatically inserted by readline. See http://bugs.python.org/issue5833""" - import ctypes + try: + import ctypes + except ImportError: + # python before 2.5 didn't have the ctypes module; but those + # old systems probably also didn't have this readline bug, so + # just ignore it. + return lib_name = find_readline_lib() if lib_name is not None: lib = ctypes.cdll.LoadLibrary(lib_name)