mirror of
https://github.com/zoriya/guessit.git
synced 2026-06-01 18:15:52 +00:00
Fix crash when using pathlib.Path object on python 3.4 & 3.5
This commit is contained in:
+10
-4
@@ -9,6 +9,7 @@ try:
|
||||
except ImportError: # pragma: no-cover
|
||||
from ordereddict import OrderedDict # pylint:disable=import-error
|
||||
|
||||
import os
|
||||
import traceback
|
||||
|
||||
import six
|
||||
@@ -131,16 +132,21 @@ class GuessItApi(object):
|
||||
"""
|
||||
Retrieves all matches from string as a dict
|
||||
:param string: the filename or release name
|
||||
:type string: str
|
||||
:type string: str|Path
|
||||
:param options:
|
||||
:type options: str|dict
|
||||
:return:
|
||||
:rtype:
|
||||
"""
|
||||
try:
|
||||
# Handle path-like object
|
||||
string = string.__fspath__()
|
||||
except AttributeError:
|
||||
from pathlib import Path
|
||||
if isinstance(string, Path):
|
||||
try:
|
||||
# Handle path-like object
|
||||
string = os.fspath(string)
|
||||
except AttributeError:
|
||||
string = str(string)
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user