Skip to content

Conversation

@dhx-mike-palandra
Copy link

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:

  1. In mycli/main.py (MyCLI.connect()): if keyword parameter passwd='' 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']
  2. In mycli/config.py (read_config_file()): a configobj.ConfigObj() object is initialized without explicit keyword parameter list_values=True, so its effective value will be True:
    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 ConfigObj with list_values=False but that just caused other problems since it preserves surrounding quotes whereas list_values=True strips them; see also:

list_values
ISSUES

Instead, I have modified the nested get() function defined inside function read_my_cnf_files() in mycli/main.py.

This might close #624.

Checklist

  • I've added this contribution to the changelog.md.
  • I've added my name to the AUTHORS file (or it's already there).

@codecov-io
Copy link

Codecov Report

Merging #743 into master will decrease coverage by 0.02%.
The diff coverage is 50%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #743      +/-   ##
==========================================
- Coverage    77.9%   77.87%   -0.03%     
==========================================
  Files          25       25              
  Lines        2394     2396       +2     
==========================================
+ Hits         1865     1866       +1     
- Misses        529      530       +1
Impacted Files Coverage Δ
mycli/main.py 76.29% <50%> (-0.07%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8da7b8d...43dbd00. Read the comment docs.

@tsroten
Copy link
Member

tsroten commented May 22, 2019

@dhx-mike-palandra Thanks for this pull request!

Good thinking on trying list_values = False first. It's a little disappointing that isn't the solution in the end due to the quotation mark handling.

I think this looks good -- I don't know of any places where we are expecting lists from the .cnf files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

object supporting the buffer API required

3 participants