Skip to content
Prev Previous commit
Next Next commit
Address review comment: Refer to caller when warning, and verify this
  • Loading branch information
Erlend E. Aasland committed Nov 5, 2020
commit a9e959f63bfc2d5aec21ca57e713dd549411a139
2 changes: 1 addition & 1 deletion Lib/sqlite3/deprecated.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ def __getattr__(name):
OptimizedUnicode is obsolete. You can safely remove it from your
code, as it defaults to 'str' anyway.
""")
warnings.warn(msg, DeprecationWarning)
warnings.warn(msg, DeprecationWarning, stacklevel=2)
return str
raise AttributeError(f"module 'sqlite3' has no attribute '{name}'")
3 changes: 2 additions & 1 deletion Lib/sqlite3/test/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,9 @@ def CheckCustom(self):

def CheckOptimizedUnicode(self):
# OptimizedUnicode is deprecated as of Python 3.10
with self.assertWarns(DeprecationWarning):
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