Skip to content

gh-118924: Remove sqlite3.version and sqlite3.version_info #118925

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 2 additions & 2 deletions Doc/library/sqlite3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ Module constants
.. deprecated-removed:: 3.12 3.14
This constant used to reflect the version number of the ``pysqlite``
package, a third-party library which used to upstream changes to
:mod:`!sqlite3`. Today, it carries no meaning or practical value.
:mod:`!sqlite3`. Before removal, it carried no meaning or practical value.

.. data:: version_info

Expand All @@ -563,7 +563,7 @@ Module constants
.. deprecated-removed:: 3.12 3.14
This constant used to reflect the version number of the ``pysqlite``
package, a third-party library which used to upstream changes to
:mod:`!sqlite3`. Today, it carries no meaning or practical value.
:mod:`!sqlite3`. Before removal, it carried no meaning or practical value.

.. _sqlite3-dbconfig-constants:

Expand Down
40 changes: 29 additions & 11 deletions Doc/whatsnew/3.14.rst
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,30 @@ Removed
argparse
--------

* The *type*, *choices*, and *metavar* parameters
of :class:`!argparse.BooleanOptionalAction` are removed.
* Remove the *type*, *choices*, and *metavar* parameters
of :class:`!argparse.BooleanOptionalAction`.
They were deprecated since 3.12.

collections.abc
---------------

* Remove :class:`!collections.abc.ByteString`. It had previously raised a
:exc:`DeprecationWarning` since Python 3.12.


email
-----

* The *isdst* parameter has been removed from :func:`email.utils.localtime`.
* Remove the *isdst* parameter from :func:`email.utils.localtime`.
(Contributed by Hugo van Kemenade in :gh:`118798`.)

itertools
---------

* Remove :mod:`itertools` support for copy, deepcopy, and pickle operations.
These had previously raised a :exc:`DeprecationWarning` since Python 3.12.
(Contributed by Raymond Hettinger in :gh:`101588`.)

pathlib
-------

Expand All @@ -122,21 +136,25 @@ pathlib
:meth:`~pathlib.PurePath.is_relative_to`. In previous versions, any such
arguments are joined onto *other*.

sqlite3
-------

* Remove :data:`~sqlite3.version` and :data:`~sqlite3.version_info` from
:mod:`sqlite3`. (Contributed by Hugo van Kemenade in :gh:`118924`.)

typing
------

* Remove :class:`!typing.ByteString`. It had previously raised a
:exc:`DeprecationWarning` since Python 3.12.

Others
------

* Using :data:`NotImplemented` in a boolean context will now raise a :exc:`TypeError`.
It had previously raised a :exc:`DeprecationWarning` since Python 3.9. (Contributed
by Jelle Zijlstra in :gh:`118767`.)

* :class:`!typing.ByteString` and :class:`!collections.abc.ByteString`
are removed. They had previously raised a :exc:`DeprecationWarning`
since Python 3.12.

* :mod:`itertools` support for copy, deepcopy, and pickle operations.
These had previously raised a :exc:`DeprecationWarning` since Python 3.12.
(Contributed by Raymond Hettinger in :gh:`101588`.)


Porting to Python 3.14
======================
Expand Down
13 changes: 0 additions & 13 deletions Lib/sqlite3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,3 @@
"""

from sqlite3.dbapi2 import *
from sqlite3.dbapi2 import (_deprecated_names,
_deprecated_version_info,
_deprecated_version)


def __getattr__(name):
if name in _deprecated_names:
from warnings import warn

warn(f"{name} is deprecated and will be removed in Python 3.14",
DeprecationWarning, stacklevel=2)
return globals()[f"_deprecated_{name}"]
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
14 changes: 1 addition & 13 deletions Lib/sqlite3/dbapi2.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@
import collections.abc

from _sqlite3 import *
from _sqlite3 import _deprecated_version

_deprecated_names = frozenset({"version", "version_info"})

paramstyle = "qmark"

Expand All @@ -48,7 +45,7 @@ def TimeFromTicks(ticks):
def TimestampFromTicks(ticks):
return Timestamp(*time.localtime(ticks)[:6])

_deprecated_version_info = tuple(map(int, _deprecated_version.split(".")))

sqlite_version_info = tuple([int(x) for x in sqlite_version.split(".")])

Binary = memoryview
Expand Down Expand Up @@ -97,12 +94,3 @@ def convert_timestamp(val):
# Clean up namespace

del(register_adapters_and_converters)

def __getattr__(name):
if name in _deprecated_names:
from warnings import warn

warn(f"{name} is deprecated and will be removed in Python 3.14",
DeprecationWarning, stacklevel=2)
return globals()[f"_deprecated_{name}"]
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
11 changes: 0 additions & 11 deletions Lib/test/test_sqlite3/test_dbapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,6 @@ def test_api_level(self):
self.assertEqual(sqlite.apilevel, "2.0",
"apilevel is %s, should be 2.0" % sqlite.apilevel)

def test_deprecated_version(self):
msg = "deprecated and will be removed in Python 3.14"
for attr in "version", "version_info":
with self.subTest(attr=attr):
with self.assertWarnsRegex(DeprecationWarning, msg) as cm:
getattr(sqlite, attr)
self.assertEqual(cm.filename, __file__)
with self.assertWarnsRegex(DeprecationWarning, msg) as cm:
getattr(sqlite.dbapi2, attr)
self.assertEqual(cm.filename, __file__)

def test_thread_safety(self):
self.assertIn(sqlite.threadsafety, {0, 1, 3},
"threadsafety is %d, should be 0, 1 or 3" %
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Remove :data:`~sqlite3.version` and :data:`~sqlite3.version_info` from
:mod:`sqlite3`. Patch by Hugo van Kemenade.
4 changes: 0 additions & 4 deletions Modules/_sqlite/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -714,10 +714,6 @@ module_exec(PyObject *module)
goto error;
}

if (PyModule_AddStringConstant(module, "_deprecated_version", PYSQLITE_VERSION) < 0) {
goto error;
}

if (PyModule_AddStringConstant(module, "sqlite_version", sqlite3_libversion())) {
goto error;
}
Expand Down
Loading