Skip to content

Fix wrong type name in __repr__ TypeError message#678

Draft
jseop-lim wants to merge 1 commit intooracle:masterfrom
jseop-lim:GH676-fix-repr
Draft

Fix wrong type name in __repr__ TypeError message#678
jseop-lim wants to merge 1 commit intooracle:masterfrom
jseop-lim:GH676-fix-repr

Conversation

@jseop-lim
Copy link

Description

Fixes #676.

When __repr__ returns a non-string value, the TypeError message incorrectly reports the type of the object being repr'd instead of the return value's type, diverging from CPython.

AS-IS

TypeError: __repr__ returned non-string (type A)

(type of the object)

TO-BE

TypeError: __repr__ returned non-string (type bool)

(type of the return value, matching CPython)

Change

Pass result (the __repr__ return value) instead of obj (the object being repr'd) to raiseTypeError in PyObjectReprAsObjectNode.java. The equivalent __str__ path in PyObjectStrAsObjectNode.java already does this correctly.

@oracle-contributor-agreement
Copy link

Thank you for your pull request and welcome to our community! To contribute, please sign the Oracle Contributor Agreement (OCA).
The following contributors of this PR have not signed the OCA:

To sign the OCA, please create an Oracle account and sign the OCA in Oracle's Contributor Agreement Application.

When signing the OCA, please provide your GitHub username. After signing the OCA and getting an OCA approval from Oracle, this PR will be automatically updated.

If you are an Oracle employee, please make sure that you are a member of the main Oracle GitHub organization, and your membership in this organization is public.

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Required At least one contributor does not have an approved Oracle Contributor Agreement. label Mar 13, 2026
@jseop-lim jseop-lim marked this pull request as draft March 13, 2026 09:54
@jseop-lim jseop-lim changed the title Fix repr to include result in TypeError [GH-676] Fix wrong type name in __repr__ TypeError message Mar 13, 2026
@jseop-lim jseop-lim changed the title [GH-676] Fix wrong type name in __repr__ TypeError message Fix wrong type name in __repr__ TypeError message Mar 13, 2026
Signed-off-by: Jeongseop Lim <jseoplim@gmail.com>
@jseop-lim jseop-lim marked this pull request as ready for review March 13, 2026 10:08
@jseop-lim jseop-lim marked this pull request as draft March 13, 2026 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

OCA Required At least one contributor does not have an approved Oracle Contributor Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: __repr__ TypeError reports wrong type in error message

1 participant