From b9655326211e0b1f15d71404aeb08225c264b4ec Mon Sep 17 00:00:00 2001 From: Luna Date: Wed, 29 Jul 2020 16:17:15 -0300 Subject: [PATCH] handle Permissions being initialized with a str --- litecord/permissions.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/litecord/permissions.py b/litecord/permissions.py index 9b74d8e..654e2be 100644 --- a/litecord/permissions.py +++ b/litecord/permissions.py @@ -18,7 +18,7 @@ along with this program. If not, see . """ import ctypes -from typing import Optional +from typing import Optional, Union from quart import current_app as app @@ -77,8 +77,10 @@ class Permissions(ctypes.Union): _fields_ = [("bits", _RawPermsBits), ("binary", ctypes.c_uint64)] - def __init__(self, val: int): - self.binary = val + def __init__(self, val: Union[str, int]): + # always coerce to int, even when the user gives us a str, because + # python ints are infinity-sized (yes, yes, the memory concerns, yes) + self.binary = int(val) def __repr__(self): return f""