summaryrefslogtreecommitdiffstats
path: root/libdimension-python
diff options
context:
space:
mode:
Diffstat (limited to 'libdimension-python')
-rw-r--r--libdimension-python/dimension.pyx16
-rwxr-xr-xlibdimension-python/tests/canvas.py4
-rwxr-xr-xlibdimension-python/tests/demo.py1
3 files changed, 16 insertions, 5 deletions
diff --git a/libdimension-python/dimension.pyx b/libdimension-python/dimension.pyx
index b8855fe..dffa8fa 100644
--- a/libdimension-python/dimension.pyx
+++ b/libdimension-python/dimension.pyx
@@ -569,9 +569,19 @@ cdef class Canvas:
if fclose(file) != 0:
_raise_OSError()
- progress = _Progress(dmnsn_png_write_canvas_async(self._canvas, file))
- progress._finalizer = finalize
- return progress
+ cdef dmnsn_progress *progress = dmnsn_png_write_canvas_async(self._canvas,
+ file)
+
+ try:
+ if progress == NULL:
+ _raise_OSError()
+
+ ret = _Progress(progress)
+ ret._finalizer = finalize
+ return ret
+ except:
+ finalize()
+ raise
def draw_GL(self):
"""Export the canvas to the current OpenGL context."""
diff --git a/libdimension-python/tests/canvas.py b/libdimension-python/tests/canvas.py
index 3b2057e..239a548 100755
--- a/libdimension-python/tests/canvas.py
+++ b/libdimension-python/tests/canvas.py
@@ -19,8 +19,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
#########################################################################
-from dimension import *
import errno
+from dimension import *
# Treat warnings as errors for tests
die_on_warnings(True)
@@ -35,7 +35,7 @@ try:
canvas.optimize_PNG()
except OSError as e:
if e.errno == errno.ENOSYS:
- havePNG = False
+ have_PNG = False
else:
raise
diff --git a/libdimension-python/tests/demo.py b/libdimension-python/tests/demo.py
index fe3518c..a9774bc 100755
--- a/libdimension-python/tests/demo.py
+++ b/libdimension-python/tests/demo.py
@@ -21,6 +21,7 @@
import os
import os.path
+import errno
from math import *
from dimension import *