snoo
snoo copied to clipboard
`ValueError: invalid interpolation syntax in '%' at position 0` if you have a password with % in it
With snoo 0.3.1, a password with % in it throws a ValueError. It's easily reproducible on first run (with the absence of a config file I assume). Just enter any username and % as the password:
$ snoo status
SNOO Username: boo
Password:
Traceback (most recent call last):
File "/Users/beaufour/repos/snoo_export/.venv/bin/snoo", line 8, in <module>
sys.exit(run())
File "/Users/beaufour/repos/snoo_export/.venv/lib/python3.8/site-packages/snoo/__init__.py", line 34, in run
print(client.status())
File "/Users/beaufour/repos/snoo_export/.venv/lib/python3.8/site-packages/snoo/client.py", line 297, in status
session = self.get_current_session()
File "/Users/beaufour/repos/snoo_export/.venv/lib/python3.8/site-packages/snoo/client.py", line 266, in get_current_session
data = self.request(self.CURRENT_ENDPOINT)
File "/Users/beaufour/repos/snoo_export/.venv/lib/python3.8/site-packages/snoo/client.py", line 187, in request
headers["Authorization"] = f"Bearer {self.get_token()}"
File "/Users/beaufour/repos/snoo_export/.venv/lib/python3.8/site-packages/snoo/client.py", line 216, in get_token
payload = {"username": self.username, "password": self.password}
File "/Users/beaufour/repos/snoo_export/.venv/lib/python3.8/site-packages/snoo/client.py", line 209, in password
self.auth["password"] = getpass.getpass()
File "/usr/local/Cellar/[email protected]/3.8.6/Frameworks/Python.framework/Versions/3.8/lib/python3.8/configparser.py", line 1259, in __setitem__
return self._parser.set(self._name, key, value)
File "/usr/local/Cellar/[email protected]/3.8.6/Frameworks/Python.framework/Versions/3.8/lib/python3.8/configparser.py", line 1201, in set
super().set(section, option, value)
File "/usr/local/Cellar/[email protected]/3.8.6/Frameworks/Python.framework/Versions/3.8/lib/python3.8/configparser.py", line 894, in set
value = self._interpolation.before_set(self, section, option,
File "/usr/local/Cellar/[email protected]/3.8.6/Frameworks/Python.framework/Versions/3.8/lib/python3.8/configparser.py", line 402, in before_set
raise ValueError("invalid interpolation syntax in %r at "
ValueError: invalid interpolation syntax in '%' at position 0
Aaah, that's a problem with configparser, because % needs to be escaped in the config file (as %%)