Skip to content

Commit 0a648be

Browse files
committed
cleanups
1 parent 9b9c8de commit 0a648be

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
.PHONY: all dist sdist wheel docs install upload clean test
1+
.PHONY: all dist docs install upload clean test
22
PYTHON=python3
33

44
all:
5-
@echo "targets include dist, docs, upload, install, clean"
5+
@echo "targets: dist, docs, upload, install, clean, test"
66

77
docs:
88
$(PYTHON) setup.py build_sphinx

Pyro5/core.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ def resolve(uri: Union[str, URI], delay_time: float = 0.0) -> URI:
203203
raise errors.PyroError("invalid uri protocol")
204204

205205

206-
from . import client # XXX circular
206+
from . import client # circular import...
207207

208208

209209
def locate_ns(host: Union[str, ipaddress.IPv4Address, ipaddress.IPv6Address] = "",

Pyro5/protocol.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,12 @@
6666
_empty_correlation_id = b"\0" * 16
6767

6868

69+
from . import core # circular import...
70+
71+
6972
class SendingMessage:
7073
"""Wire protocol message that will be sent."""
74+
7175
def __init__(self, msgtype, flags, seq, serializer_id, payload, annotations=None):
7276
self.type = msgtype
7377
self.seq = seq
@@ -82,7 +86,6 @@ def __init__(self, msgtype, flags, seq, serializer_id, payload, annotations=None
8286
total_size = len(payload) + annotations_size
8387
if total_size > config.MAX_MESSAGE_SIZE:
8488
raise errors.ProtocolError("message too large ({:d}, max={:d})".format(total_size, config.MAX_MESSAGE_SIZE))
85-
from . import core # XXX circular
8689
if core.current_context.correlation_id:
8790
flags |= FLAGS_CORR_ID
8891
self.corr_id = core.current_context.correlation_id.bytes
@@ -178,12 +181,13 @@ def log_wiredata(logger, text, msg):
178181
(text, msg.type, msg.flags, msg.serializer_id, msg.seq, num_anns, corr_id, bytes(msg.data)))
179182

180183

181-
def recv_stub(connection, accepted_msgtypes=None): # @todo decouple i/o from actual protocol logic
184+
def recv_stub(connection, accepted_msgtypes=None):
182185
"""
183186
Receives a pyro message from a given connection.
184187
Accepts the given message types (None=any, or pass a sequence).
185188
Also reads annotation chunks and the actual payload data.
186189
"""
190+
# TODO decouple i/o from actual protocol logic, so that the protocol can be easily unit tested
187191
header = connection.recv(6) # 'PYRO' + 2 bytes protocol version
188192
ReceivingMessage.validate(header)
189193
header += connection.recv(_header_size - 6)

Pyro5/serializers.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def dict_to_class(cls, data):
172172
Recreate an object out of a dict containing the class name and the attributes.
173173
Only a fixed set of classes are recognized.
174174
"""
175-
from . import core, client, server # XXX circular
175+
from . import core, client, server # circular imports...
176176
classname = data.get("__class__", "<unknown>")
177177
if isinstance(classname, bytes):
178178
classname = classname.decode("utf-8")
@@ -181,7 +181,8 @@ def dict_to_class(cls, data):
181181
return converter(classname, data)
182182
if "__" in classname:
183183
raise errors.SecurityError("refused to deserialize types with double underscores in their name: " + classname)
184-
# for performance, the constructors below are hardcoded here instead of added on a per-class basis to the dict-to-class registry
184+
# for performance reasons, the constructors below are hardcoded here
185+
# instead of added on a per-class basis to the dict-to-class registry
185186
if classname == "Pyro5.core.URI":
186187
uri = core.URI.__new__(core.URI)
187188
uri.__setstate__(data["state"])

0 commit comments

Comments
 (0)