Skip to content

Commit 435193c

Browse files
committed
BF - move ast import into byter routine to prevent python2.5 setup error
1 parent af42a2a commit 435193c

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

nisext/py3builder.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
import sys
66
import re
7-
import ast
8-
from . import codegen
97

108
try:
119
from distutils.command.build_py import build_py_2to3
@@ -217,11 +215,6 @@ def doctest_markup(in_lines):
217215
return out_lines, err_tuples
218216

219217

220-
class RewriteStr(ast.NodeTransformer):
221-
def visit_Str(self, node):
222-
return ast.Bytes(node.s.encode('ascii'))
223-
224-
225218
def byter(src):
226219
""" Convert strings in `src` to byte string literals
227220
@@ -235,6 +228,11 @@ def byter(src):
235228
p_src : str
236229
string with ``str`` literals replace by ``byte`` literals
237230
"""
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'))
238236
tree = ast.parse(src)
239237
tree = RewriteStr().visit(tree)
240238
return codegen.to_source(tree)

0 commit comments

Comments
 (0)