Commits

gstarnberger committed 1860798

Merged some fixes from http://www.xp-dev.com/sc/81844/

Comments (0)

Files changed (3)

uncompyle/Parser.py

         stmt ::= assign
         assign ::= expr DUP_TOP designList
         assign ::= expr designator
+
+        stmt ::= _25_assign2
+        stmt ::= _25_assign3
+        _25_assign2 ::= expr expr ROT_TWO designator designator
+        _25_assign3 ::= expr expr expr ROT_THREE ROT_TWO designator designator designator
         '''
 
     def p_print(self, args):
 
         stmt ::= yield_stmt
         yield_stmt ::= expr YIELD_STMT
+        yield_stmt ::= expr YIELD_STMT POP_TOP
+
         yield_stmt ::= expr YIELD_VALUE
+        yield_stmt ::= expr YIELD_VALUE POP_TOP
 
         stmt ::= break_stmt
         break_stmt ::= BREAK_LOOP
             nak = ( len(op)-len('CALL_FUNCTION') ) / 3
             rule = 'expr ::= expr ' + 'expr '*na + 'kwarg '*nk \
                    + 'expr ' * nak + k
-        # CE - Hack for >= 2.5
-        #      Now all values loaded via LOAD_CLOSURE are packed into
-        #      a tuple before calling MAKE_CLOSURE.
-        elif op == 'CLOSURE_LIST':
-            rule = 'closure_list ::= load_closure %s' % k
         else:
             raise 'unknown customize token %s' % k
         p.addRule(rule, nop)

uncompyle/Scanner.py

                 #      a tuple before calling MAKE_CLOSURE.
                 if opname == 'BUILD_TUPLE' and \
                    dis.opname[ord(code[offset-3])] == 'LOAD_CLOSURE':
-                    opname = 'CLOSURE_LIST_%d' % oparg
+                    continue
                 else:
                     opname = '%s_%d' % (opname, oparg)
-                customize[opname] = oparg
+                    customize[opname] = oparg
 
             rv.append(Token(opname, oparg, pattr, offset))
 

uncompyle/Walker.py

     '_25_ifelsestmt': ( '%|if %c:\n%+%c%-%|else:\n%+%c%-', 0, 1, -2),
     '_25_jumptarget_e': ( '%c', -1),
     '_25_jumptarget_s': ( '%c', -1),
+
+    # CE - Fixes for tuples
+    '_25_assign2':     ( '(%c, %c,) = (%c, %c)\n', 3, 4, 0, 1 ),
+    '_25_assign3':     ( '(%c, %c, %c,) = (%c, %c, %c)\n', 5, 6, 7, 0, 1, 2 ),
+
 }
 
 
                     string = string.replace(quote, unquote)
             return string
         
-        if docstring.find('\n'): # multiline string
+        if docstring.find('\\\n') or docstring.find('\n'): # multiline string
             if docstring.find('"""') >=0:
                 quote = "'''"
             else:
             self.write('['); endchar = ']'
         elif lastnode.startswith('BUILD_TUPLE'):
             self.write('('); endchar = ')'
+        elif lastnode.startswith('ROT_TWO'):
+            self.write('('); endchar = ')'
         else:
             raise 'Internal Error: n_build_list expects list or tuple'
         
         line_seperator = ',\n' + self.indent
         sep = INDENT_PER_LEVEL[:-1]
         for elem in node:
+            if (elem == 'ROT_THREE'):
+                continue
+
             assert elem == 'expr'
             value = self.traverse(elem)
             self.write(sep, value)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.