mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #795
This commit is contained in:
parent
b54dd3c059
commit
b787f041d3
@ -38,6 +38,23 @@ try:
|
|||||||
except:
|
except:
|
||||||
preferred_encoding = 'utf-8'
|
preferred_encoding = 'utf-8'
|
||||||
|
|
||||||
|
_abspath = os.path.abspath
|
||||||
|
def my_abspath(path, encoding=sys.getfilesystemencoding()):
|
||||||
|
'''
|
||||||
|
Work around for buggy os.path.abspath. This function accepts either byte strings,
|
||||||
|
in which it calls os.path.abspath, or unicode string, in which case it first converts
|
||||||
|
to byte strings using `encoding`, calls abspath and then decodes back to unicode.
|
||||||
|
'''
|
||||||
|
to_unicode = False
|
||||||
|
if isinstance(path, unicode):
|
||||||
|
path = path.encode(encoding)
|
||||||
|
to_unicode = True
|
||||||
|
res = _abspath(path)
|
||||||
|
if to_unicode:
|
||||||
|
res = res.decode(encoding)
|
||||||
|
return res
|
||||||
|
|
||||||
|
os.path.abspath = my_abspath
|
||||||
|
|
||||||
def osx_version():
|
def osx_version():
|
||||||
if isosx:
|
if isosx:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user