tools/trunk/src/pysvn_workbench/wb_preferences.py
Log:
Authorization code commit_mod 3377416041.
Mod author: cko.
Mod name: cko-workbench_crash_with_empty_prefs.
Mod description:
When a preference section becomes empty (i.e. the last project has
been deleted, etc.) wb_preferences.py/PreferenceData/__writeDictionary
will write an empty tag. When reading this back in, __getText will insert
a string (rather than a dictionary) and a subsequent access will crash
like this:
Traceback (most recent call last):
File "cko-workbench_crash_with_empty_prefs/src/workbench.py", line 28, in <module>
sys.exit( wb_main.main( sys.argv + ["--project", os.path.curdir] ) )
File "/athlon/home/cko/hp/cko-workbench_crash_with_empty_prefs/src/pysvn_workbench/wb_main.py", line 66, in main
app = wb_app.WbApp( startup_dir, args )
File "/athlon/home/cko/hp/cko-workbench_crash_with_empty_prefs/src/pysvn_workbench/wb_app.py", line 75, in __init__
wb_platform_specific.getOldPreferencesFilename() )
File "/athlon/home/cko/hp/cko-workbench_crash_with_empty_prefs/src/pysvn_workbench/wb_preferences.py", line 64, in __init__
self.readPreferences()
File "/athlon/home/cko/hp/cko-workbench_crash_with_empty_prefs/src/pysvn_workbench/wb_preferences.py", line 76, in readPreferences
handler.readPreferences( self.pref_data )
File "/athlon/home/cko/hp/cko-workbench_crash_with_empty_prefs/src/pysvn_workbench/wb_preferences.py", line 428, in readPreferences
num_bookmarks = pref_data.len_section( self.section_name, 'bookmark' )
File "/athlon/home/cko/hp/cko-workbench_crash_with_empty_prefs/src/pysvn_workbench/wb_preferences.py", line 223, in len_section
if type(self.all_sections[ section_name ][ option_name ]) == types.ListType:
TypeError: string indices must be integers
As a solution, we suppress the writing of empty dictionaries.
Successfully reviewed by js.
Modified: tools/trunk/src/pysvn_workbench/wb_preferences.py
===================================================================
--- tools/trunk/src/pysvn_workbench/wb_preferences.py 2007-01-10 10:59:30 UTC (rev 43007)
+++ tools/trunk/src/pysvn_workbench/wb_preferences.py 2007-01-10 11:07:24 UTC (rev 43008)
for key_name in all_key_names:
value = d[ key_name ]
if type(value) == types.DictType:
- f.write( '%*s<%s>n' % (indent, '', key_name) )
- self.__writeDictionary( f, value, indent + 4 )
- f.write( '%*s</%s>n' % (indent, '', key_name) )
+ if len(value) > 0:
+ f.write( '%*s<%s>n' % (indent, '', key_name) )
+ self.__writeDictionary( f, value, indent + 4 )
+ f.write( '%*s</%s>n' % (indent, '', key_name) )
elif type(value) == types.ListType:
for item in value:
f.write( '%*s<%s>n' % (indent, '', key_name) )
---------------------------------------------------------------------
To unsubscrib
e, e-mail: dev-unsubscribe
pysvn.tigris.org">dev-unsubscribe
pysvn.tigris.orgFor additional
commands, e-mail: dev-help
pysvn.tigris.org">dev-help
pysvn.tigris.org