Skip to content

Commit

Permalink
Fix PY2 error
Browse files Browse the repository at this point in the history
  • Loading branch information
karolyi committed Mar 26, 2018
1 parent 3c322a9 commit f1861fc
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion xapian_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
raise MissingDependency("The 'xapian' backend requires the installation of 'Xapian'. "
"Please refer to the documentation.")

if sys.version_info[0] == 2:
DirectoryExistsException = OSError
elif sys.version_info[0] == 3:
DirectoryExistsException = FileExistsError


class NotSupportedError(Exception):
"""
Expand Down Expand Up @@ -196,7 +201,7 @@ def __init__(self, connection_alias, **connection_options):
if self.path != MEMORY_DB_NAME:
try:
os.makedirs(self.path)
except FileExistsError:
except DirectoryExistsException:
pass

self.flags = connection_options.get('FLAGS', DEFAULT_XAPIAN_FLAGS)
Expand Down

0 comments on commit f1861fc

Please sign in to comment.