8000 Remove auto show warnings by methane · Pull Request #774 · PyMySQL/PyMySQL · GitHub
[go: up one dir, main page]

Skip to content

Remove auto show warnings #774

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 2 commits into from
Jan 17, 2019
Merged
Changes from 1 commit
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
Next Next commit
Remove auto show warnings
  • Loading branch information
methane committed Jan 17, 2019
commit beea7f6c35806baf29e949f25bff78b55557067e
31 changes: 0 additions & 31 deletions pymysql/cursors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from __future__ import print_function, absolute_import
from functools import partial
import re
import warnings

from ._compat import range_type, text_type, PY2
from . import err
Expand Down Expand Up @@ -35,8 +34,6 @@ class Cursor(object):
#: Default value of max_allowed_packet is 1048576.
max_stmt_length = 1024000

_defer_warnings = False

def __init__(self, connection):
self.connection = connection
self.description = None
Expand All @@ -46,7 +43,6 @@ def __init__(self, connection):
self._executed = None
self._result = None
self._rows = None
self._warnings_handled = False

def close(self):
"""
Expand Down Expand Up @@ -90,9 +86,6 @@ def _nextset(self, unbuffered=False):
"""Get the next query set"""
conn = self._get_db()
current_result = self._result
# for unbuffered queries warnings are only available once whole result has been read
if unbuffered:
self._show_warnings()
if current_result is None or current_result is not conn._result:
return None
if not current_result.has_next:
E517 Expand Down Expand Up @@ -347,26 +340,6 @@ def _do_get_result(self):
self.description = result.description
self.lastrowid = result.insert_id
self._rows = result.rows
self._warnings_handled = False

if not self._defer_warnings:
self._show_warnings()

def _show_warnings(self):
if self._warnings_handled:
return
self._warnings_handled = True
if self._result and (self._result.has_next or not self._result.warning_count):
return
ws = self._get_db().show_warnings()
if ws is None:
return
for w in ws:
msg = w[-1]
if PY2:
if isinstance(msg, unicode):
msg = msg.encode('utf-8', 'replace')
warnings.warn(err.Warning(*w[1:3]), stacklevel=4)

def __iter__(self):
return iter(self.fetchone, None)
Expand Down Expand Up @@ -427,8 +400,6 @@ class SSCursor(Cursor):
possible to scroll backwards, as only the current row is held in memory.
"""

_defer_warnings = True

def _conv_row(self, row):
return row

Expand Down Expand Up @@ -468,7 +439,6 @@ def fetchone(self):
self._check_executed()
row = self.read_next()
if row is None:
self._show_warnings()
return None
self.rownumber += 1
return row
Expand Down Expand Up @@ -502,7 +472,6 @@ def fetchmany(self, size=None):
for i in range_type(size):
row = self.read_next()
if row is None:
self._show_warnings()
break
rows.append(row)
self.rownumber += 1
Expand Down
0