[wicd/f14/master] - Use cPickle instead of deepcopy in configmanager.py (#645251)
David Cantrell
dcantrel at fedoraproject.org
Fri Oct 22 20:43:32 UTC 2010
commit 5484559175debb9c19e0380a445162f16b51366d
Author: David Cantrell <dcantrell at redhat.com>
Date: Fri Oct 22 10:37:17 2010 -1000
- Use cPickle instead of deepcopy in configmanager.py (#645251)
wicd-1.7.0-deepcopy.patch | 50 +++++++++++++++++++++++++++++++++++++++++++++
wicd.spec | 9 +++++++-
2 files changed, 58 insertions(+), 1 deletions(-)
---
diff --git a/wicd-1.7.0-deepcopy.patch b/wicd-1.7.0-deepcopy.patch
new file mode 100644
index 0000000..47989e8
--- /dev/null
+++ b/wicd-1.7.0-deepcopy.patch
@@ -0,0 +1,50 @@
+diff -up wicd-1.7.0/wicd/configmanager.py.deepcopy wicd-1.7.0/wicd/configmanager.py
+--- wicd-1.7.0/wicd/configmanager.py.deepcopy 2010-01-14 18:49:11.000000000 -1000
++++ wicd-1.7.0/wicd/configmanager.py 2010-10-22 10:18:14.000000000 -1000
+@@ -25,6 +25,7 @@ reusable for other purposes as well.
+ #
+
+ import os, copy
++import cPickle
+
+ from ConfigParser import RawConfigParser
+
+@@ -35,7 +36,7 @@ from dbus import Int32
+ class ConfigManager(RawConfigParser):
+ """ A class that can be used to manage a given configuration file. """
+ def __init__(self, path, debug=False, mark_whitespace="`'`"):
+- RawConfigParser.__init__(self)
++ RawConfigParser.__init__(self, allow_no_value = True)
+ self.config_file = path
+ self.debug = debug
+ self.mrk_ws = mark_whitespace
+@@ -67,7 +68,7 @@ class ConfigManager(RawConfigParser):
+ if value.startswith(' ') or value.endswith(' '):
+ value = "%(ws)s%(value)s%(ws)s" % {"value" : value,
+ "ws" : self.mrk_ws}
+- RawConfigParser.set(self, section, str(option), value)
++ RawConfigParser.set(self, section, str(option), "None" if value is None else value)
+ if write:
+ self.write()
+
+@@ -176,9 +177,7 @@ class ConfigManager(RawConfigParser):
+
+
+ def _copy_section(self, name):
+- # Yes, deepcopy sucks, but it is robust to changes in both
+- # this class and RawConfigParser.
+- p = copy.deepcopy(self)
++ p = cPickle.loads(cPickle.dumps(self, -1))
+ for sname in p.sections():
+ if sname != name:
+ p.remove_section(sname)
+@@ -188,8 +187,7 @@ class ConfigManager(RawConfigParser):
+
+ def write(self):
+ """ Writes the loaded config file to disk. """
+- # Really don't like this deepcopy.
+- p = copy.deepcopy(self)
++ p = cPickle.loads(cPickle.dumps(self, -1))
+ for sname in p.sections():
+ fname = p.get_option(sname, '_filename_')
+ if fname and fname != self.config_file:
diff --git a/wicd.spec b/wicd.spec
index ca5de5b..fb33648 100644
--- a/wicd.spec
+++ b/wicd.spec
@@ -7,7 +7,7 @@
Name: wicd
Version: 1.7.0
-Release: 3%{?dist}
+Release: 4%{?dist}
Summary: Wireless and wired network connection manager
Group: System Environment/Base
@@ -17,6 +17,7 @@ Source0: http://downloads.sourceforge.net/%{name}/%{name}-%{version}.ta
Source1: wicd.logrotate
Patch0: wicd-1.7.0-remove-WHEREAREMYFILES.patch
Patch1: wicd-1.7.0-initscript.patch
+Patch2: wicd-1.7.0-deepcopy.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(id -u -n)
BuildRequires: python2-devel
@@ -87,6 +88,9 @@ Client program for wicd that uses a GTK+ interface.
# Reported upstream: https://bugs.launchpad.net/wicd/+bug/587690
%patch1 -p1
+# Use cPickle instead of deepcopy in configmanager.py
+%patch2 -p1
+
%build
# NOTE: --etc is where dhclient.conf.template goes
%{__python} setup.py configure \
@@ -252,6 +256,9 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
%{_datadir}/icons/hicolor/scalable/apps/wicd-gtk.svg
%changelog
+* Fri Oct 22 2010 David Cantrell <dcantrell at redhat.com> - 1.7.0-4
+- Use cPickle instead of deepcopy in configmanager.py (#645251)
+
* Wed Aug 25 2010 David Cantrell <dcantrell at redhat.com> - 1.7.0-3
- Remove hard dependency on the base package by wicd-common. The
base package is arch-specific and contains optional components
More information about the scm-commits
mailing list