gh-156963: Raise TypeError when concatenating complexstr with another type - #156964
Open
fedonman wants to merge 1 commit into
Open
gh-156963: Raise TypeError when concatenating complexstr with another type#156964fedonman wants to merge 1 commit into
fedonman wants to merge 1 commit into
Conversation
…nother type complexstr_concat() is the sq_concat slot and returned NotImplemented for a non-complexstr operand. PyNumber_Add() returns an sq_concat result verbatim, so the singleton reached Python code instead of a TypeError, and an augmented assignment rebound the name to it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
complexstr_concat()is installed asPy_sq_concatand returnedPy_NotImplementedfor a non-complexstroperand, butPyNumber_Add()checks forNotImplementedonly on thenb_addpath and returns ansq_concatresult verbatim, so the singleton reached Python code ands += 'x'rebound the name to it. It now raisesTypeError, matching the twotp_richcompareslots that use the protocol where it does apply.__radd__is unaffected, sincePyNumber_Add()triesnb_addon both operands before falling back tosq_concat.There is no NEWS entry because
complexstris new in 3.16 and unreleased, so no user could hit this.curses.complexstrconcatenation returnsNotImplementedinstead of raising #156963