Make OOIION-621 fix more robust in case Python API changes