# Buggy code
def is_hidden(path):
    """Return whether or not a file is hidden.

    This method works differently depending on the platform it is called on.

    On OS X, it uses both the result of `is_hidden_osx` and `is_hidden_dot` to
    work out if a file is hidden.

    On Windows, it uses the result of `is_hidden_win` to work out if a file is
    hidden.

    On any other operating systems (i.e. Linux), it uses `is_hidden_dot` to
    work out if a file is hidden.
    """
    # Convert the path to unicode if it is not already.
    if not isinstance(path, six.text_type):
        path = path.decode("utf-8")

    # Run platform specific functions depending on the platform
    if sys.platform == "darwin":
        return _is_hidden_osx(path) or _is_hidden_dot(path)
    elif sys.platform == "win32":
        return _is_hidden_win(path)
    else:
        return _is_hidden_dot(path)


# Traceback (UnicodeDecodeError)
Traceback (most recent call last):
File "/usr/bin/beet", line 9, in <module>
load_entry_point('beets==1.3.19', 'console_scripts', 'beet')()
File "/usr/lib/python2.7/site-packages/beets/ui/__init__.py", line 1266, in main
_raw_main(args)
File "/usr/lib/python2.7/site-packages/beets/ui/__init__.py", line 1253, in _raw_main
subcommand.func(lib, suboptions, subargs)
File "/usr/lib/python2.7/site-packages/beets/ui/commands.py", line 967, in import_func
import_files(lib, paths, query)
File "/usr/lib/python2.7/site-packages/beets/ui/commands.py", line 944, in import_files
session.run()
File "/usr/lib/python2.7/site-packages/beets/importer.py", line 320, in run
pl.run_parallel(QUEUE_SIZE)
File "/usr/lib/python2.7/site-packages/beets/util/pipeline.py", line 251, in run
msg = next(self.coro)
File "/usr/lib/python2.7/site-packages/beets/importer.py", line 1202, in read_tasks
for t in task_factory.tasks():
File "/usr/lib/python2.7/site-packages/beets/importer.py", line 1038, in tasks
for dirs, paths in self.paths():
File "/usr/lib/python2.7/site-packages/beets/importer.py", line 1090, in paths
for dirs, paths in albums_in_dir(self.toppath):
File "/usr/lib/python2.7/site-packages/beets/importer.py", line 1480, in albums_in_dir
logger=log):
File "/usr/lib/python2.7/site-packages/beets/util/__init__.py", line 205, in sorted_walk
for res in sorted_walk(cur, ignore, ignore_hidden, logger):
File "/usr/lib/python2.7/site-packages/beets/util/__init__.py", line 190, in sorted_walk
if (ignore_hidden and not hidden.is_hidden(cur)) or not ignore_hidden:
File "/usr/lib/python2.7/site-packages/beets/util/hidden.py", line 78, in is_hidden
path = path.decode('utf-8')
File "/usr/lib/python2.7/encodings/utf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0x96 in position 76: invalid start byte

# Fixed code
def is_hidden(path):
    """Return whether or not a file is hidden. `path` should be a
    bytestring filename.

    This method works differently depending on the platform it is called on.

    On OS X, it uses both the result of `is_hidden_osx` and `is_hidden_dot` to
    work out if a file is hidden.

    On Windows, it uses the result of `is_hidden_win` to work out if a file is
    hidden.

    On any other operating systems (i.e. Linux), it uses `is_hidden_dot` to
    work out if a file is hidden.
    """
    # Run platform specific functions depending on the platform
    if sys.platform == "darwin":
        return _is_hidden_osx(path) or _is_hidden_dot(path)
    elif sys.platform == "win32":
        return _is_hidden_win(path)
    else:
        return _is_hidden_dot(path)