youknowone / itunes-iap

Apple iTunes In-app purchase verification tool
http://itunes-iap.readthedocs.io
Other
136 stars 50 forks source link

'InvalidReceipt' object has no attribute 'kwargs' in 2.5.0 #50

Closed notexistence closed 6 years ago

notexistence commented 6 years ago

Hello. There's a problem with the string representation of the package exceptions. Not sure if the problem in the prettyexc dependency package.

The code below prints the string response=<Response({u'status': 21002})>,status=21002 in 2.4.1.

try:
    itunesiap.verify('bad data')
except itunesiap.exc.InvalidReceipt as e:
    print(e)

And raises AttributeError in 2.5.0:

AttributeError                            Traceback (most recent call last)
<ipython-input-18-c29f6377615f> in <module>()
      2     itunesiap.verify('bad data')
      3 except itunesiap.exc.InvalidReceipt as e:
----> 4     print(e)
      5 

/home/notex/.virtualenvs/antisocial/lib/python2.7/site-packages/prettyexc/core.pyc in __str__(self)
    121 
    122     def __str__(self):
--> 123         unistr = self.__unicode__()
    124         if PY3:
    125             return unistr

/home/notex/.virtualenvs/antisocial/lib/python2.7/site-packages/prettyexc/core.pyc in __unicode__(self)
    118 
    119     def __unicode__(self):
--> 120         return self.format(self.unicode_environment)
    121 
    122     def __str__(self):

/home/notex/.virtualenvs/antisocial/lib/python2.7/site-packages/prettyexc/core.pyc in format(self, env)
    105                 ss.append(args)
    106                 ss.append(u')')
--> 107         msg = self._message(env)
    108         if typ and msg:
    109             ss.append(u': ')

/home/notex/.virtualenvs/antisocial/lib/python2.7/site-packages/prettyexc/core.pyc in _message(self, env)
     87         if env.SHOW_MESSAGE is False:
     88             return ''
---> 89         msg = self.message
     90         if not self._show_message(msg):
     91             return ''

/home/notex/.virtualenvs/antisocial/lib/python2.7/site-packages/prettyexc/core.pyc in __getattr__(self, key)
    136             return sup.__getattr__(key)
    137         except:
--> 138             return sup.__getattribute__(key)
    139 
    140     def __getitem__(self, index):

/home/notex/.virtualenvs/antisocial/lib/python2.7/site-packages/prettyexc/core.pyc in message(self)
    153                 return text_type(self.args[0])
    154             argss = list(self.args)
--> 155             for kw, arg in self.kwargs.items():
    156                 argss.append('='.join((kw, text_type(arg))))
    157             if argss:

/home/notex/.virtualenvs/antisocial/lib/python2.7/site-packages/prettyexc/core.pyc in __getattr__(self, key)
    136             return sup.__getattr__(key)
    137         except:
--> 138             return sup.__getattribute__(key)
    139 
    140     def __getitem__(self, index):

AttributeError: 'InvalidReceipt' object has no attribute 'kwargs'

Any ideas?

youknowone commented 6 years ago

Thanks for the report #51 will fix it