8000 Merge remote-tracking branch 'upstream/master' · takluyver/matplotlib@6638c4f · GitHub
[go: up one dir, main page]

Skip to content

Commit 6638c4f

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 122cc61 + 11e5284 commit 6638c4f

File tree

5 files changed

+10
-34
lines changed

5 files changed

+10
-34
lines changed

src/_backend_agg.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,11 @@ BufferRegion::to_string(const Py::Tuple &args)
103103
{
104104
// owned=true to prevent memory leak
105105
#if PY3K
106-
return Py::Bytes(PyBytes_FromStringAndSize((const char*)data, height*stride), true);
106+
return Py::Bytes
107107
#else
108-
return Py::String(PyString_FromStringAndSize((const char*)data, height*stride), true);
108+
return Py::String
109109
#endif
110+
(PyBytes_FromStringAndSize((const char*)data, height*stride), true);
110111
}
111112

112113

@@ -156,20 +157,11 @@ BufferRegion::to_string_argb(const Py::Tuple &args)
156157
unsigned char tmp;
157158
size_t i, j;
158159

159-
#if PY3K
160160
PyObject* str = PyBytes_FromStringAndSize((const char*)data, height * stride);
161161
if (PyBytes_AsStringAndSize(str, (char**)&begin, &length))
162162
{
163163
throw Py::TypeError("Could not create memory for blit");
164164
}
165-
#else
166-
PyObject* str = PyString_FromStringAndSize((const char*)data, height * stride);
167-
if (PyString_AsStringAndSize(str, (char**)&begin, &length))
168-
{
169-
throw Py::TypeError("Could not create memory for blit");
170-
}
171-
#endif
172-
173165

174166
pix = begin;
175167
end = begin + (height * stride);

src/_macosx.m

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2955,19 +2955,15 @@ static void _data_provider_release(void* info, const void* data, size_t size)
29552955
CGDataProviderRef provider;
29562956
double rect[4] = {0.0, 0.0, self->size.width, self->size.height};
29572957

2958-
#if PY3K
29592958
if (!PyBytes_Check(image))
29602959
{
2961-
PyErr_SetString(PyExc_RuntimeError, "image is not a byte array");
2962-
return NULL;
2963-
}
2960+
#if PY3K
2961+
PyErr_SetString(PyExc_RuntimeError, "image is not a bytes object");
29642962
#else
2965-
if (!PyString_Check(image))
2966-
{
2967-
PyErr_SetString(PyExc_RuntimeError, "image is not a string");
2963+
PyErr_SetString(PyExc_RuntimeError, "image is not a str object");
2964+
#endif
29682965
return NULL;
29692966
}
2970-
#endif
29712967

29722968
const size_t bytesPerComponent = 1;
29732969
const size_t bitsPerComponent = 8 * bytesPerComponent;
@@ -5096,7 +5092,7 @@ - (void)mouseDown:(NSEvent *)event
50965092
}
50975093
if ([event clickCount] == 2) {
50985094
dblclick = 1;
5099-
}
5095+
}
51005096
gstate = PyGILState_Ensure();
51015097
result = PyObject_CallMethod(canvas, "button_press_event", "iiii", x, y, num, dblclick);
51025098
if(result)
@@ -5185,7 +5181,7 @@ - (void)rightMouseDown:(NSEvent *)event
51855181
gstate = PyGILState_Ensure();
51865182
if ([event clickCount] == 2) {
51875183
dblclick = 1;
5188-
}
5184+
}
51895185
result = PyObject_CallMethod(canvas, "button_press_event", "iiii", x, y, num, dblclick);
51905186
if(result)
51915187
Py_DECREF(result);
@@ -5246,7 +5242,7 @@ - (void)otherMouseDown:(NSEvent *)event
52465242
gstate = PyGILState_Ensure();
52475243
if ([event clickCount] == 2) {
52485244
dblclick = 1;
5249-
}
5245+
}
52505246
result = PyObject_CallMethod(canvas, "button_press_event", "iiii", x, y, num, dblclick);
52515247
if(result)
52525248
Py_DECREF(result);

src/_png.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,11 +279,7 @@ static void _read_png_data(PyObject* py_file_obj, png_bytep data, png_size_t len
279279
{
280280
result = PyObject_CallFunction(read_method, (char *)"i", length);
281281
}
282-
#if PY3K
283282
if (PyBytes_AsStringAndSize(result, &buffer, &bufflen) == 0)
284-
#else
285-
if (PyString_AsStringAndSize(result, &buffer, &bufflen) == 0)
286-
#endif
287283
{
288284
if (bufflen == (Py_ssize_t)length)
289285
{

src/_ttconv.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,7 @@ class PythonDictionaryCallback : public TTDictionaryCallback
179179

180180
virtual void add_pair(const char* a, const char* b)
181181
{
182-
#if PY3K
183182
PyObject* value = PyBytes_FromString(b);
184-
#else
185-
PyObject* value = PyString_FromString(b);
186-
#endif
187183
if (value)
188184
{
189185
if (PyDict_SetItemString(_dict, a, value))

src/ft2font.cpp

Lines changed: 0 additions & 4 dele 7EE7 tions
Original file line numberDiff line numberDiff line change
@@ -296,11 +296,7 @@ FT2Image::py_as_str(const Py::Tuple & args)
296296
args.verify_length(0);
297297

298298
return Py::asObject
299-
#if PY3K
300299
(PyBytes_FromStringAndSize((const char *)_buffer, _width*_height));
301-
#else
302-
(PyString_FromStringAndSize((const char *)_buffer, _width*_height));
303-
#endif
304300
}
305301
PYCXX_VARARGS_METHOD_DECL(FT2Image, py_as_str)
306302

0 commit comments

Comments
 (0)
0