Skip to content

Update ValueError raised when storing non-integer in index #4

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 3 commits into from
Dec 20, 2021
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_24lc32.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def __setitem__(self, address, value):

if isinstance(address, int):
if not isinstance(value, int):
raise ValueError("Data must be a single integer for single addresses")
raise ValueError("Data stored in an address must be an integer 0-255")
if not 0 <= address < self._max_size:
raise ValueError(
"Address '{0}' out of range. It must be 0 <= address < {1}.".format(
Expand Down
10 changes: 4 additions & 6 deletions examples/24lc32_simpletest.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# SPDX-FileCopyrightText: Copyright (c) 2021 Tim Cocks for Adafruit Industries
#
# SPDX-License-Identifier: Unlicense

import board
import adafruit_eeprom
import adafruit_24lc32 as adafruit_eeprom

i2c = board.I2C()
eeprom = adafruit_eeprom.EEPROM_I2C(i2c)
Expand All @@ -12,8 +13,5 @@
eeprom[0] = 4
print(eeprom[0])

# eeprom[0:3] = [9, 3, 8, 1]
# print(eeprom[0:3])

while True:
pass
eeprom[0:4] = [9, 3, 8, 1]
print(eeprom[0:4])