From 02edfdfa86c828de0449efa90892eec4baccc7d7 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 30 Oct 2020 21:59:17 +0530 Subject: [PATCH] Ignore any errors from calling get_long_path_name Fixes #1902257 [failed import on newest release](https://bugs.launchpad.net/calibre/+bug/1902257) --- src/calibre/gui2/win_file_dialogs.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/calibre/gui2/win_file_dialogs.py b/src/calibre/gui2/win_file_dialogs.py index 45b18f3cd2..6ef132f48c 100644 --- a/src/calibre/gui2/win_file_dialogs.py +++ b/src/calibre/gui2/win_file_dialogs.py @@ -9,6 +9,7 @@ import subprocess import sys from threading import Thread from uuid import uuid4 +from contextlib import suppress from polyglot.builtins import filter, string_or_bytes, unicode_type @@ -227,11 +228,13 @@ def run_file_dialog( def fix_path(x): u = os.path.abspath(x.decode('utf-8')) - try: - return get_long_path_name(u) - except FileNotFoundError: - base, fn = os.path.split(u) - return os.path.join(get_long_path_name(base), fn) + with suppress(Exception): + try: + return get_long_path_name(u) + except FileNotFoundError: + base, fn = os.path.split(u) + return os.path.join(get_long_path_name(base), fn) + return u ans = tuple(map(fix_path, parts[1:])) return ans