ejwa / gitinspector

:bar_chart: The statistical analysis tool for git repositories
GNU General Public License v3.0
2.36k stars 327 forks source link

Fix unspecified stdin encoding. #117

Closed greut closed 7 years ago

greut commented 8 years ago

I've encountered this problem calling gitinspector from a subprocess within jupyter. sys.stdin.encoding was None, hence it failed.

adam-waldenberg commented 8 years ago

Hi. Often, the default encoding defaults to ascii, which I think might break things. What happens if you set the env variable "PYTHONIOENCODING=UTF-8" before starting jupyter ?

greut commented 8 years ago
from subprocess import Popen, PIPE

p = Popen(['python2', '-c', 'import sys; print(sys.stdin.encoding)'],
          stdout=PIPE)
o, e = p.communicate()
print(o)
p = Popen(['python3', '-c', 'import sys; print(sys.stdin.encoding)'],
          stdout=PIPE)
o, e = p.communicate()
print(o)
adam-waldenberg commented 8 years ago

Sorry. Completely missed this. So I am guessing it fails under Python 2 when PYTHONIOENCODING is not set ? Please provide a stacktrace and I'll have a look at this later.

adam-waldenberg commented 8 years ago

Your fix might be enough there. However, I just want to make sure we don't miss anything... Also, there is a related issue to this where a warning is printed... I'll have to consider exactly how I'll handle this.

adam-waldenberg commented 7 years ago

I'm going to considering this as an error in jupyter. I'm extremely wary of reverting to ascii under Python 2, as it can produce very strange behaviour. Closing.