Skip to content

Commit

Permalink
style: pre-commit fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Oct 24, 2024
1 parent 5629063 commit 404fbb6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
6 changes: 3 additions & 3 deletions include/pybind11/pybind11.h
Original file line number Diff line number Diff line change
Expand Up @@ -2327,11 +2327,11 @@ inline std::pair<decltype(internals::registered_types_py)::iterator, bool>
all_type_info_get_cache(PyTypeObject *type) {
auto res = with_internals([type](internals &internals) {
auto ins = internals
.registered_types_py
.registered_types_py
#ifdef __cpp_lib_unordered_map_try_emplace
.try_emplace(type);
.try_emplace(type);
#else
.emplace(type, std::vector<detail::type_info *>());
.emplace(type, std::vector<detail::type_info *>());
#endif
if (ins.second) {
// In free-threading this method should be called
Expand Down
13 changes: 5 additions & 8 deletions tests/pybind11_tests.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,25 +97,22 @@ void ignoreOldStyleInitWarnings(F &&body) {
py::dict(py::arg("body") = py::cpp_function(body)));
}


class PyTestContext {
public:
PyTestContext() = delete;
PyTestContext(const PyTestContext &) = delete;
PyTestContext(PyTestContext &&) = delete;
static PyTestContext *createNewContextForInit() {
return new PyTestContext("new-context");
}
static PyTestContext *createNewContextForInit() { return new PyTestContext("new-context"); }

pybind11::object contextEnter() {
py::object contextObj = py::cast(*this);
return contextObj;
}
void contextExit(const pybind11::object &/*excType*/,
const pybind11::object &/*excVal*/,
const pybind11::object &/*excTb*/) {}
void contextExit(const pybind11::object & /*excType*/,
const pybind11::object & /*excVal*/,
const pybind11::object & /*excTb*/) {}

private:
PyTestContext(std::string context) : context(context) {}
std::string context;
};
};
1 change: 1 addition & 0 deletions tests/test_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,7 @@ def test_all_type_info_multithreaded():
# "instance allocation failed: new instance has no pybind11-registered base types");
# }
import threading

from pybind11_tests import TestContext

class Context(TestContext):
Expand Down

0 comments on commit 404fbb6

Please sign in to comment.