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
_______________________________________________
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com