Skip to content

Commit ae173ee

Browse files
committed
Use collections.abc on Python 3
Signed-off-by: Christian Heimes <[email protected]>
1 parent 40f350f commit ae173ee

File tree

5 files changed

+31
-12
lines changed

5 files changed

+31
-12
lines changed

gssapi/names.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
import collections
2-
31
import six
42

53
from gssapi.raw import names as rname
64
from gssapi.raw import NameType
75
from gssapi.raw import named_tuples as tuples
86
from gssapi import _utils
97

8+
if six.PY3:
9+
from collections.abc import MutableMapping, Iterable
10+
else:
11+
from collections import MutableMapping, Iterable
12+
1013
rname_rfc6680 = _utils.import_gssapi_extension('rfc6680')
1114
rname_rfc6680_comp_oid = _utils.import_gssapi_extension('rfc6680_comp_oid')
1215

@@ -313,7 +316,7 @@ def attributes(self):
313316
return self._attr_obj
314317

315318

316-
class _NameAttributeMapping(collections.MutableMapping):
319+
class _NameAttributeMapping(MutableMapping):
317320

318321
"""Provides dict-like access to RFC 6680 Name attributes."""
319322
def __init__(self, name):
@@ -345,7 +348,7 @@ def __setitem__(self, key, value):
345348
complete = False
346349

347350
if (isinstance(value, (six.string_types, bytes)) or
348-
not isinstance(value, collections.Iterable)):
351+
not isinstance(value, Iterable)):
349352
# NB(directxman12): this allows us to easily assign a single
350353
# value, since that's a common case
351354
value = [value]

gssapi/raw/ext_dce.pyx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,18 @@ from gssapi.raw.sec_contexts cimport SecurityContext
99
from gssapi.raw.misc import GSSError
1010
from gssapi.raw import types as gssapi_types
1111
from gssapi.raw.named_tuples import IOVUnwrapResult, WrapResult, UnwrapResult
12-
from collections import namedtuple, Sequence
12+
from collections import namedtuple
1313

1414
from enum import IntEnum
1515
import six
1616
from gssapi.raw._enum_extensions import ExtendableEnum
1717

18+
if six.PY3:
19+
from collections.abc import Sequence
20+
else:
21+
from collections import Sequence
22+
23+
1824
cdef extern from "python_gssapi_ext.h":
1925
# NB(directxman12): this wiki page has a different argument order
2026
# than the header file, and uses size_t instead of int

gssapi/raw/types.pyx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ import numbers
1313
import operator
1414
import six
1515

16+
if six.PY3:
17+
from collections.abc import MutableSet
18+
else:
19+
from collections import MutableSet
20+
1621

1722
class NameType(object):
1823
"""
@@ -106,7 +111,7 @@ class MechType(object):
106111
# these are added in by the individual mechanism files on import
107112

108113

109-
class GenericFlagSet(collections.MutableSet):
114+
class GenericFlagSet(MutableSet):
110115
"""A set backed by a 32-bit integer
111116
112117
This is a set backed by a 32 bit integer.

gssapi/tests/test_raw.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
1-
import collections
21
import copy
32
import os
43
import socket
54
import unittest
65

6+
import six
77
import should_be.all # noqa
88

99
import gssapi.raw as gb
1010
import gssapi.raw.misc as gbmisc
1111
import k5test.unit as ktu
1212
import k5test as kt
1313

14+
if six.PY3:
15+
from collections.abc import Set
16+
else:
17+
from collections import Set
18+
1419

1520
TARGET_SERVICE_NAME = b'host'
1621
FQDN = socket.getfqdn().encode('utf-8')
@@ -355,7 +360,7 @@ def test_inquire_context(self):
355360
mech_type.should_be(gb.MechType.kerberos)
356361

357362
flags.shouldnt_be_none()
358-
flags.should_be_a(collections.Set)
363+
flags.should_be_a(Set)
359364
flags.shouldnt_be_empty()
360365

361366
local_est.should_be_a(bool)
@@ -1084,7 +1089,7 @@ def test_basic_init_default_ctx(self):
10841089

10851090
out_mech_type.should_be(gb.MechType.kerberos)
10861091

1087-
out_req_flags.should_be_a(collections.Set)
1092+
out_req_flags.should_be_a(Set)
10881093
out_req_flags.should_be_at_least_length(2)
10891094

10901095
out_token.shouldnt_be_empty()
@@ -1139,7 +1144,7 @@ def test_basic_accept_context_no_acceptor_creds(self):
11391144

11401145
out_token.shouldnt_be_empty()
11411146

1142-
out_req_flags.should_be_a(collections.Set)
1147+
out_req_flags.should_be_a(Set)
11431148
out_req_flags.should_be_at_least_length(2)
11441149

11451150
out_ttl.should_be_greater_than(0)
@@ -1167,7 +1172,7 @@ def test_basic_accept_context(self):
11671172

11681173
out_token.shouldnt_be_empty()
11691174

1170-
out_req_flags.should_be_a(collections.Set)
1175+
out_req_flags.should_be_a(Set)
11711176
out_req_flags.should_be_at_least_length(2)
11721177

11731178
out_ttl.should_be_greater_than(0)

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# and then run "tox" from this directory.
55

66
[tox]
7-
envlist = py27,py33,py34,py35
7+
envlist = py27,py33,py34,py35,py36,py37
88

99
[testenv]
1010
whitelist_externals=bash

0 commit comments

Comments
 (0)