HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux ip-172-31-42-149 5.15.0-1084-aws #91~20.04.1-Ubuntu SMP Fri May 2 07:00:04 UTC 2025 aarch64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: //lib/python3/dist-packages/pynvim/compat.py
"""Code for compatibility across Python versions."""

import sys
import warnings
from imp import find_module as original_find_module


IS_PYTHON3 = sys.version_info >= (3, 0)


if IS_PYTHON3:
    def find_module(fullname, path):
        """Compatibility wrapper for imp.find_module.

        Automatically decodes arguments of find_module, in Python3
        they must be Unicode
        """
        if isinstance(fullname, bytes):
            fullname = fullname.decode()
        if isinstance(path, bytes):
            path = path.decode()
        elif isinstance(path, list):
            newpath = []
            for element in path:
                if isinstance(element, bytes):
                    newpath.append(element.decode())
                else:
                    newpath.append(element)
            path = newpath
        return original_find_module(fullname, path)

    # There is no 'long' type in Python3 just int
    long = int
    unicode_errors_default = 'surrogateescape'
else:
    find_module = original_find_module
    unicode_errors_default = 'strict'

NUM_TYPES = (int, long, float)


def check_async(async_, kwargs, default):
    """Return a value of 'async' in kwargs or default when async_ is None.

    This helper function exists for backward compatibility (See #274).
    It shows a warning message when 'async' in kwargs is used to note users.
    """
    if async_ is not None:
        return async_
    elif 'async' in kwargs:
        warnings.warn(
            '"async" attribute is deprecated. Use "async_" instead.',
            DeprecationWarning,
        )
        return kwargs.pop('async')
    else:
        return default