view cutils/util/cm.py @ 126:dfe7bb0579e2

Extend copyright years to 2025
author Franz Glasner <fzglas.hg@dom66.de>
date Thu, 02 Jan 2025 17:09:50 +0100
parents e15b3d1ff0d9
children 0f4febf646f5
line wrap: on
line source

# -*- coding: utf-8 -*-
# :-
# :Copyright: (c) 2020-2025 Franz Glasner
# :License:   BSD-3-Clause
# :-
r"""Context manager extensions and compatibility.

"""

__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