Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 091c149

Browse files
committed
Merge pull request matplotlib#1725 from dmcdougall/fix_compiler_warnings
Fix compiler warnings
2 parents 433da1a + e1e771f commit 091c149

File tree

4 files changed

+30
-10
lines changed

4 files changed

+30
-10
lines changed

setupext.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1030,7 +1030,7 @@ def add_tk_flags(module):
10301030
if not exists(join(F, fw + '.framework')):
10311031
break
10321032
else:
1033-
# ok, F is now directory with both frameworks. Continure
1033+
# ok, F is now directory with both frameworks. Continue
10341034
# building
10351035
tk_framework_found = 1
10361036
break

src/_backend_agg.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@
3939

4040
#include "numpy/arrayobject.h"
4141
#include "agg_py_transforms.h"
42+
43+
// This C function resides in npy_3kcompat.h and is unused by
44+
// matplotlib. This is here so that the compiler doesn't complain
45+
// that it is unused.
46+
extern "C" {
47+
__attribute__((unused)) static void simple_capsule_dtor(void *ptr);
48+
}
4249
#include "file_compat.h"
4350

4451
#ifndef M_PI
@@ -2048,7 +2055,9 @@ RendererAgg::write_rgba(const Py::Tuple& args)
20482055
{
20492056
if (fwrite(pixBuffer, 1, NUMBYTES, fp) != NUMBYTES)
20502057
{
2051-
npy_PyFile_DupClose(py_file, fp);
2058+
if (npy_PyFile_DupClose(py_file, fp)) {
2059+
throw Py::RuntimeError("Error closing dupe file handle");
2060+
}
20522061

20532062
if (close_file) {
20542063
npy_PyFile_CloseFile(py_file);
@@ -2058,7 +2067,9 @@ RendererAgg::write_rgba(const Py::Tuple& args)
20582067
throw Py::RuntimeError("Error writing to file");
20592068
}
20602069

2061-
npy_PyFile_DupClose(py_file, fp);
2070+
if (npy_PyFile_DupClose(py_file, fp)) {
2071+
throw Py::RuntimeError("Error closing dupe file handle");
2072+
}
20622073

20632074
if (close_file) {
20642075
npy_PyFile_CloseFile(py_file);

src/_image.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -406,10 +406,6 @@ Image::resize(const Py::Tuple& args, const Py::Dict& kwargs)
406406

407407
typedef agg::span_allocator<agg::rgba8> span_alloc_type;
408408
span_alloc_type sa;
409-
agg::rgba8 background(agg::rgba8(int(255*bg.r),
410-
int(255*bg.g),
411-
int(255*bg.b),
412-
int(255*bg.a)));
413409

414410
// the image path
415411
agg::path_storage path;

src/_png.cpp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@
2727
#include "CXX/Extensions.hxx"
2828
#include "numpy/arrayobject.h"
2929
#include "mplutils.h"
30+
31+
// This C function resides in npy_3kcompat.h and is unused by
32+
// matplotlib. This is here so that the compiler doesn't complain
33+
// that it is unused.
34+
extern "C" {
35+
__attribute__((unused)) static void simple_capsule_dtor(void *ptr);
36+
}
3037
#include "file_compat.h"
3138

3239
// As reported in [3082058] build _png.so on aix
@@ -239,7 +246,9 @@ Py::Object _png_module::write_png(const Py::Tuple& args)
239246

240247
if (close_dup_file)
241248
{
242-
npy_PyFile_DupClose(py_file, fp);
249+
if (npy_PyFile_DupClose(py_file, fp)) {
250+
throw Py::RuntimeError("Error closing dupe file handle");
251+
}
243252
}
244253

245254
if (close_file)
@@ -258,7 +267,9 @@ Py::Object _png_module::write_png(const Py::Tuple& args)
258267
delete [] row_pointers;
259268
if (close_dup_file)
260269
{
261-
npy_PyFile_DupClose(py_file, fp);
270+
if (npy_PyFile_DupClose(py_file, fp)) {
271+
throw Py::RuntimeError("Error closing dupe file handle");
272+
}
262273
}
263274

264275
if (close_file)
@@ -569,7 +580,9 @@ _png_module::_read_png(const Py::Object& py_fileobj, const bool float_result,
569580
#endif
570581
if (close_dup_file)
571582
{
572-
npy_PyFile_DupClose(py_file, fp);
583+
if (npy_PyFile_DupClose(py_file, fp)) {
584+
throw Py::RuntimeError("Error closing dupe file handle");
585+
}
573586
}
574587

575588
if (close_file)

0 commit comments

Comments
 (0)