From df89a59c165e85114725983be6ba036d363c722a Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Tue, 20 Sep 2011 11:18:22 -0400 Subject: Add a filename parameter to _raise_OSError(). --- libdimension-python/dimension.pyx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/libdimension-python/dimension.pyx b/libdimension-python/dimension.pyx index dffa8fa..0ab47a8 100644 --- a/libdimension-python/dimension.pyx +++ b/libdimension-python/dimension.pyx @@ -28,8 +28,11 @@ import os # Helpers # ########### -cdef _raise_OSError(): - raise OSError(errno, os.strerror(errno)) +cdef _raise_OSError(filename = None): + if filename is None: + raise OSError(errno, os.strerror(errno)) + else: + raise OSError(errno, os.strerror(errno), filename) ########### # Globals # @@ -563,7 +566,7 @@ cdef class Canvas: cdef char *cpath = bpath cdef FILE *file = fopen(cpath, "wb") if file == NULL: - _raise_OSError() + _raise_OSError(path) def finalize(): if fclose(file) != 0: @@ -707,10 +710,10 @@ cdef class ImageMap(Pigment): cdef char *cpath = bpath cdef FILE *file = fopen(cpath, "rb") if file == NULL: - _raise_OSError() + _raise_OSError(path) cdef dmnsn_canvas *canvas = dmnsn_png_read_canvas(file) if canvas == NULL: - _raise_OSError() + _raise_OSError(path) if fclose(file) != 0: _raise_OSError() -- cgit v1.2.3