Bugfix/config values with comma #743
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
When a password is read from ~/.mylogin.cnf and contains a comma (,), mycli will terminate with error message "object supporting the buffer API required". Please note that the official mysql CLI client handles this case properly.
More detail:
MyCLI.connect()): if keyword parameterpasswd=''evaluates to false (it does by default), then a password will be parsed from config:cnf = self.read_my_cnf_files(self.cnf_files, cnf.keys())...
passwd = passwd or cnf['password']read_config_file()): aconfigobj.ConfigObj()object is initialized without explicit keyword parameterlist_values=True, so its effective value will beTrue:config = ConfigObj(f, interpolation=False, encoding='utf8')This will cause any string value containing a "," to be parsed as a list which causes an exception somewhere (I didn't trace all the way through).
Suggested Fix
Note that this is my first time looking at the source, so my advice may not be optimal. Initially, I thought it would be more sensible to initialize
ConfigObjwithlist_values=Falsebut that just caused other problems since it preserves surrounding quotes whereaslist_values=Truestrips them; see also:list_values
ISSUES
Instead, I have modified the nested
get()function defined inside functionread_my_cnf_files()in mycli/main.py.This might close #624.
Checklist
changelog.md.AUTHORSfile (or it's already there).