Python – restricted mode?

It seems that sometimes, but not always python is in ‘restricted mode’. This becomes troublesome when trying to access files on the filesystem.
In the past, I’ve been able to restart kodi, which restarts my applications, and the problem seems to go away.

In this particular scenario, I have a service running that is a bluetooth agent. When attempting to pair, the BT daemon responds:

Code:
RuntimeError: function attributes not accessible in restricted mode

Again, with the restricted mode. I’ve not been successful in uncovering much about this. But certainly, if anyone has experience with this, I would appreciate any tips.