Skip to content

Assertion failure in Objects/unicodeobject.c _PyUnicode_DecodeUnicodeEscapeInternal2: Assertion 'end - s <= writer.size - writer.pos' failed #141336

@YuanchengJiang

Description

@YuanchengJiang

Bug report

Bug description:

import codecs

decode = codecs.unicode_escape_decode
data = {b'\\x0': (b'\xe2\x98\x83', 0)}

def mutating(exc):
    key = exc.object[:exc.end]
    r = data.get(key)
    if r is not None:
        return ('Є', r[1])

codecs.register_error('test.mutating2', mutating)

input_obj = b'\\x0n\\z'
result, length = decode(input_obj, 'test.mutating2')
python: ../Objects/unicodeobject.c:6687: _PyUnicode_DecodeUnicodeEscapeInternal2: Assertion `end - s <= writer.size - writer.pos' failed.
Aborted (core dumped)

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Labels

interpreter-core(Objects, Python, Grammar, and Parser dirs)topic-unicodetype-crashA hard crash of the interpreter, possibly with a core dump

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions