Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error_already_set::what() is now constructed lazily #1895

Merged
merged 136 commits into from
Jun 2, 2022

Commits on Aug 28, 2019

  1. error_already_set::what() is now constructed lazily

    Prior to this commit throwing error_already_set was expensive due to the
    eager construction of the error string (which required traversing the
    Python stack). See pybind#1853 for more context and an alternative take on the
    issue.
    
    Note that error_already_set no longer inherits from std::runtime_error
    because the latter has no default constructor.
    superbobry committed Aug 28, 2019
    Configuration menu
    Copy the full SHA
    87d1f6b View commit details
    Browse the repository at this point in the history
  2. Do not attempt to normalize if no exception occurred

    This is not supported on PyPy-2.7 5.8.0.
    superbobry committed Aug 28, 2019
    Configuration menu
    Copy the full SHA
    e289e0e View commit details
    Browse the repository at this point in the history
  3. Extract exception name via tp_name

    This is faster than dynamically looking up __name__ via GetAttrString.
    Note though that the runtime of the code throwing an error_already_set
    will be dominated by stack unwinding so the improvement will not be
    noticeable.
    
    Before:
    
    396 ns ± 0.913 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)
    
    After:
    
    277 ns ± 0.549 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)
    
    Benchmark:
    
    const std::string foo() {
        PyErr_SetString(PyExc_KeyError, "");
        const std::string &s = py::detail::error_string();
        PyErr_Clear();
        return s;
    }
    
    PYBIND11_MODULE(foo, m) {
        m.def("foo", &::foo);
    }
    superbobry committed Aug 28, 2019
    Configuration menu
    Copy the full SHA
    f1435c7 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    60df143 View commit details
    Browse the repository at this point in the history
  5. Revert "Extract exception name via tp_name"

    The implementation of __name__ is slightly more complex than that.
    It handles the module name prefix, and heap-allocated types. We could
    port it to pybind11 later on but for now it seems like an overkill.
    
    This reverts commit f1435c7.
    superbobry committed Aug 28, 2019
    Configuration menu
    Copy the full SHA
    c935b73 View commit details
    Browse the repository at this point in the history

Commits on Aug 29, 2019

  1. Cosmit following @YannickJadoul's comments

    Note that detail::error_string() no longer calls PyException_SetTraceback
    as it is unncessary for pretty-printing the exception.
    superbobry committed Aug 29, 2019
    Configuration menu
    Copy the full SHA
    b48bc72 View commit details
    Browse the repository at this point in the history
  2. Fixed PyPy build

    superbobry committed Aug 29, 2019
    Configuration menu
    Copy the full SHA
    115a757 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    db14dd9 View commit details
    Browse the repository at this point in the history

Commits on Feb 13, 2022

  1. Configuration menu
    Copy the full SHA
    9635e88 View commit details
    Browse the repository at this point in the history
  2. Fix merge bugs

    Skylion007 committed Feb 13, 2022
    Configuration menu
    Copy the full SHA
    dbb3e6b View commit details
    Browse the repository at this point in the history
  3. Fix more merge errors

    Skylion007 committed Feb 13, 2022
    Configuration menu
    Copy the full SHA
    a692362 View commit details
    Browse the repository at this point in the history
  4. Improve formatting

    Skylion007 committed Feb 13, 2022
    Configuration menu
    Copy the full SHA
    ff3185e View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    95eeaef View commit details
    Browse the repository at this point in the history
  6. Revert back if statements

    Skylion007 committed Feb 13, 2022
    Configuration menu
    Copy the full SHA
    00e4852 View commit details
    Browse the repository at this point in the history
  7. Fix clang-tidy

    Skylion007 committed Feb 13, 2022
    Configuration menu
    Copy the full SHA
    648e670 View commit details
    Browse the repository at this point in the history
  8. Try removing mutable

    Skylion007 committed Feb 13, 2022
    Configuration menu
    Copy the full SHA
    244aa52 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    b09f14d View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    1d1ec9e View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    6d0354b View commit details
    Browse the repository at this point in the history

Commits on Feb 14, 2022

  1. Configuration menu
    Copy the full SHA
    2c5ad0b View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    68b349a View commit details
    Browse the repository at this point in the history

Commits on Feb 15, 2022

  1. guard if m_type is null

    Skylion007 committed Feb 15, 2022
    Configuration menu
    Copy the full SHA
    91bf33f View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    63dfbb4 View commit details
    Browse the repository at this point in the history
  3. Try to debug PGI

    Skylion007 committed Feb 15, 2022
    Configuration menu
    Copy the full SHA
    d231f15 View commit details
    Browse the repository at this point in the history
  4. One last try for PGI

    Skylion007 committed Feb 15, 2022
    Configuration menu
    Copy the full SHA
    df6cb30 View commit details
    Browse the repository at this point in the history

Commits on Feb 16, 2022

  1. Configuration menu
    Copy the full SHA
    bdcd95a View commit details
    Browse the repository at this point in the history

Commits on Feb 20, 2022

  1. Reviewer suggestions

    Skylion007 committed Feb 20, 2022
    Configuration menu
    Copy the full SHA
    225dbae View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    f8d3ed2 View commit details
    Browse the repository at this point in the history

Commits on Feb 22, 2022

  1. Configuration menu
    Copy the full SHA
    b90bd78 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    3286964 View commit details
    Browse the repository at this point in the history
  3. Fix typo

    Skylion007 committed Feb 22, 2022
    Configuration menu
    Copy the full SHA
    978bf2a View commit details
    Browse the repository at this point in the history
  4. Revert noexcept

    Skylion007 committed Feb 22, 2022
    Configuration menu
    Copy the full SHA
    6c97e68 View commit details
    Browse the repository at this point in the history

Commits on Mar 2, 2022

  1. Configuration menu
    Copy the full SHA
    6523bc2 View commit details
    Browse the repository at this point in the history
  2. Fix merge conflict error

    Skylion007 committed Mar 2, 2022
    Configuration menu
    Copy the full SHA
    6c6971f View commit details
    Browse the repository at this point in the history

Commits on Apr 23, 2022

  1. t pushMerge branch 'master' of https://github.com/pybind/pybind11 int…

    …o lazy-error-string
    Skylion007 committed Apr 23, 2022
    Configuration menu
    Copy the full SHA
    98aff18 View commit details
    Browse the repository at this point in the history

Commits on Apr 24, 2022

  1. Abuse assignment operator

    Skylion007 committed Apr 24, 2022
    Configuration menu
    Copy the full SHA
    e71d9b9 View commit details
    Browse the repository at this point in the history

Commits on May 3, 2022

  1. Revert operator abuse

    Skylion007 committed May 3, 2022
    Configuration menu
    Copy the full SHA
    e9a2e6d View commit details
    Browse the repository at this point in the history

Commits on May 4, 2022

  1. Configuration menu
    Copy the full SHA
    a83028c View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    e0d8d0e View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    d32bc91 View commit details
    Browse the repository at this point in the history

Commits on May 5, 2022

  1. Merge branch 'master' into lazy-error-string

    Ralf W. Grosse-Kunstleve committed May 5, 2022
    Configuration menu
    Copy the full SHA
    226cdde View commit details
    Browse the repository at this point in the history
  2. Report "FATAL failure building pybind11::error_already_set error_stri…

    …ng" and terminate process.
    Ralf W. Grosse-Kunstleve committed May 5, 2022
    Configuration menu
    Copy the full SHA
    f4a440a View commit details
    Browse the repository at this point in the history

Commits on May 6, 2022

  1. Configuration menu
    Copy the full SHA
    8f6ab3f View commit details
    Browse the repository at this point in the history
  2. Try explicit ctor

    Skylion007 committed May 6, 2022
    Configuration menu
    Copy the full SHA
    4da9968 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    f181dac View commit details
    Browse the repository at this point in the history

Commits on May 8, 2022

  1. Configuration menu
    Copy the full SHA
    6e781a0 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    1f8f0ab View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    2031225 View commit details
    Browse the repository at this point in the history
  4. Clang-Tidy fix

    Skylion007 committed May 8, 2022
    Configuration menu
    Copy the full SHA
    0aee425 View commit details
    Browse the repository at this point in the history

Commits on May 10, 2022

  1. Merge branch 'master' into lazy-error-string

    Ralf W. Grosse-Kunstleve committed May 10, 2022
    Configuration menu
    Copy the full SHA
    1c8398f View commit details
    Browse the repository at this point in the history
  2. Merge branch 'lazy-error-string' of https://github.com/superbobry/pyb…

    …ind11 into lazy-error-string
    Ralf W. Grosse-Kunstleve committed May 10, 2022
    Configuration menu
    Copy the full SHA
    a8f7a97 View commit details
    Browse the repository at this point in the history
  3. detail::obj_class_name(), fprintf with [STDERR], [STDOUT] tags, polis…

    …h comments
    Ralf W. Grosse-Kunstleve committed May 10, 2022
    Configuration menu
    Copy the full SHA
    0691d5f View commit details
    Browse the repository at this point in the history

Commits on May 11, 2022

  1. consistently check m_lazy_what.empty() also in production builds

    Ralf W. Grosse-Kunstleve committed May 11, 2022
    Configuration menu
    Copy the full SHA
    28de959 View commit details
    Browse the repository at this point in the history
  2. Make a comment slightly less ambiguous.

    Ralf W. Grosse-Kunstleve committed May 11, 2022
    Configuration menu
    Copy the full SHA
    c7a7146 View commit details
    Browse the repository at this point in the history
  3. Bug fix: Remove what(); from restore().

    It sure would need to be guarded by `if (m_type)`, otherwise `what()` fails and masks that no error was set (see update unit test). But since `error_already_set` is copyable, there is no point in releasing m_type, m_value, m_trace, therefore we can just as well avoid the runtime overhead of force-building `m_lazy_what`, it may never be used.
    Ralf W. Grosse-Kunstleve committed May 11, 2022
    Configuration menu
    Copy the full SHA
    de84a27 View commit details
    Browse the repository at this point in the history
  4. Replace extremely opaque (unhelpful) error message with a truthful re…

    …flection of what we know.
    Ralf W. Grosse-Kunstleve committed May 11, 2022
    Configuration menu
    Copy the full SHA
    498195a View commit details
    Browse the repository at this point in the history
  5. Fix clang-tidy error [performance-move-constructor-init].

    Ralf W. Grosse-Kunstleve committed May 11, 2022
    Configuration menu
    Copy the full SHA
    80b05ba View commit details
    Browse the repository at this point in the history
  6. Make expected error message less specific.

    Ralf W. Grosse-Kunstleve committed May 11, 2022
    Configuration menu
    Copy the full SHA
    acdf332 View commit details
    Browse the repository at this point in the history
  7. Various changes.

    Ralf W. Grosse-Kunstleve committed May 11, 2022
    Configuration menu
    Copy the full SHA
    58ad49b View commit details
    Browse the repository at this point in the history
  8. bug fix: error_string(PyObject **, ...)

    Ralf W. Grosse-Kunstleve committed May 11, 2022
    Configuration menu
    Copy the full SHA
    90b2453 View commit details
    Browse the repository at this point in the history

Commits on May 12, 2022

  1. Putting back the two eager PyErr_NormalizeException() calls.

    Ralf W. Grosse-Kunstleve committed May 12, 2022
    Configuration menu
    Copy the full SHA
    dded024 View commit details
    Browse the repository at this point in the history
  2. Change error_already_set() to call pybind11_fail() if the Python erro…

    …r indicator not set. The net result is that a std::runtime_error is thrown instead of error_already_set, but all tests pass as is.
    Ralf W. Grosse-Kunstleve committed May 12, 2022
    Configuration menu
    Copy the full SHA
    4193375 View commit details
    Browse the repository at this point in the history
  3. Remove mutable (fixes oversight in the previous commit).

    Ralf W. Grosse-Kunstleve committed May 12, 2022
    Configuration menu
    Copy the full SHA
    b020e04 View commit details
    Browse the repository at this point in the history
  4. Normalize the exception only locally in error_string(). Python 3.6 & …

    …3.7 test failures expected. This is meant for benchmarking, to determine if it is worth the trouble looking into the failures.
    Ralf W. Grosse-Kunstleve committed May 12, 2022
    Configuration menu
    Copy the full SHA
    02df6c0 View commit details
    Browse the repository at this point in the history
  5. clang-tidy: use auto

    Ralf W. Grosse-Kunstleve committed May 12, 2022
    Configuration menu
    Copy the full SHA
    d28c155 View commit details
    Browse the repository at this point in the history
  6. Use gil_scoped_acquire_local in error_already_set destructor. See…

    … long comment.
    Ralf W. Grosse-Kunstleve committed May 12, 2022
    Configuration menu
    Copy the full SHA
    7578de9 View commit details
    Browse the repository at this point in the history
  7. For Python < 3.8: PyErr_NormalizeException before `PyErr_WriteUnrai…

    …sable`
    Ralf W. Grosse-Kunstleve committed May 12, 2022
    Configuration menu
    Copy the full SHA
    bab6f66 View commit details
    Browse the repository at this point in the history

Commits on May 13, 2022

  1. Go back to replacing the held Python exception with then normalized e…

    …xception, if & when needed. Consistently document the side-effect.
    Ralf W. Grosse-Kunstleve committed May 13, 2022
    Configuration menu
    Copy the full SHA
    2ad2285 View commit details
    Browse the repository at this point in the history
  2. Slightly rewording comment. (There were also other failures.)

    Ralf W. Grosse-Kunstleve committed May 13, 2022
    Configuration menu
    Copy the full SHA
    e3ebb0d View commit details
    Browse the repository at this point in the history
  3. Add 1-line comment for obj_class_name()

    Ralf W. Grosse-Kunstleve committed May 13, 2022
    Configuration menu
    Copy the full SHA
    8dff51d View commit details
    Browse the repository at this point in the history
  4. Benchmark code, with results in this commit message.

              function                   #calls  test time [s]  μs / call
    master    pure_unwind                729540      1.061      14.539876
              err_set_unwind_err_clear   681476      1.040      15.260282
              err_set_error_already_set  508038      1.049      20.640525
              error_already_set_restore  555578      1.052      18.933288
              pr1895_original_foo        244113      1.050      43.018168
                                                                           PR / master
    PR pybind#1895  pure_unwind                736981      1.054      14.295685       98.32%
              err_set_unwind_err_clear   685820      1.045      15.237399       99.85%
              err_set_error_already_set  661374      1.046      15.811879       76.61%
              error_already_set_restore  669881      1.048      15.645176       82.63%
              pr1895_original_foo        318243      1.059      33.290806       77.39%
    
    master @ commit ad146b2
    
    Running tests in directory "/usr/local/google/home/rwgk/forked/pybind11/tests":
    ============================= test session starts ==============================
    platform linux -- Python 3.9.10, pytest-6.2.3, py-1.10.0, pluggy-0.13.1 -- /usr/bin/python3
    cachedir: .pytest_cache
    rootdir: /usr/local/google/home/rwgk/forked/pybind11/tests, configfile: pytest.ini
    collecting ... collected 5 items
    
    test_perf_error_already_set.py::test_perf[pure_unwind]
    PERF pure_unwind,729540,1.061,14.539876
    PASSED
    test_perf_error_already_set.py::test_perf[err_set_unwind_err_clear]
    PERF err_set_unwind_err_clear,681476,1.040,15.260282
    PASSED
    test_perf_error_already_set.py::test_perf[err_set_error_already_set]
    PERF err_set_error_already_set,508038,1.049,20.640525
    PASSED
    test_perf_error_already_set.py::test_perf[error_already_set_restore]
    PERF error_already_set_restore,555578,1.052,18.933288
    PASSED
    test_perf_error_already_set.py::test_perf[pr1895_original_foo]
    PERF pr1895_original_foo,244113,1.050,43.018168
    PASSED
    
    ============================== 5 passed in 12.38s ==============================
    
    pr1895 @ commit 8dff51d
    
    Running tests in directory "/usr/local/google/home/rwgk/forked/pybind11/tests":
    ============================= test session starts ==============================
    platform linux -- Python 3.9.10, pytest-6.2.3, py-1.10.0, pluggy-0.13.1 -- /usr/bin/python3
    cachedir: .pytest_cache
    rootdir: /usr/local/google/home/rwgk/forked/pybind11/tests, configfile: pytest.ini
    collecting ... collected 5 items
    
    test_perf_error_already_set.py::test_perf[pure_unwind]
    PERF pure_unwind,736981,1.054,14.295685
    PASSED
    test_perf_error_already_set.py::test_perf[err_set_unwind_err_clear]
    PERF err_set_unwind_err_clear,685820,1.045,15.237399
    PASSED
    test_perf_error_already_set.py::test_perf[err_set_error_already_set]
    PERF err_set_error_already_set,661374,1.046,15.811879
    PASSED
    test_perf_error_already_set.py::test_perf[error_already_set_restore]
    PERF error_already_set_restore,669881,1.048,15.645176
    PASSED
    test_perf_error_already_set.py::test_perf[pr1895_original_foo]
    PERF pr1895_original_foo,318243,1.059,33.290806
    PASSED
    
    ============================== 5 passed in 12.40s ==============================
    
    clang++ -o pybind11/tests/test_perf_error_already_set.os -c -std=c++17 -fPIC -fvisibility=hidden -Os -flto -Wall -Wextra -Wconversion -Wcast-qual -Wdeprecated -Wnon-virtual-dtor -Wunused-result -isystem /usr/include/python3.9 -isystem /usr/include/eigen3 -DPYBIND11_STRICT_ASSERTS_CLASS_HOLDER_VS_TYPE_CASTER_MIX -DPYBIND11_TEST_BOOST -Ipybind11/include -I/usr/local/google/home/rwgk/forked/pybind11/include -I/usr/local/google/home/rwgk/clone/pybind11/include /usr/local/google/home/rwgk/forked/pybind11/tests/test_perf_error_already_set.cpp
    
    clang++ -o lib/pybind11_tests.so -shared -fPIC -Os -flto -shared ...
    
    Debian clang version 13.0.1-3+build2
    Target: x86_64-pc-linux-gnu
    Thread model: posix
    Ralf W. Grosse-Kunstleve committed May 13, 2022
    Configuration menu
    Copy the full SHA
    923725a View commit details
    Browse the repository at this point in the history
  5. Changing call_repetitions_target_elapsed_secs to 0.1 for regular unit…

    … testing.
    Ralf W. Grosse-Kunstleve committed May 13, 2022
    Configuration menu
    Copy the full SHA
    53f40a0 View commit details
    Browse the repository at this point in the history

Commits on May 14, 2022

  1. Adding in recursion_depth

    Ralf W. Grosse-Kunstleve committed May 14, 2022
    Configuration menu
    Copy the full SHA
    b77e703 View commit details
    Browse the repository at this point in the history
  2. Optimized ctor

    Skylion007 committed May 14, 2022
    Configuration menu
    Copy the full SHA
    493d751 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    6d0ec49 View commit details
    Browse the repository at this point in the history

Commits on May 15, 2022

  1. Fix silly bug in recurse_first_then_call()

    Ralf W. Grosse-Kunstleve committed May 15, 2022
    Configuration menu
    Copy the full SHA
    6d9188f View commit details
    Browse the repository at this point in the history
  2. Add tests that have equivalent PyErr_Fetch(), PyErr_Restore() but no …

    …try-catch.
    Ralf W. Grosse-Kunstleve committed May 15, 2022
    Configuration menu
    Copy the full SHA
    8f3d3a6 View commit details
    Browse the repository at this point in the history
  3. Add call_error_string to tests. Sample only recursion_depth 0, 100.

    Ralf W. Grosse-Kunstleve committed May 15, 2022
    Configuration menu
    Copy the full SHA
    724ee3d View commit details
    Browse the repository at this point in the history
  4. Show lazy-what speed-up in percent.

    Ralf W. Grosse-Kunstleve committed May 15, 2022
    Configuration menu
    Copy the full SHA
    467ab00 View commit details
    Browse the repository at this point in the history
  5. Include real_work in benchmarks.

    Ralf W. Grosse-Kunstleve committed May 15, 2022
    Configuration menu
    Copy the full SHA
    eaa1a48 View commit details
    Browse the repository at this point in the history

Commits on May 16, 2022

  1. Replace all PyErr_SetString() with generate_python_exception_with_tra…

    …ceback()
    Ralf W. Grosse-Kunstleve committed May 16, 2022
    Configuration menu
    Copy the full SHA
    dbed20a View commit details
    Browse the repository at this point in the history
  2. Better organization of test loops.

    Ralf W. Grosse-Kunstleve committed May 16, 2022
    Configuration menu
    Copy the full SHA
    f021543 View commit details
    Browse the repository at this point in the history
  3. Add test_error_already_set_copy_move

    Ralf W. Grosse-Kunstleve committed May 16, 2022
    Configuration menu
    Copy the full SHA
    125e2d0 View commit details
    Browse the repository at this point in the history
  4. Fix bug in newly added test (discovered by clang-tidy): actually use …

    …move ctor
    Ralf W. Grosse-Kunstleve committed May 16, 2022
    Configuration menu
    Copy the full SHA
    b037958 View commit details
    Browse the repository at this point in the history
  5. MSVC detects the unreachable return

    Ralf W. Grosse-Kunstleve committed May 16, 2022
    Configuration menu
    Copy the full SHA
    2baa3bc View commit details
    Browse the repository at this point in the history

Commits on May 17, 2022

  1. change test_perf_error_already_set.py back to quick mode

    Ralf W. Grosse-Kunstleve committed May 17, 2022
    Configuration menu
    Copy the full SHA
    4c479f4 View commit details
    Browse the repository at this point in the history
  2. Inherit from std::exception (instead of std::runtime_error, which doe…

    …s not make sense anymore with the lazy what)
    Ralf W. Grosse-Kunstleve committed May 17, 2022
    2 Configuration menu
    Copy the full SHA
    b4326f9 View commit details
    Browse the repository at this point in the history
  3. Special handling under Windows.

    Ralf W. Grosse-Kunstleve committed May 17, 2022
    Configuration menu
    Copy the full SHA
    aaec34e View commit details
    Browse the repository at this point in the history
  4. print with leading newline

    Ralf W. Grosse-Kunstleve committed May 17, 2022
    Configuration menu
    Copy the full SHA
    99af318 View commit details
    Browse the repository at this point in the history
  5. Merge branch 'master' into lazy-error-string

    Ralf W. Grosse-Kunstleve committed May 17, 2022
    Configuration menu
    Copy the full SHA
    e5f028f View commit details
    Browse the repository at this point in the history

Commits on May 18, 2022

  1. Removing test_perf_error_already_set (copies are under rwgk/rwgk_tbx@7…

    Ralf W. Grosse-Kunstleve committed May 18, 2022
    Configuration menu
    Copy the full SHA
    8c76360 View commit details
    Browse the repository at this point in the history
  2. Avoid gil and scope overhead if there is nothing to release.

    Ralf W. Grosse-Kunstleve committed May 18, 2022
    Configuration menu
    Copy the full SHA
    c7149d8 View commit details
    Browse the repository at this point in the history
  3. Restore default move ctor. "member function" instead of "function" (n…

    …ote that "method" is Python terminology).
    Ralf W. Grosse-Kunstleve committed May 18, 2022
    Configuration menu
    Copy the full SHA
    47f5445 View commit details
    Browse the repository at this point in the history
  4. Delete error_already_set copy ctor.

    Ralf W. Grosse-Kunstleve committed May 18, 2022
    Configuration menu
    Copy the full SHA
    7c08e7f View commit details
    Browse the repository at this point in the history
  5. Make restore() non-const again to resolve clang-tidy failure (still e…

    …xperimenting).
    Ralf W. Grosse-Kunstleve committed May 18, 2022
    Configuration menu
    Copy the full SHA
    f746a3d View commit details
    Browse the repository at this point in the history
  6. Bring back error_already_set copy ctor, to see if that resolves the 4…

    … MSVC test failures.
    Ralf W. Grosse-Kunstleve committed May 18, 2022
    Configuration menu
    Copy the full SHA
    25e4cc9 View commit details
    Browse the repository at this point in the history
  7. Add noexcept to error_already_set copy & move ctors (as suggested by @…

    Ralf W. Grosse-Kunstleve committed May 18, 2022
    Configuration menu
    Copy the full SHA
    70b870a View commit details
    Browse the repository at this point in the history
  8. Trying one-by-one noexcept copy ctor for old compilers.

    Ralf W. Grosse-Kunstleve committed May 18, 2022
    Configuration menu
    Copy the full SHA
    d425bb8 View commit details
    Browse the repository at this point in the history
  9. Add back test covering copy ctor. Add another simple test that exerci…

    …ses the copy ctor.
    Ralf W. Grosse-Kunstleve committed May 18, 2022
    Configuration menu
    Copy the full SHA
    65aaa4c View commit details
    Browse the repository at this point in the history

Commits on May 19, 2022

  1. Exclude more older compilers from using the noexcept = default ctors.…

    … (The tests in the previous commit exposed that those are broken.)
    Ralf W. Grosse-Kunstleve committed May 19, 2022
    Configuration menu
    Copy the full SHA
    19bb595 View commit details
    Browse the repository at this point in the history
  2. Factor out & reuse gil_scoped_acquire_local as gil_scoped_acquire_simple

    Ralf W. Grosse-Kunstleve committed May 19, 2022
    Configuration menu
    Copy the full SHA
    d07b5ba View commit details
    Browse the repository at this point in the history
  3. Guard gil_scoped_acquire_simple by _Py_IsFinalizing() check.

    Ralf W. Grosse-Kunstleve committed May 19, 2022
    Configuration menu
    Copy the full SHA
    f6bf5aa View commit details
    Browse the repository at this point in the history
  4. what() GIL safety

    Ralf W. Grosse-Kunstleve committed May 19, 2022
    Configuration menu
    Copy the full SHA
    cc5d76a View commit details
    Browse the repository at this point in the history
  5. clang-tidy & Python 3.6 fixes

    Ralf W. Grosse-Kunstleve committed May 19, 2022
    Configuration menu
    Copy the full SHA
    2b31e4d View commit details
    Browse the repository at this point in the history

Commits on May 20, 2022

  1. Merge branch 'master' into lazy-error-string

    Ralf W. Grosse-Kunstleve committed May 20, 2022
    Configuration menu
    Copy the full SHA
    73cffe4 View commit details
    Browse the repository at this point in the history
  2. Use gil_scoped_acquire in dtor, copy ctor, what(). Remove `_Py_Is…

    …Finalizing()` checks (they are racy: python/cpython#28525).
    Ralf W. Grosse-Kunstleve committed May 20, 2022
    6 Configuration menu
    Copy the full SHA
    2c5dd19 View commit details
    Browse the repository at this point in the history

Commits on May 21, 2022

  1. Remove error_scope from copy ctor.

    Ralf W. Grosse-Kunstleve committed May 21, 2022
    Configuration menu
    Copy the full SHA
    14be38c View commit details
    Browse the repository at this point in the history
  2. Add error_scope to get_internals(), to cover the situation that `…

    …get_internals()` is called from the `error_already_set` dtor while a new Python error is in flight already. Also backing out `gil_scoped_acquire_simple` change.
    Ralf W. Grosse-Kunstleve committed May 21, 2022
    Configuration menu
    Copy the full SHA
    db97ce7 View commit details
    Browse the repository at this point in the history

Commits on May 23, 2022

  1. Add FlakyException tests with failure triggers in __init__ and `_…

    …_str__`
    
    THIS IS STILL A WORK IN PROGRESS. This commit is only an important resting point.
    
    This commit is a first attempt at addressing the observation that `PyErr_NormalizeException()` completely replaces the original exception if `__init__` fails. This can be very confusing even in small applications, and extremely confusing in large ones.
    Ralf W. Grosse-Kunstleve committed May 23, 2022
    Configuration menu
    Copy the full SHA
    42d2e1a View commit details
    Browse the repository at this point in the history

Commits on May 24, 2022

  1. Tweaks to resolve Py 3.6 and PyPy CI failures.

    Ralf W. Grosse-Kunstleve committed May 24, 2022
    Configuration menu
    Copy the full SHA
    6417a76 View commit details
    Browse the repository at this point in the history
  2. Normalize Python exception immediately in error_already_set ctor.

    For background see: pybind#1895 (comment)
    Ralf W. Grosse-Kunstleve committed May 24, 2022
    Configuration menu
    Copy the full SHA
    a62b3d7 View commit details
    Browse the repository at this point in the history
  3. Merge branch 'master' into lazy-error-string

    Ralf W. Grosse-Kunstleve committed May 24, 2022
    Configuration menu
    Copy the full SHA
    c54309c View commit details
    Browse the repository at this point in the history
  4. Fix oversights based on CI failures (copy & move ctor initialization).

    Ralf W. Grosse-Kunstleve committed May 24, 2022
    Configuration menu
    Copy the full SHA
    c786796 View commit details
    Browse the repository at this point in the history
  5. Move @pytest.mark.xfail("env.PYPY") after @pytest.mark.parametrize(...)

    Ralf W. Grosse-Kunstleve committed May 24, 2022
    Configuration menu
    Copy the full SHA
    61bb513 View commit details
    Browse the repository at this point in the history
  6. Use @pytest.mark.skipif (xfail does not work for segfaults, of course).

    Ralf W. Grosse-Kunstleve committed May 24, 2022
    Configuration menu
    Copy the full SHA
    bb3f24c View commit details
    Browse the repository at this point in the history

Commits on May 31, 2022

  1. Merge branch 'master' into lazy-error-string

    Ralf W. Grosse-Kunstleve committed May 31, 2022
    Configuration menu
    Copy the full SHA
    087ef29 View commit details
    Browse the repository at this point in the history

Commits on Jun 1, 2022

  1. Remove unused obj_class_name_or() function (it was added only under t…

    …his PR).
    Ralf W. Grosse-Kunstleve committed Jun 1, 2022
    Configuration menu
    Copy the full SHA
    bee5fb4 View commit details
    Browse the repository at this point in the history
  2. Remove already obsolete C++ comments and code that were added only un…

    …der this PR.
    Ralf W. Grosse-Kunstleve committed Jun 1, 2022
    Configuration menu
    Copy the full SHA
    bea0c9f View commit details
    Browse the repository at this point in the history
  3. Slightly better (newly added) comments.

    Ralf W. Grosse-Kunstleve committed Jun 1, 2022
    Configuration menu
    Copy the full SHA
    d6d371a View commit details
    Browse the repository at this point in the history
  4. Factor out detail::error_fetch_and_normalize. Preparation for produci…

    …ng identical results from error_already_set::what() and detail::error_string(). Note that this is a very conservative refactoring. It would be much better to first move detail::error_string into detail/error_string.h
    Ralf W. Grosse-Kunstleve committed Jun 1, 2022
    Configuration menu
    Copy the full SHA
    eec0547 View commit details
    Browse the repository at this point in the history
  5. Copy most of error_string() code to new error_fetch_and_normalize::co…

    …mplete_lazy_error_string()
    Ralf W. Grosse-Kunstleve committed Jun 1, 2022
    Configuration menu
    Copy the full SHA
    ec1a2c0 View commit details
    Browse the repository at this point in the history
  6. Remove all error_string() code from detail/type_caster_base.h. Note t…

    …hat this commit includes a subtle bug fix: previously error_string() restored the Python error, which will upset pybind11_fail(). This never was a problem in practice because the two PyType_Ready() calls in detail/class.h do not usually fail.
    Ralf W. Grosse-Kunstleve committed Jun 1, 2022
    Configuration menu
    Copy the full SHA
    c39ebd5 View commit details
    Browse the repository at this point in the history
  7. Return const std::string& instead of const char * and move error_stri…

    …ng() to pytypes.h
    Ralf W. Grosse-Kunstleve committed Jun 1, 2022
    Configuration menu
    Copy the full SHA
    286023b View commit details
    Browse the repository at this point in the history
  8. Remove gil_scope_acquire from error_fetch_and_normalize, add back to …

    …error_already_set
    Ralf W. Grosse-Kunstleve committed Jun 1, 2022
    Configuration menu
    Copy the full SHA
    156b57b View commit details
    Browse the repository at this point in the history
  9. Better handling of FlakyException __str__ failure.

    Ralf W. Grosse-Kunstleve committed Jun 1, 2022
    Configuration menu
    Copy the full SHA
    6f175ac View commit details
    Browse the repository at this point in the history
  10. Move error_fetch_and_normalize::complete_lazy_error_string() implemen…

    …tation from pybind11.h to pytypes.h
    Ralf W. Grosse-Kunstleve committed Jun 1, 2022
    Configuration menu
    Copy the full SHA
    71f33a8 View commit details
    Browse the repository at this point in the history
  11. Add error_fetch_and_normalize::release_py_object_references() and use…

    … from error_already_set dtor.
    Ralf W. Grosse-Kunstleve committed Jun 1, 2022
    Configuration menu
    Copy the full SHA
    0739d4c View commit details
    Browse the repository at this point in the history
  12. Use shared_ptr for m_fetched_error => 1. non-racy, copy ctor that doe…

    …s not need the GIL; 2. enables guard against duplicate restore() calls.
    Ralf W. Grosse-Kunstleve committed Jun 1, 2022
    Configuration menu
    Copy the full SHA
    80dfaea View commit details
    Browse the repository at this point in the history
  13. Add comments.

    Ralf W. Grosse-Kunstleve committed Jun 1, 2022
    Configuration menu
    Copy the full SHA
    a7ba693 View commit details
    Browse the repository at this point in the history
  14. Trivial renaming of a newly introduced member function.

    Ralf W. Grosse-Kunstleve committed Jun 1, 2022
    Configuration menu
    Copy the full SHA
    9854589 View commit details
    Browse the repository at this point in the history
  15. Merge branch 'master' into lazy-error-string

    Ralf W. Grosse-Kunstleve committed Jun 1, 2022
    Configuration menu
    Copy the full SHA
    d2e78b0 View commit details
    Browse the repository at this point in the history
  16. Workaround for PyPy

    Ralf W. Grosse-Kunstleve committed Jun 1, 2022
    Configuration menu
    Copy the full SHA
    0e50c45 View commit details
    Browse the repository at this point in the history
  17. Bug fix (oversight). Only valgrind got this one.

    Ralf W. Grosse-Kunstleve committed Jun 1, 2022
    Configuration menu
    Copy the full SHA
    4e06fb1 View commit details
    Browse the repository at this point in the history

Commits on Jun 2, 2022

  1. Use shared_ptr custom deleter for m_fetched_error in error_already_se…

    …t. This enables removing the dtor, copy ctor, move ctor completely.
    Ralf W. Grosse-Kunstleve committed Jun 2, 2022
    Configuration menu
    Copy the full SHA
    f892cce View commit details
    Browse the repository at this point in the history
  2. Further small simplification. With the GIL held, simply deleting the …

    …raw_ptr takes care of everything.
    Ralf W. Grosse-Kunstleve committed Jun 2, 2022
    Configuration menu
    Copy the full SHA
    53e29f4 View commit details
    Browse the repository at this point in the history
  3. IWYU cleanup

    ```
    iwyu version: include-what-you-use 0.17 based on Debian clang version 13.0.1-3+build2
    ```
    
    Command used:
    
    ```
    iwyu -c -std=c++17 -DPYBIND11_TEST_BOOST -Iinclude/pybind11 -I/usr/include/python3.9 -I/usr/include/eigen3 include/pybind11/pytypes.cpp
    ```
    
    pytypes.cpp is a temporary file: `#include "pytypes.h"`
    
    The raw output is very long and noisy.
    
    I decided to use `#include <cstddef>` instead of `#include <cstdio>` for `std::size_t` (iwyu sticks to the manual choice).
    
    I ignored all iwyu suggestions that are indirectly covered by `#include <Python.h>`.
    
    I manually verified that all added includes are actually needed.
    Ralf W. Grosse-Kunstleve committed Jun 2, 2022
    Configuration menu
    Copy the full SHA
    8e145c0 View commit details
    Browse the repository at this point in the history