New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

repr(Image()) raises an Error #265

Closed
roelandschoukens opened this Issue Nov 29, 2015 · 2 comments

Comments

3 participants
@roelandschoukens
Contributor

roelandschoukens commented Nov 29, 2015

calling repr(Image()) will raise an error:

>>> from wand.image import Image
>>> i = Image()
>>> print(i.wand)
820470904512
>>> print(i.signature)
None
>>> repr(i)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\roeland\Documents\dev\wand\wand\image.py", line 3162, in __repr__
    self.signature[:7], self.format, self.width, self.height
TypeError: 'NoneType' object is not subscriptable
@emcconville

This comment has been minimized.

Owner

emcconville commented Nov 30, 2015

It's true that this use-case should be handled better. The __repr__ method should expect null structures.

with Image() as i:
  print(i.wand)  # Should give wand structure pointer. =>  '0xbf07e076c0'
  print(i.signature)  # No authenticated/cache pixels, so 'None' is expected.
  repr(i)  # Empty MagicWand structure. => '???'
repr(i)  # Deallocated structure. => '<wand.image.Image: (closed)>'

So I should ask. What should repr string be for the allocated, but uninitialized wand instant?

Perhaps <wand.image.Image: (empty)>, or <wand.image.Image: (alloc)>?

@dahlia

This comment has been minimized.

Collaborator

dahlia commented Dec 1, 2015

<wand.image.Image: (empty)> seems fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment