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

UnicodeDecodeError'ascii' codec can't decode byte 0xff in position 247: ordinal not in range(128) #154

Closed
husainihisan opened this issue Mar 14, 2013 · 15 comments

Comments

@husainihisan
Copy link

please help, update status with normal message is fine but with media, i get this error :(

from twython import Twython

twitter = Twython(
twitter_token = '52IKIxxxx',
twitter_secret = 'SvwK4xmxxxx',
oauth_token = '5164xxxxxxx',
oauth_token_secret = 'kVkrHxxxxxx'
)

twitter.updateStatus(status='hello tweet from raspberry pi 1.47am')
twitter.updateStatusWithMedia("/home/pi/teddy.jpg", status='hello!')

image of error http://i.stack.imgur.com/5W1Bq.png

@grillermo
Copy link

Having the exact same problem, pin pointed it to the requests library.
It would be nice to know what requests version does it work.
I got the error with updateProfileBannerImage running requests 1.1.0 on python 2.7.2

@michaelhelmick
Copy link
Collaborator

You can follow the new requests issue here: https://github.com/kennethreitz/requests/issues/1252

@husainihisan
Copy link
Author

does this error fixed? im try update twython and still gettings this error :(

@michaelhelmick
Copy link
Collaborator

The changes in requests-oauthlib have JUST been merged in (requests/requests-oauthlib#26 (comment)). When a version bump to that library is pushed, I'll push an update to Twython requiring that version of requests-oauthlib

This should be fixed shortly!

@michaelhelmick
Copy link
Collaborator

I'm closing this and will let everyone know when the updates to requests_oauthlib have been pushed and this has been fixed!

@peterbe
Copy link

peterbe commented Apr 9, 2013

I'm confused about this. @husainihisan's traceback there's no mention of requests_oauthlib
Neither is it in this one: http://pastebin.com/WWNx9TYn

Also, I tried installing the tip of requests-oauthlib but it didn't help.

What did help was to do this:

text = text.encode('utf-8')
twitter.updateStatusWithMedia(
    file_path,
    status=text
)

In other words, I think it's erroring somewhere else. By the way, I'm using requests 1.2.0 as per twython's requirements.

@michaelhelmick
Copy link
Collaborator

@peterbe Please see kennethreitz/requests#1252 and requests/requests-oauthlib/pull/26

@mgrouchy
Copy link
Contributor

@michaelhelmick so this is still an ongoing issue? I tried the same thing @peterbe did, but alas, Im having less success then he did.

@michaelhelmick
Copy link
Collaborator

@mgrouchy Yes, I actually just talked to @kennethreitz yesterday about a possible new release of requests_oauthlib since there wasn't one with the issue was fixed.

Uploading an image works currently in master branch of https://github.com/requests/requests-oauthlib, so.. for now if you can; clone the repo and install it to your site-packages for the time being. If you can't, hopefully we'll see a new version on PyPi soon :)

@mgrouchy
Copy link
Contributor

@michaelhelmick thats so strange, because I installed like so:
pip install -e git+https://github.com/requests/requests-oauthlib.git#egg=requests_oauthlib
and still no joy. That being said, my stack trace still looks like @husainihisan's.

https://gist.github.com/mgrouchy/5462228

Maybe something got messed up with the installation. I will investigate and see if I can dig anything else up.

@michaelhelmick
Copy link
Collaborator

Nope, you're right...
Mind Blown

@michaelhelmick
Copy link
Collaborator

Haha, sorry. I just tried installing every version of requests_oauthlib since this commit:
requests/requests-oauthlib@156543b

Even that commit doesn't work anymore.
I've tried requests 1.1.0 and 1.2.0..... it literally just worked the other day. My brain hurts. Let me get back to you on this later today (in like an hour) or tomorrow and figure out what's going on. I'm literally just dumbfounded right now. haha

@mgrouchy
Copy link
Contributor

@michaelhelmick haha, okay. Thanks! Much appreciated!

@michaelhelmick
Copy link
Collaborator

@mgrouchy Alright, I was right: it is fixed at this commit requests/requests-oauthlib@156543b but breaks on the commit after. I'm talking to the guys in requests-oauthlib in an issue about it now. I'll keep you updated, or you can follow requests/requests-oauthlib#36

michaelhelmick added a commit that referenced this issue May 4, 2013
@michaelhelmick
Copy link
Collaborator

@mgrouchy @peterbe @husainihisan @grillermo requests-oauthlib 0.3.1 fixes this. I updated setup.py to require that version only on new installs of Twython!

You can either:
pip install -I requests-oauthlib

or install Twython 2.9.0
pip install -I twython (warning: 2.9.0 offers fixed streaming. So if you are using Twython's streaming API, be sure to upgrade to use the new TwythonStreamer)

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

5 participants