Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code Quality, Unicode Safe Read #11

Open
ajinabraham opened this issue Aug 1, 2016 · 2 comments
Open

Code Quality, Unicode Safe Read #11

ajinabraham opened this issue Aug 1, 2016 · 2 comments
Assignees
Labels

Comments

@ajinabraham
Copy link
Contributor

Lot of places have open file pointers like
https://github.com/torque59/Nosql-Exploitation-Framework/blob/master/dbattacks/utils.py#L116
close all the file pointers after use.
This will save memory.

Also replace open with io.open which is unicode safe.
usingwith will handle file pointers efficiently and you don't have to close them explicitly.

example code

with io.open(file_path, mode='r', encoding="utf8", errors="ignore") as f:
     dat = f.read()
@torque59 torque59 added the bug label Aug 1, 2016
@torque59 torque59 self-assigned this Aug 1, 2016
@torque59
Copy link
Owner

torque59 commented Aug 1, 2016

io.open is the alias for open in python, so both are same i guess, as for closing the files , i am cleaning up the code, should see an update soon.

@ajinabraham
Copy link
Contributor Author

both are same in python3, but not in python2. If you need to read data that contain Unicode, using open will throw errors. If you use io.open specifying the encoding and ignores error .it will work gracefully

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants