From b9e5c33dc96da7255740cc23660a183baafbadd4 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Wed, 23 Jan 2013 20:56:57 -0500 Subject: [PATCH] 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... --- libbe/storage/util/upgrade.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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): -- 2.26.2