MCPcopy Index your code
hub / github.com/rocky/python-uncompyle6 / customize_for_version25

Function customize_for_version25

uncompyle6/semantics/customize25.py:24–60  ·  view source on GitHub ↗
(self, version)

Source from the content-addressed store, hash-verified

22# Python 2.5+ Changes #
23#######################
24def customize_for_version25(self, version):
25 ########################
26 # Import style for 2.5+
27 ########################
28 self.TABLE_DIRECT.update(
29 {
30 "importmultiple": ("%|import %c%c\n", 2, 3),
31 "import_cont": (", %c", 2),
32 # With/as is allowed as "from future" thing in 2.5
33 # Note: It is safe to put the variables after "as" in parenthesis,
34 # and sometimes it is needed.
35 "with": ("%|with %c:\n%+%c%-", 0, 3),
36 "and_then": ("%c and %c", (0, "expr"), (4, "expr")),
37 }
38 )
39
40 # In 2.5+ "except" handlers and the "finally" can appear in one
41 # "try" statement. So the below has the effect of combining the
42 # "tryfinally" with statement with the "try_except" statement.
43 # FIXME: something doesn't smell right, since the semantics
44 # are different. See test_fileio.py for an example that shows this.
45 def tryfinallystmt(node):
46 if len(node[1][0]) == 1 and node[1][0][0] == "stmt":
47 if node[1][0][0][0] == "try_except":
48 node[1][0][0][0].kind = "tf_try_except"
49 if node[1][0][0][0] == "tryelsestmt":
50 node[1][0][0][0].kind = "tf_tryelsestmt"
51 self.default(node)
52
53 self.n_tryfinallystmt = tryfinallystmt
54
55 def n_import_from(node):
56 if node[0].pattr > 0:
57 node[2].pattr = ("." * node[0].pattr) + node[2].pattr
58 self.default(node)
59
60 self.n_import_from = n_import_from

Callers 1

customize_for_versionFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected