Re: [Python-Dev] Const-correctness in C-API Object Protocol

2011-02-22 Thread Martin v. Löwis
> I don't think it's a good idea to backport visible API changes. > (someone successfully compiling on 2.7.N could then have users > complaining that compilation fails on 2.7.N-1). +1. If it was a bug fix (which it isn't), having this kind of breakage would be fine, of course (i.e. code relying on

Re: [Python-Dev] Const-correctness in C-API Object Protocol

2011-02-22 Thread Alexander Belopolsky
On Tue, Feb 22, 2011 at 6:36 PM, Antoine Pitrou wrote: .. > To quote the message above: someone successfully compiling on 2.7.N > could then have users complaining that compilation fails on 2.7.N-1. > (note: *N-1*) I missed that. Yes, this is a valid concern. I change my vote from -0 to -1. :-)

Re: [Python-Dev] Const-correctness in C-API Object Protocol

2011-02-22 Thread Martin v. Löwis
> Even if it is eventually decided not to backport those patches to 2.7, > it would be nice if the documentation could be updated to indicate > that strings passed to those functions won't be modified, so that API > users like myself can feel a little safer when passing literals in, > without havin

Re: [Python-Dev] Const-correctness in C-API Object Protocol

2011-02-22 Thread Antoine Pitrou
Le mardi 22 février 2011 à 18:30 -0500, Alexander Belopolsky a écrit : > On Tue, Feb 22, 2011 at 6:18 PM, Antoine Pitrou wrote: > .. > > I don't think it's a good idea to backport visible API changes. > > (someone successfully compiling on 2.7.N could then have users > > complaining that compilati

Re: [Python-Dev] Const-correctness in C-API Object Protocol

2011-02-22 Thread Alexander Belopolsky
On Tue, Feb 22, 2011 at 6:18 PM, Antoine Pitrou wrote: .. > I don't think it's a good idea to backport visible API changes. > (someone successfully compiling on 2.7.N could then have users > complaining that compilation fails on 2.7.N-1). > Moreover, it doesn't really fix a bug. That was the argu

Re: [Python-Dev] Const-correctness in C-API Object Protocol

2011-02-22 Thread Antoine Pitrou
On Tue, 22 Feb 2011 18:08:01 -0500 Alexander Belopolsky wrote: > On Mon, Feb 21, 2011 at 6:34 PM, David Claridge wrote: > .. > > I was wondering if there is some reason why C API functions like > > PyObject_CallMethod[1] and PySys_GetObject[2] take char* arguments > > rather than const char*s? >

Re: [Python-Dev] Const-correctness in C-API Object Protocol

2011-02-22 Thread David Claridge
> If you compile > > #include > > int main() > { >    PyObject_CallMethod(0, "stdin", "stdin"); > } > > you get > > a.cc: In function ‘int main()’: > a.cc:5: warning: deprecated conversion from string constant to ‘char*’ > a.cc:5: warning: deprecated conversion from string constant to ‘char*’ > >

Re: [Python-Dev] Const-correctness in C-API Object Protocol

2011-02-22 Thread Alexander Belopolsky
On Mon, Feb 21, 2011 at 6:34 PM, David Claridge wrote: .. > I was wondering if there is some reason why C API functions like > PyObject_CallMethod[1] and PySys_GetObject[2] take char* arguments > rather than const char*s? The later is addressed by issue 1699259

Re: [Python-Dev] Const-correctness in C-API Object Protocol

2011-02-22 Thread Martin v. Löwis
>> Though I do not get that warning -- which compiler and version issues >> it? Is it a C or a C++ compiler? > > Well, which warning are you talking about? I think Guido assumed that the OP was getting actual complaints from some actual compiler - else he wouldn't have asked the question. However

Re: [Python-Dev] Const-correctness in C-API Object Protocol

2011-02-22 Thread Martin v. Löwis
> Also changing it now would be a giant hassle, leading to so-called > "const poisoning" where many, many APIs need to be changed before > everything would again work. We have been adding const to many places over the years. I think the specific case was just missed (i.e. nobody cared about adding

Re: [Python-Dev] Const-correctness in C-API Object Protocol

2011-02-22 Thread Guido van Rossum
On Tue, Feb 22, 2011 at 1:17 PM, Xavier Morel wrote: > On 2011-02-22, at 21:55 , Antoine Pitrou wrote: >> On Tue, 22 Feb 2011 21:48:51 +0100 >> Stefan Behnel wrote: >>> Reid Kleckner, 22.02.2011 21:21: On Tue, Feb 22, 2011 at 2:09 PM, Eric Smith wrote: > Also changing it now would be a g

Re: [Python-Dev] Const-correctness in C-API Object Protocol

2011-02-22 Thread Xavier Morel
On 2011-02-22, at 21:55 , Antoine Pitrou wrote: > On Tue, 22 Feb 2011 21:48:51 +0100 > Stefan Behnel wrote: >> Reid Kleckner, 22.02.2011 21:21: >>> On Tue, Feb 22, 2011 at 2:09 PM, Eric Smith wrote: Also changing it now would be a giant hassle, leading to so-called "const poisoning" wher

Re: [Python-Dev] Const-correctness in C-API Object Protocol

2011-02-22 Thread Antoine Pitrou
On Tue, 22 Feb 2011 21:48:51 +0100 Stefan Behnel wrote: > Reid Kleckner, 22.02.2011 21:21: > > On Tue, Feb 22, 2011 at 2:09 PM, Eric Smith wrote: > >> Also changing it now would be a giant hassle, leading to so-called "const > >> poisoning" where many, many APIs need to be changed before everythin

Re: [Python-Dev] Const-correctness in C-API Object Protocol

2011-02-22 Thread Stefan Behnel
Reid Kleckner, 22.02.2011 21:21: On Tue, Feb 22, 2011 at 2:09 PM, Eric Smith wrote: Also changing it now would be a giant hassle, leading to so-called "const poisoning" where many, many APIs need to be changed before everything would again work. The poisoning will not break any users of the AP

Re: [Python-Dev] Const-correctness in C-API Object Protocol

2011-02-22 Thread Reid Kleckner
On Tue, Feb 22, 2011 at 2:09 PM, Eric Smith wrote: > Also changing it now would be a giant hassle, leading to so-called "const > poisoning" where many, many APIs need to be changed before everything would > again work. The poisoning will not break any users of the API, though, since they can pass

Re: [Python-Dev] Const-correctness in C-API Object Protocol

2011-02-22 Thread Antoine Pitrou
On Tue, 22 Feb 2011 11:06:41 -0800 Guido van Rossum wrote: > > > > Probably because (a) the person who first wrote them used char* instead of > > const char*, and (b) it gives us API flexibility by not promising to not > > alter the char array at some point in the future. > > I'm sorry, but (b) d

Re: [Python-Dev] Const-correctness in C-API Object Protocol

2011-02-22 Thread Eric Smith
On 02/22/2011 01:55 PM, Brett Cannon wrote: On Mon, Feb 21, 2011 at 15:34, David Claridge mailto:da...@daave.com>> wrote: Hi, I was wondering if there is some reason why C API functions like PyObject_CallMethod[1] and PySys_GetObject[2] take char* arguments rather than const c

Re: [Python-Dev] Const-correctness in C-API Object Protocol

2011-02-22 Thread Guido van Rossum
On Tue, Feb 22, 2011 at 10:55 AM, Brett Cannon wrote: > > > On Mon, Feb 21, 2011 at 15:34, David Claridge wrote: >> >> Hi, >> >> I was wondering if there is some reason why C API functions like >> PyObject_CallMethod[1] and PySys_GetObject[2] take char* arguments >> rather than const char*s? If t

Re: [Python-Dev] Const-correctness in C-API Object Protocol

2011-02-22 Thread Brett Cannon
On Mon, Feb 21, 2011 at 15:34, David Claridge wrote: > Hi, > > I was wondering if there is some reason why C API functions like > PyObject_CallMethod[1] and PySys_GetObject[2] take char* arguments > rather than const char*s? If there is some reason these methods will > modify their string argumen

[Python-Dev] Const-correctness in C-API Object Protocol

2011-02-21 Thread David Claridge
Hi, I was wondering if there is some reason why C API functions like PyObject_CallMethod[1] and PySys_GetObject[2] take char* arguments rather than const char*s? If there is some reason these methods will modify their string arguments, it would be nice if it was documented, because at the moment i