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

Commitffc58a9

Browse files
rawwarAlexWaygoodAA-Turnererlend-aasland
authored
gh-93370: Deprecate sqlite3.version and sqlite3.version_info (#93482)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
1 parentf8eae6f commitffc58a9

File tree

7 files changed

+50
-2
lines changed

7 files changed

+50
-2
lines changed

‎Doc/library/sqlite3.rst‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,22 @@ Module functions and constants
142142
The version number of this module, as a string. This is not the version of
143143
the SQLite library.
144144

145+
..deprecated-removed::3.12 3.14
146+
This constant used to reflect the version number of the ``pysqlite``
147+
package, a third-party library which used to upstream changes to
148+
``sqlite3``. Today, it carries no meaning or practical value.
149+
145150

146151
..data::version_info
147152

148153
The version number of this module, as a tuple of integers. This is not the
149154
version of the SQLite library.
150155

156+
..deprecated-removed::3.12 3.14
157+
This constant used to reflect the version number of the ``pysqlite``
158+
package, a third-party library which used to upstream changes to
159+
``sqlite3``. Today, it carries no meaning or practical value.
160+
151161

152162
..data::sqlite_version
153163

‎Lib/sqlite3/__init__.py‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,16 @@
5555
"""
5656

5757
fromsqlite3.dbapi2import*
58+
fromsqlite3.dbapi2import (_deprecated_names,
59+
_deprecated_version_info,
60+
_deprecated_version)
61+
62+
63+
def__getattr__(name):
64+
ifnamein_deprecated_names:
65+
fromwarningsimportwarn
66+
67+
warn(f"{name} is deprecated and will be removed in Python 3.14",
68+
DeprecationWarning,stacklevel=2)
69+
returnglobals()[f"_deprecated_{name}"]
70+
raiseAttributeError(f"module{__name__!r} has no attribute{name!r}")

‎Lib/sqlite3/dbapi2.py‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
importcollections.abc
2626

2727
from_sqlite3import*
28+
from_sqlite3import_deprecated_version
29+
30+
_deprecated_names=frozenset({"version","version_info"})
2831

2932
paramstyle="qmark"
3033

@@ -45,7 +48,7 @@ def TimeFromTicks(ticks):
4548
defTimestampFromTicks(ticks):
4649
returnTimestamp(*time.localtime(ticks)[:6])
4750

48-
version_info=tuple([int(x)forxinversion.split(".")])
51+
_deprecated_version_info=tuple(map(int,_deprecated_version.split(".")))
4952
sqlite_version_info=tuple([int(x)forxinsqlite_version.split(".")])
5053

5154
Binary=memoryview
@@ -85,3 +88,12 @@ def convert_timestamp(val):
8588
# Clean up namespace
8689

8790
del(register_adapters_and_converters)
91+
92+
def__getattr__(name):
93+
ifnamein_deprecated_names:
94+
fromwarningsimportwarn
95+
96+
warn(f"{name} is deprecated and will be removed in Python 3.14",
97+
DeprecationWarning,stacklevel=2)
98+
returnglobals()[f"_deprecated_{name}"]
99+
raiseAttributeError(f"module{__name__!r} has no attribute{name!r}")

‎Lib/test/test_sqlite3/test_dbapi.py‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,17 @@ def test_api_level(self):
5757
self.assertEqual(sqlite.apilevel,"2.0",
5858
"apilevel is %s, should be 2.0"%sqlite.apilevel)
5959

60+
deftest_deprecated_version(self):
61+
msg="deprecated and will be removed in Python 3.14"
62+
forattrin"version","version_info":
63+
withself.subTest(attr=attr):
64+
withself.assertWarnsRegex(DeprecationWarning,msg)ascm:
65+
getattr(sqlite,attr)
66+
self.assertEqual(cm.filename,__file__)
67+
withself.assertWarnsRegex(DeprecationWarning,msg)ascm:
68+
getattr(sqlite.dbapi2,attr)
69+
self.assertEqual(cm.filename,__file__)
70+
6071
deftest_thread_safety(self):
6172
self.assertIn(sqlite.threadsafety, {0,1,3},
6273
"threadsafety is %d, should be 0, 1 or 3"%

‎Misc/ACKS‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1456,6 +1456,7 @@ Edward K. Ream
14561456
Chris Rebert
14571457
Marc Recht
14581458
John Redford
1459+
Kalyan Reddy
14591460
Terry J. Reedy
14601461
Gareth Rees
14611462
John Reese
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Deprecate:data:`sqlite3.version` and:data:`sqlite3.version_info`.

‎Modules/_sqlite/module.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ module_exec(PyObject *module)
707707
gotoerror;
708708
}
709709

710-
if (PyModule_AddStringConstant(module,"version",PYSQLITE_VERSION)<0) {
710+
if (PyModule_AddStringConstant(module,"_deprecated_version",PYSQLITE_VERSION)<0) {
711711
gotoerror;
712712
}
713713

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp