Skip to content

check initial_value is explicitly None #80

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion adafruit_ble/characteristics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def __init__(
):
self._struct_format = struct_format
self._expected_size = struct.calcsize(struct_format)
if initial_value:
if initial_value is not None:
initial_value = struct.pack(self._struct_format, *initial_value)
super().__init__(
uuid=uuid,
Expand Down
2 changes: 1 addition & 1 deletion adafruit_ble/characteristics/float.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def __init__(
write_perm=Attribute.OPEN,
initial_value=None
):
if initial_value:
if initial_value is not None:
initial_value = (initial_value,)
super().__init__(
"<f",
Expand Down
2 changes: 1 addition & 1 deletion adafruit_ble/characteristics/int.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def __init__(
):
self._min_value = min_value
self._max_value = max_value
if initial_value:
if initial_value is not None:
if not self._min_value <= initial_value <= self._max_value:
raise ValueError("initial_value out of range")
initial_value = (initial_value,)
Expand Down