diff --git a/hbutils/system/filesystem/tempfile.py b/hbutils/system/filesystem/tempfile.py index 2ac27653fd5..d555199f5c1 100644 --- a/hbutils/system/filesystem/tempfile.py +++ b/hbutils/system/filesystem/tempfile.py @@ -6,10 +6,14 @@ import platform import shutil import tempfile -import types import warnings import weakref +try: + from types import GenericAlias +except (ImportError, ModuleNotFoundError): + GenericAlias = None + __all__ = [ 'TemporaryDirectory', ] @@ -90,7 +94,8 @@ def cleanup(self): if self._finalizer.detach() or os.path.exists(self.name): self._rmtree(self.name, ignore_errors=self._ignore_cleanup_errors) - __class_getitem__ = classmethod(types.GenericAlias) + if GenericAlias is not None: + __class_getitem__ = classmethod(GenericAlias) else: class TemporaryDirectory(object):