Skip to content

Commit

Permalink
dev(hansbug): add safe protection
Browse files Browse the repository at this point in the history
  • Loading branch information
HansBug committed Oct 27, 2023
1 parent ce336bb commit 844db19
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions hbutils/system/filesystem/tempfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
]
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 844db19

Please sign in to comment.