Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Python 3.3 patch #634

Closed
wants to merge 2 commits into from

2 participants

@doganaydin

When I trying to to auth an user I get an KeyError in python3.3.

doganaydin added some commits
@doganaydin doganaydin Python 3.3 patch
When I trying to to auth an user I get an KeyError in python3.3.
bb46502
@doganaydin doganaydin py2.5 tests fails because of b"screen_name" 2485e92
@bdarnell
Owner

You can't just try/catch a SyntaxError like that. The right fix is to use the tornado.util.b function to get bytes on all versions of python. I also added a test and found that I needed to coerce the byte string back to a native string to get it working.

@bdarnell bdarnell closed this pull request from a commit
@bdarnell bdarnell Fix TwitterMixin on Python 3.
Also add tests, and add get_auth_http_client method to all auth mixins.

Closes #634.
e7485f8
@bdarnell bdarnell closed this in e7485f8
@bdarnell bdarnell referenced this pull request from a commit
@bdarnell bdarnell Fix TwitterMixin on Python 3.
Also add tests, and add get_auth_http_client method to all auth mixins.

Closes #634.

Conflicts:
	tornado/test/auth_test.py
	website/sphinx/releases/next.rst
c113ac1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 12, 2012
  1. @doganaydin

    Python 3.3 patch

    doganaydin authored
    When I trying to to auth an user I get an KeyError in python3.3.
Commits on Nov 13, 2012
  1. @doganaydin
This page is out of date. Refresh to see the latest.
Showing with 13 additions and 3 deletions.
  1. +13 −3 tornado/auth.py
View
16 tornado/auth.py
@@ -562,9 +562,19 @@ def _oauth_consumer_token(self):
def _oauth_get_user(self, access_token, callback):
callback = self.async_callback(self._parse_user_response, callback)
- self.twitter_request(
- "/users/show/" + access_token["screen_name"],
- access_token=access_token, callback=callback)
+ try:
+ self.twitter_request(
+ "/users/show/" + access_token["screen_name"],
+ access_token=access_token, callback=callback)
+ except KeyError:
+ try:
+ self.twitter_request(
+ "/users/show/" + access_token.get(b"screen_name").decode("utf-8"),
+ access_token=access_token, callback=callback)
+ except SyntaxError:
+ self.twitter_request(
+ "/users/show/" + access_token["screen_name"],
+ access_token=access_token, callback=callback)
def _parse_user_response(self, callback, user):
if user:
Something went wrong with that request. Please try again.