From 5ff3cc06b7301dc211c18b942c63cd250e9c1a3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Alvergnat?= Date: Tue, 22 May 2018 00:01:26 +0200 Subject: [PATCH] Fix crash when using pathlib.Path object on python 3.4 & 3.5 --- guessit/api.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/guessit/api.py b/guessit/api.py index 41c0191..555b8d8 100644 --- a/guessit/api.py +++ b/guessit/api.py @@ -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: