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:
Rapptz 2020-04-19 18:33:03 -04:00
parent 0d5e6e213c
commit e473f3c775

View File

@ -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