Skip to content

Commit 589bb5f

Browse files
committed
Remove all print LOOOK and clang-format the fix.
1 parent a3ef2f3 commit 589bb5f

File tree

4 files changed

+4
-28
lines changed

4 files changed

+4
-28
lines changed

include/pybind11/detail/smart_holder_poc.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@ struct smart_holder {
220220
}
221221

222222
static smart_holder from_raw_ptr_unowned(void *raw_ptr) {
223-
printf("\nLOOOK %s:%d\n", __FILE__, __LINE__); fflush(stdout);
224223
smart_holder hld;
225224
hld.vptr.reset(raw_ptr, [](void *) {});
226225
hld.vptr_is_using_noop_deleter = true;
@@ -251,7 +250,6 @@ struct smart_holder {
251250

252251
template <typename T>
253252
static smart_holder from_raw_ptr_take_ownership(T *raw_ptr, bool void_cast_raw_ptr = false) {
254-
printf("\nLOOOK [%lu] %s:%d\n", (std::size_t) raw_ptr, __FILE__, __LINE__); fflush(stdout);
255253
ensure_pointee_is_destructible<T>("from_raw_ptr_take_ownership");
256254
smart_holder hld;
257255
auto gd = make_guarded_builtin_delete<T>(true);
@@ -304,7 +302,6 @@ struct smart_holder {
304302
template <typename T, typename D>
305303
static smart_holder from_unique_ptr(std::unique_ptr<T, D> &&unq_ptr,
306304
bool void_cast_raw_ptr = false) {
307-
printf("\nLOOOK %s:%d\n", __FILE__, __LINE__); fflush(stdout);
308305
smart_holder hld;
309306
hld.rtti_uqp_del = &typeid(D);
310307
hld.vptr_is_using_builtin_delete = is_std_default_delete<T>(*hld.rtti_uqp_del);
@@ -336,8 +333,6 @@ struct smart_holder {
336333

337334
template <typename T>
338335
static smart_holder from_shared_ptr(std::shared_ptr<T> shd_ptr) {
339-
printf("\nLOOOK [%lu] %s:%d\n", (std::size_t) shd_ptr.get(), __FILE__, __LINE__); fflush(stdout);
340-
// long *BAD = nullptr; *BAD = 101;
341336
smart_holder hld;
342337
hld.vptr = std::static_pointer_cast<void>(shd_ptr);
343338
hld.vptr_is_external_shared_ptr = true;

include/pybind11/detail/smart_holder_type_casters.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -356,8 +356,6 @@ struct smart_holder_type_caster_class_hooks : smart_holder_type_caster_base_tag
356356
auto *holder_void_ptr = const_cast<void *>(holder_const_void_ptr);
357357

358358
auto v_h = inst->get_value_and_holder(detail::get_type_info(typeid(WrappedType)));
359-
printf("\nLOOOK [%lu] %s:%d\n", (std::size_t) v_h.value_ptr(), __FILE__, __LINE__); fflush(stdout);
360-
// long *BAD = nullptr; *BAD = 101;
361359
if (!v_h.instance_registered()) {
362360
register_instance(inst, v_h.value_ptr(), v_h.type);
363361
v_h.set_instance_registered();
@@ -652,7 +650,6 @@ struct smart_holder_type_caster : smart_holder_type_caster_load<T>,
652650
}
653651

654652
static handle cast(T const *src, return_value_policy policy, handle parent) {
655-
printf("\nLOOOK [%lu] IsBase0Still %s:%d\n", (std::size_t) src, __FILE__, __LINE__); fflush(stdout);
656653
auto st = type_caster_base<T>::src_and_type(src);
657654
if (policy == return_value_policy::_clif_automatic) {
658655
policy = return_value_policy::copy;
@@ -705,7 +702,6 @@ struct smart_holder_type_caster : smart_holder_type_caster_load<T>,
705702
void *(*copy_constructor)(const void *),
706703
void *(*move_constructor)(const void *),
707704
const void *existing_holder = nullptr) {
708-
printf("\nLOOOK [%lu] IsDerivedAlready %s:%d\n", (std::size_t) _src, __FILE__, __LINE__); fflush(stdout);
709705
if (!tinfo) { // no type info: error will be set already
710706
return handle();
711707
}
@@ -798,7 +794,6 @@ struct smart_holder_type_caster<std::shared_ptr<T>> : smart_holder_type_caster_l
798794
static constexpr auto name = const_name<T>();
799795

800796
static handle cast(const std::shared_ptr<T> &src, return_value_policy policy, handle parent) {
801-
printf("\nLOOOK [%lu] %s:%d\n", (std::size_t) src.get(), __FILE__, __LINE__); fflush(stdout);
802797
switch (policy) {
803798
case return_value_policy::automatic:
804799
case return_value_policy::automatic_reference:
@@ -840,10 +835,9 @@ struct smart_holder_type_caster<std::shared_ptr<T>> : smart_holder_type_caster_l
840835
inst_raw_ptr->owned = true;
841836
void *&valueptr = values_and_holders(inst_raw_ptr).begin()->value_ptr();
842837
valueptr = src_raw_void_ptr;
843-
printf("\nLOOOK [%lu] IsBase0 %s:%d\n", (std::size_t) valueptr, __FILE__, __LINE__); fflush(stdout);
844-
printf("\nLOOOK [%lu] IsDerived %s:%d\n", (std::size_t) st.first, __FILE__, __LINE__); fflush(stdout);
845838

846-
auto smhldr = pybindit::memory::smart_holder::from_shared_ptr(std::shared_ptr<void>(src, const_cast<void *>(st.first)));
839+
auto smhldr = pybindit::memory::smart_holder::from_shared_ptr(
840+
std::shared_ptr<void>(src, const_cast<void *>(st.first)));
847841
tinfo->init_instance(inst_raw_ptr, static_cast<const void *>(&smhldr));
848842

849843
if (policy == return_value_policy::reference_internal) {

tests/test_mi_debug.cpp

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,23 +56,15 @@ TEST_SUBMODULE(mi_debug, m) {
5656

5757
m.def("make_derived_as_base0", []() -> std::shared_ptr<Base0> {
5858
auto ret_der = std::make_shared<Derived>();
59-
printf("\nLOOOK [%lu] %s:%d\n", (std::size_t) ret_der.get(), __FILE__, __LINE__);
60-
fflush(stdout);
6159
auto ret = std::dynamic_pointer_cast<Base0>(ret_der);
62-
printf("\nLOOOK [%lu] %s:%d\n", (std::size_t) ret.get(), __FILE__, __LINE__);
63-
fflush(stdout);
6460
return ret;
6561
});
6662

6763
m.def(
6864
"make_derived_as_base0_raw_ptr",
6965
[]() {
7066
auto ret_der = new Derived{};
71-
printf("\nLOOOK [%lu] %s:%d\n", (std::size_t) ret_der, __FILE__, __LINE__);
72-
fflush(stdout);
7367
auto ret = dynamic_cast<Base0 *>(ret_der);
74-
printf("\nLOOOK [%lu] %s:%d\n", (std::size_t) ret, __FILE__, __LINE__);
75-
fflush(stdout);
7668
return ret;
7769
},
7870
py::return_value_policy::take_ownership);
@@ -89,11 +81,7 @@ TEST_SUBMODULE(mi_debug, m) {
8981

9082
// class_ OK
9183
// classh FAIL
92-
m.def("get_vec_size_raw_ptr_derived", [](const Derived *obj) {
93-
printf("\nLOOOK [%lu] %s:%d\n", (std::size_t) obj, __FILE__, __LINE__);
94-
fflush(stdout);
95-
return obj->vec.size();
96-
});
84+
m.def("get_vec_size_raw_ptr_derived", [](const Derived *obj) { return obj->vec.size(); });
9785

9886
// class_ OK
9987
// classh FAIL

tests/test_mi_debug.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,11 @@ def test_get_vec_size_raw_ptr_base0():
88

99
def test_get_vec_size_raw_ptr_derived_from_shared():
1010
obj = m.make_derived_as_base0()
11-
print("\nLOOOK", obj)
1211
assert m.get_vec_size_raw_ptr_derived(obj) == 5
1312

13+
1414
def test_get_vec_size_raw_ptr_derived():
1515
obj = m.make_derived_as_base0_raw_ptr()
16-
print("\nLOOOK", obj)
1716
assert m.get_vec_size_raw_ptr_derived(obj) == 5
1817

1918

0 commit comments

Comments
 (0)