amazon-archives/aws-security-benchmark

_csv.Error: iterator should return strings, not bytes (did you open the file in text mode?)

neomatic999 opened this issue · 13 comments

Hi there

We think we have everything correctly configured but the script always stops with the error detailed below. Can you help??

START RequestId: 89291a84-36f1-11e7-a7f4-1f479e181a6e Version: $LATEST
iterator should return strings, not bytes (did you open the file in text mode?): Error
Traceback (most recent call last):
File "/var/task/lambda_function.py", line 2244, in lambda_handler
cred_report = get_cred_report()
File "/var/task/lambda_function.py", line 1943, in get_cred_report
for row in reader:
File "/var/lang/lib/python3.6/csv.py", line 111, in next
self.fieldnames

Looking into this

Hi, thank you.

We are one of your larger enterprise customers in APAC. I have also spoken to the local AWS team to help with this. I have asked them to reach out to you.

The code seems to fall over in the following section (iterating through reader object):
untitled

Can you provide some info on the environment you are running the script on?
OS? Python version?

Sure, I have tried a few different things. I tried running it as a Lambda function in AWS with the Python 3.6 runtime and all other values as default except for timeout which I set to 5 min.

I have also tried running it on my laptop on Win 10, with the latest version of Python.

In both examples, I get exactly the same error message.

I have not yet test it against Python 3.6 but added it to todo.
To verify, can you modify the Lambda function and switch to Python 2.7 to test?

Will update docs and have on the todo to validate against Python 3.6.
Thanks for reporting.

Great to hear, and please send in any feature requests either here or to your account team/me.
I am currently working on some multi account support as well but no ETA.

Had same error but saw this closed case and code seems to be working now thanks for comment @obijan42.

This issue is occurring with Python 3.6, 3.8.