Infinite recursion when setting connection client_flags
Affects | Status | Importance | Assigned to | Milestone | ||
---|---|---|---|---|---|---|
MySQL Connector/Python | Status tracked in Trunk | |||||
0.3 |
Fix Released
|
Medium
|
Geert JM Vanderkelen | |||
Trunk |
In Progress
|
Medium
|
Geert JM Vanderkelen |
Bug Description
* How to reproduce:
import mysql.connector
mysql.connector
[...]
File "C:\Python31\
self.
File "C:\Python31\
self.
File "C:\Python31\
if isinstance(
RuntimeError: maximum recursion depth exceeded in cmp
* Cause:
def set_client_
if isinstance(
=> if an int is passed, an infinite recursion occurs my guess is that self.set_
Environment info:
* MySQL Connector/Python version (and/or revision)
python -c "import mysql.connector as db; print( db.__version__ )"
(0, 3, 0, 'devel', 287)
* Python version
python --version
Python 3.1.1
mysql> SELECT VERSION()
| 5.0.51b-
* Platform/OS: Windows XP SP2 32 bits
Yes, the RunTimeError is indeed a bug. It should have been self.client_flags = flags when an int is given.
It is, however, not recommended to use an int, but a list. From the docs (which we really need to push online one day..):
---
MySQL uses client flags when connecting to enable or disable
certain features. Using the *client_flags* arguments you have
control of what is set. To find out what flags are available,
you can use the following:
>>> from mysql.connector .constants import ClientFlag ClientFlag. get_full_ info())
>>> print '\n'.join(
If *client_flags* is not specified (that is, it is zero), defaults
will used for MySQL v4.1 and later. If you specify an integer greater
than ``0``, you need to make sure all flags are set. However, a much
better way to set and unset flags is to use a list.
For example, you want to set the FOUND_ROWS-flag:
>>> mysql.connector .connect( client_ flags=[ ClientFlag. FOUND_ROWS] )
If you want to unset one of the defaults, e.g. LONG_FLAG:
>>> mysql.connector .connect( client_ flags=[
ClientFlag .FOUND_ ROWS,
-ClientFla g.LONG_ FLAG,
])
---
Thus, in this case, correct would be:
mysql.connector .connect( client_ flags=[ mysql.connector .ClientFlag. FOUND_ROWS] )
I found doing it using a sequence much more intuitive and clearer, what you think?