diff --git a/src/_zkapauthorizer/foolscap.py b/src/_zkapauthorizer/foolscap.py index 701a5eafd2e3603ec9683c24ac073e0c1e310f6b..1478d76136278b53f46135bfbf8516b196e83f30 100644 --- a/src/_zkapauthorizer/foolscap.py +++ b/src/_zkapauthorizer/foolscap.py @@ -141,6 +141,20 @@ def add_arguments(schema, kwargs): return modified_schema +def remoteinterface_hasattr(ri, name): + """ + :param InterfaceClass ri: A ``RemoteInterface`` to inspect. + :param str name: The name of an attribute. + + :return bool: ``True`` if and only if ``ri`` has the attribute named by + ``name``, ``False`` otherwise. + """ + try: + ri[name] + except KeyError: + return False + return True + class RIPrivacyPassAuthorizedStorageServer(RemoteInterface): """ @@ -162,7 +176,7 @@ class RIPrivacyPassAuthorizedStorageServer(RemoteInterface): add_lease = add_passes(RIStorageServer["add_lease"]) - if "renew_lease" in RIStorageServer: + if remoteinterface_hasattr(RIStorageServer, "renew_lease"): # Tahoe-LAFS 1.16.0 drops renew_lease from the interface. Do likewise # here, if we discover we have a version of Tahoe that has done so. # If Tahoe has dropped this method then nothing in Tahoe is going to