Mercurial > hgrepos > Python > apps > py-cutils
view cutils/util/cm.py @ 365:d5c920ace3cb
treesum: FIX: Python<2.7.9 has no hashlib.algorithms_available: fall back to hashlib.algorithms in this case
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Wed, 09 Apr 2025 22:14:49 +0200 |
| parents | 48430941c18c |
| children |
line wrap: on
line source
# -*- coding: utf-8 -*- # :- # SPDX-FileCopyrightText: © 2024-2025 Franz Glasner # SPDX-License-Identifier: BSD-3-Clause # :- r"""Context manager extensions and compatibility. """ from __future__ import print_function, absolute_import __all__ = ["nullcontext"] try: from contextlib import nullcontext except ImportError: class nullcontext(object): """Compatibility implementation for systems that are missing yet a standard :class:`contextlib.nullcontext`. """ __slots__ = ("thing", ) def __init__(self, thing=None): self.thing = thing def __enter__(self): return self.thing def __exit__(self, *args, **kwds): pass
