Skip to content

Commit

Permalink
Error for incompatible keywords #32
Browse files Browse the repository at this point in the history
  • Loading branch information
dahlia committed Aug 11, 2012
1 parent e2ed5aa commit 4c50863
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions wand/image.py
Expand Up @@ -306,11 +306,16 @@ def __init__(self, image=None, blob=None, file=None, filename=None,
for b in args[:i] + args[i + 1:]):
raise TypeError('parameters are exclusive each other; use only '
'one at once')
elif not (format is None or isinstance(format, basestring)):
raise TypeError('format must be a string, not ' + repr(format))
with self.allocate():
if image is not None:
if not isinstance(image, Image):
raise TypeError('image must be a wand.image.Image '
'instance, not ' + repr(image))
elif format:
raise TypeError('format option cannot be used with image '
'nor filename')
self.wand = library.CloneMagickWand(image.wand)
else:
self.wand = library.NewMagickWand()
Expand Down Expand Up @@ -345,6 +350,11 @@ def __init__(self, image=None, blob=None, file=None, filename=None,
library.MagickReadImageBlob(self.wand, blob, len(blob))
read = True
elif filename is not None:
if format:
raise TypeError(
'format option cannot be used with image '
'nor filename'
)
library.MagickReadImage(self.wand, filename)
read = True
if not read:
Expand Down

0 comments on commit 4c50863

Please sign in to comment.