Replace error printing code gated by NDEBUG with a new flag: PYBIND11_DETAILED_ERROR_MESSAGES (#3913)

* Update cast.h

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Move definition to detail/common, change name, apply everywhere

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Rename debug_enabled in tests to detailed_error_messages_enabled
This commit is contained in:
Michael Voznesensky
2022-05-02 12:30:19 -07:00
committed by GitHub
parent 75007dda72
commit f0b9f755e4
10 changed files with 82 additions and 66 deletions

View File

@@ -4,7 +4,7 @@ import sys
import pytest
import env
from pybind11_tests import debug_enabled
from pybind11_tests import detailed_error_messages_enabled
from pybind11_tests import pytypes as m
@@ -416,8 +416,8 @@ def test_print(capture):
m.print_failure()
assert str(excinfo.value) == "Unable to convert call argument " + (
"'1' of type 'UnregisteredType' to Python object"
if debug_enabled
else "to Python object (compile in debug mode for details)"
if detailed_error_messages_enabled
else "to Python object (#define PYBIND11_DETAILED_ERROR_MESSAGES or compile in debug mode for details)"
)