#327 info/infosssd: Work around breakage in dbus-python on Python 3.8+
Merged a year ago by simo. Opened a year ago by ngompa.
ngompa/ipsilon fix-infosssd-py38  into  master

file modified
+14 -6
@@ -57,6 +57,14 @@ 

                  False),

          )

  

+     # utility function to unwrap dbus.String to String

+     # but if it's already not a dbus.String, just pass through

+     def _unwrap_dbus_str(self, dbus_string):

+          if isinstance(dbus_string, dbus.String):

+              return str(dbus_string)

+          else:

+              return dbus_string

+ 

      def _get_user_data(self, user):

          reply = dict()

          groups = []
@@ -77,10 +85,10 @@ 

                                         user_path)

  

          # Get GECOS, attributes, and groups

-         reply['gecos'] = user_obj.Get(

+         reply['gecos'] = self._unwrap_dbus_str(user_obj.Get(

              'org.freedesktop.sssd.infopipe.Users.User',

              'gecos',

-             dbus_interface=dbus.PROPERTIES_IFACE)

+             dbus_interface=dbus.PROPERTIES_IFACE))

          user_attrs = user_obj.Get('org.freedesktop.sssd.infopipe.Users.User',

                                    'extraAttributes',

                                    dbus_interface=dbus.PROPERTIES_IFACE)
@@ -89,16 +97,16 @@ 

              dbus_interface='org.freedesktop.sssd.infopipe')

  

          for group in user_groups:

-             groups.append(group)

+             groups.append(self._unwrap_dbus_str(group))

  

          for attr_name in user_attrs:

-             attr_name = attr_name

+             attr_name = self._unwrap_dbus_str(attr_name)

              if len(user_attrs[attr_name]) == 1:

-                 reply[attr_name] = user_attrs[attr_name][0]

+                 reply[attr_name] = self._unwrap_dbus_str(user_attrs[attr_name][0])

              else:

                  reply[attr_name] = []

                  for attr_val in user_attrs[attr_name]:

-                     reply[attr_name].append(attr_val)

+                     reply[attr_name].append(self._unwrap_dbus_str(attr_val))

  

          return reply, groups

  

In Python 3.8+, dbus-python now returns dbus.String instead of
regular strings when stringify repr is called. This bug has
been reported upstream, but for now, we work around it...

Signed-off-by: Neal Gompa ngompa13@gmail.com

rebased onto a1ff5b3

a year ago

Pull-Request has been merged by simo

a year ago
Metadata