Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

bpo-42264: Deprecate sqlite3.OptimizedUnicode#23163

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
serhiy-storchaka merged 11 commits intopython:masterfromerlend-aasland:bpo-42264
Nov 17, 2020
Merged
Show file tree
Hide file tree
Changes fromall 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: 5 additions & 0 deletionsDoc/whatsnew/3.10.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -299,6 +299,11 @@ Deprecated
as appropriate to help identify code which needs updating during
this transition.

* ``sqlite3.OptimizedUnicode`` has been undocumented and obsolete since Python
3.3, when it was made an alias to :class:`str`. It is now deprecated,
scheduled for removal in Python 3.12.
(Contributed by Erlend E. Aasland in :issue:`42264`.)


Removed
=======
Expand Down
14 changes: 14 additions & 0 deletionsLib/sqlite3/__init__.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -21,3 +21,17 @@
# 3. This notice may not be removed or altered from any source distribution.

from sqlite3.dbapi2 import *


# bpo-42264: OptimizedUnicode was deprecated in Python 3.10. It's scheduled
# for removal in Python 3.12.
def __getattr__(name):
if name == "OptimizedUnicode":
import warnings
msg = ("""
OptimizedUnicode is deprecated and will be removed in Python 3.12.
Since Python 3.3 it has simply been an alias for 'str'.
""")
warnings.warn(msg, DeprecationWarning, stacklevel=2)
return str
raise AttributeError(f"module 'sqlite3' has no attribute '{name}'")
7 changes: 4 additions & 3 deletionsLib/sqlite3/test/factory.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -254,9 +254,10 @@ def CheckCustom(self):
self.assertTrue(row[0].endswith("reich"), "column must contain original data")

def CheckOptimizedUnicode(self):
# In py3k, str objects are always returned when text_factory
# is OptimizedUnicode
self.con.text_factory = sqlite.OptimizedUnicode
# OptimizedUnicode is deprecated as of Python 3.10
with self.assertWarns(DeprecationWarning) as cm:
self.con.text_factory = sqlite.OptimizedUnicode
self.assertIn("factory.py", cm.filename)
austria = "�sterreich"
germany = "Deutchland"
a_row = self.con.execute("select ?", (austria,)).fetchone()
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
``sqlite3.OptimizedUnicode`` has been undocumented and obsolete since Python
3.3, when it was made an alias to :class:`str`. It is now deprecated,
scheduled for removal in Python 3.12.
9 changes: 0 additions & 9 deletionsModules/_sqlite/module.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -412,15 +412,6 @@ PyMODINIT_FUNC PyInit__sqlite3(void)
ADD_EXCEPTION(module, "DataError", pysqlite_DataError, pysqlite_DatabaseError);
ADD_EXCEPTION(module, "NotSupportedError", pysqlite_NotSupportedError, pysqlite_DatabaseError);

/* In Python 2.x, setting Connection.text_factory to
OptimizedUnicode caused Unicode objects to be returned for
non-ASCII data and bytestrings to be returned for ASCII data.
Now OptimizedUnicode is an alias for str, so it has no
effect. */
if (PyModule_AddObjectRef(module, "OptimizedUnicode", (PyObject*)&PyUnicode_Type) < 0) {
goto error;
}

/* Set integer constants */
if (add_integer_constants(module) < 0) {
goto error;
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp