You are examining the first iteration, which works fine.
The exception occurs later on. Step through the loop some more, because at some point you'll run into a namespace key for which the value has been set to True
(not a tuple of a boolean and a list).
Why? Because earlier in your code you do:
for ns in namespaces.keys():
if ns in open_url.url:
namespaces[ns] = True
Note the = True
there; you perhaps meant to set that to:
namespaces[ns] = (True, namespaces[ns][1])
Note that to loop over the keys of a dictionary, you can do so directly:
for ns in namespaces:
and save yourself an attribute lookup, a function call, and the creation of a whole new list object.