HEX
Server: Apache/2.4.65 (Unix) OpenSSL/3.5.5
System: Linux cpanel.ns-taberra.com 5.14.0-681.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Feb 11 20:19:22 UTC 2026 x86_64
User: asif201 (1002)
PHP: 8.3.0
Disabled: NONE
Upload Files
File: //usr/lib/python3.9/site-packages/argcomplete/compat.py
from __future__ import absolute_import, division, print_function, unicode_literals

import locale
import sys

sys_encoding = locale.getpreferredencoding()

USING_PYTHON2 = True if sys.version_info < (3, 0) else False

if USING_PYTHON2:
    str = unicode  # noqa
else:
    str = str


def ensure_bytes(x, encoding=sys_encoding):
    if not isinstance(x, bytes):
        x = x.encode(encoding)
    return x


def ensure_str(x, encoding=sys_encoding):
    if not isinstance(x, str):
        x = x.decode(encoding)
    return x