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