HEX
Server: LiteSpeed
System: Linux srv146.niagahoster.com 4.18.0-553.30.1.lve.el8.x86_64 #1 SMP Tue Dec 3 01:21:19 UTC 2024 x86_64
User: kodi1989 (1633)
PHP: 8.1.34
Disabled: symlink,shell_exec,exec,popen,system,dl,passthru,escapeshellarg,escapeshellcmd,show_source,pcntl_exec
Upload Files
File: //opt/alt/python37/lib/python3.7/site-packages/bmemcached/utils.py
import six

__all__ = ('str_to_bytes',)


def str_to_bytes(value):
    """
    Simply convert a string type to bytes if the value is a string
    and is an instance of six.string_types but not of six.binary_type
    in python2 struct.pack("<Q") is both string_types and binary_type but
    in python3 struct.pack("<Q") is binary_type but not a string_types
    :param value:
    :param binary:
    :return:
    """
    if not isinstance(value, six.binary_type) and isinstance(value, six.string_types):
        return value.encode()
    return value