Skip to content

Commit ea0c1e7

Browse files
committed
Merge branch 'master' into sh_merge_master
2 parents ea4cc14 + f8d4aa4 commit ea0c1e7

13 files changed

+185
-101
lines changed

.clang-tidy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ readability-simplify-subscript-expr,
4646
readability-static-accessed-through-instance,
4747
readability-static-definition-in-anonymous-namespace,
4848
readability-string-compare,
49+
readability-suspicious-call-argument,
4950
readability-uniqueptr-delete-release,
5051
-bugprone-exception-escape,
5152
-bugprone-reserved-identifier,

.github/CONTRIBUTING.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,9 @@ tests with these targets:
159159
* `test_cmake_build`: Install / subdirectory tests
160160

161161
If you want to build just a subset of tests, use
162-
`-DPYBIND11_TEST_OVERRIDE="test_callbacks.cpp;test_pickling.cpp"`. If this is
163-
empty, all tests will be built.
162+
`-DPYBIND11_TEST_OVERRIDE="test_callbacks;test_pickling"`. If this is
163+
empty, all tests will be built. Tests are specified without an extension if they need both a .py and
164+
.cpp file.
164165

165166
You may also pass flags to the `pytest` target by editing `tests/pytest.ini` or
166167
by using the `PYTEST_ADDOPTS` environment variable

.github/workflows/ci.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -560,37 +560,37 @@ jobs:
560560
set +e; source /opt/intel/oneapi/setvars.sh; set -e
561561
cmake --build build-11 --target test_cmake_build
562562
563-
- name: Configure C++14
563+
- name: Configure C++17
564564
run: |
565565
set +e; source /opt/intel/oneapi/setvars.sh; set -e
566-
cmake -S . -B build-14 \
566+
cmake -S . -B build-17 \
567567
-DPYBIND11_WERROR=ON \
568568
-DDOWNLOAD_CATCH=ON \
569569
-DDOWNLOAD_EIGEN=OFF \
570-
-DCMAKE_CXX_STANDARD=14 \
570+
-DCMAKE_CXX_STANDARD=17 \
571571
-DCMAKE_CXX_COMPILER=$(which icpc) \
572572
-DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)")
573573
574-
- name: Build C++14
574+
- name: Build C++17
575575
run: |
576576
set +e; source /opt/intel/oneapi/setvars.sh; set -e
577-
cmake --build build-14 -j 2 -v
577+
cmake --build build-17 -j 2 -v
578578
579-
- name: Python tests C++14
579+
- name: Python tests C++17
580580
run: |
581581
set +e; source /opt/intel/oneapi/setvars.sh; set -e
582582
sudo service apport stop
583-
cmake --build build-14 --target check
583+
cmake --build build-17 --target check
584584
585-
- name: C++ tests C++14
585+
- name: C++ tests C++17
586586
run: |
587587
set +e; source /opt/intel/oneapi/setvars.sh; set -e
588-
cmake --build build-14 --target cpptest
588+
cmake --build build-17 --target cpptest
589589
590-
- name: Interface test C++14
590+
- name: Interface test C++17
591591
run: |
592592
set +e; source /opt/intel/oneapi/setvars.sh; set -e
593-
cmake --build build-14 --target test_cmake_build
593+
cmake --build build-17 --target test_cmake_build
594594
595595
596596
# Testing on CentOS (manylinux uses a centos base, and this is an easy way

.github/workflows/pip.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,13 @@ jobs:
9797
- uses: actions/download-artifact@v2
9898

9999
- name: Publish standard package
100-
uses: pypa/gh-action-pypi-publish@v1.4.2
100+
uses: pypa/gh-action-pypi-publish@v1.5.0
101101
with:
102102
password: ${{ secrets.pypi_password }}
103103
packages_dir: standard/
104104

105105
- name: Publish global package
106-
uses: pypa/gh-action-pypi-publish@v1.4.2
106+
uses: pypa/gh-action-pypi-publish@v1.5.0
107107
with:
108108
password: ${{ secrets.pypi_password_global }}
109109
packages_dir: global/

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ repos:
106106

107107
# Check static types with mypy
108108
- repo: https://github.com/pre-commit/mirrors-mypy
109-
rev: v0.930
109+
rev: v0.931
110110
hooks:
111111
- id: mypy
112112
# Running per-file misbehaves a bit, so just run on all files, it's fast

include/pybind11/chrono.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
#include <ctime>
1818
#include <mutex>
1919

20-
#include <time.h>
21-
2220
#include <datetime.h>
2321

2422
// Backport the PyDateTime_DELTA functions from Python3.3 if required
@@ -108,7 +106,7 @@ inline std::tm *localtime_thread_safe(const std::time_t *time, std::tm *buf) {
108106
#else
109107
static std::mutex mtx;
110108
std::lock_guard<std::mutex> lock(mtx);
111-
std::tm *tm_ptr = localtime(time);
109+
std::tm *tm_ptr = std::localtime(time);
112110
if (tm_ptr != nullptr) {
113111
*buf = *tm_ptr;
114112
}

include/pybind11/detail/class.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -626,9 +626,9 @@ inline PyObject* make_new_python_type(const type_record &rec) {
626626
if (rec.doc && options::show_user_defined_docstrings()) {
627627
/* Allocate memory for docstring (using PyObject_MALLOC, since
628628
Python will free this later on) */
629-
size_t size = strlen(rec.doc) + 1;
629+
size_t size = std::strlen(rec.doc) + 1;
630630
tp_doc = (char *) PyObject_MALLOC(size);
631-
memcpy((void *) tp_doc, rec.doc, size);
631+
std::memcpy((void *) tp_doc, rec.doc, size);
632632
}
633633

634634
auto &internals = get_internals();

include/pybind11/embed.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,13 @@ inline wchar_t *widen_chars(const char *safe_arg) {
110110
#endif
111111

112112
# if defined(HAVE_BROKEN_MBSTOWCS) && HAVE_BROKEN_MBSTOWCS
113-
size_t count = strlen(safe_arg);
113+
size_t count = std::strlen(safe_arg);
114114
# else
115-
size_t count = mbstowcs(nullptr, safe_arg, 0);
115+
size_t count = std::mbstowcs(nullptr, safe_arg, 0);
116116
# endif
117117
if (count != static_cast<size_t>(-1)) {
118118
widened_arg = new wchar_t[count + 1];
119-
mbstowcs(widened_arg, safe_arg, count + 1);
119+
std::mbstowcs(widened_arg, safe_arg, count + 1);
120120
}
121121

122122
#if defined(_MSC_VER)

include/pybind11/pybind11.h

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include <string>
2626
#include <utility>
2727

28-
#include <string.h>
28+
#include <cstring>
2929

3030
#if defined(__cpp_lib_launder) && !(defined(_MSC_VER) && (_MSC_VER < 1914))
3131
# define PYBIND11_STD_LAUNDER std::launder
@@ -329,8 +329,8 @@ class cpp_function : public function {
329329
a.descr = guarded_strdup(repr(a.value).cast<std::string>().c_str());
330330
}
331331

332-
rec->is_constructor
333-
= (strcmp(rec->name, "__init__") == 0) || (strcmp(rec->name, "__setstate__") == 0);
332+
rec->is_constructor = (std::strcmp(rec->name, "__init__") == 0)
333+
|| (std::strcmp(rec->name, "__setstate__") == 0);
334334

335335
#if !defined(NDEBUG) && !defined(PYBIND11_DISABLE_NEW_STYLE_INIT_WARNING)
336336
if (rec->is_constructor && !rec->is_new_style_constructor) {
@@ -411,10 +411,10 @@ class cpp_function : public function {
411411
pybind11_fail("Internal error while parsing type signature (2)");
412412

413413
#if PY_MAJOR_VERSION < 3
414-
if (strcmp(rec->name, "__next__") == 0) {
414+
if (std::strcmp(rec->name, "__next__") == 0) {
415415
std::free(rec->name);
416416
rec->name = guarded_strdup("next");
417-
} else if (strcmp(rec->name, "__bool__") == 0) {
417+
} else if (std::strcmp(rec->name, "__bool__") == 0) {
418418
std::free(rec->name);
419419
rec->name = guarded_strdup("__nonzero__");
420420
}
@@ -998,6 +998,13 @@ class cpp_function : public function {
998998
"Python type! The signature was\n\t";
999999
msg += it->signature;
10001000
append_note_if_missing_header_is_suspected(msg);
1001+
#if PY_VERSION_HEX >= 0x03030000
1002+
// Attach additional error info to the exception if supported
1003+
if (PyErr_Occurred()) {
1004+
raise_from(PyExc_TypeError, msg.c_str());
1005+
return nullptr;
1006+
}
1007+
#endif
10011008
PyErr_SetString(PyExc_TypeError, msg.c_str());
10021009
return nullptr;
10031010
}
@@ -1298,8 +1305,8 @@ inline void call_operator_delete(void *p, size_t s, size_t a) {
12981305

12991306
inline void add_class_method(object& cls, const char *name_, const cpp_function &cf) {
13001307
cls.attr(cf.name()) = cf;
1301-
if (strcmp(name_, "__eq__") == 0 && !cls.attr("__dict__").contains("__hash__")) {
1302-
cls.attr("__hash__") = none();
1308+
if (std::strcmp(name_, "__eq__") == 0 && !cls.attr("__dict__").contains("__hash__")) {
1309+
cls.attr("__hash__") = none();
13031310
}
13041311
}
13051312

0 commit comments

Comments
 (0)