code: def _to_bytes(x):
      """Convert to a byte string.
  
      Convert a Python unicode string or a pathlib.Path to a utf-8-encoded
      byte string. You must call this on strings you pass to libvips.
  
      """
      if isinstance(x, text_type):
          # n.b. str also converts pathlib.Path objects
          x = str(x).encode("utf-8")
  
      return x
  
file_path: pyvips/pyvips/error.py
imports: import sys
  import logging
  from pyvips import ffi, vips_lib, glib_lib
label_desc: Use image node_id 1 for calling a global function with example usage: _to_bytes(x) and returns: x