Skip to content

When closed, cursor.execute() raises TypeError; expect ProgrammingError #37

@jdufresne

Description

@jdufresne

mysqlclient==1.3.6

In the following script, cursor.execute() is called on a closed cursor. The results is "TypeError: 'NoneType' object is not callable" but one expects a ProgrammingError. It looks as though errorhandler is assigned to None when closed in BaseCursor.close(). Full output below:

import MySQLdb

conn = MySQLdb.connect(user='root', db='mytest')
with conn.cursor() as cursor:
    cursor.execute('select 1')
cursor.execute('select 1')
$ venv/bin/python test.py
Traceback (most recent call last):
  File "test.py", line 6, in <module>
    cursor.execute('select 1')
  File "/home/jon/venv/lib/python2.7/site-packages/MySQLdb/cursors.py", line 181, in execute
    while self.nextset():
  File "/home/jon/venv/lib/python2.7/site-packages/MySQLdb/cursors.py", line 133, in nextset
    db = self._get_db()
  File "/home/jon/venv/lib/python2.7/site-packages/MySQLdb/cursors.py", line 166, in _get_db
    self.errorhandler(self, ProgrammingError, "cursor closed")
TypeError: 'NoneType' object is not callable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions