[New-bugs-announce] [issue34973] Crash in bytes constructor with mutating list

Serhiy Storchaka report at bugs.python.org
Sat Oct 13 09:37:47 EDT 2018


New submission from Serhiy Storchaka <storchaka+cpython at gmail.com>:

Constructing bytes from mutating list can cause a crash.

class X:
    def __index__(self):
        if len(a) < 1000:
            a.append(self)
        return 0

a = [X()]
bytes(a)

This is not an issue about weird integer-like objects. It is about . The size of the list can be changed in other thread while iterate it in the bytes constructor.

The optimization for the case of the list argument was added in issue6688. The code was refactored several times since, but this flaw was always.

----------
assignee: serhiy.storchaka
components: Interpreter Core
messages: 327653
nosy: alexandre.vassalotti, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Crash in bytes constructor with mutating list
type: crash
versions: Python 3.6, Python 3.7, Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34973>
_______________________________________


More information about the New-bugs-announce mailing list