akamai / AkamaiOPEN-edgegrid-python

This library implements an Authentication handler for the Akamai OPEN EdgeGrid Authentication scheme
Apache License 2.0
88 stars 52 forks source link

Python3.7 complains about option values #33

Closed bytesplit closed 6 years ago

bytesplit commented 6 years ago

I've just updated my homebrew python3.6 to 3.7. Now I'm getting an error for the default config values: Traceback (most recent call last): File "./egcurl", line 333, in <module> sys.exit(main()) File "./egcurl", line 254, in main config = get_config(args.eg_edgerc, args.eg_config, section) File "./egcurl", line 85, in get_config config = _parse_edgerc(os.path.expanduser(edgerc_filename), section) File "./egcurl", line 91, in _parse_edgerc edgerc = EdgeRc(file) File "/usr/local/lib/python3.7/site-packages/akamai/edgegrid/edgerc.py", line 36, in __init__ ConfigParser.__init__(self, {'max_body': '131072', 'headers_to_sign': None}) File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/configparser.py", line 638, in __init__ self._read_defaults(defaults) File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/configparser.py", line 1216, in _read_defaults self.read_dict({self.default_section: defaults}) File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/configparser.py", line 753, in read_dict self.set(section, key, value) File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/configparser.py", line 1197, in set self._validate_value_types(option=option, value=value) File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/configparser.py", line 1182, in _validate_value_types raise TypeError("option values must be strings") TypeError: option values must be strings

In file edgerc.py I adjusted from: ConfigParser.__init__(self, {'max_body': '131072', 'headers_to_sign': None}) to: ConfigParser.__init__(self, {'max_body': '131072', 'headers_to_sign': 'None'})

Strange is that the edgerc.py file found in this repo is different to what I have. Seems the pip download is at a different version. I found my edgerc matching the branch support_python3. But there even is another one call python3_support.

I guess this needs a little cleaning :) So I'm not making a pull request without knowing which version to base to.

NeilJed commented 6 years ago

I can confirm the above as I've been struggling with it myself on and off for two days.

Attempting to run http with an .edgerc file results in:

Traceback (most recent call last): File "/usr/local/bin/http", line 11, in <module> sys.exit(main()) File "/usr/local/lib/python3.7/site-packages/httpie/__main__.py", line 11, in main sys.exit(main()) File "/usr/local/lib/python3.7/site-packages/httpie/core.py", line 210, in main parsed_args = parser.parse_args(args=args, env=env) File "/usr/local/lib/python3.7/site-packages/httpie/input.py", line 168, in parse_args self._process_auth() File "/usr/local/lib/python3.7/site-packages/httpie/input.py", line 268, in _process_auth password=credentials.value, File "/usr/local/lib/python3.7/site-packages/httpie_edgegrid.py", line 36, in get_auth rc = EdgeRc(rc_path) File "/usr/local/lib/python3.7/site-packages/akamai/edgegrid/edgerc.py", line 36, in __init__ ConfigParser.__init__(self, {'max_body': '131072', 'headers_to_sign': None}) File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/configparser.py", line 638, in __init__ self._read_defaults(defaults) File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/configparser.py", line 1216, in _read_defaults self.read_dict({self.default_section: defaults}) File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/configparser.py", line 753, in read_dict self.set(section, key, value) File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/configparser.py", line 1197, in set self._validate_value_types(option=option, value=value) File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/configparser.py", line 1182, in _validate_value_types raise TypeError("option values must be strings") TypeError: option values must be strings

Issue was fixed by editing /usr/local/lib/python3.7/site-packages/akamai/edgegrid/edgerc.py and surrounding the None parameter in single-quotes.

As bytesplit mentions, edgerc.py installed via pip3 does not match the version here although both claim to be 1.1.0.

dwasss commented 6 years ago

This issue seems to affect other packages as well, like https://github.com/akamai/cli-firewall

cneedss commented 6 years ago

Did a quick functional test of the fix using httpie-edgegrid. No longer get the error on python 3.7.0. Test Passed.

javiergarza commented 6 years ago

Please do a pull, this should be fixed now.