Issue 1866: const arg for PyInt_FromString (original) (raw)

Created on 2008-01-18 18:46 by philipdumont, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
Python-2.5.patch philipdumont,2008-01-22 20:12
autotest.out.after philipdumont,2008-01-22 20:13 Output of test run after patch
make_test_after philipdumont,2008-02-12 16:10 Output of 'make test' after patch
Messages (8)
msg60108 - (view) Author: phil (philipdumont) Date: 2008-01-18 18:46
In PyInt_FromString(), please change the type of the first arg from char * to const char *. That is, of course, if the function indeed does not write to the string. (I took a quick look at the code; it doesn't appear to.) If the function does modify the string, it should be documented. I'm getting a compiler error in some C++ code when I use a std:🧵:c_str() as the arg. Of course, I could cast away the const, but paranoid as I am, I'd like reassurance that I can do so with impunity. :-)
msg60117 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2008-01-18 21:03
So how about submitting a patch *and* building everything from scratch and running all the unit tests to make sure this doesn't break anything?
msg61531 - (view) Author: phil (philipdumont) Date: 2008-01-22 20:12
Oh, all right. Just don't tell my boss -- he thinks I'm doing "real" work. :-) I haven't thoroughly studied the test harness, but it looked like /bin/python /lib/python2.5/test/autotest.py was what I should do? The output generated before/after the patch was identical.
msg62312 - (view) Author: Alyssa Coghlan (ncoghlan) * (Python committer) Date: 2008-02-12 12:29
The test suite is run via test/regrtest.py. If you aren't on windows, 'make test' works as well. For myself, I tend to just run "./python -m test.regrtest" in the directory where I built Python.
msg62321 - (view) Author: phil (philipdumont) Date: 2008-02-12 16:10
Ok. Ran 'make test' before and after patch. Output identical. Attaching output after patch.
msg87734 - (view) Author: Walter Dörwald (doerwalter) * (Python committer) Date: 2009-05-14 10:57
The patch no longer applies cleanly to the trunk.
msg116916 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2010-09-20 07:50
Any opinions as to whether the patch should be reworked for 3.2 or not?
msg116924 - (view) Author: Alyssa Coghlan (ncoghlan) * (Python committer) Date: 2010-09-20 11:16
I'm rejecting this due to the effect it has on the output parameters. The patch ends up have to stick (char *) casts in several places because a pointer into the string provided via the char * input parameter is returned by each affected API to the calling function via a char **output parameter. We can't change the signature of the output parameters since that would break existing code. That then means we also can't change the signature of the input parameters, since we can't guarantee that the recipient of the output parameter won't later use it to change things. The calling code knows whether or not it is going to modify the pointer it receives back, and hence whether or not it is safe to cast away the const-ness of the passed in pointer.
History
Date User Action Args
2022-04-11 14:56:29 admin set github: 46174
2010-09-20 11:16:41 ncoghlan set status: open -> closedresolution: rejectedmessages: +
2010-09-20 07:50:04 BreamoreBoy set nosy: + BreamoreBoymessages: + versions: - Python 2.7
2009-05-14 10:57:57 doerwalter set nosy: + doerwaltermessages: +
2009-05-13 21:55:16 ajaksu2 set keywords: + patchversions: + Python 2.7, Python 3.2, - Python 2.5
2008-02-12 16:10:23 philipdumont set files: + make_test_aftermessages: +
2008-02-12 12:29:04 ncoghlan set nosy: + ncoghlanmessages: +
2008-01-22 20:13:27 philipdumont set files: + autotest.out.after
2008-01-22 20:12:38 philipdumont set files: + Python-2.5.patchmessages: +
2008-01-18 21:03:15 gvanrossum set priority: lownosy: + gvanrossummessages: +
2008-01-18 18:46:08 philipdumont create