Failed to send request: 'str' object has no attribute 'decode' on Ubuntu 16.04

Bug #1702459 reported by Erltoichi
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
python3-defaults (Ubuntu)
Expired
Undecided
Unassigned

Bug Description

The code attached below generates an error on Ubuntu 16.04 LTS with python3 default package installed (python3 --version returns 3.5.2).

The error message is:
«Failed to send request: 'str' object has no attribute 'decode'»

The code works fine on Ubuntu 17.04 and Fedora 25 (both python3 --version returning 3.5.3). The code also runs on Ubuntu 16.04 LTS with self-compiled from source python 3.6.1.
Also, the code has been running ok for over a year on Ubuntu 16.04 LTS - it only fails since mid June 2017.
Not sure where the issue is, probably in Ubuntu package for python or in python version 3.5.2.

from datetime import datetime,date,time,timezone
import tweepy as twitter

def sendToTwitter():
        consumer_key='...'
        consumer_secret='...'
        access_token_key='...'
        access_token_secret='..'
        #connect to the twitter api
        message = "tweet test"
        print("trying to send the tweet...")
        try:
                auth = twitter.OAuthHandler(consumer_key, consumer_secret)
                auth.set_access_token(access_token_key, access_token_secret)
                api = twitter.API(auth)
                status = api.update_status(status=message)
                print("tweet sent")
        except Exception as e:
                        print("error while tweeting. reason : " + str(e))
        return
sendToTwitter()

Revision history for this message
Serhiy Storchaka (storchaka) wrote :

It would be helpful if you provide a traceback. Just remove try/except or insert raise before print.

Matthias Klose (doko)
Changed in python3-defaults (Ubuntu):
status: New → Incomplete
Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for python3-defaults (Ubuntu) because there has been no activity for 60 days.]

Changed in python3-defaults (Ubuntu):
status: Incomplete → Expired
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.