code: def encode_filename(filename):
      """If ``filename`` is a :data:`text_type`, encode it to
      :data:`binary_type` according to filesystem's default encoding.
  
      .. versionchanged:: 0.5.3
         Added support for PEP-519 https://github.com/emcconville/wand/pull/339
      """
      if hasattr(filename, "__fspath__"):  # PEP 519
          filename = filename.__fspath__()
      if isinstance(filename, text_type):
          return filename.encode(sys.getfilesystemencoding())
      return filename
  
file_path: wand/wand/compat.py
imports: import collections
  import contextlib
  import io
  import sys
  import types
label_desc: Use image node_id 3 for calling a global function with example usage: encode_filename(filename) and returns: filename, filename