Bug #70324 AttributeError: ‘str’ object has no attribute ‘decode’

Submitted: 13 Sep 2013 7:47 Modified: 25 Sep 2013 17:54
Reporter: Antonio Martinez Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / Python Severity:S1 (Critical)
Version:1.1.1a1 OS:Windows (8)
Assigned to: CPU Architecture:Any
Tags: Django, MySQL, python

[13 Sep 2013 7:47] Antonio Martinez
Description:
When you install the MySQL connector/python ver. 1.1.1a1 and try to define the Django Backend, this error is thrown:

AttributeError: ‘str’ object has no attribute ‘decode’

How to repeat:
Just install the connector, update your django database settings and run:

python manage.py syncdb

The error appears. 

Suggested fix:
File: mysql/connector/django/base.py

on line 278 change 

return cursor.statement.decode('utf-8')

for

return cursor.statement

Reason: the str on Phyton 3.x are unicode already so the code and decode functions are deprectaed.
[25 Sep 2013 17:54] Paul DuBois
Noted in 1.1.2 changelog.

The DatabaseOperations.last_executed_query() method in the Django
base module was unnecessarily decoding the string, resulting in an
error when using Python 3.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.055 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.