Skip to content

curses.complexstr concatenation returns NotImplemented instead of raising #156963

Description

@fedonman

curses.complexstr returns Py_NotImplemented from its sq_concat slot for a non-complexstr operand, and PyNumber_Add() returns an sq_concat result verbatim, so the singleton reaches Python code instead of a TypeError.

import curses

s = curses.complexstr('ab')
print('s + "x" ->', repr(s + 'x'))
s += 'x'
print('after s += "x":', repr(s))
s + "x" -> NotImplemented
after s += "x": NotImplemented

Expected: TypeError from both. The augmented assignment is the same slot, so it silently rebinds the name to NotImplemented rather than failing.

complexstr is new in 3.16, so no released version is affected.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions