aboutsummaryrefslogtreecommitdiff
path: root/security/pwman3/files/patch-2to3
blob: df330dcf8e9309ff2a239a8171ef7ae0ec8211af (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
--- pwman/data/drivers/mysql.py.orig	2007-02-04 18:44:43 UTC
+++ pwman/data/drivers/mysql.py
@@ -24,7 +24,7 @@ from pwman.data.tags import Tag
 
 import MySQLdb
 import pwman.util.config as config
-import cPickle
+import pickle
 
 class MySQLDatabase(Database):
     """MySQL Database implementation"""
@@ -46,7 +46,7 @@ class MySQLDatabase(Database):
             self._password = config.get_value('Database', 'password')
             self._database = config.get_value('Database', 'database')
             self._prefix = config.get_value('Database', 'table_prefix')
-        except KeyError, e:
+        except KeyError as e:
             raise DatabaseException(
                 "MySQL: missing parameter [%s]" % (e))
 
@@ -60,14 +60,14 @@ class MySQLDatabase(Database):
 #                                     password = self._password)
 #            self._cur = self._con.cursor()
             self._checktables()
-        except MySQLdb.DatabaseError, e:
+        except MySQLdb.DatabaseError as e:
             raise DatabaseException("MySQL: %s" % (e))
 
     def _get_cur(self):
         try:
             if (self._con != None):
                 return self._con.cursor()
-        except MySQLdb.DatabaseError, e:
+        except MySQLdb.DatabaseError as e:
             pass
         self._con = MySQLdb.connect(host = self._server,
                                  port = int(self._port),
@@ -105,7 +105,7 @@ class MySQLDatabase(Database):
                 sql += ("SELECT NODE FROM %sLOOKUP LEFT JOIN %sTAGS ON TAG = %sTAGS.ID "
                         + " WHERE %sTAGS.DATA = %%s") % (self._prefix, self._prefix,
                                                              self._prefix, self._prefix)
-                params.append(cPickle.dumps(t))
+                params.append(pickle.dumps(t))
             sql += ") EXCEPT SELECT DATA FROM %sTAGS WHERE " %(self._prefix)
             first = True
             for t in self._filtertags:
@@ -114,7 +114,7 @@ class MySQLDatabase(Database):
                 else:
                     first = False
                 sql += "%sTAGS.DATA = %%s" % (self._prefix)
-                params.append(cPickle.dumps(t))
+                params.append(pickle.dumps(t))
         try:
             cursor = self._get_cur()
             cursor.execute(sql, params)
@@ -122,11 +122,11 @@ class MySQLDatabase(Database):
             tags = []
             row = cursor.fetchone()
             while (row != None):
-                tag = cPickle.loads(str(row[0]))
+                tag = pickle.loads(str(row[0]))
                 tags.append(tag)
                 row = cursor.fetchone()
             return tags
-        except MySQLdb.DatabaseError, e:
+        except MySQLdb.DatabaseError as e:
             raise DatabaseException("MySQL: %s" % (e))
         
     def getnodes(self, ids):
@@ -151,11 +151,11 @@ class MySQLDatabase(Database):
             
             row = cursor.fetchone()
             while row != None:
-                node = cPickle.loads(str(row[1]))
+                node = pickle.loads(str(row[1]))
                 node.set_id(row[0])
                 nodes.append(node)
                 row = cursor.fetchone()
-        except MySQLdb.DatabaseError, e:
+        except MySQLdb.DatabaseError as e:
             raise DatabaseException("MySQL: %s" % (e))
         return nodes
 
@@ -165,9 +165,9 @@ class MySQLDatabase(Database):
         try:
             cursor = self._get_cur()
             sql = "UPDATE %sNODES SET DATA = %%s WHERE ID = %%s" % (self._prefix)
-            cursor.execute(sql, (cPickle.dumps(node), id))
+            cursor.execute(sql, (pickle.dumps(node), id))
             
-        except MySQL.DatabaseError, e:
+        except MySQL.DatabaseError as e:
             raise DatabaseException("MySQL: %s" % (e))
         self._setnodetags(node)
         self._checktags()
@@ -179,13 +179,13 @@ class MySQLDatabase(Database):
             sql = "INSERT INTO %sNODES(DATA) VALUES(%%s)" % (self._prefix)
             if not isinstance(n, Node): raise DatabaseException(
                 "Tried to insert foreign object into database [%s]", n)
-            values = [cPickle.dumps(n)]
+            values = [pickle.dumps(n)]
             try:
                 cursor.execute(sql, values)
-            except MySQLdb.DatabaseError, e:
+            except MySQLdb.DatabaseError as e:
                 raise DatabaseException("MySQL: %s" % (e))
             id = cursor.lastrowid
-            print "id: %d" % (id)
+            print("id: %d" % (id))
             n.set_id(id)
 
             self._setnodetags(n)
@@ -200,7 +200,7 @@ class MySQLDatabase(Database):
                 sql = "DELETE FROM %sNODES WHERE ID = %%s" % (self._prefix)
                 cursor.execute(sql, [n.get_id()])
                 
-            except MySQLdb.DatabaseError, e:
+            except MySQLdb.DatabaseError as e:
                 raise DatabaseException("MySQL: %s" % (e))
             self._deletenodetags(n)
 
@@ -226,9 +226,9 @@ class MySQLDatabase(Database):
                 sql += (("SELECT NODE FROM %sLOOKUP LEFT JOIN %sTAGS ON TAG = %sTAGS.ID"
                          + " WHERE %sTAGS.DATA = %%s ") % (self._prefix, self._prefix,
                                                            self._prefix, self._prefix))
-                params.append(cPickle.dumps(t))
+                params.append(pickle.dumps(t))
         try:
-            print sql
+            print(sql)
             cursor.execute(sql, params)
 
             ids = []
@@ -237,13 +237,13 @@ class MySQLDatabase(Database):
                 ids.append(row[0])
                 row = cursor.fetchone()
             return ids
-        except MySQLdb.DatabaseError, e:
+        except MySQLdb.DatabaseError as e:
             raise DatabaseException("MySQL: %s" % (e))
 
     def _commit(self):
         try:
             self._con.commit()
-        except MySQLdb.DatabaseError, e:
+        except MySQLdb.DatabaseError as e:
             self._con.rollback()
             raise DatabaseException(
                 "MySQL: Error commiting data to db [%s]" % (e))
@@ -252,11 +252,11 @@ class MySQLDatabase(Database):
         ids = []
         cursor = self._get_cur()
         for t in tags:
-            pickled = cPickle.dumps(t)
+            pickled = pickle.dumps(t)
             try:
                 ids.append(self._tagidcache[pickled])
                 continue
-            except KeyError, e:
+            except KeyError as e:
                 pass # not in cache
             sql = "SELECT ID FROM %sTAGS WHERE DATA = %%s" % (self._prefix)
             if not isinstance(t, Tag): raise DatabaseException(
@@ -275,7 +275,7 @@ class MySQLDatabase(Database):
                     id = cursor.lastrowid
                     ids.append(id)
                     self._tagidcache[pickled] = id
-            except MySQLdb.DatabaseError, e:
+            except MySQLdb.DatabaseError as e:
                 raise DatabaseException("MySQLdb: %s" % (e))
         return ids
 
@@ -285,7 +285,7 @@ class MySQLDatabase(Database):
             sql = "DELETE FROM %sLOOKUP WHERE NODE = %%s" % (self._prefix)
             cursor.execute(sql, [node.get_id()])
             
-        except MySQLdb.DatabaseError, e:
+        except MySQLdb.DatabaseError as e:
             raise DatabaseException("MySQLdb: %s" % (e))
         
     def _setnodetags(self, node):
@@ -299,7 +299,7 @@ class MySQLDatabase(Database):
             try:
                 cursor = self._get_cur()
                 cursor.execute(sql, params)
-            except MySQLdb.DatabaseError, e:
+            except MySQLdb.DatabaseError as e:
                 raise DatabaseException("MySQLdb: %s" % (e))
 
     def _checktags(self):
@@ -310,7 +310,7 @@ class MySQLDatabase(Database):
                    + "(SELECT TAG FROM %sLOOKUP GROUP BY TAG)") % (self._prefix,
                                                                    self._prefix)
             cursor.execute(sql)
-        except MySQLdb.DatabaseError, e:
+        except MySQLdb.DatabaseError as e:
             raise DatabaseException("MySQL: %s" % (e))
         self._commit()
 
@@ -342,7 +342,7 @@ class MySQLDatabase(Database):
             
             try:
                 self._con.commit()
-            except MySQLdb.DatabaseError, e:
+            except MySQLdb.DatabaseError as e:
                 self._con.rollback()
                 raise e
 
@@ -353,7 +353,7 @@ class MySQLDatabase(Database):
         cursor.execute(sql, values)
         try:
             self._con.commit()
-        except MySQLdb.DatabaseError, e:
+        except MySQLdb.DatabaseError as e:
             self._con.rollback()
             raise DatabaseException(
                 "MySQL: Error saving key [%s]" % (e))
--- pwman/data/drivers/postgresql.py.orig	2007-02-04 18:44:43 UTC
+++ pwman/data/drivers/postgresql.py
@@ -24,7 +24,7 @@ from pwman.data.tags import Tag
 
 import pgdb
 import pwman.util.config as config
-import cPickle
+import pickle
 
 class PostgresqlDatabase(Database):
     """Postgresql Database implementation"""
@@ -46,7 +46,7 @@ class PostgresqlDatabase(Database):
             self._password = config.get_value('Database', 'password')
             self._database = config.get_value('Database', 'database')
             self._prefix = config.get_value('Database', 'table_prefix')
-        except KeyError, e:
+        except KeyError as e:
             raise DatabaseException(
                 "Postgresql: missing parameter [%s]" % (e))
 
@@ -60,14 +60,14 @@ class PostgresqlDatabase(Database):
 #                                     password = self._password)
 #            self._cur = self._con.cursor()
             self._checktables()
-        except pgdb.DatabaseError, e:
+        except pgdb.DatabaseError as e:
             raise DatabaseException("Postgresql: %s" % (e))
 
     def _get_cur(self):
         try:
             if (self._con != None):
                 return self._con.cursor()
-        except pgdb.DatabaseError, e:
+        except pgdb.DatabaseError as e:
             pass
         server = "%s:%s" % (self._server, self._port)
         self._con = pgdb.connect(host = server,
@@ -106,7 +106,7 @@ class PostgresqlDatabase(Database):
                         + " WHERE %sTAGS.DATA = %%(%s)s") % (self._prefix, self._prefix,
                                                              self._prefix, self._prefix,
                                                              paramname)
-                params[paramname] = cPickle.dumps(t)
+                params[paramname] = pickle.dumps(t)
             sql += ") EXCEPT SELECT DATA FROM %sTAGS WHERE " %(self._prefix)
             first = True
             for t in self._filtertags:
@@ -122,11 +122,11 @@ class PostgresqlDatabase(Database):
             tags = []
             row = cursor.fetchone()
             while (row != None):
-                tag = cPickle.loads(str(row[0]))
+                tag = pickle.loads(str(row[0]))
                 tags.append(tag)
                 row = cursor.fetchone()
             return tags
-        except pgdb.DatabaseError, e:
+        except pgdb.DatabaseError as e:
             raise DatabaseException("Postgresql: %s" % (e))
         
     def getnodes(self, ids):
@@ -151,11 +151,11 @@ class PostgresqlDatabase(Database):
             
             row = cursor.fetchone()
             while row != None:
-                node = cPickle.loads(str(row[1]))
+                node = pickle.loads(str(row[1]))
                 node.set_id(row[0])
                 nodes.append(node)
                 row = cursor.fetchone()
-        except pgdb.DatabaseError, e:
+        except pgdb.DatabaseError as e:
             raise DatabaseException("Postgresql: %s" % (e))
         return nodes
 
@@ -165,10 +165,10 @@ class PostgresqlDatabase(Database):
         try:
             cursor = self._get_cur()
             sql = "UPDATE %sNODES SET DATA = %%(data)s WHERE ID = %%(id)d" % (self._prefix)
-            cursor.execute(sql, {"data":cPickle.dumps(node),
+            cursor.execute(sql, {"data":pickle.dumps(node),
                                  "id": id})
             
-        except pgdb.DatabaseError, e:
+        except pgdb.DatabaseError as e:
             raise DatabaseException("Postgresql: %s" % (e))
         self._setnodetags(node)
         self._checktags()
@@ -180,10 +180,10 @@ class PostgresqlDatabase(Database):
             sql = "INSERT INTO %sNODES(DATA) VALUES(%%(data)s)" % (self._prefix)
             if not isinstance(n, Node): raise DatabaseException(
                 "Tried to insert foreign object into database [%s]", n)
-            values = {"data": cPickle.dumps(n)}
+            values = {"data": pickle.dumps(n)}
             try:
                 cursor.execute(sql, values)
-            except pgdb.DatabaseError, e:
+            except pgdb.DatabaseError as e:
                 raise DatabaseException("Postgresql: %s" % (e))
             id = self._lastrowid("NODES")
             n.set_id(id)
@@ -200,7 +200,7 @@ class PostgresqlDatabase(Database):
                 sql = "DELETE FROM %sNODES WHERE ID = %%(id)d" % (self._prefix)
                 cursor.execute(sql, {"id": n.get_id()})
                 
-            except pgdb.DatabaseError, e:
+            except pgdb.DatabaseError as e:
                 raise DatabaseException("Postgresql: %s" % (e))
             self._deletenodetags(n)
 
@@ -228,7 +228,7 @@ class PostgresqlDatabase(Database):
                          + " WHERE %sTAGS.DATA = %%(%s)s ") % (self._prefix, self._prefix,
                                                                self._prefix, self._prefix,
                                                                paramname))
-                params[paramname] = cPickle.dumps(t)
+                params[paramname] = pickle.dumps(t)
         try:
             cursor.execute(sql, params)
 
@@ -238,13 +238,13 @@ class PostgresqlDatabase(Database):
                 ids.append(row[0])
                 row = cursor.fetchone()
             return ids
-        except pgdb.DatabaseError, e:
+        except pgdb.DatabaseError as e:
             raise DatabaseException("Postgresql: %s" % (e))
 
     def _commit(self):
         try:
             self._con.commit()
-        except pgdb.DatabaseError, e:
+        except pgdb.DatabaseError as e:
             self._con.rollback()
             raise DatabaseException(
                 "Postgresql: Error commiting data to db [%s]" % (e))
@@ -253,11 +253,11 @@ class PostgresqlDatabase(Database):
         ids = []
         cursor = self._get_cur()
         for t in tags:
-            pickled = cPickle.dumps(t)
+            pickled = pickle.dumps(t)
             try:
                 ids.append(self._tagidcache[pickled])
                 continue
-            except KeyError, e:
+            except KeyError as e:
                 pass # not in cache
             sql = "SELECT ID FROM %sTAGS WHERE DATA = %%(tag)s" % (self._prefix)
             if not isinstance(t, Tag): raise DatabaseException(
@@ -276,7 +276,7 @@ class PostgresqlDatabase(Database):
                     id = self._lastrowid("TAGS")
                     ids.append(id)
                     self._tagidcache[pickled] = id
-            except pgdb.DatabaseError, e:
+            except pgdb.DatabaseError as e:
                 raise DatabaseException("Postgresql: %s" % (e))
         return ids
 
@@ -286,7 +286,7 @@ class PostgresqlDatabase(Database):
             sql = "DELETE FROM %sLOOKUP WHERE NODE = %%(node)d" % (self._prefix)
             cursor.execute(sql, {"node":node.get_id()})
             
-        except pgdb.DatabaseError, e:
+        except pgdb.DatabaseError as e:
             raise DatabaseException("Postgresql: %s" % (e))
         
     def _setnodetags(self, node):
@@ -300,7 +300,7 @@ class PostgresqlDatabase(Database):
             try:
                 cursor = self._get_cur()
                 cursor.execute(sql, params)
-            except pgdb.DatabaseError, e:
+            except pgdb.DatabaseError as e:
                 raise DatabaseException("Postgresql: %s" % (e))
 
     def _checktags(self):
@@ -311,7 +311,7 @@ class PostgresqlDatabase(Database):
                    + "(SELECT TAG FROM %sLOOKUP GROUP BY TAG)") % (self._prefix,
                                                                    self._prefix)
             cursor.execute(sql)
-        except pgdb.DatabaseError, e:
+        except pgdb.DatabaseError as e:
             raise DatabaseException("Postgresql: %s" % (e))
         self._commit()
 
@@ -352,7 +352,7 @@ class PostgresqlDatabase(Database):
             
             try:
                 self._con.commit()
-            except pgdb.DatabaseError, e:
+            except pgdb.DatabaseError as e:
                 self._con.rollback()
                 raise e
 
@@ -363,7 +363,7 @@ class PostgresqlDatabase(Database):
         cursor.execute(sql, values)
         try:
             self._con.commit()
-        except pgdb.DatabaseError, e:
+        except pgdb.DatabaseError as e:
             self._con.rollback()
             raise DatabaseException(
                 "Postgresql: Error saving key [%s]" % (e))
--- pwman/data/drivers/sqlite.py.orig	2007-02-04 18:44:43 UTC
+++ pwman/data/drivers/sqlite.py
@@ -22,9 +22,9 @@ from pwman.data.tags import Tag
 from pwman.data.nodes import Node
 from pwman.data.tags import Tag
 
-from pysqlite2 import dbapi2 as sqlite
+from sqlite3 import dbapi2 as sqlite
 import pwman.util.config as config
-import cPickle
+import pickle
 
 class SQLiteDatabase(Database):
     """SQLite Database implementation"""
@@ -35,7 +35,7 @@ class SQLiteDatabase(Database):
 
         try:
             self._filename = config.get_value('Database', 'filename')
-        except KeyError, e:
+        except KeyError as e:
             raise DatabaseException(
                 "SQLite: missing parameter [%s]" % (e))
 
@@ -44,7 +44,7 @@ class SQLiteDatabase(Database):
             self._con = sqlite.connect(self._filename)
             self._cur = self._con.cursor()
             self._checktables()
-        except sqlite.DatabaseError, e:
+        except sqlite.DatabaseError as e:
             raise DatabaseException("SQLite: %s" % (s))
 
     def close(self):
@@ -69,7 +69,7 @@ class SQLiteDatabase(Database):
                     
                 sql += ("SELECT NODE FROM LOOKUP OUTER JOIN TAGS ON TAG = TAGS.ID "
                         + " WHERE TAGS.DATA = ?")
-                params.append(cPickle.dumps(t))
+                params.append(pickle.dumps(t))
             sql += ") EXCEPT SELECT DATA FROM TAGS WHERE "
             first = True
             for t in self._filtertags:
@@ -78,18 +78,18 @@ class SQLiteDatabase(Database):
                 else:
                     first = False
                 sql += "TAGS.DATA = ?"
-                params.append(cPickle.dumps(t))
+                params.append(pickle.dumps(t))
         try:
             self._cur.execute(sql, params)
 
             tags = []
             row = self._cur.fetchone()
             while (row != None):
-                tag = cPickle.loads(str(row[0]))
+                tag = pickle.loads(str(row[0]))
                 tags.append(tag)
                 row = self._cur.fetchone()
             return tags
-        except sqlite.DatabaseError, e:
+        except sqlite.DatabaseError as e:
             raise DatabaseException("SQLite: %s" % (e))
         
     def getnodes(self, ids):
@@ -101,10 +101,10 @@ class SQLiteDatabase(Database):
 
                 row = self._cur.fetchone()
                 if row != None:
-                    node = cPickle.loads(str(row[0]))
+                    node = pickle.loads(str(row[0]))
                     node.set_id(i)
                     nodes.append(node)
-            except sqlite.DatabaseError, e:
+            except sqlite.DatabaseError as e:
                 raise DatabaseException("SQLite: %s" % (e))
         return nodes
 
@@ -113,9 +113,9 @@ class SQLiteDatabase(Database):
                 "Tried to insert foreign object into database [%s]" % node)
         try:
             sql = "UPDATE NODES SET DATA = ? WHERE ID = ?";
-            self._cur.execute(sql, [cPickle.dumps(node), id])
+            self._cur.execute(sql, [pickle.dumps(node), id])
             
-        except sqlite.DatabaseError, e:
+        except sqlite.DatabaseError as e:
             raise DatabaseException("SQLite: %s" % (e))
         self._setnodetags(node)
         self._checktags()
@@ -126,10 +126,10 @@ class SQLiteDatabase(Database):
             sql = "INSERT INTO NODES(DATA) VALUES(?)"
             if not isinstance(n, Node): raise DatabaseException(
                 "Tried to insert foreign object into database [%s]", n)
-            value = cPickle.dumps(n)
+            value = pickle.dumps(n)
             try:
                 self._cur.execute(sql, [value])
-            except sqlite.DatabaseError, e:
+            except sqlite.DatabaseError as e:
                 raise DatabaseException("SQLite: %s" % (e))
             id = self._cur.lastrowid
             n.set_id(id)
@@ -145,7 +145,7 @@ class SQLiteDatabase(Database):
                 sql = "DELETE FROM NODES WHERE ID = ?";
                 self._cur.execute(sql, [n.get_id()])
                 
-            except sqlite.DatabaseError, e:
+            except sqlite.DatabaseError as e:
                 raise DatabaseException("SQLite: %s" % (e))
             self._deletenodetags(n)
 
@@ -167,7 +167,7 @@ class SQLiteDatabase(Database):
                 sql += ("SELECT NODE FROM LOOKUP OUTER JOIN TAGS ON TAG = TAGS.ID"
                         + " WHERE TAGS.DATA = ? ")
 
-                params.append(cPickle.dumps(t))
+                params.append(pickle.dumps(t))
         try:
             self._cur.execute(sql, params)
 
@@ -177,13 +177,13 @@ class SQLiteDatabase(Database):
                 ids.append(row[0])
                 row = self._cur.fetchone()
             return ids
-        except sqlite.DatabaseError, e:
+        except sqlite.DatabaseError as e:
             raise DatabaseException("SQLite: %s" % (e))
 
     def _commit(self):
         try:
             self._con.commit()
-        except sqlite.DatabaseError, e:
+        except sqlite.DatabaseError as e:
             self._con.rollback()
             raise DatabaseException(
                 "SQLite: Error commiting data to db [%s]" % (e))
@@ -194,7 +194,7 @@ class SQLiteDatabase(Database):
             sql = "SELECT ID FROM TAGS WHERE DATA = ?"
             if not isinstance(t, Tag): raise DatabaseException(
                 "Tried to insert foreign object into database [%s]", t)
-            data = cPickle.dumps(t)
+            data = pickle.dumps(t)
             
             try:
                 self._cur.execute(sql, [data])
@@ -205,7 +205,7 @@ class SQLiteDatabase(Database):
                     sql = "INSERT INTO TAGS(DATA) VALUES(?)"
                     self._cur.execute(sql, [data])
                     ids.append(self._cur.lastrowid)
-            except sqlite.DatabaseError, e:
+            except sqlite.DatabaseError as e:
                 raise DatabaseException("SQLite: %s" % (e))
         return ids
 
@@ -214,7 +214,7 @@ class SQLiteDatabase(Database):
             sql = "DELETE FROM LOOKUP WHERE NODE = ?"
             self._cur.execute(sql, [node.get_id()])
             
-        except sqlite.DatabaseError, e:
+        except sqlite.DatabaseError as e:
             raise DatabaseException("SQLite: %s" % (e))
         self._commit()
         
@@ -228,7 +228,7 @@ class SQLiteDatabase(Database):
             
             try:
                 self._cur.execute(sql, params)
-            except sqlite.DatabaseError, e:
+            except sqlite.DatabaseError as e:
                 raise DatabaseException("SQLite: %s" % (e))
         self._commit()
 
@@ -236,7 +236,7 @@ class SQLiteDatabase(Database):
         try:
             sql = "DELETE FROM TAGS WHERE ID NOT IN (SELECT TAG FROM LOOKUP GROUP BY TAG)"
             self._cur.execute(sql)
-        except sqlite.DatabaseError, e:
+        except sqlite.DatabaseError as e:
             raise DatabaseException("SQLite: %s" % (e))
         self._commit()
         
@@ -263,7 +263,7 @@ class SQLiteDatabase(Database):
             
             try:
                 self._con.commit()
-            except DatabaseError, e:
+            except DatabaseError as e:
                 self._con.rollback()
                 raise e
 
@@ -273,7 +273,7 @@ class SQLiteDatabase(Database):
         self._cur.execute(sql, values)
         try:
             self._con.commit()
-        except sqlite.DatabaseError, e:
+        except sqlite.DatabaseError as e:
             self._con.rollback()
             raise DatabaseException(
                 "SQLite: Error saving key [%s]" % (e))
--- pwman/data/factory.py.orig	2007-02-04 18:44:43 UTC
+++ pwman/data/factory.py
@@ -45,19 +45,19 @@ def create(type):
         try: 
             from pwman.data.drivers import sqlite
             db = sqlite.SQLiteDatabase()
-        except ImportError, e:
+        except ImportError as e:
             raise DatabaseException("python-sqlite not installed")
     elif (type == "Postgresql"):
         try:
             from pwman.data.drivers import postgresql
             db = postgresql.PostgresqlDatabase()
-        except ImportError, e:
+        except ImportError as e:
             raise DatabaseException("python-pygresql not installed")
     elif (type == "MySQL"):
         try:
             from pwman.data.drivers import mysql
             db = mysql.MySQLDatabase()
-        except ImportError, e:
+        except ImportError as e:
             raise DatabaseException("python-mysqldb not installed")
     else:
         raise DatabaseException("Unknown database type specified")
--- pwman/ui/cli.py.orig	2007-02-04 18:44:44 UTC
+++ pwman/ui/cli.py
@@ -40,12 +40,12 @@ import traceback
 try:
     import readline
     _readline_available = True
-except ImportError, e:
+except ImportError as e:
     _readline_available = False
 
 class CLICallback(Callback):
     def getinput(self, question):
-        return raw_input(question)
+        return input(question)
     
     def getsecret(self, question):
         return getpass.getpass(question + ":")
@@ -67,19 +67,19 @@ class ANSI(object):
 class PwmanCli(cmd.Cmd):
     def error(self, exception):
         if (isinstance(exception, KeyboardInterrupt)):
-            print
+            print()
         else:
 #            traceback.print_exc()
-            print "Error: %s " % (exception)
+            print("Error: %s " % (exception))
     
     def do_EOF(self, args):
         return self.do_exit(args)
 
     def do_exit(self, args):
-        print
+        print()
         try:
             self._db.close()
-        except Exception, e:
+        except Exception as e:
             self.error(e)
         return True
 
@@ -92,8 +92,8 @@ class PwmanCli(cmd.Cmd):
             if m == None:
                 ids.append(int(i))
             else:
-                ids += range(int(m.group(1)),
-                             int(m.group(2))+1)
+                ids += list(range(int(m.group(1)),
+                             int(m.group(2))+1))
         return ids
     
     def get_filesystem_path(self, default=""):
@@ -108,7 +108,7 @@ class PwmanCli(cmd.Cmd):
             length = getinput("Password length (default 7): ", "7")
             length = int(length)
             (password, dumpme) = generator.generate_password(length, length)
-            print "New password: %s" % (password)
+            print("New password: %s" % (password))
             return password
         else:
             return password
@@ -153,30 +153,30 @@ class PwmanCli(cmd.Cmd):
         
     def print_node(self, node):
         width = str(_defaultwidth)
-        print "Node %d." % (node.get_id())
-        print ("%"+width+"s %s") % (typeset("Username:", ANSI.Red),
-                                    node.get_username())
-        print ("%"+width+"s %s") % (typeset("Password:", ANSI.Red),
-                                    node.get_password())
-        print ("%"+width+"s %s") % (typeset("Url:", ANSI.Red),
-                                    node.get_url())
-        print ("%"+width+"s %s") % (typeset("Notes:", ANSI.Red),
-                                    node.get_notes())
-        print typeset("Tags: ", ANSI.Red),
+        print("Node %d." % (node.get_id()))
+        print(("%"+width+"s %s") % (typeset("Username:", ANSI.Red),
+                                    node.get_username()))
+        print(("%"+width+"s %s") % (typeset("Password:", ANSI.Red),
+                                    node.get_password()))
+        print(("%"+width+"s %s") % (typeset("Url:", ANSI.Red),
+                                    node.get_url()))
+        print(("%"+width+"s %s") % (typeset("Notes:", ANSI.Red),
+                                    node.get_notes()))
+        print(typeset("Tags: ", ANSI.Red), end=' ')
         for t in node.get_tags():
-            print "%s " % t.get_name(),
-        print
+            print("%s " % t.get_name(), end=' ')
+        print()
 
     def do_tags(self, arg):
         tags = self._db.listtags()
         if len(tags) > 0:
             tags[0].get_name() # hack to get password request before output
-        print "Tags: ",
+        print("Tags: ", end=' ')
         if len(tags) == 0:
-            print "None",
+            print("None", end=' ')
         for t in tags:
-            print "%s " % (t.get_name()),
-        print
+            print("%s " % (t.get_name()), end=' ')
+        print()
 
     def complete_filter(self, text, line, begidx, endidx):
         strings = []
@@ -202,19 +202,19 @@ class PwmanCli(cmd.Cmd):
             self._db.filter(tags)
 
             tags = self._db.currenttags()
-            print "Current tags: ",
+            print("Current tags: ", end=' ')
             if len(tags) == 0:
-                print "None",
+                print("None", end=' ')
             for t in tags:
-                print "%s " % (t.get_name()),
-            print
-        except Exception, e:
+                print("%s " % (t.get_name()), end=' ')
+            print()
+        except Exception as e:
             self.error(e)
 
     def do_clear(self, args):
         try:
             self._db.clearfilter()
-        except Exception, e:
+        except Exception as e:
             self.error(e)
 
 
@@ -225,7 +225,7 @@ class PwmanCli(cmd.Cmd):
                 i = int(i)
                 node = self._db.getnodes([i])[0]
                 menu = CliMenu()
-                print "Editing node %d." % (i)
+                print("Editing node %d." % (i))
                 menu.add(CliMenuItem("Username", self.get_username,
                                      node.get_username,
                                      node.set_username))
@@ -244,7 +244,7 @@ class PwmanCli(cmd.Cmd):
 
                 menu.run()
                 self._db.editnode(i, node)
-            except Exception, e:
+            except Exception as e:
                 self.error(e)
 
 
@@ -263,7 +263,7 @@ class PwmanCli(cmd.Cmd):
                     type = select("Select filetype:", types)
                     imp = importer.Importer.get(type)
                     imp.import_data(self._db, i)
-        except Exception, e:
+        except Exception as e:
             self.error(e)
 
     def do_export(self, arg):
@@ -292,8 +292,8 @@ class PwmanCli(cmd.Cmd):
                 if not b:
                     return
                 exp.export_data(self._db, file, nodes)
-            print "Data exported."
-        except Exception, e:
+            print("Data exported.")
+        except Exception as e:
             self.error(e)
 
     def do_new(self, arg):
@@ -306,8 +306,8 @@ class PwmanCli(cmd.Cmd):
             tags = self.get_tags()
             node.set_tags(tags)
             self._db.addnodes([node])
-            print "Password ID: %d" % (node.get_id())
-        except Exception, e:
+            print("Password ID: %d" % (node.get_id()))
+        except Exception as e:
             self.error(e)
 
     def do_print(self, arg):
@@ -315,7 +315,7 @@ class PwmanCli(cmd.Cmd):
             try:
                 node = self._db.getnodes([i])
                 self.print_node(node[0])
-            except Exception, e:
+            except Exception as e:
                 self.error(e)
 
     def do_rm(self, arg):
@@ -330,8 +330,8 @@ class PwmanCli(cmd.Cmd):
                               % (n.get_username(), n.get_url()), False)
                  if b == True:
                      self._db.removenodes([n])
-                     print "%s@%s deleted" % (n.get_username(), n.get_url())
-         except Exception, e:
+                     print("%s@%s deleted" % (n.get_username(), n.get_url()))
+         except Exception as e:
              self.error(e)
 
     def do_ls(self, args):
@@ -359,28 +359,28 @@ class PwmanCli(cmd.Cmd):
                 if len(tagstring) > 20:
                     tagstring = tagstring[:17] + "..."
                     
-                print typeset("%5d. %-30s %-20s" % (n.get_id(), name, tagstring),
-                              ANSI.Yellow, False)
+                print(typeset("%5d. %-30s %-20s" % (n.get_id(), name, tagstring),
+                              ANSI.Yellow, False))
                 i += 1
                 if i > 23:
                     i = 0
                     c = getonechar("Press <Space> for more, or 'Q' to cancel")
                     if c == 'q':
                         break
-        except Exception, e:
+        except Exception as e:
             self.error(e)
 
     def do_forget(self, args):
         try:
             enc = CryptoEngine.get()
             enc.forget()
-        except Exception,e:
+        except Exception as e:
             self.error(e)
             
     def do_passwd(self, args):
         try:
             self._db.changepassword()
-        except Exception, e:
+        except Exception as e:
             self.error(e)
 
     def do_set(self, args):
@@ -388,29 +388,29 @@ class PwmanCli(cmd.Cmd):
         try:
             if len(argstrs) == 0:
                 conf = config.get_conf()
-                for s in conf.keys():
-                    for n in conf[s].keys():
-                        print "%s.%s = %s" % (s, n, conf[s][n])
+                for s in list(conf.keys()):
+                    for n in list(conf[s].keys()):
+                        print("%s.%s = %s" % (s, n, conf[s][n]))
             elif len(argstrs) == 1:
                 r = re.compile("(.+)\.(.+)")
                 m = r.match(argstrs[0])
                 if m is None or len(m.groups()) != 2:
-                    print "Invalid option format"
+                    print("Invalid option format")
                     self.help_set()
                     return
-                print "%s.%s = %s" % (m.group(1), m.group(2),
-                                      config.get_value(m.group(1), m.group(2)))
+                print("%s.%s = %s" % (m.group(1), m.group(2),
+                                      config.get_value(m.group(1), m.group(2))))
             elif len(argstrs) == 2:
                 r = re.compile("(.+)\.(.+)")
                 m = r.match(argstrs[0])
                 if m is None or len(m.groups()) != 2:
-                    print "Invalid option format"
+                    print("Invalid option format")
                     self.help_set()
                     return
                 config.set_value(m.group(1), m.group(2), argstrs[1])
             else:
                 self.help_set()
-        except Exception, e:
+        except Exception as e:
             self.error(e)
 
     def do_save(self, args):
@@ -420,103 +420,103 @@ class PwmanCli(cmd.Cmd):
                 config.save(argstrs[0])
             else:
                 config.save()
-            print "Config saved."
-        except Exception, e:
+            print("Config saved.")
+        except Exception as e:
             self.error(e)
     
     ##
     ## Help functions
     ##
     def usage(self, string):
-        print "Usage: %s" % (string)
+        print("Usage: %s" % (string))
         
     def help_ls(self):
         self.help_list()
         
     def help_list(self):
         self.usage("list")
-        print "List nodes that match current filter. ls is an alias."
+        print("List nodes that match current filter. ls is an alias.")
 
     def help_EOF(self):
         self.help_quit()
 
     def help_delete(self):
         self.usage("delete <ID> ...")
-        print "Deletes nodes. rm is an alias."
+        print("Deletes nodes. rm is an alias.")
         self._mult_id_help()
 
     def help_help(self):
         self.usage("help [topic]")
-        print "Prints a help message for a command."
+        print("Prints a help message for a command.")
     
     def help_edit(self):
         self.usage("edit <ID> ... ")
-        print "Edits a nodes."
+        print("Edits a nodes.")
         self._mult_id_help()
     
     def help_import(self):
         self.usage("import [filename] ...")
-        print "Imports a nodes from a file."
+        print("Imports a nodes from a file.")
 
     def help_export(self):
         self.usage("export <ID> ... ")
-        print "Exports a list of ids to an external format. If no IDs are specified, then all nodes under the current filter are exported."
+        print("Exports a list of ids to an external format. If no IDs are specified, then all nodes under the current filter are exported.")
         self._mult_id_help()
         
     def help_new(self):
         self.usage("new")
-        print "Creates a new node."
+        print("Creates a new node.")
     
     def help_rm(self):
         self.help_delete()
     
     def help_print(self):
         self.usage("print <ID> ...")
-        print "Displays a node. ",
+        print("Displays a node. ", end=' ')
         self._mult_id_help()
 
     def _mult_id_help(self):
-        print "Multiple ids can be specified, separated by a space. A range of ids can be specified in the format n-N. e.g. 10-20 would specify all ids from 10 to 20 inclusive."
+        print("Multiple ids can be specified, separated by a space. A range of ids can be specified in the format n-N. e.g. 10-20 would specify all ids from 10 to 20 inclusive.")
     
     def help_exit(self):
         self.usage("exit")
-        print "Exits the application."
+        print("Exits the application.")
 
     def help_save(self):
         self.usage("save [filename]")
-        print "Saves the current configuration to [filename]. If no filename is given, the configuration is saved to the file from which the initial configuration was loaded."
+        print("Saves the current configuration to [filename]. If no filename is given, the configuration is saved to the file from which the initial configuration was loaded.")
 
     def help_set(self):
         self.usage("set [configoption] [value]")
-        print "Sets a configuration option. If no value is specified, the current value for [configoption] is output. If neither [configoption] nor [value] are specified, the whole current configuration is output. [configoption] must be of the format <section>.<option>"
+        print("Sets a configuration option. If no value is specified, the current value for [configoption] is output. If neither [configoption] nor [value] are specified, the whole current configuration is output. [configoption] must be of the format <section>.<option>")
         
     def help_ls(self):
         self.help_list()
     
     def help_passwd(self):
         self.usage("passwd")
-        print "Changes the password on the database. "
+        print("Changes the password on the database. ")
 
     def help_forget(self):
         self.usage("forget")
-        print "Forgets the database password. Your password will need to be reentered before accessing the database again."
+        print("Forgets the database password. Your password will need to be reentered before accessing the database again.")
 
     def help_clear(self):
         self.usage("clear")
-        print "Clears the filter criteria. "
+        print("Clears the filter criteria. ")
 
     def help_filter(self):
         self.usage("filter <tag> ...")
-        print "Filters nodes on tag. Arguments can be zero or more tags. Displays current tags if called without arguments."
+        print("Filters nodes on tag. Arguments can be zero or more tags. Displays current tags if called without arguments.")
 
     def help_tags(self):
         self.usage("tags")
-        print "Displays all tags in used in the database."
+        print("Displays all tags in used in the database.")
         
     def postloop(self):
         try:
             readline.write_history_file(self._historyfile)
-        except Exception, e:
+        except Exception as e:
             pass
     
     def __init__(self, db):
@@ -530,13 +530,13 @@ class PwmanCli(cmd.Cmd):
             enc.set_callback(CLICallback())
             self._db = db
             self._db.open()
-        except Exception, e:
+        except Exception as e:
             self.error(e)
             sys.exit(1)
 
         try:
             readline.read_history_file(self._historyfile)
-        except Exception, e:
+        except Exception as e:
             pass
         
         _colors = True
@@ -549,7 +549,7 @@ _colors = True
 
 def getonechar(question, width=_defaultwidth):
     question = "%s " % (question)
-    print question.ljust(width),
+    print(question.ljust(width), end=' ')
     sys.stdout.flush()
         
     fd = sys.stdin.fileno()
@@ -559,7 +559,7 @@ def getonechar(question, width=_defaultwidth):
         ch = os.read(fd, 1)
     finally:
         tty.tcsetattr(fd, tty.TCSAFLUSH, tty_mode)
-    print ch
+    print(ch)
     return ch
     
 def getyesno(question, defaultyes=False, width=_defaultwidth):
@@ -583,14 +583,14 @@ def getyesno(question, defaultyes=False, width=_defaul
 
 def getinput(question, default="", completer=None, width=_defaultwidth):
     if (not _readline_available):
-        return raw_input(question.ljust(width))
+        return input(question.ljust(width))
     else:
         def defaulter(): readline.insert_text(default)
         readline.set_startup_hook(defaulter)
         oldcompleter = readline.get_completer()
         readline.set_completer(completer)
         
-        x = raw_input(question.ljust(width))
+        x = input(question.ljust(width))
 
         readline.set_completer(oldcompleter)
         readline.set_startup_hook()
@@ -598,7 +598,7 @@ def getinput(question, default="", completer=None, wid
 
 def getpassword(question, width=_defaultwidth, echo=False):
     if echo:
-        print question.ljust(width),
+        print(question.ljust(width), end=' ')
         return sys.stdin.readline().rstrip()
     else:
         return getpass.getpass(question.ljust(width))
@@ -619,7 +619,7 @@ def typeset(text, color, bold=False, underline=False):
 
 def select(question, possible):
     for i in range(0, len(possible)):
-        print ("%d - %-"+str(_defaultwidth)+"s") % (i+1, possible[i])
+        print(("%d - %-"+str(_defaultwidth)+"s") % (i+1, possible[i]))
     while 1:
         input = getonechar(question)
         if input.isdigit() and int(input) in range(1, len(possible)+1):
@@ -633,7 +633,7 @@ class CliMenu(object):
         if (isinstance(item, CliMenuItem)):
             self.items.append(item)
         else:
-            print item.__class__
+            print(item.__class__)
 
     def run(self):
         while True:
@@ -648,9 +648,9 @@ class CliMenu(object):
                 else:
                     currentstr = current
                     
-                print ("%d - %-"+str(_defaultwidth)+"s %s") % (i, x.name+":",
-                                                               currentstr)
-            print "%c - Finish editing" % ('X')
+                print(("%d - %-"+str(_defaultwidth)+"s %s") % (i, x.name+":",
+                                                               currentstr))
+            print("%c - Finish editing" % ('X'))
             option = getonechar("Enter your choice:")
             try:
                 # substract 1 because array subscripts start at 1
@@ -660,7 +660,7 @@ class CliMenu(object):
             except (ValueError,IndexError):
                 if (option.upper() == 'X'):
                     break
-                print "Invalid selection"
+                print("Invalid selection")
                 
 class CliMenuItem(object):
     def __init__(self, name, editor, getter, setter):
--- pwman/util/config.py.orig	2007-02-04 18:44:44 UTC
+++ pwman/util/config.py
@@ -17,7 +17,7 @@
 # Copyright (C) 2006 Ivan Kelly <ivan@ivankelly.net>
 #============================================================================
 
-from ConfigParser import ConfigParser,ParsingError
+from configparser import ConfigParser,ParsingError
 import copy
 
 class ConfigException(Exception):
@@ -41,17 +41,17 @@ def set_defaults(defaults):
 
 def add_defaults(defaults):
     global _defaults
-    for n in defaults.keys():
-        if not _defaults.has_key(n):
+    for n in list(defaults.keys()):
+        if n not in _defaults:
             _defaults[n] = dict()
-        for k in defaults[n].keys():
+        for k in list(defaults[n].keys()):
             _defaults[n][k] = defaults[n][k]
     
 def get_value(section, name):
     global _conf, _defaults
     try:
         return _conf[section][name]
-    except KeyError, e:
+    except KeyError as e:
         pass
     
     try:
@@ -59,14 +59,14 @@ def get_value(section, name):
         set_value(section, name, value)
         return value
     
-    except KeyError, e:
+    except KeyError as e:
         pass
     
     return ''
 
 def set_value(section, name, value):
     global _conf
-    if not _conf.has_key(section):
+    if section not in _conf:
         _conf[section] = dict()
     _conf[section][name] = value
 
@@ -88,9 +88,9 @@ def load(filename):
         try:
             fp = file(filename, "r")
             res = parser.readfp(fp)
-        except ParsingError,e:
+        except ParsingError as e:
             raise ConfigException(e)
-        except IOError, e:
+        except IOError as e:
             raise ConfigNoConfigException(e)
     finally:
         if (fp):
@@ -107,18 +107,18 @@ def save(filename=None):
         filename = _file
         
     parser = ConfigParser()
-    for key in _conf.keys():
+    for key in list(_conf.keys()):
         if not parser.has_section(key):
             parser.add_section(key)
         sectiondict = _conf[key]
         if (type(sectiondict) == dict):
-            for optionkey in sectiondict.keys():
+            for optionkey in list(sectiondict.keys()):
                 parser.set(key, optionkey, sectiondict[optionkey])
     try:
         fp = file(filename, "w+")
         parser.write(fp)
         fp.close()
-    except IOError, e:
+    except IOError as e:
         raise ConfigException(str(e))