Skip to content

Commit 4b27ff8

Browse files
committed
Fix dumping co_varnames
fix to dump co_varnames like co_names, which prevents uncompyle6's decompilation from outputting inappropriate results when processing function parameters.
1 parent 6c8fab7 commit 4b27ff8

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

xdis/marsh.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,12 @@ def dump_code2(self, x):
327327
for name in x.co_names:
328328
self.dump_string(name)
329329

330-
self.dump(x.co_varnames)
330+
# The tuple "varnames" in Python2 also must have string entries
331+
self._write(TYPE_TUPLE)
332+
self.w_long(len(x.co_varnames))
333+
for name in x.co_varnames:
334+
self.dump_string(name)
335+
331336
self.dump(x.co_freevars)
332337
self.dump(x.co_cellvars)
333338
self.dump_string(x.co_filename)

0 commit comments

Comments
 (0)