Skip to content

Commit 21f9aa8

Browse files
committed
pyassem: Turns out lambdas have co_consts[0] reserved for docstring.
Just like normal functions, except that lambdas can't have a docstring, so that entry is always 0. Behavior per CPython3.5.
1 parent ffb93a3 commit 21f9aa8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

compiler/pyassem.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ def convertArgs(self):
446446
# (Other types of code objects deal with docstrings in different
447447
# manner, e.g. lambdas and comprehensions don't have docstrings,
448448
# classes store them as __doc__ attribute.
449-
if not self.name.startswith("<") and not self.klass:
449+
if self.name == "<lambda>" or (not self.name.startswith("<") and not self.klass):
450450
self.consts.insert(0, self.docstring)
451451
self.sort_cellvars()
452452
for i in range(len(self.insts)):

0 commit comments

Comments
 (0)