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: Don't use assert for checking arguments in pprint
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: berker.peksag, fdrake, python-dev, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2015-03-25 09:37 by serhiy.storchaka, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
pprint_args_check.patch serhiy.storchaka, 2015-03-25 09:37 review
Messages (4)
msg239241 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-03-25 09:37
The assert statement should be used only for checking internal logic, and not for checking user data. These assertions should be either removed or converted into explicit raising ValueError.
msg239243 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2015-03-25 09:55
Looks good. Two things:

* I'd apply this only to the default branch. Changing exceptions from AssertionError to ValueError in bugfix releases may break third party code. I couldn't find a similar bug report in the tracker, so it's probably not worth to take that risk.
* We should audit the standard library for similar issues
msg239244 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-03-25 10:18
Similar issues are issue8361 and issue17840.
msg239307 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015-03-26 06:45
New changeset bf570ff87c60 by Serhiy Storchaka in branch 'default':
Issue #23776: Removed asserts from pprint.PrettyPrinter constructor.
https://hg.python.org/cpython/rev/bf570ff87c60
History
Date User Action Args
2022-04-11 14:58:14adminsetgithub: 67964
2015-03-26 06:56:44serhiy.storchakasetversions: - Python 2.7, Python 3.4
2015-03-26 06:56:17serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: commit review -> resolved
2015-03-26 06:45:32python-devsetnosy: + python-dev
messages: + msg239307
2015-03-25 10:18:29serhiy.storchakasetmessages: + msg239244
2015-03-25 09:55:53berker.peksagsetnosy: + berker.peksag
messages: + msg239243

assignee: serhiy.storchaka
stage: patch review -> commit review
2015-03-25 09:37:56serhiy.storchakasetfiles: + pprint_args_check.patch
keywords: + patch
2015-03-25 09:37:42serhiy.storchakacreate