Merge ~mitya57/compiz:lp1816629 into compiz:master

Proposed by Dmitry Shachnev
Status: Merged
Approved by: Dmitry Shachnev
Approved revision: 39970fab6a68d39ea17bc5dee8050ce6d10ee0b4
Merged at revision: 9527c55642a2f5f3934663e1b11481f0d1b39c20
Proposed branch: ~mitya57/compiz:lp1816629
Merge into: compiz:master
Diff against target: 112 lines (+17/-16)
1 file modified
compizconfig/compizconfig-python/src/compizconfig.pyx (+17/-16)
Reviewer Review Type Date Requested Status
Alberts Muktupāvels Approve
Marco Trevisan (Treviño) Pending
Compiz Maintainers Pending
Review via email: mp+363377@code.launchpad.net

Commit message

ccsm: Fix UnicodeDecodeError caused by non-ASCII plugin descriptions.

Description of the change

ccsm: Fix UnicodeDecodeError caused by non-ASCII plugin descriptions.

To post a comment you must log in.
Revision history for this message
Alberts Muktupāvels (muktupavels) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/compizconfig/compizconfig-python/src/compizconfig.pyx b/compizconfig/compizconfig-python/src/compizconfig.pyx
2index 79d6362..60e5301 100644
3--- a/compizconfig/compizconfig-python/src/compizconfig.pyx
4+++ b/compizconfig/compizconfig-python/src/compizconfig.pyx
5@@ -1,4 +1,5 @@
6-# cython: c_string_type=str, c_string_encoding=ascii, language_level=3
7+# cython: c_string_type=str, c_string_encoding=utf8, language_level=3
8+
9 '''
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU Lesser General Public License
12@@ -471,9 +472,9 @@ cdef CCSSettingValue * EncodeValue (object data,
13 else:
14 t = ccsSettingGetType (setting)
15 if t == TypeString:
16- bv.value.asString = strdup (data)
17+ bv.value.asString = strdup (data.encode ("utf-8"))
18 elif t == TypeMatch:
19- bv.value.asMatch = strdup (data)
20+ bv.value.asMatch = strdup (data.encode ("utf-8"))
21 elif t == TypeInt:
22 bv.value.asInt = data
23 elif t == TypeFloat:
24@@ -489,11 +490,11 @@ cdef CCSSettingValue * EncodeValue (object data,
25 bv.value.asColor.color.blue = data[2]
26 bv.value.asColor.color.alpha = data[3]
27 elif t == TypeKey:
28- ccsStringToKeyBinding (data, &bv.value.asKey)
29+ ccsStringToKeyBinding (data.encode ("utf-8"), &bv.value.asKey)
30 elif t == TypeButton:
31- ccsStringToButtonBinding (data, &bv.value.asButton)
32+ ccsStringToButtonBinding (data.encode ("utf-8"), &bv.value.asButton)
33 elif t == TypeEdge:
34- bv.value.asEdge = ccsStringToEdges (data)
35+ bv.value.asEdge = ccsStringToEdges (data.encode ("utf-8"))
36 elif t == TypeBell:
37 if (data):
38 bv.value.asBell = 1
39@@ -591,7 +592,7 @@ cdef class Setting:
40 cdef CCSSettingType t
41 cdef CCSSettingInfo * i
42
43- self.ccsSetting = ccsFindSetting (plugin.ccsPlugin, name)
44+ self.ccsSetting = ccsFindSetting (plugin.ccsPlugin, name.encode ("utf-8"))
45 self.plugin = plugin
46
47 self.extendedStrRestrictions = None
48@@ -717,7 +718,7 @@ cdef class Plugin:
49 cdef object hasExtendedString
50
51 def __cinit__ (self, Context context, name):
52- self.ccsPlugin = ccsFindPlugin (context.ccsContext, name)
53+ self.ccsPlugin = ccsFindPlugin (context.ccsContext, name.encode ("utf-8"))
54 self.context = context
55 self.screen = {}
56 self.groups = {}
57@@ -1037,7 +1038,7 @@ cdef class Profile:
58
59 def __cinit__ (self, Context context, name):
60 self.context = context
61- self.name = strdup (name)
62+ self.name = strdup (name.encode ("utf-8"))
63
64 def __dealloc__ (self):
65 free (self.name)
66@@ -1059,9 +1060,9 @@ cdef class Backend:
67
68 def __cinit__ (self, Context context, info):
69 self.context = context
70- self.name = strdup (info[0])
71- self.shortDesc = strdup (info[1])
72- self.longDesc = strdup (info[2])
73+ self.name = strdup (info[0].encode ("utf-8"))
74+ self.shortDesc = strdup (info[1].encode ("utf-8"))
75+ self.longDesc = strdup (info[2].encode ("utf-8"))
76 self.profileSupport = bool (info[3])
77 self.integrationSupport = bool (info[4])
78
79@@ -1226,13 +1227,13 @@ cdef class Context:
80 ccsReadSettings (self.ccsContext)
81
82 def Import (self, path, autoSave = True):
83- ret = bool (ccsImportFromFile (self.ccsContext, path, True))
84+ ret = bool (ccsImportFromFile (self.ccsContext, path.encode ("utf-8"), True))
85 if autoSave:
86 ccsWriteSettings (self.ccsContext)
87 return ret
88
89 def Export (self, path, skipDefaults = False):
90- return bool (ccsExportToFile (self.ccsContext, path, skipDefaults))
91+ return bool (ccsExportToFile (self.ccsContext, path.encode ("utf-8"), skipDefaults))
92
93 property Plugins:
94 def __get__ (self):
95@@ -1247,7 +1248,7 @@ cdef class Context:
96 return self.currentProfile
97 def __set__ (self, profile):
98 self.currentProfile = profile
99- ccsSetProfile (self.ccsContext, profile.Name)
100+ ccsSetProfile (self.ccsContext, profile.Name.encode ("utf-8"))
101 ccsReadSettings (self.ccsContext)
102
103 property Profiles:
104@@ -1259,7 +1260,7 @@ cdef class Context:
105 return self.currentBackend
106 def __set__ (self, backend):
107 self.currentBackend = backend
108- ccsSetBackend (self.ccsContext, backend.Name)
109+ ccsSetBackend (self.ccsContext, backend.Name.encode ("utf-8"))
110 ccsReadSettings (self.ccsContext)
111
112 property Backends:

Subscribers

People subscribed via source and target branches