Quantcast
Channel: MySQL Forums - Connector/Python
Viewing all articles
Browse latest Browse all 384

unclosed files in mysql/connector/optionfiles.py (no replies)

$
0
0
Hi,

I don't know if I am reporting a bug or my misunderstanding. I am running Python 3.8.x from a virtualenv on a Linux Mint 19.x system. I have the latest pip install of MySQL Connector for Python.

I was running a test suit on an app I am building. I had just rearranged where I was doing the DB connections -- this app responds to async requests and I don't know enough about MySQL connections in this environment.

I received a message about a file being opn in the MySQL Connector venv/lib/python3.8/site-packages/mysql/connector/optionfiles.py in the "read()" method. That method has the line:

for line in codecs.open(filename, encoding='utf-8'):

The file(s) are obviously read but they do not appear to be explicitly closed.

I modified that line to:

in_file = codecs.open(filename, encoding='utf-8')
for line in in_file:

and added

in_file.close()

immediately after the loop. That mostly seemed to do the trick for me but maybe there are unintended consequences I can't see?

If this is a reasonable modification what is the recommended way to send a patch?


Lastly, after making that change and in the same file in the "read_option_files()" method there is a line:

except KeyError:
if group is 'connector_python':

I had a warning that the "is" should be "==" for the constant. This might be a python version thing, don't know.

Cheers

Viewing all articles
Browse latest Browse all 384

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>