/mandos/trunk

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/trunk

« back to all changes in this revision

Viewing changes to mandos

  • Committer: Teddy Hogeborn
  • Date: 2020-02-06 15:56:51 UTC
  • Revision ID: teddy@recompile.se-20200206155651-kx7r39zj8hpv8udl
Use collections.abc.Callable instead of collections.Callable

In Python 3.7, collections.Callable (among others) was moved to
collections.abc.Callable, and its old location deprecated.

* mandos: Create "collections.abc.Callable" if it does not exist, and
  only use the new name.

Show diffs side-by-side

added added

removed removed

Lines of Context:
78
78
import collections
79
79
import codecs
80
80
import unittest
 
81
import random
81
82
 
82
83
import dbus
83
84
import dbus.service
91
92
 
92
93
if sys.version_info.major == 2:
93
94
    __metaclass__ = type
 
95
    str = unicode
 
96
 
 
97
# Add collections.abc.Callable if it does not exist
 
98
try:
 
99
    collections.abc.Callable
 
100
except AttributeError:
 
101
    class abc:
 
102
        Callable = collections.Callable
 
103
    collections.abc = abc
 
104
    del abc
94
105
 
95
106
# Show warnings by default
96
107
if not sys.warnoptions:
122
133
            # No value found
123
134
            SO_BINDTODEVICE = None
124
135
 
125
 
if sys.version_info.major == 2:
126
 
    str = unicode
127
 
 
128
136
if sys.version_info < (3, 2):
129
137
    configparser.Configparser = configparser.SafeConfigParser
130
138
 
1037
1045
        if self.checker_initiator_tag is not None:
1038
1046
            GLib.source_remove(self.checker_initiator_tag)
1039
1047
        self.checker_initiator_tag = GLib.timeout_add(
1040
 
            int(self.interval.total_seconds() * 1000),
 
1048
            random.randrange(int(self.interval.total_seconds() * 1000
 
1049
                                 + 1)),
1041
1050
            self.start_checker)
1042
1051
        # Schedule a disable() when 'timeout' has passed
1043
1052
        if self.disable_initiator_tag is not None:
1413
1422
                raise ValueError("Byte arrays not supported for non-"
1414
1423
                                 "'ay' signature {!r}"
1415
1424
                                 .format(prop._dbus_signature))
1416
 
            value = dbus.ByteArray(b''.join(chr(byte)
1417
 
                                            for byte in value))
 
1425
            value = dbus.ByteArray(bytes(value))
1418
1426
        prop(value)
1419
1427
 
1420
1428
    @dbus.service.method(dbus.PROPERTIES_IFACE,
2749
2757
        if command == 'getattr':
2750
2758
            attrname = request[1]
2751
2759
            if isinstance(client_object.__getattribute__(attrname),
2752
 
                          collections.Callable):
 
2760
                          collections.abc.Callable):
2753
2761
                parent_pipe.send(('function', ))
2754
2762
            else:
2755
2763
                parent_pipe.send((