[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [stem/master] Optimize error check for non-negative inputs
commit 71bb7d5e42125f2d89c8dddc56fa16c71989c5cd
Author: Dave Rolek <dmr-x@xxxxxxxxxx>
Date: Tue Aug 7 18:32:31 2018 +0000
Optimize error check for non-negative inputs
stem.client presently makes typical use of non-negative inputs with
unsigned types.
---
stem/client/datatype.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/stem/client/datatype.py b/stem/client/datatype.py
index e19adfb1..1c7aec77 100644
--- a/stem/client/datatype.py
+++ b/stem/client/datatype.py
@@ -358,7 +358,7 @@ class Size(Field):
def pack(self, content):
if not stem.util._is_int(content):
raise ValueError('Size.pack encodes an integer, but was a %s' % type(content).__name__)
- if self.unsigned and content < 0:
+ if content < 0 and self.unsigned:
raise ValueError('A %s field cannot pack negative values, but %i was tried' % (self.name, content))
packed = struct.pack(self.format, content)
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits