From 734ce1caf3d02b297b93092ecd91a8f2c4c16de1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C2=A8Andreas?= <¨andreas.dachsberger@gmail.com¨> Date: Mon, 10 Sep 2018 11:38:36 +0200 Subject: Solved some 2 to 3 issues --- tftpy/TftpPacketTypes.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/tftpy/TftpPacketTypes.py b/tftpy/TftpPacketTypes.py index 7f9bafb..0479ccb 100644 --- a/tftpy/TftpPacketTypes.py +++ b/tftpy/TftpPacketTypes.py @@ -62,10 +62,8 @@ class TftpPacketWithOptions(object): # Count the nulls in the buffer. Each one terminates a string. log.debug("about to iterate options buffer counting nulls") length = 0 - for c in buffer: - if sys.version_info[0] <= 2: - c = ord(c) - if c == 0: + for i in range(len(buffer)): + if ord(buffer[i:i+1]) == 0: log.debug("found a null at length %d", length) if length > 0: fmt += b"%dsx" % length @@ -177,10 +175,8 @@ class TftpPacketInitial(TftpPacket, TftpPacketWithOptions): nulls = length = tlength = 0 log.debug("in decode: about to iterate buffer counting nulls") subbuf = self.buffer[2:] - for c in subbuf: - if sys.version_info[0] <= 2: - c = ord(c) - if c == 0: + for i in range(len(subbuf)): + if ord(subbuf[i:i+1]) == 0: nulls += 1 log.debug("found a null at length %d, now have %d", length, nulls) fmt += b"%dsx" % length -- cgit v1.2.1