summaryrefslogtreecommitdiff
path: root/Lib
diff options
context:
space:
mode:
authorSeth R Johnson <johnsonsr@ornl.gov>2022-12-06 21:54:24 -0500
committerSeth R Johnson <johnsonsr@ornl.gov>2022-12-06 21:54:24 -0500
commitf734c23e8c9b1316f7c242f25e1fda816770ed77 (patch)
tree619350a61ddeae7eb33553fc847a82fbc81ef768 /Lib
parent8a24c19d2621e0de6a4429a039dc75d3a761acd4 (diff)
downloadswig-f734c23e8c9b1316f7c242f25e1fda816770ed77.tar.gz
Eliminate sprintf in generated python code
Newer clang versions emit warnings in generated code: ``` warning: 'sprintf' is deprecated: This function is provided for compatibility reasons only. Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead. [-Wdeprecated-declarations] ```
Diffstat (limited to 'Lib')
-rw-r--r--Lib/python/pycontainer.swg6
1 files changed, 3 insertions, 3 deletions
diff --git a/Lib/python/pycontainer.swg b/Lib/python/pycontainer.swg
index d6fdff087..4910fecc0 100644
--- a/Lib/python/pycontainer.swg
+++ b/Lib/python/pycontainer.swg
@@ -386,7 +386,7 @@ namespace swig {
size_t replacecount = (jj - ii + step - 1) / step;
if (is.size() != replacecount) {
char msg[1024];
- sprintf(msg, "attempt to assign sequence of size %lu to extended slice of size %lu", (unsigned long)is.size(), (unsigned long)replacecount);
+ PyOS_snprintf(msg, sizeof(msg), "attempt to assign sequence of size %lu to extended slice of size %lu", (unsigned long)is.size(), (unsigned long)replacecount);
throw std::invalid_argument(msg);
}
typename Sequence::const_iterator isit = is.begin();
@@ -402,7 +402,7 @@ namespace swig {
size_t replacecount = (ii - jj - step - 1) / -step;
if (is.size() != replacecount) {
char msg[1024];
- sprintf(msg, "attempt to assign sequence of size %lu to extended slice of size %lu", (unsigned long)is.size(), (unsigned long)replacecount);
+ PyOS_snprintf(msg, sizeof(msg), "attempt to assign sequence of size %lu to extended slice of size %lu", (unsigned long)is.size(), (unsigned long)replacecount);
throw std::invalid_argument(msg);
}
typename Sequence::const_iterator isit = is.begin();
@@ -478,7 +478,7 @@ namespace swig
return swig::as<T>(item);
} catch (const std::invalid_argument& e) {
char msg[1024];
- sprintf(msg, "in sequence element %d ", (int)_index);
+ PyOS_snprintf(msg, sizeof(msg), "in sequence element %d ", (int)_index);
if (!PyErr_Occurred()) {
::%type_error(swig::type_name<T>());
}