Commits

Jason R. Coombs committed 71b05c3

Fix usage of memoryview

  • Participants
  • Parent commits 4e4fa30

Comments (0)

Files changed (2)

jaraco/net/devices/linux2.py

 		if ifr.detail.flags & IFF_LOOPBACK: continue
 		res = ioctl(s.fileno(), SIOCGIFHWADDR, ctypes.byref(ifr))
 		if res != 0: continue
-		yield bytes(memoryview(ifr.detail.hardware_addr.data))[:6]
+		yield memoryview(ifr.detail.hardware_addr.data).tobytes()[:6]
 
 def get_ip_addresses(if_names):
 	s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
 		ifr = ifreq(name)
 		res = ioctl(s.fileno(), SIOCGIFADDR, ctypes.byref(ifr))
 		if res != 0: continue
-		yield bytes(memoryview(ifr.detail.addr.data))[2:6]
+		yield memoryview(ifr.detail.addr.data).tobytes()[2:6]
 
 class Manager(BaseManager):
 	def get_host_mac_addresses(self):

jaraco/net/devices/win32.py

 	def get_variable_length_property(self, name):
 		val = getattr(self, name+'_raw')
 		length = getattr(self, name+'_length')
-		return str(memoryview(val))[:length]
+		return memoryview(val).tobytes()[:length]
 
 	def physical_address(self):
 		return self.get_variable_length_property('physical_address')