database name *must* be of type str()

Bug #790226 reported by tormen
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MySQL Connector/Python
Status tracked in Trunk
0.3
Fix Committed
Low
Geert JM Vanderkelen
Trunk
In Progress
Low
Geert JM Vanderkelen

Bug Description

MySQL connector/python v0.3.2:

if you pass in a database name "1234" then mysql connector/python [connector.py line 381] tries to do a .strip() on it which will fail as it is not a string.

It is probably arguable if this is a bug ...
but to me as python is officially dynamically typed [oh-yeah! ;) ...]
IMHO this line should be either:

   self._database = str(database).strip() if database else None
OR to save the str() call if not necessary:
   try: self._database = database.strip() if database else None
   except: self._database = str(database).strip() if database else None

Related branches

Revision history for this message
Geert JM Vanderkelen (geertjmvdk) wrote :

Thanks for this bug report!

  Fix: Unhandled exception when database was given as integer

  o There was an unhandled exception when you pass the database name as an
    integer. We now force the database name to be a string.
  o Using self._username and self._database when opening the connection
    in MySQLConnection.connect()
  o Adding test case for bug lp:790226

Changed in myconnpy:
assignee: nobody → Geert JM Vanderkelen (geertjmvdk)
importance: Undecided → Low
status: New → Fix Committed
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.