[New-bugs-announce] [issue27707] List reports incorrect length if modifed after yield

Robin report at bugs.python.org
Mon Aug 8 04:49:01 EDT 2016


New submission from Robin:

reproduction script below. In the last print statement, it shows me a list with items in it, but with a length of 0

def generator():
	l = []
	yield l
	l.append(1)
	# this correctly prints 1
	print(len(l))

# this should print [([1], 1)], but actually gives [([1], 0)]
print([(l, len(l)) for l in generator()])

----------
components: Interpreter Core
messages: 272151
nosy: robinh
priority: normal
severity: normal
status: open
title: List reports incorrect length if modifed after yield
type: behavior
versions: Python 3.4

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue27707>
_______________________________________


More information about the New-bugs-announce mailing list