Adrian Sampson committed 01596f1

format None values as the empty string

Fix due to @pscn. Includes test. Closes #108.

Comments (0)

Files changed (3)

     elif key == 'samplerate':
         # Sample rate formatted as kHz.
         value = u'%ikHz' % ((value or 0) // 1000)
+    elif value is None:
+        value = u''
         value = unicode(value)


 * When the importer encounters an error (insufficient permissions, for
   example) when walking a directory tree, it now logs an error instead of
+* In path formats, null database values now expand to the empty string instead
+  of the string "None".
 * Add "System Volume Information" (an internal directory found on some
   Windows filesystems) to the default ignore list.
 * Fix a crash when ReplayGain values were set to null.
         val = beets.library.format_for_path(12345, 'samplerate', posixpath)
         self.assertEqual(val, u'12kHz')
+    def test_component_sanitize_none(self):
+        val = beets.library.format_for_path(None, 'foo', posixpath)
+        self.assertEqual(val, u'')
     def test_artist_falls_back_to_albumartist(self):
         self.i.artist = ''
         self.i.albumartist = 'something'