mirror of
				https://github.com/python-escpos/python-escpos
				synced 2025-10-23 09:30:00 +00:00 
			
		
		
		
	fix AttributeError when executing close
When self.device is already None an AttributeError will occur. This is relevant to #189.
This commit is contained in:
		| @@ -211,6 +211,7 @@ class Network(Escpos): | |||||||
|  |  | ||||||
|     def close(self): |     def close(self): | ||||||
|         """ Close TCP connection """ |         """ Close TCP connection """ | ||||||
|  |         if self.device is not None: | ||||||
|             self.device.shutdown(socket.SHUT_RDWR) |             self.device.shutdown(socket.SHUT_RDWR) | ||||||
|             self.device.close() |             self.device.close() | ||||||
|  |  | ||||||
| @@ -263,6 +264,7 @@ class File(Escpos): | |||||||
|  |  | ||||||
|     def close(self): |     def close(self): | ||||||
|         """ Close system file """ |         """ Close system file """ | ||||||
|  |         if self.device is not None: | ||||||
|             self.device.flush() |             self.device.flush() | ||||||
|             self.device.close() |             self.device.close() | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Patrick Kanzler
					Patrick Kanzler