TypeError when calling usr.friends
juanchristian opened this issue · 5 comments
juanchristian commented
Code:
import steamapi
import pprint
steamapi.core.APIConnection(api_key="B9XXXXXX20")
usr = steamapi.user.SteamUser(76561198067618735)
pp = pprint.PrettyPrinter(indent=4)
pp.pprint(usr.friends)
Traceback:
Traceback (most recent call last):
File "C:\Development\Languages\Python34\lib\site-packages\steamapi-0.1-py3.4.egg\steamapi\decorators.py", line 67, in
__get__
value, last_update = inst._cache[self.__name__]
AttributeError: 'SteamUser' object has no attribute '_cache'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\Documents\HomeBroker\main.py", line 9, in <module>
pp.pprint(usr.friends)
File "C:\Development\Languages\Python34\lib\site-packages\steamapi-0.1-py3.4.egg\steamapi\decorators.py", line 71, in
__get__
value = self.fget(inst)
File "C:\Development\Languages\Python34\lib\site-packages\steamapi-0.1-py3.4.egg\steamapi\user.py", line 322, in frien
ds
chunks = [ids[start:start+CHUNK_SIZE] for start in range(len(ids))[::CHUNK_SIZE]]
File "C:\Development\Languages\Python34\lib\site-packages\steamapi-0.1-py3.4.egg\steamapi\user.py", line 322, in <list
comp>
chunks = [ids[start:start+CHUNK_SIZE] for start in range(len(ids))[::CHUNK_SIZE]]
TypeError: 'dict_keys' object is not subscriptable
smiley commented
Looks like Python 3.x redid dict.keys()
with dict_keys
instead of list
. (Why?!) I'll change it to something compatible with both 2.x and 3.x.
smiley commented
The first exception is handled, though. When an AttributeError for _cache
is thrown, that means the object's cache has yet to be initialised. It is then caught and the wrapped property-getter is called, then used to fill in the _cache
.
juanchristian commented
So, the first exception is something normal, but the second one is really an issue, right?
Python 3.4.1
smiley commented
Well, yes. While handing the first exception -- which merely causes the data to be fetched -- the second one was thrown.