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:
parent
0d5e6e213c
commit
e473f3c775
@ -62,6 +62,11 @@ class Object(Hashable):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, id):
|
def __init__(self, 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
|
self.id = id
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user