From: W. Trevor King Date: Thu, 24 Jan 2013 01:56:57 +0000 (-0500) Subject: storage:util:upgrade: Strip any trailing space from the version X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=b9e5c33dc96da7255740cc23660a183baafbadd4;p=be.git storage:util:upgrade: Strip any trailing space from the version Not just '\n'. Mark Mikofski reported an error on the upgrade from 1.4 to 1.5 on MS Windows: > upgrading bugdir from "Bugs Everywhere Directory v1.4" to "Bugs Everywhere Directory v1.5" > Traceback (most recent call last): > ... > File "c:\...\libbe\storage\util\upgrade.py", line 141, in check_initial_version > assert version == self.initial_version, '%s: %s' % (path, version) > AssertionError: c:\...\.be\version: Bugs Everywhere Directory v1.4 > > **notes:** I set a breakpoint and it does seem that they are not the same > (Pdb) self.initial_version > 'Bugs Everywhere Directory v1.4' > (Pdb) version > u'Bugs Everywhere Directory v1.4\r' We don't need to convert to Unicode, because on Python 2.7: $ python2.7 -c "print('a' == u'a')" True Strange, but true ;). One day we'll migrate BE to Python 3... --- diff --git a/libbe/storage/util/upgrade.py b/libbe/storage/util/upgrade.py index ddc434a..c3a5df1 100644 --- a/libbe/storage/util/upgrade.py +++ b/libbe/storage/util/upgrade.py @@ -137,7 +137,7 @@ class Upgrader (object): def check_initial_version(self): path = self.get_path('version') - version = encoding.get_file_contents(path, decode=True).rstrip('\n') + version = encoding.get_file_contents(path, decode=True).rstrip() assert version == self.initial_version, '%s: %s' % (path, version) def set_version(self):