File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# -*- coding: utf-8 -*-
22import os
33import io
4+ try :
5+ # Python 2.x and 3.x support for checking string types
6+ assert basestring
7+ assert unicode
8+ except NameError :
9+ basestring = str
10+ unicode = str
11+
412
513
614class Source (object ):
@@ -38,4 +46,12 @@ def isFileObj(self):
3846 return hasattr (self .source , 'read' )
3947
4048 def to_s (self ):
41- return self .source
49+ # String should be in unicode(python2)/str(python3) type since we will
50+ # later encode it to utf-8 bytes array to pipe into subprocess
51+ # With some charachters on python 2 it sets to str type (bytes) which is wrong
52+ # and cant later encode properly, this is a workaround for this.
53+ # See issue #42
54+ if isinstance (self .source , unicode ):
55+ return self .source
56+ else :
57+ return unicode (self .source , 'utf-8' )
You can’t perform that action at this time.
0 commit comments