File tree Expand file tree Collapse file tree 1 file changed +5
-7
lines changed Expand file tree Collapse file tree 1 file changed +5
-7
lines changed Original file line number Diff line number Diff line change 4
4
5
5
import sys
6
6
import re
7
- import ast
8
- from . import codegen
9
7
10
8
try :
11
9
from distutils .command .build_py import build_py_2to3
@@ -217,11 +215,6 @@ def doctest_markup(in_lines):
217
215
return out_lines , err_tuples
218
216
219
217
220
- class RewriteStr (ast .NodeTransformer ):
221
- def visit_Str (self , node ):
222
- return ast .Bytes (node .s .encode ('ascii' ))
223
-
224
-
225
218
def byter (src ):
226
219
""" Convert strings in `src` to byte string literals
227
220
@@ -235,6 +228,11 @@ def byter(src):
235
228
p_src : str
236
229
string with ``str`` literals replace by ``byte`` literals
237
230
"""
231
+ import ast
232
+ from . import codegen
233
+ class RewriteStr (ast .NodeTransformer ):
234
+ def visit_Str (self , node ):
235
+ return ast .Bytes (node .s .encode ('ascii' ))
238
236
tree = ast .parse (src )
239
237
tree = RewriteStr ().visit (tree )
240
238
return codegen .to_source (tree )
You can’t perform that action at this time.
0 commit comments