mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-24 22:25:10 +00:00
(chore): Remove deprecated c-headers (#3610)
* Remove deprecated c-headers * Update calls to old cfunctions * Add missing one * Add another missing one
This commit is contained in:
parent
f588810871
commit
d434b5f31e
@ -17,8 +17,6 @@
|
||||
#include <ctime>
|
||||
#include <mutex>
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#include <datetime.h>
|
||||
|
||||
// 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) {
|
||||
#else
|
||||
static std::mutex mtx;
|
||||
std::lock_guard<std::mutex> lock(mtx);
|
||||
std::tm *tm_ptr = localtime(time);
|
||||
std::tm *tm_ptr = std::localtime(time);
|
||||
if (tm_ptr != nullptr) {
|
||||
*buf = *tm_ptr;
|
||||
}
|
||||
|
@ -624,9 +624,9 @@ inline PyObject* make_new_python_type(const type_record &rec) {
|
||||
if (rec.doc && options::show_user_defined_docstrings()) {
|
||||
/* Allocate memory for docstring (using PyObject_MALLOC, since
|
||||
Python will free this later on) */
|
||||
size_t size = strlen(rec.doc) + 1;
|
||||
size_t size = std::strlen(rec.doc) + 1;
|
||||
tp_doc = (char *) PyObject_MALLOC(size);
|
||||
memcpy((void *) tp_doc, rec.doc, size);
|
||||
std::memcpy((void *) tp_doc, rec.doc, size);
|
||||
}
|
||||
|
||||
auto &internals = get_internals();
|
||||
|
@ -110,13 +110,13 @@ inline wchar_t *widen_chars(const char *safe_arg) {
|
||||
#endif
|
||||
|
||||
# if defined(HAVE_BROKEN_MBSTOWCS) && HAVE_BROKEN_MBSTOWCS
|
||||
size_t count = strlen(safe_arg);
|
||||
size_t count = std::strlen(safe_arg);
|
||||
# else
|
||||
size_t count = mbstowcs(nullptr, safe_arg, 0);
|
||||
size_t count = std::mbstowcs(nullptr, safe_arg, 0);
|
||||
# endif
|
||||
if (count != static_cast<size_t>(-1)) {
|
||||
widened_arg = new wchar_t[count + 1];
|
||||
mbstowcs(widened_arg, safe_arg, count + 1);
|
||||
std::mbstowcs(widened_arg, safe_arg, count + 1);
|
||||
}
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include <string.h>
|
||||
#include <cstring>
|
||||
|
||||
#if defined(__cpp_lib_launder) && !(defined(_MSC_VER) && (_MSC_VER < 1914))
|
||||
# define PYBIND11_STD_LAUNDER std::launder
|
||||
@ -327,8 +327,8 @@ protected:
|
||||
a.descr = guarded_strdup(repr(a.value).cast<std::string>().c_str());
|
||||
}
|
||||
|
||||
rec->is_constructor
|
||||
= (strcmp(rec->name, "__init__") == 0) || (strcmp(rec->name, "__setstate__") == 0);
|
||||
rec->is_constructor = (std::strcmp(rec->name, "__init__") == 0)
|
||||
|| (std::strcmp(rec->name, "__setstate__") == 0);
|
||||
|
||||
#if !defined(NDEBUG) && !defined(PYBIND11_DISABLE_NEW_STYLE_INIT_WARNING)
|
||||
if (rec->is_constructor && !rec->is_new_style_constructor) {
|
||||
@ -409,10 +409,10 @@ protected:
|
||||
pybind11_fail("Internal error while parsing type signature (2)");
|
||||
|
||||
#if PY_MAJOR_VERSION < 3
|
||||
if (strcmp(rec->name, "__next__") == 0) {
|
||||
if (std::strcmp(rec->name, "__next__") == 0) {
|
||||
std::free(rec->name);
|
||||
rec->name = guarded_strdup("next");
|
||||
} else if (strcmp(rec->name, "__bool__") == 0) {
|
||||
} else if (std::strcmp(rec->name, "__bool__") == 0) {
|
||||
std::free(rec->name);
|
||||
rec->name = guarded_strdup("__nonzero__");
|
||||
}
|
||||
@ -1302,8 +1302,8 @@ inline void call_operator_delete(void *p, size_t s, size_t a) {
|
||||
|
||||
inline void add_class_method(object& cls, const char *name_, const cpp_function &cf) {
|
||||
cls.attr(cf.name()) = cf;
|
||||
if (strcmp(name_, "__eq__") == 0 && !cls.attr("__dict__").contains("__hash__")) {
|
||||
cls.attr("__hash__") = none();
|
||||
if (std::strcmp(name_, "__eq__") == 0 && !cls.attr("__dict__").contains("__hash__")) {
|
||||
cls.attr("__hash__") = none();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user