From 557911b606d1609016985fdb67aae6970b7363ed Mon Sep 17 00:00:00 2001 From: Jakub Roztocil Date: Thu, 17 Mar 2016 16:14:14 +0800 Subject: [PATCH] Handle that os.pathconf is posix-only --- httpie/downloads.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/httpie/downloads.py b/httpie/downloads.py index 972151e1f0..58e7b943e9 100644 --- a/httpie/downloads.py +++ b/httpie/downloads.py @@ -148,13 +148,17 @@ def trim_filename(filename, max_len): def get_filename_max_length(directory): + max_len = 255 try: - max_len = os.pathconf(directory, 'PC_NAME_MAX') - except OSError as e: - if e.errno == errno.EINVAL: - max_len = 255 - else: - raise + pathconf = os.pathconf + except AttributeError: + pass # non-posix + else: + try: + max_len = pathconf(directory, 'PC_NAME_MAX') + except OSError as e: + if e.errno != errno.EINVAL: + raise return max_len