Skip to content
Merged
Prev Previous commit
Next Next commit
Address review: Move deprecation warning to __init__.py
  • Loading branch information
Erlend E. Aasland committed Nov 5, 2020
commit b364cf5d3be0208861e3fe05ee248d4491932282
15 changes: 14 additions & 1 deletion Lib/sqlite3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,17 @@
# 3. This notice may not be removed or altered from any source distribution.

from .dbapi2 import *
from .deprecated import __getattr__


# OptimizedUnicode was deprecated in Python 3.10. It's scheduled for removal
Comment thread
erlend-aasland marked this conversation as resolved.
Outdated
# in Python 3.12.
def __getattr__(name):
if name == "OptimizedUnicode":
import warnings
msg = ("""
OptimizedUnicode is obsolete. You can safely remove it from your
code, as it defaults to 'str' anyway.
Comment thread
erlend-aasland marked this conversation as resolved.
Outdated
""")
warnings.warn(msg, DeprecationWarning, stacklevel=2)
return str
raise AttributeError(f"module 'sqlite3' has no attribute '{name}'")
10 changes: 0 additions & 10 deletions Lib/sqlite3/deprecated.py

This file was deleted.