From: Nikita Sobolev Date: Fri, 12 May 2023 12:36:12 +0000 (+0300) Subject: gh-104415: Fix refleak tests for `typing.ByteString` deprecation (#104416) X-Git-Tag: v3.12.0b1~146 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5b8cd5abe5924646b9ed90e7ba90085b56d5f634;p=thirdparty%2FPython%2Fcpython.git gh-104415: Fix refleak tests for `typing.ByteString` deprecation (#104416) --- diff --git a/Lib/typing.py b/Lib/typing.py index bf7bd241972a..513d4d96dd6e 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -3586,3 +3586,12 @@ def __getattr__(attr): ) return ByteString raise AttributeError(f"module 'typing' has no attribute {attr!r}") + + +def _remove_cached_ByteString_from_globals(): + try: + del globals()["ByteString"] + except KeyError: + pass + +_cleanups.append(_remove_cached_ByteString_from_globals)