Package: pypar2 Version: 1.4-5 Severity: normal Tags: patch User: debian-pyt...@lists.debian.org Usertag: python2.7
From https://bugs.launchpad.net/ubuntu/+source/pypar2/+bug/719708 Under Python 2.7: Traceback (most recent call last): File "/usr/bin/pypar2", line 20, in <module> import consts, dlgAbout, dlgOutput, gettext, gtk, gtk.glade, locale, os.path, prefsManager, sys, treeview File "/usr/share/pypar2/src/dlgOutput.py", line 19, in <module> import consts, gtk, prefsManager, signal, sys, os, vte File "/usr/share/pypar2/src/prefsManager.py", line 116, in <module> value = typeToolBox.cast(elt.getAttribute('value'), elt.getAttribute('type')) File "/usr/share/pypar2/src/typeToolBox.py", line 39, in cast return int(value) ValueError: invalid literal for int() with base 10: 'False' This happens on the second execution of the program, because it has saved an incorrect preferences file containing: <pref name="chkUniformFileSize" type="int" value="False"/> Under Python 2.7, the dict in typeToolBox.py appears to change iteration order. One can't rely on the order of the iteration of a dictionary (unless you use the new OrderedDict). Here's a trivial patch to use a list of tuples instead. SR -- System Information: Debian Release: wheezy/sid APT prefers testing APT policy: (990, 'testing'), (500, 'unstable'), (1, 'experimental') Architecture: amd64 (x86_64) Kernel: Linux 2.6.32-5-amd64 (SMP w/8 CPU cores) Locale: LANG=en_ZA.UTF-8, LC_CTYPE=en_ZA.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Versions of packages pypar2 depends on: ii par2 0.4-11 Parity Archive Volume Set, for che ii python 2.6.6-3+squeeze5 interactive high-level object-orie ii python-glade2 2.17.0-4 GTK+ bindings: Glade support ii python-gtk2 2.17.0-4 Python bindings for the GTK+ widge ii python-support 1.0.11 automated rebuilding support for P ii python-vte 1:0.24.3-2 Python bindings for the VTE widget pypar2 recommends no packages. pypar2 suggests no packages. -- no debconf information
--- a/src/typeToolBox.py +++ b/src/typeToolBox.py @@ -20,14 +20,14 @@ # Supported types # 'bool' type must be placed *before* 'int' type, otherwise booleans are detected as integers -types = {bool : 'bool', int : 'int', str : 'str'} +types = [(bool, 'bool'), (int, 'int'), (str, 'str')] # Return a String with the type of value def getType(value) : - for type in types.keys() : + for type, name in types: if isinstance(value, type) : - return types[type] + return name raise TypeError, str(value) + _(' has an unsupported type')