laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/35440?usp=email ) Change subject: Fix enumeration of GlobbalPlatformISDR during card_init() ...................................................................... Fix enumeration of GlobbalPlatformISDR during card_init() We used __subclasses__(), but this only returns the immediate subclasses and not all further/nested subclasses. Instead, we must use the pySim.utils.all_subclasses() function to really get all of them. The hack to use the method signature of the constructor to determine if it's an intermediate class didn't work, as even GlobbalPlatformISDR has a optional argument for non-default AIDs. So let's introduce an explicit class attribute for that purpose. Change-Id: I7fb1637f8f7a149b536c4d77dac92736c526aa6c --- M pySim/app.py M pySim/global_platform.py 2 files changed, 22 insertions(+), 4 deletions(-) Approvals: laforge: Looks good to me, approved fixeria: Looks good to me, but someone else must approve Jenkins Builder: Verified diff --git a/pySim/app.py b/pySim/app.py index b0df85f..43ef06d 100644 --- a/pySim/app.py +++ b/pySim/app.py @@ -14,7 +14,6 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. -import inspect from typing import Tuple from pySim.transport import LinkBase @@ -26,6 +25,7 @@ from pySim.profile import CardProfile from pySim.cdma_ruim import CardProfileRUIM from pySim.ts_102_221 import CardProfileUICC +from pySim.utils import all_subclasses # we need to import this module so that the SysmocomSJA2 sub-class of # CardModel is created, which will add the ATR-based matching and @@ -87,10 +87,9 @@ # We cannot do it within pySim/profile.py as that would create circular # dependencies between the individual profiles and profile.py. if isinstance(profile, CardProfileUICC): - for app_cls in CardApplication.__subclasses__(): - constr_sig = inspect.signature(app_cls.__init__) + for app_cls in all_subclasses(CardApplication): # skip any intermediary sub-classes such as CardApplicationSD - if len(constr_sig.parameters) != 1: + if hasattr(app_cls, '_' + app_cls.__name__ + '__intermediate'): continue profile.add_application(app_cls()) # We have chosen SimCard() above, but we now know it actually is an UICC diff --git a/pySim/global_platform.py b/pySim/global_platform.py index 2ed6ee4..0ceb884 100644 --- a/pySim/global_platform.py +++ b/pySim/global_platform.py @@ -267,6 +267,7 @@ # Card Application of a Security Domain class CardApplicationSD(CardApplication): + __intermediate = True def __init__(self, aid: str, name: str, desc: str): super().__init__(name, adf=ADF_SD(aid, name, desc), sw=sw_table) -- To view, visit https://gerrit.osmocom.org/c/pysim/+/35440?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: I7fb1637f8f7a149b536c4d77dac92736c526aa6c Gerrit-Change-Number: 35440 Gerrit-PatchSet: 3 Gerrit-Owner: laforge <laforge@osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter <pmaier@sysmocom.de> Gerrit-Reviewer: fixeria <vyanitskiy@sysmocom.de> Gerrit-Reviewer: laforge <laforge@osmocom.org> Gerrit-MessageType: merged