Fix property getter for non-available properties
Properties which are not currently available weren't handled properly: The getter for a property that is not available with proptype 'str' would return "None" (as a string) instead of None. Trying to retrieve a non-available property with proptype 'int' would raise a TypeError, because the getter tries to call 'int(None)'. An alternative would be to raise some kind of exception for non-available properties, but I would prefer the getter to return None. For example None should be a valid value for the property 'path' if no video is loaded yet.
This commit is contained in:
parent
ee8316a282
commit
bcd8166829
3
mpv.py
3
mpv.py
|
@ -620,7 +620,8 @@ ALL_PROPERTIES = {
|
|||
|
||||
def bindproperty(MPV, name, proptype, access):
|
||||
def getter(self):
|
||||
return proptype(_ensure_encoding(_mpv_get_property_string(self.handle, name.encode())))
|
||||
value = _ensure_encoding(_mpv_get_property_string(self.handle, name.encode()))
|
||||
return proptype(value) if value is not None else value
|
||||
def setter(self, value):
|
||||
_mpv_set_property_string(self.handle, name.encode(), str(proptype(value)).encode())
|
||||
def barf(*args):
|
||||
|
|
Loading…
Reference in New Issue