import warnings
import ctypes


def pack(ctypes_obj):
    """Convert a :mod:`ctypes` structure into a Python string.

    Args:
        ctypes_obj (ctypes.Structure): The :mod:`ctypes` structure to convert to a string.

    Returns:
        New Python string containing the bytes from memory holding *ctypes_obj*.

    .. deprecated:: 1.5
        This function is deprecated, use ``bytes(ctypes_obj)`` instead.
    """
    warnings.warn(
        "This function is deprecated and will be removed, use ``bytes(ctypes_obj)`` instead.",
        DeprecationWarning,
        stacklevel=2,
    )
    return ctypes.string_at(ctypes.addressof(ctypes_obj), ctypes.sizeof(ctypes_obj))