mirror of https://gitlab.com/litecord/litecord.git
handle Permissions being initialized with a str
This commit is contained in:
parent
fa4a4138f0
commit
b965532621
|
|
@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
"""
|
||||
|
||||
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"<Permissions binary={self.binary}>"
|
||||
|
|
|
|||
Loading…
Reference in New Issue