mirror of
https://github.com/ejwa/gitinspector.git
synced 2024-11-16 00:28:25 +01:00
String encoding was broken during redirection of stdout.
The encoding now defaults to UTF-8 whenever stdout does not point to a proper terminal.
This commit is contained in:
parent
cf40f16119
commit
fe3f067d6a
3 changed files with 7 additions and 0 deletions
|
@ -18,6 +18,7 @@
|
|||
# along with gitinspector. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import print_function
|
||||
from __future__ import unicode_literals
|
||||
from outputable import Outputable
|
||||
import codecs
|
||||
import extensions
|
||||
|
|
|
@ -50,6 +50,7 @@ class Runner:
|
|||
|
||||
def output(self):
|
||||
terminal.skip_escapes(not sys.stdout.isatty())
|
||||
terminal.set_stdout_encoding()
|
||||
previous_directory = os.getcwd()
|
||||
os.chdir(self.repo)
|
||||
format.output_header()
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
# along with gitinspector. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import print_function
|
||||
import codecs
|
||||
import os
|
||||
import platform
|
||||
import sys
|
||||
|
@ -101,3 +102,7 @@ def get_size():
|
|||
return (width, height)
|
||||
|
||||
return (80, 25)
|
||||
|
||||
def set_stdout_encoding():
|
||||
if not sys.stdout.isatty() and sys.version_info < (3,):
|
||||
sys.stdout = codecs.getwriter('utf-8')(sys.stdout)
|
||||
|
|
Loading…
Reference in a new issue