134
134
from typing import Optional
135
135
136
136
from spark_parser import GenericASTTraversal
137
- from xdis import COMPILER_FLAG_BIT , iscode
137
+ from xdis import COMPILER_FLAG_BIT , IS_PYPY , iscode
138
138
from xdis .version_info import PYTHON_VERSION_TRIPLE
139
139
140
140
from uncompyle6 .parser import get_python_parser , parse
149
149
MAP ,
150
150
MAP_DIRECT ,
151
151
NAME_MODULE ,
152
+ NO_PARENTHESIS_EVER ,
152
153
NONE ,
153
154
PASS ,
154
155
PRECEDENCE ,
@@ -189,8 +190,6 @@ def unicode(x):
189
190
"dups" : False ,
190
191
}
191
192
192
- IS_PYPY = "__pypy__" in sys .builtin_module_names
193
-
194
193
TREE_DEFAULT_DEBUG = {"before" : False , "after" : False }
195
194
196
195
DEFAULT_DEBUG_OPTS = {
@@ -210,7 +209,7 @@ def __str__(self):
210
209
211
210
class SourceWalker (GenericASTTraversal , NonterminalActions , ComprehensionMixin ):
212
211
"""
213
- Class to traverses a Parse Tree of the bytecode instruction built from parsing to
212
+ Class to traverse a Parse Tree of the bytecode instruction built from parsing to
214
213
produce some sort of source text.
215
214
The Parse tree may be turned an Abstract Syntax tree as an intermediate step.
216
215
"""
@@ -267,27 +266,32 @@ def __init__(
267
266
is_pypy = is_pypy ,
268
267
)
269
268
269
+ self .ERROR = None
270
270
self .ast_errors = []
271
- self .currentclass = None
272
271
self .classes = []
272
+ self .compile_mode = compile_mode
273
+ self .currentclass = None
273
274
self .debug_parser = dict (debug_parser )
274
- self .line_number = 1
275
+ self .is_pypy = is_pypy
275
276
self .linemap = {}
276
- self .params = params
277
+ self .line_number = 1
278
+ self .linestarts = linestarts
279
+ self .mod_globs = set ()
280
+ self .name = None
281
+ self .offset2inst_index = scanner .offset2inst_index
277
282
self .param_stack = []
278
- self .ERROR = None
279
- self .prec = 100
283
+ self .params = params
284
+ self .pending_newlines = 0
285
+ self .prec = NO_PARENTHESIS_EVER
280
286
self .return_none = False
281
- self .mod_globs = set ()
282
287
self .showast = showast
283
- self .pending_newlines = 0
284
- self . linestarts = linestarts
288
+ self .version = version
289
+
285
290
self .treeTransform = TreeTransform (version = self .version , show_ast = showast )
286
291
287
292
# FIXME: have p.insts update in a better way
288
293
# modularity is broken here
289
294
self .insts = scanner .insts
290
- self .offset2inst_index = scanner .offset2inst_index
291
295
292
296
# Initialize p_lambda on demand
293
297
self .p_lambda = None
@@ -312,10 +316,6 @@ def __init__(
312
316
# An example is:
313
317
# __module__ = __name__
314
318
self .hide_internal = True
315
- self .compile_mode = compile_mode
316
- self .name = None
317
- self .version = version
318
- self .is_pypy = is_pypy
319
319
customize_for_version (self , is_pypy , version )
320
320
return
321
321
0 commit comments