[issue26476] Constness in _PyErr_BadInternalCall

2016-03-03 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
resolution:  -> fixed
stage: commit review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26476] Constness in _PyErr_BadInternalCall

2016-03-03 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 0e3526ab6a9b by Serhiy Storchaka in branch '2.7':
Issue #26476: Fixed compilation error when use PyErr_BadInternalCall() in C++.
https://hg.python.org/cpython/rev/0e3526ab6a9b

--
nosy: +python-dev

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26476] Constness in _PyErr_BadInternalCall

2016-03-03 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

OK, now I understand. Since _PyErr_BadInternalCall() is private function, we 
will not break any code. Since it is used only by the PyErr_BadInternalCall() 
macro and always called with string literal as an argument, C++ user can't use 
PyErr_BadInternalCall() (without a trick described below). Thus the patch fixes 
a bug. Thank you Jeroen.

The workaround for unpatched Python 2.7 is to undefine the 
PyErr_BadInternalCall() macro.

#undef PyErr_BadInternalCall

There is the PyErr_BadInternalCall() function hidden by the macro. It provides 
less detailed error message, without file name and line number.

--
assignee:  -> serhiy.storchaka
stage:  -> commit review
type:  -> compile error

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26476] Constness in _PyErr_BadInternalCall

2016-03-03 Thread Jeroen Demeyer

Jeroen Demeyer added the comment:

> CPython is written on C and provides C API.

If you look at the title of https://docs.python.org/2/extending/extending.html 
clearly C++ extensions are also supported.

> Even if change the signature of one function, this will not help much, 
> because a lot of other functions require "char *" instead of "const char *".

I don't know which functions you mean, I only encountered this problem for 
PyErr_BadInternalCall().

I should also add that the problem cannot be avoided or worked around for 
PyErr_BadInternalCall() because it's a CPython header itself which does an 
illegal conversion of a string constant to char*.

> This will lead to incompatibility of your extension with older bugfix 
> releases.

I don't see why there would be ABI incompatibility. My patch is only adding 
"const" in the call of a C function.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26476] Constness in _PyErr_BadInternalCall

2016-03-03 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

CPython is written on C and provides C API.

Even if change the signature of one function, this will not help much, because 
a lot of other functions require "char *" instead of "const char *".

There is small disadvantage of changing the signature in a bugfix release. This 
will lead to incompatibility of your extension with older bugfix releases.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26476] Constness in _PyErr_BadInternalCall

2016-03-03 Thread Jeroen Demeyer

Jeroen Demeyer added the comment:

> It is questionable wherever it should be backported to 2.7.

It violates the C++ standard (for extension modules written in C++), so it's 
clearly a bug.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26476] Constness in _PyErr_BadInternalCall

2016-03-03 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Was already fixed in 84618b2064c1. It is questionable wherever it should be 
backported to 2.7. Most other "const" additions were applied only to the 
default branch (see issue25923, issue24436, issue1772673, issue9369, 
issue16369, issue12173, issue1419652 and many others).

--
nosy: +nnorwitz, serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26476] Constness in _PyErr_BadInternalCall

2016-03-03 Thread Jeroen Demeyer

New submission from Jeroen Demeyer:

PyErr_BadInternalCall() calls _PyErr_BadInternalCall(__FILE__, __LINE__). Since 
__FILE__ is a string constant, the first argument of _PyErr_BadInternalCall 
should be a "const char*" instead of a "char*".

This is a follow-up to #4949. Most of the patch from #4949 was applied, but not 
the change to _PyErr_BadInternalCall on Python 2.

--
components: Interpreter Core
files: PyErr_BadInternalCall_const.patch
keywords: patch
messages: 261156
nosy: jdemeyer
priority: normal
severity: normal
status: open
title: Constness in _PyErr_BadInternalCall
versions: Python 2.7
Added file: http://bugs.python.org/file42068/PyErr_BadInternalCall_const.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com