File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ except:
4545 pass
4646
4747import codecs
48+ import io
4849
4950from docutils import nodes
5051from docutils .parsers .rst import directives , roles
@@ -164,7 +165,11 @@ def main():
164165 except IOError : # given filename could not be found
165166 return ''
166167 except IndexError : # no filename given
167- text = sys .stdin .read ()
168+ if sys .version_info [0 ] < 3 : # python 3
169+ input_stream = io .TextIOWrapper (sys .stdin .buffer , encoding = 'utf-8' )
170+ text = input_stream .read ()
171+ else : # python 2
172+ text = sys .stdin .read ()
168173
169174 writer = Writer ()
170175 writer .translator_class = GitHubHTMLTranslator
@@ -187,5 +192,9 @@ def main():
187192 return ''
188193
189194if __name__ == '__main__' :
190- sys .stdout .write ("%s%s" % (main (), "\n " ))
195+ if sys .version_info [0 ] < 3 : # python 3
196+ output_stream = io .TextIOWrapper (sys .stdout .buffer , encoding = 'utf-8' )
197+ output_stream .write ("%s%s" % (main (), "\n " ))
198+ else : # python 2.x
199+ sys .stdout .write ("%s%s" % (main (), "\n " ))
191200 sys .stdout .flush ()
You can’t perform that action at this time.
0 commit comments