Convert id parameter of Object into int or raise TypeError on failure
This prevents breakage for users who pass in a str as an ID whereas it previously worked. Fix #4002
This commit is contained in:
		| @@ -62,7 +62,12 @@ class Object(Hashable): | ||||
|     """ | ||||
|  | ||||
|     def __init__(self, id): | ||||
|         self.id = id | ||||
|         try: | ||||
|             id = int(id) | ||||
|         except ValueError: | ||||
|             raise TypeError('id parameter must be convertable to int not {0.__class__!r}'.format(id)) from None | ||||
|         else: | ||||
|             self.id = id | ||||
|  | ||||
|     def __repr__(self): | ||||
|         return '<Object id=%r>' % self.id | ||||
|   | ||||
		Reference in New Issue
	
	Block a user