Skip to content

Commit 01b2fb5

Browse files
committed
Additional check for image()
Throw an error if someone calls image() without any arguments, rather than crashing later when trying to access the non-existent _nsImage
1 parent 6399225 commit 01b2fb5

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

plotdevice/gfx/image.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ def __init__(self, *args, **kwargs):
6363
elif args and args[0] is None:
6464
args.pop(0) # make image(None, 10,20, image=...) work properly for compat
6565

66+
# Validate that we have either a source or data
67+
if not (src or data):
68+
raise DeviceError("Image requires either a source (path/url/Image) or image data")
69+
6670
# get an NSImage reference (once way or another)
6771
if data:
6872
self._nsImage = self._lazyload(data=data)

0 commit comments

Comments
 (0)