pyhtml2md 1.5.2__tar.gz → 1.5.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of pyhtml2md might be problematic. Click here for more details.

Files changed (74) hide show
  1. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/CMakeLists.txt +1 -1
  2. {pyhtml2md-1.5.2/pyhtml2md.egg-info → pyhtml2md-1.5.4}/PKG-INFO +3 -2
  3. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/include/html2md.h +0 -2
  4. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4/pyhtml2md.egg-info}/PKG-INFO +3 -2
  5. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/pyhtml2md.egg-info/SOURCES.txt +2 -0
  6. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/python/pybind11/CMakeLists.txt +58 -7
  7. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/python/pybind11/include/pybind11/buffer_info.h +14 -14
  8. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/python/pybind11/include/pybind11/cast.h +142 -9
  9. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/python/pybind11/include/pybind11/detail/class.h +18 -13
  10. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/python/pybind11/include/pybind11/detail/common.h +22 -14
  11. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/python/pybind11/include/pybind11/detail/descr.h +3 -2
  12. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/python/pybind11/include/pybind11/detail/init.h +1 -1
  13. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/python/pybind11/include/pybind11/detail/internals.h +20 -9
  14. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/python/pybind11/include/pybind11/detail/type_caster_base.h +55 -14
  15. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/python/pybind11/include/pybind11/eigen/tensor.h +3 -2
  16. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/python/pybind11/include/pybind11/functional.h +2 -1
  17. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/python/pybind11/include/pybind11/gil.h +9 -1
  18. pyhtml2md-1.5.4/python/pybind11/include/pybind11/gil_safe_call_once.h +91 -0
  19. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/python/pybind11/include/pybind11/numpy.h +157 -22
  20. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/python/pybind11/include/pybind11/pybind11.h +121 -48
  21. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/python/pybind11/include/pybind11/pytypes.h +27 -5
  22. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/python/pybind11/include/pybind11/stl.h +8 -7
  23. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/python/pybind11/include/pybind11/stl_bind.h +29 -58
  24. pyhtml2md-1.5.4/python/pybind11/include/pybind11/typing.h +125 -0
  25. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/python/pybind11/tools/FindPythonLibsNew.cmake +24 -1
  26. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/python/pybind11/tools/make_changelog.py +29 -1
  27. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/python/pybind11/tools/pybind11Common.cmake +37 -15
  28. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/python/pybind11/tools/pybind11Config.cmake.in +4 -2
  29. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/python/pybind11/tools/pybind11NewTools.cmake +77 -22
  30. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/python/pybind11/tools/pybind11Tools.cmake +13 -7
  31. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/setup.py +1 -1
  32. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/src/html2md.cpp +34 -28
  33. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/src/table.cpp +4 -0
  34. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/COPYING +0 -0
  35. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/MANIFEST.in +0 -0
  36. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/README.md +0 -0
  37. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/include/table.h +0 -0
  38. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/pyhtml2md.egg-info/dependency_links.txt +0 -0
  39. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/pyhtml2md.egg-info/not-zip-safe +0 -0
  40. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/pyhtml2md.egg-info/requires.txt +0 -0
  41. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/pyhtml2md.egg-info/top_level.txt +0 -0
  42. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/pyproject.toml +0 -0
  43. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/python/README.md +0 -0
  44. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/python/bindings.cpp +0 -0
  45. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/python/pybind11/LICENSE +0 -0
  46. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/python/pybind11/include/pybind11/attr.h +0 -0
  47. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/python/pybind11/include/pybind11/chrono.h +0 -0
  48. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/python/pybind11/include/pybind11/common.h +0 -0
  49. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/python/pybind11/include/pybind11/complex.h +0 -0
  50. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/python/pybind11/include/pybind11/detail/typeid.h +0 -0
  51. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/python/pybind11/include/pybind11/eigen/common.h +0 -0
  52. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/python/pybind11/include/pybind11/eigen/matrix.h +0 -0
  53. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/python/pybind11/include/pybind11/eigen.h +0 -0
  54. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/python/pybind11/include/pybind11/embed.h +0 -0
  55. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/python/pybind11/include/pybind11/eval.h +0 -0
  56. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/python/pybind11/include/pybind11/iostream.h +0 -0
  57. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/python/pybind11/include/pybind11/operators.h +0 -0
  58. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/python/pybind11/include/pybind11/options.h +0 -0
  59. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/python/pybind11/include/pybind11/stl/filesystem.h +0 -0
  60. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/python/pybind11/include/pybind11/type_caster_pyobject_ptr.h +0 -0
  61. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/python/pybind11/tools/FindCatch.cmake +0 -0
  62. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/python/pybind11/tools/FindEigen3.cmake +0 -0
  63. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/python/pybind11/tools/JoinPaths.cmake +0 -0
  64. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/python/pybind11/tools/check-style.sh +0 -0
  65. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/python/pybind11/tools/cmake_uninstall.cmake.in +0 -0
  66. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/python/pybind11/tools/codespell_ignore_lines_from_errors.py +0 -0
  67. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/python/pybind11/tools/libsize.py +0 -0
  68. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/python/pybind11/tools/pybind11.pc.in +0 -0
  69. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/python/pybind11/tools/pyproject.toml +0 -0
  70. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/python/pybind11/tools/setup_global.py.in +0 -0
  71. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/python/pybind11/tools/setup_main.py.in +0 -0
  72. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/setup.cfg +0 -0
  73. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/tests/test_advanced.py +0 -0
  74. {pyhtml2md-1.5.2 → pyhtml2md-1.5.4}/tests/test_basic.py +0 -0
@@ -1,5 +1,5 @@
1
1
  cmake_minimum_required(VERSION 3.8)
2
- project(html2md VERSION 1.5.2 LANGUAGES CXX)
2
+ project(html2md VERSION 1.5.4 LANGUAGES CXX)
3
3
 
4
4
  set(PROJECT_HOMEPAGE_URL "https://tim-gromeyer.github.io/html2md/")
5
5
  set(html2md_HOMEPAGE_URL "${PROJECT_HOMEPAGE_URL}")
@@ -1,14 +1,15 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyhtml2md
3
- Version: 1.5.2
3
+ Version: 1.5.4
4
4
  Summary: Transform your HTML into clean, easy-to-read markdown with pyhtml2md.
5
5
  Home-page: https://github.com/tim-gromeyer/html2md
6
6
  Author: Tim Gromeyer
7
7
  Author-email: sakul8826@gmail.com
8
8
  Requires-Python: >=3.7
9
9
  Description-Content-Type: text/markdown
10
- Provides-Extra: test
11
10
  License-File: COPYING
11
+ Provides-Extra: test
12
+ Requires-Dist: pytest>=6.0; extra == "test"
12
13
 
13
14
  # pyhtml2md
14
15
 
@@ -142,8 +142,6 @@ struct Options {
142
142
  * if (!c.ok()) std::cout << "There was something wrong in the HTML\n";
143
143
  * std::cout << md; // # example
144
144
  * ```
145
- *
146
- * \todo Rework `blockquote`s
147
145
  */
148
146
  class Converter {
149
147
  public:
@@ -1,14 +1,15 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyhtml2md
3
- Version: 1.5.2
3
+ Version: 1.5.4
4
4
  Summary: Transform your HTML into clean, easy-to-read markdown with pyhtml2md.
5
5
  Home-page: https://github.com/tim-gromeyer/html2md
6
6
  Author: Tim Gromeyer
7
7
  Author-email: sakul8826@gmail.com
8
8
  Requires-Python: >=3.7
9
9
  Description-Content-Type: text/markdown
10
- Provides-Extra: test
11
10
  License-File: COPYING
11
+ Provides-Extra: test
12
+ Requires-Dist: pytest>=6.0; extra == "test"
12
13
 
13
14
  # pyhtml2md
14
15
 
@@ -27,6 +27,7 @@ python/pybind11/include/pybind11/embed.h
27
27
  python/pybind11/include/pybind11/eval.h
28
28
  python/pybind11/include/pybind11/functional.h
29
29
  python/pybind11/include/pybind11/gil.h
30
+ python/pybind11/include/pybind11/gil_safe_call_once.h
30
31
  python/pybind11/include/pybind11/iostream.h
31
32
  python/pybind11/include/pybind11/numpy.h
32
33
  python/pybind11/include/pybind11/operators.h
@@ -36,6 +37,7 @@ python/pybind11/include/pybind11/pytypes.h
36
37
  python/pybind11/include/pybind11/stl.h
37
38
  python/pybind11/include/pybind11/stl_bind.h
38
39
  python/pybind11/include/pybind11/type_caster_pyobject_ptr.h
40
+ python/pybind11/include/pybind11/typing.h
39
41
  python/pybind11/include/pybind11/detail/class.h
40
42
  python/pybind11/include/pybind11/detail/common.h
41
43
  python/pybind11/include/pybind11/detail/descr.h
@@ -5,15 +5,25 @@
5
5
  # All rights reserved. Use of this source code is governed by a
6
6
  # BSD-style license that can be found in the LICENSE file.
7
7
 
8
- cmake_minimum_required(VERSION 3.4)
8
+ # Propagate this policy (FindPythonInterp removal) so it can be detected later
9
+ if(NOT CMAKE_VERSION VERSION_LESS "3.27")
10
+ cmake_policy(GET CMP0148 _pybind11_cmp0148)
11
+ endif()
12
+
13
+ cmake_minimum_required(VERSION 3.5)
9
14
 
10
- # The `cmake_minimum_required(VERSION 3.4...3.22)` syntax does not work with
15
+ # The `cmake_minimum_required(VERSION 3.5...3.29)` syntax does not work with
11
16
  # some versions of VS that have a patched CMake 3.11. This forces us to emulate
12
17
  # the behavior using the following workaround:
13
- if(${CMAKE_VERSION} VERSION_LESS 3.22)
18
+ if(${CMAKE_VERSION} VERSION_LESS 3.29)
14
19
  cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
15
20
  else()
16
- cmake_policy(VERSION 3.22)
21
+ cmake_policy(VERSION 3.29)
22
+ endif()
23
+
24
+ if(_pybind11_cmp0148)
25
+ cmake_policy(SET CMP0148 ${_pybind11_cmp0148})
26
+ unset(_pybind11_cmp0148)
17
27
  endif()
18
28
 
19
29
  # Avoid infinite recursion if tests include this as a subdirectory
@@ -82,33 +92,58 @@ if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
82
92
  set(pybind11_system "")
83
93
 
84
94
  set_property(GLOBAL PROPERTY USE_FOLDERS ON)
95
+ if(CMAKE_VERSION VERSION_LESS "3.18")
96
+ set(_pybind11_findpython_default OFF)
97
+ else()
98
+ set(_pybind11_findpython_default ON)
99
+ endif()
85
100
  else()
86
101
  set(PYBIND11_MASTER_PROJECT OFF)
87
102
  set(pybind11_system SYSTEM)
103
+ set(_pybind11_findpython_default OFF)
88
104
  endif()
89
105
 
90
106
  # Options
91
107
  option(PYBIND11_INSTALL "Install pybind11 header files?" ${PYBIND11_MASTER_PROJECT})
92
108
  option(PYBIND11_TEST "Build pybind11 test suite?" ${PYBIND11_MASTER_PROJECT})
93
109
  option(PYBIND11_NOPYTHON "Disable search for Python" OFF)
110
+ option(PYBIND11_DISABLE_HANDLE_TYPE_NAME_DEFAULT_IMPLEMENTATION
111
+ "To enforce that a handle_type_name<> specialization exists" OFF)
94
112
  option(PYBIND11_SIMPLE_GIL_MANAGEMENT
95
113
  "Use simpler GIL management logic that does not support disassociation" OFF)
114
+ option(PYBIND11_NUMPY_1_ONLY
115
+ "Disable NumPy 2 support to avoid changes to previous pybind11 versions." OFF)
96
116
  set(PYBIND11_INTERNALS_VERSION
97
117
  ""
98
118
  CACHE STRING "Override the ABI version, may be used to enable the unstable ABI.")
99
119
 
120
+ if(PYBIND11_DISABLE_HANDLE_TYPE_NAME_DEFAULT_IMPLEMENTATION)
121
+ add_compile_definitions(PYBIND11_DISABLE_HANDLE_TYPE_NAME_DEFAULT_IMPLEMENTATION)
122
+ endif()
100
123
  if(PYBIND11_SIMPLE_GIL_MANAGEMENT)
101
124
  add_compile_definitions(PYBIND11_SIMPLE_GIL_MANAGEMENT)
102
125
  endif()
126
+ if(PYBIND11_NUMPY_1_ONLY)
127
+ add_compile_definitions(PYBIND11_NUMPY_1_ONLY)
128
+ endif()
103
129
 
104
130
  cmake_dependent_option(
105
131
  USE_PYTHON_INCLUDE_DIR
106
132
  "Install pybind11 headers in Python include directory instead of default installation prefix"
107
133
  OFF "PYBIND11_INSTALL" OFF)
108
134
 
109
- cmake_dependent_option(PYBIND11_FINDPYTHON "Force new FindPython" OFF
135
+ cmake_dependent_option(PYBIND11_FINDPYTHON "Force new FindPython" ${_pybind11_findpython_default}
110
136
  "NOT CMAKE_VERSION VERSION_LESS 3.12" OFF)
111
137
 
138
+ # Allow PYTHON_EXECUTABLE if in FINDPYTHON mode and building pybind11's tests
139
+ # (makes transition easier while we support both modes).
140
+ if(PYBIND11_MASTER_PROJECT
141
+ AND PYBIND11_FINDPYTHON
142
+ AND DEFINED PYTHON_EXECUTABLE
143
+ AND NOT DEFINED Python_EXECUTABLE)
144
+ set(Python_EXECUTABLE "${PYTHON_EXECUTABLE}")
145
+ endif()
146
+
112
147
  # NB: when adding a header don't forget to also add it to setup.py
113
148
  set(PYBIND11_HEADERS
114
149
  include/pybind11/detail/class.h
@@ -132,6 +167,7 @@ set(PYBIND11_HEADERS
132
167
  include/pybind11/embed.h
133
168
  include/pybind11/eval.h
134
169
  include/pybind11/gil.h
170
+ include/pybind11/gil_safe_call_once.h
135
171
  include/pybind11/iostream.h
136
172
  include/pybind11/functional.h
137
173
  include/pybind11/numpy.h
@@ -141,7 +177,8 @@ set(PYBIND11_HEADERS
141
177
  include/pybind11/stl.h
142
178
  include/pybind11/stl_bind.h
143
179
  include/pybind11/stl/filesystem.h
144
- include/pybind11/type_caster_pyobject_ptr.h)
180
+ include/pybind11/type_caster_pyobject_ptr.h
181
+ include/pybind11/typing.h)
145
182
 
146
183
  # Compare with grep and warn if mismatched
147
184
  if(PYBIND11_MASTER_PROJECT AND NOT CMAKE_VERSION VERSION_LESS 3.12)
@@ -277,7 +314,21 @@ if(PYBIND11_INSTALL)
277
314
 
278
315
  # pkg-config support
279
316
  if(NOT prefix_for_pc_file)
280
- set(prefix_for_pc_file "${CMAKE_INSTALL_PREFIX}")
317
+ if(IS_ABSOLUTE "${CMAKE_INSTALL_DATAROOTDIR}")
318
+ set(prefix_for_pc_file "${CMAKE_INSTALL_PREFIX}")
319
+ else()
320
+ set(pc_datarootdir "${CMAKE_INSTALL_DATAROOTDIR}")
321
+ if(CMAKE_VERSION VERSION_LESS 3.20)
322
+ set(prefix_for_pc_file "\${pcfiledir}/..")
323
+ while(pc_datarootdir)
324
+ get_filename_component(pc_datarootdir "${pc_datarootdir}" DIRECTORY)
325
+ string(APPEND prefix_for_pc_file "/..")
326
+ endwhile()
327
+ else()
328
+ cmake_path(RELATIVE_PATH CMAKE_INSTALL_PREFIX BASE_DIRECTORY CMAKE_INSTALL_DATAROOTDIR
329
+ OUTPUT_VARIABLE prefix_for_pc_file)
330
+ endif()
331
+ endif()
281
332
  endif()
282
333
  join_paths(includedir_for_pc_file "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}")
283
334
  configure_file("${CMAKE_CURRENT_SOURCE_DIR}/tools/pybind11.pc.in"
@@ -102,22 +102,22 @@ struct buffer_info {
102
102
  template <typename T>
103
103
  buffer_info(const T *ptr, ssize_t size, bool readonly = true)
104
104
  : buffer_info(
105
- const_cast<T *>(ptr), sizeof(T), format_descriptor<T>::format(), size, readonly) {}
105
+ const_cast<T *>(ptr), sizeof(T), format_descriptor<T>::format(), size, readonly) {}
106
106
 
107
107
  explicit buffer_info(Py_buffer *view, bool ownview = true)
108
108
  : buffer_info(
109
- view->buf,
110
- view->itemsize,
111
- view->format,
112
- view->ndim,
113
- {view->shape, view->shape + view->ndim},
114
- /* Though buffer::request() requests PyBUF_STRIDES, ctypes objects
115
- * ignore this flag and return a view with NULL strides.
116
- * When strides are NULL, build them manually. */
117
- view->strides
118
- ? std::vector<ssize_t>(view->strides, view->strides + view->ndim)
119
- : detail::c_strides({view->shape, view->shape + view->ndim}, view->itemsize),
120
- (view->readonly != 0)) {
109
+ view->buf,
110
+ view->itemsize,
111
+ view->format,
112
+ view->ndim,
113
+ {view->shape, view->shape + view->ndim},
114
+ /* Though buffer::request() requests PyBUF_STRIDES, ctypes objects
115
+ * ignore this flag and return a view with NULL strides.
116
+ * When strides are NULL, build them manually. */
117
+ view->strides
118
+ ? std::vector<ssize_t>(view->strides, view->strides + view->ndim)
119
+ : detail::c_strides({view->shape, view->shape + view->ndim}, view->itemsize),
120
+ (view->readonly != 0)) {
121
121
  // NOLINTNEXTLINE(cppcoreguidelines-prefer-member-initializer)
122
122
  this->m_view = view;
123
123
  // NOLINTNEXTLINE(cppcoreguidelines-prefer-member-initializer)
@@ -176,7 +176,7 @@ private:
176
176
  detail::any_container<ssize_t> &&strides_in,
177
177
  bool readonly)
178
178
  : buffer_info(
179
- ptr, itemsize, format, ndim, std::move(shape_in), std::move(strides_in), readonly) {}
179
+ ptr, itemsize, format, ndim, std::move(shape_in), std::move(strides_in), readonly) {}
180
180
 
181
181
  Py_buffer *m_view = nullptr;
182
182
  bool ownview = false;
@@ -42,13 +42,15 @@ using make_caster = type_caster<intrinsic_t<type>>;
42
42
  // Shortcut for calling a caster's `cast_op_type` cast operator for casting a type_caster to a T
43
43
  template <typename T>
44
44
  typename make_caster<T>::template cast_op_type<T> cast_op(make_caster<T> &caster) {
45
- return caster.operator typename make_caster<T>::template cast_op_type<T>();
45
+ using result_t = typename make_caster<T>::template cast_op_type<T>; // See PR #4893
46
+ return caster.operator result_t();
46
47
  }
47
48
  template <typename T>
48
49
  typename make_caster<T>::template cast_op_type<typename std::add_rvalue_reference<T>::type>
49
50
  cast_op(make_caster<T> &&caster) {
50
- return std::move(caster).operator typename make_caster<T>::
51
- template cast_op_type<typename std::add_rvalue_reference<T>::type>();
51
+ using result_t = typename make_caster<T>::template cast_op_type<
52
+ typename std::add_rvalue_reference<T>::type>; // See PR #4893
53
+ return std::move(caster).operator result_t();
52
54
  }
53
55
 
54
56
  template <typename type>
@@ -325,8 +327,9 @@ public:
325
327
  value = false;
326
328
  return true;
327
329
  }
328
- if (convert || (std::strcmp("numpy.bool_", Py_TYPE(src.ptr())->tp_name) == 0)) {
329
- // (allow non-implicit conversion for numpy booleans)
330
+ if (convert || is_numpy_bool(src)) {
331
+ // (allow non-implicit conversion for numpy booleans), use strncmp
332
+ // since NumPy 1.x had an additional trailing underscore.
330
333
 
331
334
  Py_ssize_t res = -1;
332
335
  if (src.is_none()) {
@@ -358,6 +361,15 @@ public:
358
361
  return handle(src ? Py_True : Py_False).inc_ref();
359
362
  }
360
363
  PYBIND11_TYPE_CASTER(bool, const_name("bool"));
364
+
365
+ private:
366
+ // Test if an object is a NumPy boolean (without fetching the type).
367
+ static inline bool is_numpy_bool(handle object) {
368
+ const char *type_name = Py_TYPE(object.ptr())->tp_name;
369
+ // Name changed to `numpy.bool` in NumPy 2, `numpy.bool_` is needed for 1.x support
370
+ return std::strcmp("numpy.bool", type_name) == 0
371
+ || std::strcmp("numpy.bool_", type_name) == 0;
372
+ }
361
373
  };
362
374
 
363
375
  // Helper class for UTF-{8,16,32} C++ stl strings:
@@ -660,8 +672,9 @@ public:
660
672
  return cast(*src, policy, parent);
661
673
  }
662
674
 
663
- static constexpr auto name
664
- = const_name("Tuple[") + concat(make_caster<Ts>::name...) + const_name("]");
675
+ static constexpr auto name = const_name("tuple[")
676
+ + ::pybind11::detail::concat(make_caster<Ts>::name...)
677
+ + const_name("]");
665
678
 
666
679
  template <typename T>
667
680
  using cast_op_type = type;
@@ -869,10 +882,53 @@ struct is_holder_type
869
882
  template <typename base, typename deleter>
870
883
  struct is_holder_type<base, std::unique_ptr<base, deleter>> : std::true_type {};
871
884
 
885
+ #ifdef PYBIND11_DISABLE_HANDLE_TYPE_NAME_DEFAULT_IMPLEMENTATION // See PR #4888
886
+
887
+ // This leads to compilation errors if a specialization is missing.
888
+ template <typename T>
889
+ struct handle_type_name;
890
+
891
+ #else
892
+
872
893
  template <typename T>
873
894
  struct handle_type_name {
874
895
  static constexpr auto name = const_name<T>();
875
896
  };
897
+
898
+ #endif
899
+
900
+ template <>
901
+ struct handle_type_name<object> {
902
+ static constexpr auto name = const_name("object");
903
+ };
904
+ template <>
905
+ struct handle_type_name<list> {
906
+ static constexpr auto name = const_name("list");
907
+ };
908
+ template <>
909
+ struct handle_type_name<dict> {
910
+ static constexpr auto name = const_name("dict");
911
+ };
912
+ template <>
913
+ struct handle_type_name<anyset> {
914
+ static constexpr auto name = const_name("Union[set, frozenset]");
915
+ };
916
+ template <>
917
+ struct handle_type_name<set> {
918
+ static constexpr auto name = const_name("set");
919
+ };
920
+ template <>
921
+ struct handle_type_name<frozenset> {
922
+ static constexpr auto name = const_name("frozenset");
923
+ };
924
+ template <>
925
+ struct handle_type_name<str> {
926
+ static constexpr auto name = const_name("str");
927
+ };
928
+ template <>
929
+ struct handle_type_name<tuple> {
930
+ static constexpr auto name = const_name("tuple");
931
+ };
876
932
  template <>
877
933
  struct handle_type_name<bool_> {
878
934
  static constexpr auto name = const_name("bool");
@@ -882,6 +938,10 @@ struct handle_type_name<bytes> {
882
938
  static constexpr auto name = const_name(PYBIND11_BYTES_NAME);
883
939
  };
884
940
  template <>
941
+ struct handle_type_name<buffer> {
942
+ static constexpr auto name = const_name("Buffer");
943
+ };
944
+ template <>
885
945
  struct handle_type_name<int_> {
886
946
  static constexpr auto name = const_name("int");
887
947
  };
@@ -898,10 +958,50 @@ struct handle_type_name<float_> {
898
958
  static constexpr auto name = const_name("float");
899
959
  };
900
960
  template <>
961
+ struct handle_type_name<function> {
962
+ static constexpr auto name = const_name("Callable");
963
+ };
964
+ template <>
965
+ struct handle_type_name<handle> {
966
+ static constexpr auto name = handle_type_name<object>::name;
967
+ };
968
+ template <>
901
969
  struct handle_type_name<none> {
902
970
  static constexpr auto name = const_name("None");
903
971
  };
904
972
  template <>
973
+ struct handle_type_name<sequence> {
974
+ static constexpr auto name = const_name("Sequence");
975
+ };
976
+ template <>
977
+ struct handle_type_name<bytearray> {
978
+ static constexpr auto name = const_name("bytearray");
979
+ };
980
+ template <>
981
+ struct handle_type_name<memoryview> {
982
+ static constexpr auto name = const_name("memoryview");
983
+ };
984
+ template <>
985
+ struct handle_type_name<slice> {
986
+ static constexpr auto name = const_name("slice");
987
+ };
988
+ template <>
989
+ struct handle_type_name<type> {
990
+ static constexpr auto name = const_name("type");
991
+ };
992
+ template <>
993
+ struct handle_type_name<capsule> {
994
+ static constexpr auto name = const_name("capsule");
995
+ };
996
+ template <>
997
+ struct handle_type_name<ellipsis> {
998
+ static constexpr auto name = const_name("ellipsis");
999
+ };
1000
+ template <>
1001
+ struct handle_type_name<weakref> {
1002
+ static constexpr auto name = const_name("weakref");
1003
+ };
1004
+ template <>
905
1005
  struct handle_type_name<args> {
906
1006
  static constexpr auto name = const_name("*args");
907
1007
  };
@@ -909,6 +1009,30 @@ template <>
909
1009
  struct handle_type_name<kwargs> {
910
1010
  static constexpr auto name = const_name("**kwargs");
911
1011
  };
1012
+ template <>
1013
+ struct handle_type_name<obj_attr_accessor> {
1014
+ static constexpr auto name = const_name<obj_attr_accessor>();
1015
+ };
1016
+ template <>
1017
+ struct handle_type_name<str_attr_accessor> {
1018
+ static constexpr auto name = const_name<str_attr_accessor>();
1019
+ };
1020
+ template <>
1021
+ struct handle_type_name<item_accessor> {
1022
+ static constexpr auto name = const_name<item_accessor>();
1023
+ };
1024
+ template <>
1025
+ struct handle_type_name<sequence_accessor> {
1026
+ static constexpr auto name = const_name<sequence_accessor>();
1027
+ };
1028
+ template <>
1029
+ struct handle_type_name<list_accessor> {
1030
+ static constexpr auto name = const_name<list_accessor>();
1031
+ };
1032
+ template <>
1033
+ struct handle_type_name<tuple_accessor> {
1034
+ static constexpr auto name = const_name<tuple_accessor>();
1035
+ };
912
1036
 
913
1037
  template <typename type>
914
1038
  struct pyobject_caster {
@@ -1377,7 +1501,15 @@ inline namespace literals {
1377
1501
  /** \rst
1378
1502
  String literal version of `arg`
1379
1503
  \endrst */
1380
- constexpr arg operator"" _a(const char *name, size_t) { return arg(name); }
1504
+ constexpr arg
1505
+ #if !defined(__clang__) && defined(__GNUC__) && __GNUC__ < 5
1506
+ operator"" _a // gcc 4.8.5 insists on having a space (hard error).
1507
+ #else
1508
+ operator""_a // clang 17 generates a deprecation warning if there is a space.
1509
+ #endif
1510
+ (const char *name, size_t) {
1511
+ return arg(name);
1512
+ }
1381
1513
  } // namespace literals
1382
1514
 
1383
1515
  PYBIND11_NAMESPACE_BEGIN(detail)
@@ -1438,7 +1570,8 @@ public:
1438
1570
  static_assert(args_pos == -1 || args_pos == constexpr_first<argument_is_args, Args...>(),
1439
1571
  "py::args cannot be specified more than once");
1440
1572
 
1441
- static constexpr auto arg_names = concat(type_descr(make_caster<Args>::name)...);
1573
+ static constexpr auto arg_names
1574
+ = ::pybind11::detail::concat(type_descr(make_caster<Args>::name)...);
1442
1575
 
1443
1576
  bool load_args(function_call &call) { return load_impl_sequence(call, indices{}); }
1444
1577
 
@@ -86,17 +86,16 @@ inline PyTypeObject *make_static_property_type() {
86
86
  type->tp_descr_get = pybind11_static_get;
87
87
  type->tp_descr_set = pybind11_static_set;
88
88
 
89
- if (PyType_Ready(type) < 0) {
90
- pybind11_fail("make_static_property_type(): failure in PyType_Ready()!");
91
- }
92
-
93
89
  # if PY_VERSION_HEX >= 0x030C0000
94
- // PRE 3.12 FEATURE FREEZE. PLEASE REVIEW AFTER FREEZE.
95
90
  // Since Python-3.12 property-derived types are required to
96
91
  // have dynamic attributes (to set `__doc__`)
97
92
  enable_dynamic_attributes(heap_type);
98
93
  # endif
99
94
 
95
+ if (PyType_Ready(type) < 0) {
96
+ pybind11_fail("make_static_property_type(): failure in PyType_Ready()!");
97
+ }
98
+
100
99
  setattr((PyObject *) type, "__module__", str("pybind11_builtins"));
101
100
  PYBIND11_SET_OLDPY_QUALNAME(type, name_obj);
102
101
 
@@ -189,12 +188,10 @@ extern "C" inline PyObject *pybind11_meta_call(PyObject *type, PyObject *args, P
189
188
  return nullptr;
190
189
  }
191
190
 
192
- // This must be a pybind11 instance
193
- auto *instance = reinterpret_cast<detail::instance *>(self);
194
-
195
191
  // Ensure that the base __init__ function(s) were called
196
- for (const auto &vh : values_and_holders(instance)) {
197
- if (!vh.holder_constructed()) {
192
+ values_and_holders vhs(self);
193
+ for (const auto &vh : vhs) {
194
+ if (!vh.holder_constructed() && !vhs.is_redundant_value_and_holder(vh)) {
198
195
  PyErr_Format(PyExc_TypeError,
199
196
  "%.200s.__init__() must be called when overriding __init__",
200
197
  get_fully_qualified_tp_name(vh.type->type).c_str());
@@ -375,7 +372,7 @@ extern "C" inline PyObject *pybind11_object_new(PyTypeObject *type, PyObject *,
375
372
  extern "C" inline int pybind11_object_init(PyObject *self, PyObject *, PyObject *) {
376
373
  PyTypeObject *type = Py_TYPE(self);
377
374
  std::string msg = get_fully_qualified_tp_name(type) + ": No constructor defined!";
378
- PyErr_SetString(PyExc_TypeError, msg.c_str());
375
+ set_error(PyExc_TypeError, msg.c_str());
379
376
  return -1;
380
377
  }
381
378
 
@@ -522,8 +519,12 @@ inline PyObject *make_object_base_type(PyTypeObject *metaclass) {
522
519
 
523
520
  /// dynamic_attr: Allow the garbage collector to traverse the internal instance `__dict__`.
524
521
  extern "C" inline int pybind11_traverse(PyObject *self, visitproc visit, void *arg) {
522
+ #if PY_VERSION_HEX >= 0x030D0000
523
+ PyObject_VisitManagedDict(self, visit, arg);
524
+ #else
525
525
  PyObject *&dict = *_PyObject_GetDictPtr(self);
526
526
  Py_VISIT(dict);
527
+ #endif
527
528
  // https://docs.python.org/3/c-api/typeobj.html#c.PyTypeObject.tp_traverse
528
529
  #if PY_VERSION_HEX >= 0x03090000
529
530
  Py_VISIT(Py_TYPE(self));
@@ -533,8 +534,12 @@ extern "C" inline int pybind11_traverse(PyObject *self, visitproc visit, void *a
533
534
 
534
535
  /// dynamic_attr: Allow the GC to clear the dictionary.
535
536
  extern "C" inline int pybind11_clear(PyObject *self) {
537
+ #if PY_VERSION_HEX >= 0x030D0000
538
+ PyObject_ClearManagedDict(self);
539
+ #else
536
540
  PyObject *&dict = *_PyObject_GetDictPtr(self);
537
541
  Py_CLEAR(dict);
542
+ #endif
538
543
  return 0;
539
544
  }
540
545
 
@@ -579,7 +584,7 @@ extern "C" inline int pybind11_getbuffer(PyObject *obj, Py_buffer *view, int fla
579
584
  if (view) {
580
585
  view->obj = nullptr;
581
586
  }
582
- PyErr_SetString(PyExc_BufferError, "pybind11_getbuffer(): Internal error");
587
+ set_error(PyExc_BufferError, "pybind11_getbuffer(): Internal error");
583
588
  return -1;
584
589
  }
585
590
  std::memset(view, 0, sizeof(Py_buffer));
@@ -587,7 +592,7 @@ extern "C" inline int pybind11_getbuffer(PyObject *obj, Py_buffer *view, int fla
587
592
  if ((flags & PyBUF_WRITABLE) == PyBUF_WRITABLE && info->readonly) {
588
593
  delete info;
589
594
  // view->obj = nullptr; // Was just memset to 0, so not necessary
590
- PyErr_SetString(PyExc_BufferError, "Writable buffer requested for readonly storage");
595
+ set_error(PyExc_BufferError, "Writable buffer requested for readonly storage");
591
596
  return -1;
592
597
  }
593
598
  view->obj = obj;
@@ -10,12 +10,12 @@
10
10
  #pragma once
11
11
 
12
12
  #define PYBIND11_VERSION_MAJOR 2
13
- #define PYBIND11_VERSION_MINOR 11
13
+ #define PYBIND11_VERSION_MINOR 13
14
14
  #define PYBIND11_VERSION_PATCH 0.dev1
15
15
 
16
16
  // Similar to Python's convention: https://docs.python.org/3/c-api/apiabiversion.html
17
17
  // Additional convention: 0xD = dev
18
- #define PYBIND11_VERSION_HEX 0x020B00D1
18
+ #define PYBIND11_VERSION_HEX 0x020D00D1
19
19
 
20
20
  // Define some generic pybind11 helper macros for warning management.
21
21
  //
@@ -118,6 +118,14 @@
118
118
  # endif
119
119
  #endif
120
120
 
121
+ #if defined(PYBIND11_CPP20)
122
+ # define PYBIND11_CONSTINIT constinit
123
+ # define PYBIND11_DTOR_CONSTEXPR constexpr
124
+ #else
125
+ # define PYBIND11_CONSTINIT
126
+ # define PYBIND11_DTOR_CONSTEXPR
127
+ #endif
128
+
121
129
  // Compiler version assertions
122
130
  #if defined(__INTEL_COMPILER)
123
131
  # if __INTEL_COMPILER < 1800
@@ -288,6 +296,10 @@ PYBIND11_WARNING_DISABLE_MSVC(4505)
288
296
  # undef copysign
289
297
  #endif
290
298
 
299
+ #if defined(PYBIND11_NUMPY_1_ONLY)
300
+ # define PYBIND11_INTERNAL_NUMPY_1_ONLY_DETECTED
301
+ #endif
302
+
291
303
  #if defined(PYPY_VERSION) && !defined(PYBIND11_SIMPLE_GIL_MANAGEMENT)
292
304
  # define PYBIND11_SIMPLE_GIL_MANAGEMENT
293
305
  #endif
@@ -324,11 +336,8 @@ PYBIND11_WARNING_POP
324
336
  #endif
325
337
 
326
338
  // See description of PR #4246:
327
- #if !defined(NDEBUG) && !defined(PY_ASSERT_GIL_HELD_INCREF_DECREF) \
328
- && !(defined(PYPY_VERSION) \
329
- && defined(_MSC_VER)) /* PyPy Windows: pytest hangs indefinitely at the end of the \
330
- process (see PR #4268) */ \
331
- && !defined(PYBIND11_ASSERT_GIL_HELD_INCREF_DECREF)
339
+ #if !defined(PYBIND11_NO_ASSERT_GIL_HELD_INCREF_DECREF) && !defined(NDEBUG) \
340
+ && !defined(PYPY_VERSION) && !defined(PYBIND11_ASSERT_GIL_HELD_INCREF_DECREF)
332
341
  # define PYBIND11_ASSERT_GIL_HELD_INCREF_DECREF
333
342
  #endif
334
343
 
@@ -402,7 +411,7 @@ PYBIND11_WARNING_POP
402
411
  return nullptr; \
403
412
  } \
404
413
  catch (const std::exception &e) { \
405
- PyErr_SetString(PyExc_ImportError, e.what()); \
414
+ ::pybind11::set_error(PyExc_ImportError, e.what()); \
406
415
  return nullptr; \
407
416
  }
408
417
 
@@ -916,8 +925,7 @@ using is_template_base_of
916
925
  = decltype(is_template_base_of_impl<Base>::check((intrinsic_t<T> *) nullptr));
917
926
  #else
918
927
  struct is_template_base_of
919
- : decltype(is_template_base_of_impl<Base>::check((intrinsic_t<T> *) nullptr)) {
920
- };
928
+ : decltype(is_template_base_of_impl<Base>::check((intrinsic_t<T> *) nullptr)){};
921
929
  #endif
922
930
 
923
931
  /// Check if T is an instantiation of the template `Class`. For example:
@@ -1099,14 +1107,14 @@ struct overload_cast_impl {
1099
1107
  }
1100
1108
 
1101
1109
  template <typename Return, typename Class>
1102
- constexpr auto operator()(Return (Class::*pmf)(Args...), std::false_type = {}) const noexcept
1103
- -> decltype(pmf) {
1110
+ constexpr auto operator()(Return (Class::*pmf)(Args...),
1111
+ std::false_type = {}) const noexcept -> decltype(pmf) {
1104
1112
  return pmf;
1105
1113
  }
1106
1114
 
1107
1115
  template <typename Return, typename Class>
1108
- constexpr auto operator()(Return (Class::*pmf)(Args...) const, std::true_type) const noexcept
1109
- -> decltype(pmf) {
1116
+ constexpr auto operator()(Return (Class::*pmf)(Args...) const,
1117
+ std::true_type) const noexcept -> decltype(pmf) {
1110
1118
  return pmf;
1111
1119
  }
1112
1120
  };
@@ -156,8 +156,9 @@ constexpr auto concat(const descr<N, Ts...> &d, const Args &...args) {
156
156
  }
157
157
  #else
158
158
  template <size_t N, typename... Ts, typename... Args>
159
- constexpr auto concat(const descr<N, Ts...> &d, const Args &...args)
160
- -> decltype(std::declval<descr<N + 2, Ts...>>() + concat(args...)) {
159
+ constexpr auto concat(const descr<N, Ts...> &d,
160
+ const Args &...args) -> decltype(std::declval<descr<N + 2, Ts...>>()
161
+ + concat(args...)) {
161
162
  return d + const_name(", ") + concat(args...);
162
163
  }
163
164
  #endif