def _encode_pth(content: str) -> bytes:
    """.pth files are always read with 'locale' encoding, the recommendation
    from the cpython core developers is to write them as ``open(path, "w")``
    and ignore warnings (see python/cpython#77102, pypa/setuptools#3937).
    This function tries to simulate this behaviour without having to create an
    actual file, in a way that supports a range of active Python versions.
    (There seems to be some variety in the way different version of Python handle
    ``encoding=None``, not all of them use ``locale.getpreferredencoding(False)``).
    """
    encoding = "locale" if sys.version_info >= (3, 10) else None
    with io.BytesIO() as buffer:
        wrapper = io.TextIOWrapper(buffer, encoding)
        wrapper.write(content)
        wrapper.flush()
        buffer.seek(0)
        return buffer.read()
.pth files are always read with 'locale' encoding, the recommendation
    from the cpython core developers is to write them as ``open(path, "w")``
    and ignore warnings (see python/cpython#77102, pypa/setuptools#3937).
    This function tries to simulate this behaviour without having to create an
    actual file, in a way that supports a range of active Python versions.
    (There seems to be some variety in the way different version of Python handle
    ``encoding=None``, not all of them use ``locale.getpreferredencoding(False)``).
    
product/gradle-plugin/src/main/python/setuptools/command/editable_wheel.py