| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 23ca04a commit 637fe7e
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -32,6 +32,7 @@ Release date: TBD | |||
| 32 | 32 | * Support MySQL 8 row/column alias syntax in `executemany` INSERT regex. (#1235) | |
| 33 | 33 | * Expose SQLSTATE on MySQL protocol exceptions without changing exception formatting. (#1236) | |
| 34 | 34 | * Reject non-finite `decimal.Decimal` query parameters (`NaN`, `sNaN`, `±Infinity`). (#1237) | |
| 35 | + * `Connection.set_charset(charset)` now emits `DeprecationWarning`. | ||
| 35 | 36 | ||
| 36 | 37 | ## v1.1.3 | |
| 37 | 38 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -630,6 +630,11 @@ def ping(self, reconnect=False): | |||
| 630 | 630 | ||
| 631 | 631 | def set_charset(self, charset): | |
| 632 | 632 | """Deprecated. Use set_character_set() instead.""" | |
| 633 | + warnings.warn( | ||
| 634 | + "'set_charset' is deprecated, use 'set_character_set' instead", | ||
| 635 | + DeprecationWarning, | ||
| 636 | + 2, | ||
| 637 | + ) | ||
| 633 | 638 | # This function has been implemented in old PyMySQL. | |
| 634 | 639 | # But this name is different from MySQLdb. | |
| 635 | 640 | # So we keep this function for compatibility and add | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,8 @@ | |||
| 1 | 1 | import pytest | |
| 2 | + from unittest import mock | ||
| 3 | + | ||
| 2 | 4 | from pymysql import err | |
| 5 | + from pymysql.connections import Connection | ||
| 3 | 6 | ||
| 4 | 7 | ||
| 5 | 8 | def test_error_init_sqlstate(): | |
@@ -26,3 +29,13 @@ def test_raise_mysql_exception(): | |||
| 26 | 29 | assert cm.type == err.OperationalError | |
| 27 | 30 | assert cm.value.args == (1040, "Too many connections") | |
| 28 | 31 | assert cm.value.sqlstate is None | |
| 32 | + | ||
| 33 | + | ||
| 34 | + def test_set_charset_deprecated(): | ||
| 35 | + con = mock.Mock(spec=Connection) | ||
| 36 | + with pytest.warns( | ||
| 37 | + DeprecationWarning, | ||
| 38 | + match="'set_charset' is deprecated, use 'set_character_set' instead", | ||
| 39 | + ): | ||
| 40 | + Connection.set_charset(con, "utf8mb4") | ||
| 41 | + con.set_character_set.assert_called_once_with("utf8mb4") | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments