Thanks to visit codestin.com
Credit goes to github.com

Skip to content

gh-76763: chr function raises ValueError exception instead OverflowError #104486

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

furkanonder
Copy link
Contributor

@furkanonder furkanonder commented May 14, 2023

@@ -247,6 +247,9 @@ builtin_chr(PyObject *module, PyObject *arg)

i = _PyLong_AsInt(arg);
if (i == -1 && PyErr_Occurred()) {
if (PyErr_ExceptionMatches(PyExc_OverflowError)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't change the generated Argument Clinic files directly. I'm not sure, unfortunately, if there's an easy way to implement the desired behavior while still using Argument Clinic.

@furkanonder furkanonder added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error labels Aug 6, 2023
Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is an implementation detail. On platform with INT_MAX >= 2**32 it raises ValueError.

@serhiy-storchaka
Copy link
Member

Also it may raise ValueError on other Python implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting review interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants