The select function in SparqlQuery assumes that are values are set. When you do an optional query like " SELECT ?item ?id ?url WHERE { ?item wdt:P217 ?id . ?item wdt:P195 wd:Q190804 . OPTIONAL { ?item wdt:P973 ?url } } ", this is not always the case.
for var in qvars:
Check if var is in row, if it's true, do the normal things, if it's not true, set it to None?