From 14b150090e030656d379bf874d6751e49a5a7fc0 Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Sun, 30 Nov 2014 11:42:40 -0800 Subject: [PATCH] Fix #1124: avoid crash when deleting fields --- beets/ui/commands.py | 5 ++++- docs/changelog.rst | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/beets/ui/commands.py b/beets/ui/commands.py index 30a74b766..855ae2748 100644 --- a/beets/ui/commands.py +++ b/beets/ui/commands.py @@ -1262,7 +1262,10 @@ def modify_items(lib, mods, dels, query, write, move, album, confirm): for obj in objs: obj.update(mods) for field in dels: - del obj[field] + try: + del obj[field] + except KeyError: + pass if ui.show_model_changes(obj): changed.add(obj) diff --git a/docs/changelog.rst b/docs/changelog.rst index 5dfc0c5ae..d92d729cc 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -17,6 +17,9 @@ Fixed: * We now print a better error message when the database file is corrupted. * :doc:`/plugins/discogs`: Only prompt for authentication when running the :ref:`import-cmd` command. :bug:`1123` +* When deleting fields with the :ref:`modify-cmd` command, do not crash when + the field cannot be removed (i.e., when it does not exist, when it is a + built-in field, or when it is a computed field). :ref:`1124` .. _Plex: https://plex.tv/