Skip to content
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

Does not work with python <= 2.6 #1

Closed
mjallday opened this issue Jul 3, 2012 · 7 comments
Closed

Does not work with python <= 2.6 #1

mjallday opened this issue Jul 3, 2012 · 7 comments

Comments

@mjallday
Copy link
Contributor

mjallday commented Jul 3, 2012

>>> balanced.Card(card_number='4111111111111111', expiration_month=12, expiration_year=2020).save()
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "/usr/local/lib/python2.6/dist-packages/balanced/resources.py", line 356, in the_init
     self.uri = uri_discovery(self)
   File "/usr/local/lib/python2.6/dist-packages/balanced/resources.py", line 265, in uri_discovery
     resource.RESOURCE['collection']
 ValueError: zero length field name in format
@shenberg
Copy link

empty formatting is used a lot (things like "{}/{}".format(val1, val2) instead of "{0}/{1}".format(...))

I ended up moving to 2.7 but in platforms where 2.6 is the default (like OSX) it's a bit annoying.

@mahmoudimus
Copy link
Contributor

Yeah, that's one issue I'm aware of.

@shenberg
Copy link

The other issue is that since identifiers can't be unicode in Python 2.x, you can't unpack keyword arguments with unicode string keys (in 2.7 this limitation was removed on the unpacking side, but you still can't have unicode identifiers):
def f(a): print a
f({'a':1}) # prints 1
f(
{u'a':1}) # throws TypeError

You're using simplejson for unpacking the json responses, and it always turns strings to unicode (This is done in the Page object for example). A work around would be to create a dict where you call str() on all the keys whenever you're unpacking deserialized json into a function call (I have a version where I implemented this fix locally, but I ended up upgrading to Python 2.7 since that's what heroku provides and my client uses).

Please note that a lot of environments still provide only 2.6 (for example, that's what you get by default on AWS), so I would recommend supporting it.

@mjallday
Copy link
Contributor Author

We've got a python2.6 branch which will solve this. It's on the way.

@shenberg
Copy link

Thanks!

On Wed, Jul 18, 2012 at 6:44 PM, Marshall Jones <
reply@reply.github.com

wrote:

We've got a python2.6 branch which will
solve this. It's on the way.


Reply to this email directly or view it on GitHub:
#1 (comment)

@mjallday
Copy link
Contributor Author

Do we want to merge this into master? The differences are just string formatting and losing some of the nice helpers that we get in the 2.7 test library.

Failing to do so requires us to keep 2 separate branches up to date.

@mjallday
Copy link
Contributor Author

FIXED!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants