Bug #87815 | MySQL Connector methods `fetchone` and `fetchmany` are not PEP 249 compliant | ||
---|---|---|---|
Submitted: | 20 Sep 2017 9:36 | Modified: | 16 Oct 2020 20:50 |
Reporter: | Géry Ogam | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | Connector / Python | Severity: | S2 (Serious) |
Version: | 2.1.6, 8.0.4 | OS: | Windows (10) |
Assigned to: | CPU Architecture: | Any | |
Tags: | MySQL, mysql-connector, PEP, python |
[20 Sep 2017 9:36]
Géry Ogam
[20 Sep 2017 12:32]
MySQL Verification Team
Hello Géry Ogam, Thank you for the report and feedback! Thanks, Umesh
[20 Sep 2017 14:40]
Géry Ogam
Suggested fix: Copying the first two lines (890 and 891) from the `fetchall` method body in the site-packages\mysql\connector\cursor.py file to the start of the `fetchone` and `fetchmany` methods bodies in the same file resolves the bug: def fetchone(self): + if not self._have_unread_result(): + raise errors.InterfaceError("No result set to fetch from.") def fetchmany(self, size=None): + if not self._have_unread_result(): + raise errors.InterfaceError("No result set to fetch from.")
[16 Oct 2020 20:50]
Philip Olson
Posted by developer: Fixed as of the upcoming MySQL Connector/Python 8.0.23 release, and here's the proposed changelog entry from the documentation team: Fixed cursor.fetchone() and cursor.fetchmany() to comply with PEP 249, which specifies that an exception must be raised if the previous call to cursor.execute*() does not produce any result set or no call was issued yet. Thank you for the bug report.