This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Assertion failures when calling PyNumber_ToBase() with an invalid base
Type: crash Stage: resolved
Components: C API Versions: Python 3.9, Python 3.8, Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: ZackerySpytz, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2019-10-30 14:20 by ZackerySpytz, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 16996 closed ZackerySpytz, 2019-10-30 14:24
PR 18863 merged serhiy.storchaka, 2020-03-08 21:08
PR 18954 merged serhiy.storchaka, 2020-03-12 06:52
PR 18955 merged serhiy.storchaka, 2020-03-12 07:37
Messages (6)
msg355715 - (view) Author: Zackery Spytz (ZackerySpytz) * (Python triager) Date: 2019-10-30 14:20
If a base other than 2, 8, or 16 is passed to PyNumber_ToBase(), an assertion failure will occur. An exception should be raised instead.

This was mentioned in bpo-38249 (msg353039).
msg363686 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2020-03-08 21:10
Sorry Zackery, I did not know about this issue so I wrote different PR to fix this problem. And only after writing it I have found this issue.

There are several differences between your PR and PR 18863.

* SystemError is raised instead of ValueError because this is incorrect use of the C API.
* The error message mentions also base 10.
* The test is written mostly in Python.

For these reasons I prefer my PR.

Please let me know if you need a review for other PRs.
msg363758 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2020-03-09 18:03
New changeset e5ccc94bbb153431698b2391df625e8d47a93276 by Serhiy Storchaka in branch 'master':
bpo-38643: Raise SystemError instead of crashing when PyNumber_ToBase is called with invalid base. (GH-18863)
https://github.com/python/cpython/commit/e5ccc94bbb153431698b2391df625e8d47a93276
msg363994 - (view) Author: Zackery Spytz (ZackerySpytz) * (Python triager) Date: 2020-03-12 05:09
Okay, Serhiy.  I think your patch is a better choice.
msg363999 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2020-03-12 07:31
New changeset ab9c72912178cfdb4d0637be036d78913b769154 by Serhiy Storchaka in branch '3.8':
[3.8] bpo-38643: Raise SystemError instead of crashing when PyNumber_ToBase is called with invalid base. (GH-18863). (GH-18954)
https://github.com/python/cpython/commit/ab9c72912178cfdb4d0637be036d78913b769154
msg364002 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2020-03-12 08:15
New changeset 6f4e7fcfca6923d0422b20fc8702240bd4e56ebd by Serhiy Storchaka in branch '3.7':
[3.7] bpo-38643: Raise SystemError instead of crashing when PyNumber_ToBase is called with invalid base. (GH-18863). (GH-18955)
https://github.com/python/cpython/commit/6f4e7fcfca6923d0422b20fc8702240bd4e56ebd
History
Date User Action Args
2022-04-11 14:59:22adminsetgithub: 82824
2020-03-12 08:18:44serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2020-03-12 08:15:23serhiy.storchakasetmessages: + msg364002
2020-03-12 07:37:08serhiy.storchakasetpull_requests: + pull_request18306
2020-03-12 07:31:15serhiy.storchakasetmessages: + msg363999
2020-03-12 06:52:01serhiy.storchakasetpull_requests: + pull_request18305
2020-03-12 05:09:59ZackerySpytzsetmessages: + msg363994
2020-03-09 18:03:45serhiy.storchakasetmessages: + msg363758
2020-03-08 21:10:58serhiy.storchakasetcomponents: + C API, - Interpreter Core
2020-03-08 21:10:44serhiy.storchakasetversions: - Python 2.7
2020-03-08 21:10:33serhiy.storchakasetmessages: + msg363686
2020-03-08 21:08:28serhiy.storchakasetnosy: + serhiy.storchaka
pull_requests: + pull_request18220
2019-10-30 14:24:53ZackerySpytzsetkeywords: + patch
stage: patch review
pull_requests: + pull_request16523
2019-10-30 14:20:36ZackerySpytzcreate