Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Mar 25, 2025. It is now read-only.

Commit f22f421

Browse filesBrowse files
committed
Drop support for Python 2 and 3.3
This simplifies the code slightly, reduces the number of dependencies and otherwise speeds up the CI process. If someone *really* needs to use really old Python they have the option of using older versions of the package.
1 parent 6ad04a5 commit f22f421
Copy full SHA for f22f421

File tree

Expand file treeCollapse file tree

9 files changed

+40
-55
lines changed
Filter options
Expand file treeCollapse file tree

9 files changed

+40
-55
lines changed

‎.travis.yml

Copy file name to clipboardExpand all lines: .travis.yml
+1-4Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
language: python
22
python:
3-
- "2.7"
4-
- "3.3"
53
- "3.4"
64
- "3.5"
75
- "3.6"
8-
- "pypy"
9-
- "pypy3.3-5.2-alpha1"
6+
- "pypy3.5-5.8.0"
107
matrix:
118
fast_finish: true
129
install:

‎README.rst

Copy file name to clipboardExpand all lines: README.rst
+8-5Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,8 @@ Compared to some other Zeroconf/Bonjour/Avahi Python packages, python-zeroconf:
4343
Python compatibility
4444
--------------------
4545

46-
* CPython 2.7, 3.3+
47-
* PyPy 2.2+ (possibly 1.9-2.1 as well)
48-
* PyPy3 2.4+
46+
* CPython 3.4+
47+
* PyPy3 5.8+
4948

5049
Versioning
5150
----------
@@ -82,11 +81,10 @@ Here's an example of browsing for a service:
8281

8382
.. code-block:: python
8483
85-
from six.moves import input
8684
from zeroconf import ServiceBrowser, Zeroconf
8785
8886
89-
class MyListener(object):
87+
class MyListener:
9088
9189
def remove_service(self, zeroconf, type, name):
9290
print("Service %s removed" % (name,))
@@ -122,6 +120,11 @@ See examples directory for more.
122120
Changelog
123121
=========
124122

123+
0.20.0
124+
------
125+
126+
* Dropped support for Python 2 (this includes PyPy) and 3.3
127+
125128
0.19.1
126129
------
127130

‎examples/browser.py

Copy file name to clipboardExpand all lines: examples/browser.py
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#!/usr/bin/env python
2-
from __future__ import absolute_import, division, print_function, unicode_literals
1+
#!/usr/bin/env python3
32

43
""" Example of browsing for a service (in this case, HTTP) """
54

‎examples/registration.py

Copy file name to clipboardExpand all lines: examples/registration.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22

33
""" Example of announcing a service (in this case, a fake HTTP server) """
44

‎examples/self_test.py

Copy file name to clipboardExpand all lines: examples/self_test.py
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#!/usr/bin/env python
2-
from __future__ import absolute_import, division, print_function, unicode_literals
1+
#!/usr/bin/env python3
32

43
import logging
54
import socket

‎requirements-dev.txt

Copy file name to clipboard
-3Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
autopep8
22
coveralls
33
coverage
4-
enum34
54
# Upper bound because of https://github.com/PyCQA/flake8-import-order/issues/79
65
flake8<3
76
flake8-blind-except
87
# Upper bound because of https://github.com/public/flake8-import-order/issues/42
98
flake8-import-order>=0.4.0, <0.6.0
10-
mock
119
# See setup.py comment for why this version is restricted
1210
netifaces!=0.10.5
1311
nose
1412
pep8==1.5.7
1513
pep8-naming
16-
six

‎setup.py

Copy file name to clipboardExpand all lines: setup.py
+1-5Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
#!/usr/bin/env python
2-
from __future__ import absolute_import, division, print_function
3-
1+
#!/usr/bin/env python3
42
from io import open
53

64
from os.path import abspath, dirname, join
@@ -55,12 +53,10 @@
5553
'mDNS',
5654
],
5755
install_requires=[
58-
'enum-compat',
5956
# netifaces 0.10.5 has a bug that results in all interfaces' netmasks
6057
# to be 255.255.255.255 on Windows which breaks things. See:
6158
# * https://github.com/jstasiak/python-zeroconf/issues/84
6259
# * https://bitbucket.org/al45tair/netifaces/issues/39/netmask-is-always-255255255255
6360
'netifaces!=0.10.5',
64-
'six',
6561
],
6662
)

‎test_zeroconf.py

Copy file name to clipboardExpand all lines: test_zeroconf.py
+6-9Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
import unittest
1313
from threading import Event
1414

15-
from six import indexbytes
16-
from six.moves import xrange
17-
1815
import zeroconf as r
1916
from zeroconf import (
2017
DNSHinfo,
@@ -189,19 +186,19 @@ def test_transaction_id(self):
189186
"""ID must be zero in a DNS-SD packet"""
190187
generated = r.DNSOutgoing(r._FLAGS_QR_QUERY)
191188
bytes = generated.packet()
192-
id = indexbytes(bytes, 0) << 8 | indexbytes(bytes, 1)
189+
id = bytes[0] << 8 | bytes[1]
193190
self.assertEqual(id, 0)
194191

195192
def test_query_header_bits(self):
196193
generated = r.DNSOutgoing(r._FLAGS_QR_QUERY)
197194
bytes = generated.packet()
198-
flags = indexbytes(bytes, 2) << 8 | indexbytes(bytes, 3)
195+
flags = bytes[2] << 8 | bytes[3]
199196
self.assertEqual(flags, 0x0)
200197

201198
def test_response_header_bits(self):
202199
generated = r.DNSOutgoing(r._FLAGS_QR_RESPONSE)
203200
bytes = generated.packet()
204-
flags = indexbytes(bytes, 2) << 8 | indexbytes(bytes, 3)
201+
flags = bytes[2] << 8 | bytes[3]
205202
self.assertEqual(flags, 0x8000)
206203

207204
def test_numbers(self):
@@ -217,7 +214,7 @@ def test_numbers(self):
217214
def test_numbers_questions(self):
218215
generated = r.DNSOutgoing(r._FLAGS_QR_RESPONSE)
219216
question = r.DNSQuestion("testname.local.", r._TYPE_SRV, r._CLASS_IN)
220-
for i in xrange(10):
217+
for i in range(10):
221218
generated.add_question(question)
222219
bytes = generated.packet()
223220
(numQuestions, numAnswers, numAuthorities,
@@ -316,7 +313,7 @@ def on_service_state_change(zeroconf, service_type, state_change, name):
316313
assert longest_packet[0] >= r._MAX_MSG_ABSOLUTE - 100
317314

318315
# mock zeroconf's logger warning() and debug()
319-
from mock import patch
316+
from unittest.mock import patch
320317
patch_warn = patch('zeroconf.log.warning')
321318
patch_debug = patch('zeroconf.log.debug')
322319
mocked_log_warn = patch_warn.start()
@@ -622,7 +619,7 @@ def test_integration_with_listener_class(self):
622619
name = "xxxyyy"
623620
registration_name = "%s.%s" % (name, type_)
624621

625-
class MyListener(object):
622+
class MyListener:
626623
def add_service(self, zeroconf, type, name):
627624
zeroconf.get_service_info(type, name)
628625
service_added.set()

‎zeroconf.py

Copy file name to clipboardExpand all lines: zeroconf.py
+21-24Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
from __future__ import (
2-
absolute_import, division, print_function, unicode_literals)
3-
41
""" Multicast DNS Service Discovery for Python, v0.14-wmcbrine
52
Copyright 2003 Paul Scott-Murphy, 2014 William McBrine
63
@@ -36,8 +33,6 @@
3633
from functools import reduce
3734

3835
import netifaces
39-
from six import binary_type, indexbytes, int2byte, iteritems, text_type
40-
from six.moves import xrange
4136

4237
__author__ = 'Paul Scott-Murphy, William McBrine'
4338
__maintainer__ = 'Jakub Stasiak <jakub@stasiak.at>'
@@ -151,6 +146,8 @@
151146
_HAS_ONLY_A_TO_Z_NUM_HYPHEN = re.compile(r'^[A-Za-z0-9\-]+$')
152147
_HAS_ASCII_CONTROL_CHARS = re.compile(r'[\x00-\x1f\x7f]')
153148

149+
int2byte = struct.Struct(">B").pack
150+
154151

155152
@enum.unique
156153
class InterfaceChoice(enum.Enum):
@@ -309,7 +306,7 @@ class BadTypeInNameException(Error):
309306
# implementation classes
310307

311308

312-
class QuietLogger(object):
309+
class QuietLogger:
313310
_seen_logs = {}
314311

315312
@classmethod
@@ -338,7 +335,7 @@ def log_warning_once(cls, *args):
338335
logger(*args)
339336

340337

341-
class DNSEntry(object):
338+
class DNSEntry:
342339

343340
"""A DNS entry"""
344341

@@ -666,7 +663,7 @@ def read_header(self):
666663

667664
def read_questions(self):
668665
"""Reads questions section of packet"""
669-
for i in xrange(self.num_questions):
666+
for i in range(self.num_questions):
670667
name = self.read_name()
671668
type_, class_ = self.unpack(b'!HH')
672669

@@ -679,7 +676,7 @@ def read_questions(self):
679676

680677
def read_character_string(self):
681678
"""Reads a character string from the packet"""
682-
length = indexbytes(self.data, self.offset)
679+
length = self.data[self.offset]
683680
self.offset += 1
684681
return self.read_string(length)
685682

@@ -697,7 +694,7 @@ def read_others(self):
697694
"""Reads the answers, authorities and additionals section of the
698695
packet"""
699696
n = self.num_answers + self.num_authorities + self.num_additionals
700-
for i in xrange(n):
697+
for i in range(n):
701698
domain = self.read_name()
702699
type_, class_, ttl, length = self.unpack(b'!HHiH')
703700

@@ -742,7 +739,7 @@ def is_response(self):
742739

743740
def read_utf(self, offset, length):
744741
"""Reads a UTF-8 string of a given length from the packet"""
745-
return text_type(self.data[offset:offset + length], 'utf-8', 'replace')
742+
return str(self.data[offset:offset + length], 'utf-8', 'replace')
746743

747744
def read_name(self):
748745
"""Reads a domain name from the packet"""
@@ -752,7 +749,7 @@ def read_name(self):
752749
first = off
753750

754751
while True:
755-
length = indexbytes(self.data, off)
752+
length = self.data[off]
756753
off += 1
757754
if length == 0:
758755
break
@@ -763,7 +760,7 @@ def read_name(self):
763760
elif t == 0xC0:
764761
if next_ < 0:
765762
next_ = off + 1
766-
off = ((length & 0x3F) << 8) | indexbytes(self.data, off)
763+
off = ((length & 0x3F) << 8) | self.data[off]
767764
if off >= first:
768765
raise IncomingDecodeError(
769766
"Bad domain name (circular) at %s" % (off,))
@@ -779,7 +776,7 @@ def read_name(self):
779776
return result
780777

781778

782-
class DNSOutgoing(object):
779+
class DNSOutgoing:
783780

784781
"""Object representation of an outgoing packet"""
785782

@@ -1033,7 +1030,7 @@ def packet(self):
10331030
return b''.join(self.data)
10341031

10351032

1036-
class DNSCache(object):
1033+
class DNSCache:
10371034

10381035
"""A cache of DNS entries"""
10391036

@@ -1217,7 +1214,7 @@ def run(self):
12171214
self.zc.cache.remove(record)
12181215

12191216

1220-
class Signal(object):
1217+
class Signal:
12211218
def __init__(self):
12221219
self._handlers = []
12231220

@@ -1230,7 +1227,7 @@ def registration_interface(self):
12301227
return SignalRegistrationInterface(self._handlers)
12311228

12321229

1233-
class SignalRegistrationInterface(object):
1230+
class SignalRegistrationInterface:
12341231

12351232
def __init__(self, handlers):
12361233
self._handlers = handlers
@@ -1363,7 +1360,7 @@ def run(self):
13631360
handler(self.zc)
13641361

13651362

1366-
class ServiceInfo(object):
1363+
class ServiceInfo:
13671364

13681365
"""Service information"""
13691366

@@ -1406,15 +1403,15 @@ def _set_properties(self, properties):
14061403
self._properties = properties
14071404
list_ = []
14081405
result = b''
1409-
for key, value in iteritems(properties):
1410-
if isinstance(key, text_type):
1406+
for key, value in properties.items():
1407+
if isinstance(key, str):
14111408
key = key.encode('utf-8')
14121409

14131410
if value is None:
14141411
suffix = b''
1415-
elif isinstance(value, text_type):
1412+
elif isinstance(value, str):
14161413
suffix = value.encode('utf-8')
1417-
elif isinstance(value, binary_type):
1414+
elif isinstance(value, bytes):
14181415
suffix = value
14191416
elif isinstance(value, int):
14201417
if value:
@@ -1438,7 +1435,7 @@ def _set_text(self, text):
14381435
index = 0
14391436
strs = []
14401437
while index < end:
1441-
length = indexbytes(text, index)
1438+
length = text[index]
14421439
index += 1
14431440
strs.append(text[index:index + length])
14441441
index += length
@@ -1571,7 +1568,7 @@ def __repr__(self):
15711568
)
15721569

15731570

1574-
class ZeroconfServiceTypes(object):
1571+
class ZeroconfServiceTypes:
15751572
"""
15761573
Return all of the advertised services on any local networks
15771574
"""

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.