Skip to content

Commit

Permalink
Allow cf_create to create integer types as well.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Mar 12, 2024
1 parent 55bdd84 commit f3e711d
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions keyring/backends/macOS/api.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import contextlib
import ctypes
import functools
Expand Down Expand Up @@ -74,10 +76,14 @@ def create_cf(ob):
return ob


@create_cf.register
def _(b: bool):
# explicit bool and int required for Python 3.10 compatibility
@create_cf.register(bool)
@create_cf.register(int)
def _(val: bool | int):
if val.bit_length() > 31:
raise OverflowError(val)
int32 = 0x9
return CFNumberCreate(None, int32, ctypes.byref(c_int32(b)))
return CFNumberCreate(None, int32, ctypes.byref(c_int32(val)))


@create_cf.register
Expand Down

0 comments on commit f3e711d

Please sign in to comment.