Skip to content

Commit e4fd573

Browse files
committed
Fix a bug in FileCache.read()
Default `size` value should be a negative integer instead of None. From python docs: > When size is omitted or negative, the entire contents of the file > will be read.
1 parent 00ed242 commit e4fd573

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

ev3dev.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def file_handle( self, path, mode, reopen=False ):
7272

7373
return f
7474

75-
def read(self, path, size=None):
75+
def read(self, path, size=-1):
7676
f = self.file_handle(path, 'r')
7777

7878
try:
@@ -81,7 +81,7 @@ def read(self, path, size=None):
8181
f = self.file_handle( path, 'w+', reopen=True )
8282
value = f.read(size)
8383

84-
if size is None:
84+
if size < 0:
8585
return value.strip()
8686
else:
8787
return value
@@ -154,7 +154,7 @@ def _matches(self, attribute, pattern):
154154
else:
155155
return value.find(pattern) >= 0
156156

157-
def _get_attribute( self, attribute, size=None ):
157+
def _get_attribute( self, attribute, size=-1 ):
158158
"""Device attribute getter"""
159159
return self._attribute_cache.read(abspath(self._path + '/' + attribute), size)
160160

0 commit comments

Comments
 (0)