# Buggy code
def try_filesize(self):
    try:
        return os.path.getsize(syspath(self.path))
    except (OSError, Exception) as exc:
        log.warning("could not get filesize: {0}", exc)
        return 0


# Traceback (OSError)
$ beet im /dunehd/Musica\ pendiente/Madonna\ –\ Rebel\ Heart\ \[Deluxe\ Edition\ 2015\]\(MP3\ 320\ Kbps\)/

/dunehd/Musica pendiente/Madonna – Rebel Heart [Deluxe Edition 2015](MP3 320 Kbps)/Track List (25 items)
Correcting tags from:
Madonna - Rebel Heart Deluxe
To:
Madonna - Rebel Heart (Super Deluxe Edition)
URL:
http://musicbrainz.org/release/0911931a-3770-4cb7-ba67-3d2fda24d2e8
(Similarity: 97.5%) (album, tracks) (Digital Media, 2015)
* Living For Love                               -> Living for Love
* Bitch I'm Madonna (feat. Nicki Minaj)         -> Bitch I’m Madonna (title)
* Iconic (feat. Chance the Rapper &amp; Mike Tyson) -> Iconic (title)
* Veni Vidi Vici (feat. Nas)                    -> Veni Vedi Vici (title)
This album is already in the library!
Traceback (most recent call last):
File "/usr/local/bin/beet", line 9, in <module>
load_entry_point('beets==1.3.11', 'console_scripts', 'beet')()
File "/usr/local/lib/python2.7/dist-packages/beets-1.3.11-py2.7.egg/beets/ui/__init__.py", line 953, in main
_raw_main(args)
File "/usr/local/lib/python2.7/dist-packages/beets-1.3.11-py2.7.egg/beets/ui/__init__.py", line 943, in _raw_main
subcommand.func(lib, suboptions, subargs)
File "/usr/local/lib/python2.7/dist-packages/beets-1.3.11-py2.7.egg/beets/ui/commands.py", line 874, in import_func
import_files(lib, paths, query)
File "/usr/local/lib/python2.7/dist-packages/beets-1.3.11-py2.7.egg/beets/ui/commands.py", line 851, in import_files
session.run()
File "/usr/local/lib/python2.7/dist-packages/beets-1.3.11-py2.7.egg/beets/importer.py", line 316, in run
pl.run_parallel(QUEUE_SIZE)
File "/usr/local/lib/python2.7/dist-packages/beets-1.3.11-py2.7.egg/beets/util/pipeline.py", line 301, in run
out = self.coro.send(msg)
File "/usr/local/lib/python2.7/dist-packages/beets-1.3.11-py2.7.egg/beets/util/pipeline.py", line 160, in coro
task = func(*(args + (task,)))
File "/usr/local/lib/python2.7/dist-packages/beets-1.3.11-py2.7.egg/beets/importer.py", line 1287, in user_query
resolve_duplicates(session, task)
File "/usr/local/lib/python2.7/dist-packages/beets-1.3.11-py2.7.egg/beets/importer.py", line 1299, in resolve_duplicates
session.resolve_duplicate(task, found_duplicates)
File "/usr/local/lib/python2.7/dist-packages/beets-1.3.11-py2.7.egg/beets/ui/commands.py", line 789, in resolve_duplicate
not task.is_album,
File "/usr/local/lib/python2.7/dist-packages/beets-1.3.11-py2.7.egg/beets/ui/commands.py", line 446, in summarize_items
total_filesize = sum([item.filesize for item in items])
File "/usr/local/lib/python2.7/dist-packages/beets-1.3.11-py2.7.egg/beets/dbcore/db.py", line 316, in __getattr__
return self[key]
File "/usr/local/lib/python2.7/dist-packages/beets-1.3.11-py2.7.egg/beets/dbcore/db.py", line 224, in __getitem__
return getters[key](self)
File "/usr/local/lib/python2.7/dist-packages/beets-1.3.11-py2.7.egg/beets/library.py", line 424, in <lambda>
getters['filesize'] = lambda i: os.path.getsize(syspath(i.path))
File "/usr/lib/python2.7/genericpath.py", line 49, in getsize
return os.stat(filename).st_size
OSError: [Errno 2] No such file or directory: '/home/simon/M\xc3\xbasica/Madonna/Rebel Heart (Super Deluxe Edition)/01 - Living for Love.mp3'

# Fixed code
def try_filesize(self):
    """Get the size of the underlying file in bytes.

    If the file is missing, return 0 (and log a warning).
    """
    try:
        return os.path.getsize(syspath(self.path))
    except (OSError, Exception) as exc:
        log.warning("could not get filesize: {0}", exc)
        return 0