Loading pybtex/cmdline.py +3 −1 Original line number Diff line number Diff line Loading @@ -214,8 +214,10 @@ class CommandLine(object): return [self._replace_legacy_option(arg) for arg in args] def _replace_legacy_option(self, arg): # sys.argv contains byte strings in Python 2 and unicode strings in Python 3 try: # legacy options are ASCII # all legacy options are ASCII-only unicode_arg = arg if isinstance(arg, six.text_type) else arg.decode('ASCII') except UnicodeDecodeError: return arg Loading pybtex/exceptions.py +7 −1 Original line number Diff line number Diff line Loading @@ -21,6 +21,8 @@ from __future__ import absolute_import, unicode_literals import sys import six Loading @@ -35,7 +37,11 @@ class PybtexError(Exception): def get_filename(self): """Return filename, if relevant.""" if isinstance(self.filename, six.text_type): return self.filename else: from .io import _decode_filename return _decode_filename(self.filename, errors='replace') def __eq__(self, other): return six.text_type(self) == six.text_type(other) Loading pybtex/io.py +7 −0 Original line number Diff line number Diff line Loading @@ -41,6 +41,13 @@ def get_stream_encoding(stream): return stream_encoding or get_default_encoding() def _decode_filename(filename, errors='strict'): """Decode byte-encoded filename.""" encoding = sys.getfilesystemencoding() or self.get_default_encoding() return filename.decode(encoding, errors=errors) def _open_existing(opener, filename, mode, locate, **kwargs): if not path.isfile(filename): found = locate(filename) Loading Loading
pybtex/cmdline.py +3 −1 Original line number Diff line number Diff line Loading @@ -214,8 +214,10 @@ class CommandLine(object): return [self._replace_legacy_option(arg) for arg in args] def _replace_legacy_option(self, arg): # sys.argv contains byte strings in Python 2 and unicode strings in Python 3 try: # legacy options are ASCII # all legacy options are ASCII-only unicode_arg = arg if isinstance(arg, six.text_type) else arg.decode('ASCII') except UnicodeDecodeError: return arg Loading
pybtex/exceptions.py +7 −1 Original line number Diff line number Diff line Loading @@ -21,6 +21,8 @@ from __future__ import absolute_import, unicode_literals import sys import six Loading @@ -35,7 +37,11 @@ class PybtexError(Exception): def get_filename(self): """Return filename, if relevant.""" if isinstance(self.filename, six.text_type): return self.filename else: from .io import _decode_filename return _decode_filename(self.filename, errors='replace') def __eq__(self, other): return six.text_type(self) == six.text_type(other) Loading
pybtex/io.py +7 −0 Original line number Diff line number Diff line Loading @@ -41,6 +41,13 @@ def get_stream_encoding(stream): return stream_encoding or get_default_encoding() def _decode_filename(filename, errors='strict'): """Decode byte-encoded filename.""" encoding = sys.getfilesystemencoding() or self.get_default_encoding() return filename.decode(encoding, errors=errors) def _open_existing(opener, filename, mode, locate, **kwargs): if not path.isfile(filename): found = locate(filename) Loading