Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
bpo-32582: chr() doesn't raise OverflowError anymore#5218
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| The :func:`chr` builtin function now catchs :exc:`OverflowError` and raises | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "catches" -- this is an implementation detail. And I think it is better to not raise and catch it. | ||
| a :exc:`ValueError` exception instead. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -715,17 +715,24 @@ builtin_format_impl(PyObject *module, PyObject *value, PyObject *format_spec) | ||
| /*[clinic input] | ||
| chr as builtin_chr | ||
| i: int | ||
| i: object | ||
| / | ||
| Return a Unicode string of one character with ordinal i; 0 <= i <= 0x10ffff. | ||
| [clinic start generated code]*/ | ||
| static PyObject * | ||
| builtin_chr_impl(PyObject *module, int i) | ||
| /*[clinic end generated code: output=c733afcd200afcb7 input=3f604ef45a70750d]*/ | ||
| builtin_chr(PyObject *module, PyObject *i) | ||
| /*[clinic end generated code: output=d34f25b8035a9b10 input=f919867f0ba2f496]*/ | ||
| { | ||
| return PyUnicode_FromOrdinal(i); | ||
| int ch = _PyLong_AsInt(i); | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is better to use | ||
| if (ch == -1 && PyErr_Occurred()){ | ||
| if (!PyErr_ExceptionMatches(PyExc_OverflowError)){ | ||
| return NULL; | ||
| } | ||
| PyErr_Clear(); | ||
| } | ||
| return PyUnicode_FromOrdinal(ch); | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use
2**1000. It is possible that once Python will run platform with 128-bit C long.