8000 set unbuffered_active = False before error raise by ppd0705 · Pull Request #810 · PyMySQL/PyMySQL · GitHub
[go: up one dir, main page]

Skip to content

set unbuffered_active = False before error raise #810

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion pymysql/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,10 @@ def _read_packet(self, packet_type=MysqlPacket):
break

packet = packet_type(bytes(buff), self.encoding)
packet.check_error()
if packet.is_error_packet():
if self._result is not None and self._result.unbuffered_active is True:
self._result.unbuffered_active = False
packet.raise_for_error()
return packet

def _read_bytes(self, num_bytes):
Expand Down
13 changes: 8 additions & 5 deletions pymysql/protocol.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,14 @@ def is_error_packet(self):

def check_error(self):
if self.is_error_packet():
self.rewind()
self.advance(1) # field_count == error (we already know that)
errno = self.read_uint16()
if DEBUG: print("errno =", errno)
err.raise_mysql_exception(self._data)
self.raise_for_error()

def raise_for_error(self):
self.rewind()
self.advance(1) # field_count == error (we already know that)
errno = self.read_uint16()
if DEBUG: print("errno =", errno)
err.raise_mysql_exception(self._data)

def dump(self):
dump_packet(self._data)
Expand Down
0