Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 118861f

Browse filesBrowse files
committed
deprecate Connection.__enter__
1 parent d587e81 commit 118861f
Copy full SHA for 118861f

File tree

Expand file treeCollapse file tree

1 file changed

+6
-3
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+6
-3
lines changed

‎MySQLdb/connections.py

Copy file name to clipboardExpand all lines: MySQLdb/connections.py
+6-3Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,12 +265,10 @@ def autocommit(self, on):
265265

266266
def cursor(self, cursorclass=None):
267267
"""
268-
269268
Create a cursor on which queries may be performed. The
270269
optional cursorclass parameter is used to create the
271270
Cursor. By default, self.cursorclass=cursors.Cursor is
272271
used.
273-
274272
"""
275273
return (cursorclass or self.cursorclass)(self)
276274

@@ -286,6 +284,9 @@ def query(self, query):
286284
_mysql.connection.query(self, query)
287285

288286
def __enter__(self):
287+
from warnings import warn
288+
warn("context interface will be changed. Use explicit conn.commit() or conn.rollback().",
289+
DeprecationWarning, 2)
289290
if self.get_autocommit():
290291
self.query("BEGIN")
291292
return self.cursor()
@@ -319,7 +320,7 @@ def begin(self):
319320
DEPRECATED: Will be removed in 1.3.
320321
Use an SQL BEGIN statement instead."""
321322
from warnings import warn
322-
warn("begin() is non-standard and will be removed in 1.3",
323+
warn("begin() is non-standard and will be removed in 1.4",
323324
DeprecationWarning, 2)
324325
self.query("BEGIN")
325326

@@ -386,3 +387,5 @@ def show_warnings(self):
386387
NotSupportedError = NotSupportedError
387388

388389
errorhandler = defaulterrorhandler
390+
391+
# vim: colorcolumn=100

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.