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,6 +62,11 @@ class Object(Hashable):
"""
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
def __repr__(self):