File tree Expand file tree Collapse file tree 2 files changed +6
-6
lines changed
Filter options
Expand file tree Collapse file tree 2 files changed +6
-6
lines changed
Original file line number Diff line number Diff line change @@ -1279,8 +1279,8 @@ def pilread(fname):
1279
1279
from PIL import Image
1280
1280
except ImportError :
1281
1281
return None
1282
- image = Image .open (fname )
1283
- return pil_to_array (image )
1282
+ with Image .open (fname ) as image :
1283
+ return pil_to_array (image )
1284
1284
1285
1285
handlers = {'png' : _png .read_png , }
1286
1286
if format is None :
Original file line number Diff line number Diff line change @@ -328,10 +328,10 @@ static void _read_png_data(PyObject *py_file_obj, png_bytep data, png_size_t len
328
328
Py_ssize_t bufflen;
329
329
if (read_method) {
330
330
result = PyObject_CallFunction (read_method, (char *)" i" , length);
331
- }
332
- if ( PyBytes_AsStringAndSize (result, &buffer, & bufflen) == 0 ) {
333
- if (bufflen == (Py_ssize_t) length) {
334
- memcpy (data, buffer, length);
331
+ if ( PyBytes_AsStringAndSize (result, &buffer, &bufflen) == 0 ) {
332
+ if ( bufflen == (Py_ssize_t)length ) {
333
+ memcpy (data, buffer, length);
334
+ }
335
335
}
336
336
}
337
337
Py_XDECREF (read_method);
You can’t perform that action at this time.
0 commit comments