googleads / googleads-python-lib

The Python client library for Google's Ads APIs
Apache License 2.0
685 stars 975 forks source link

AttributeError: 'float' object has no attribute '__iter__' #36

Closed colorstain closed 9 years ago

colorstain commented 10 years ago

The function _IsSudsIterable(obj) in google/ads/common.py fails for floats

Consider checking if obj has the attribute __iter__ instead:

def _IsSudsIterable(obj):
     return (obj and not isinstance(obj, basestring) and hasattr(obj, '__iter__'))
nicholaschen commented 10 years ago

Hiya Aldo,

Curious - where in the library did this pop up - more specifically - in what call chain did this fail?

Your solution is far cleaner than my own, but I had for some reason black-boxed the services that return floats as part of the response, so I'm just wondering where it stems from.

Nicholas Chen, DFP API Team

colorstain commented 10 years ago

I ran into the problem while using DFP api and updating manual rotation weights in the . I modified one of your examples to show the problem:

https://gist.github.com/colorstain/f3b0660f540dad8a5d9d

nicholaschen commented 10 years ago

ah, missed this one since the examples were written off the old adspygoogle library in which everything is a string, will include this in the next release in early November (since it's not a breaking change).

For now, you can either use the patch suggested above or simply send over '0.3' as the value.

nicholaschen commented 10 years ago

Just a note - going to leave this as open until the release goes out, but consider it noted and fixed :+1: thanks!

colorstain commented 10 years ago

great! :+1:

msaniscalchi commented 9 years ago

This was fixed in an earlier release.