From 118861f8cbe0463ea33f8b63cdf9d6ff41210e51 Mon Sep 17 00:00:00 2001 From: INADA Naoki Date: Mon, 20 Feb 2017 16:47:56 +0900 Subject: [PATCH] deprecate Connection.__enter__ --- MySQLdb/connections.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/MySQLdb/connections.py b/MySQLdb/connections.py index 8375041..d2a854f 100644 --- a/MySQLdb/connections.py +++ b/MySQLdb/connections.py @@ -265,12 +265,10 @@ class Connection(_mysql.connection): def cursor(self, cursorclass=None): """ - Create a cursor on which queries may be performed. The optional cursorclass parameter is used to create the Cursor. By default, self.cursorclass=cursors.Cursor is used. - """ return (cursorclass or self.cursorclass)(self) @@ -286,6 +284,9 @@ class Connection(_mysql.connection): _mysql.connection.query(self, query) def __enter__(self): + from warnings import warn + warn("context interface will be changed. Use explicit conn.commit() or conn.rollback().", + DeprecationWarning, 2) if self.get_autocommit(): self.query("BEGIN") return self.cursor() @@ -319,7 +320,7 @@ class Connection(_mysql.connection): DEPRECATED: Will be removed in 1.3. Use an SQL BEGIN statement instead.""" from warnings import warn - warn("begin() is non-standard and will be removed in 1.3", + warn("begin() is non-standard and will be removed in 1.4", DeprecationWarning, 2) self.query("BEGIN") @@ -386,3 +387,5 @@ class Connection(_mysql.connection): NotSupportedError = NotSupportedError errorhandler = defaulterrorhandler + +# vim: colorcolumn=100