From: Ben Darnell Date: Fri, 7 Jun 2024 20:36:52 +0000 (-0400) Subject: util: Remove pre-py35 is_finalizing compatibility X-Git-Tag: v6.5.0b1~57^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=12243ab3fd96469253f8ad5917901ba23528fdef;p=thirdparty%2Ftornado.git util: Remove pre-py35 is_finalizing compatibility This code appears to be unused and in any case is unnecessary since is_finalizing has been in the standard library since 3.5. --- diff --git a/tornado/test/util_test.py b/tornado/test/util_test.py index 02cf0c19..7a6e817f 100644 --- a/tornado/test/util_test.py +++ b/tornado/test/util_test.py @@ -14,7 +14,6 @@ from tornado.util import ( timedelta_to_seconds, import_object, re_unescape, - is_finalizing, ) import typing @@ -301,8 +300,3 @@ class ReUnescapeTest(unittest.TestCase): re_unescape("\\b") with self.assertRaises(ValueError): re_unescape("\\Z") - - -class IsFinalizingTest(unittest.TestCase): - def test_basic(self): - self.assertFalse(is_finalizing()) diff --git a/tornado/util.py b/tornado/util.py index 3a3a52f1..1fc2c69a 100644 --- a/tornado/util.py +++ b/tornado/util.py @@ -12,7 +12,6 @@ and `.Resolver`. import array import asyncio -import atexit from inspect import getfullargspec import os import re @@ -47,22 +46,6 @@ bytes_type = bytes unicode_type = str basestring_type = str -try: - from sys import is_finalizing -except ImportError: - # Emulate it - def _get_emulated_is_finalizing() -> Callable[[], bool]: - L = [] # type: List[None] - atexit.register(lambda: L.append(None)) - - def is_finalizing() -> bool: - # Not referencing any globals here - return L != [] - - return is_finalizing - - is_finalizing = _get_emulated_is_finalizing() - # versionchanged:: 6.2 # no longer our own TimeoutError, use standard asyncio class