A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2006-February/060694.html below:

[Python-Dev] Baffled by PyArg_ParseTupleAndKeywords modification

[Python-Dev] Baffled by PyArg_ParseTupleAndKeywords modification [Python-Dev] Baffled by PyArg_ParseTupleAndKeywords modification"Martin v. Löwis" martin at v.loewis.de
Fri Feb 10 18:02:03 CET 2006
Jeremy Hylton wrote:
> I admit that I'm also puzzled by Jack's specific question.  I don't
> understand why an array passed to PyArg_ParseTupleAndKeywords() would
> need to be declared as const.  I observed the problem in my initial
> changes but didn't think very hard about the cause of the problem. 
> Perhaps someone with better C/C++ standards chops can explain.

Please take a look at this code:

void foo(const char** x, const char*s)
{
        x[0] = s;
}

void bar()
{
        char *kwds[] = {0};
        const char *s = "Text";
        foo(kwds, s);
        kwds[0][0] = 't';
}

If it was correct, you would be able to modify the const char
array in the string literal, without any compiler errors. The
assignment

  x[0] = s;

is kosher, because you are putting a const char* into a
const char* array, and the assigment

     kwds[0][0] = 't';

is ok, because you are modifying a char array. So the place
where it has to fail is the passing of the pointer-pointer.

Regards,
Martin
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4