Issue 31514: There is a problem with the setdefault type conversion in the tuple

The setdefault method of the tuple allows the introduction of custom data types.At this point, the __repr__ method is implemented so that the returned data type has an error.The type of str is returned, but the int type is written to the tuple.Also, write str without quotation marks.
Look at the demo.py in the attachment
The demo code you give seems to be working perfectly correctly. I don't think anything here is a bug.

(1) You are working with a dict, not a tuple.

(2) The potint.__repr__ method does NOT have a bug.

(3) de['four'] is NOT an int, it is a potint object, just as you set. It only looks like an int when you print it because that's what the __repr__ does.

To see what the object really is, call:

type(de['four'])

and you will see it is a potint.


And I have no idea what you think is wrong with string without quotation marks, it works correctly in the demo.


I'm going to close this bug report as Works For Me. If you disagree, please re-open it with more information.