Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Encoding Issue with write_file() in helpers.py #11

Open
jdong03 opened this issue Jun 9, 2023 · 0 comments
Open

Encoding Issue with write_file() in helpers.py #11

jdong03 opened this issue Jun 9, 2023 · 0 comments

Comments

@jdong03
Copy link

jdong03 commented Jun 9, 2023

Use Case

I'm unable to properly retrieve and parse the data to a new file from the UltiPro API. I get a UnicodeEncodeError when I attempt to do so.

Describe the Solution You Would Like

The method open() in write_file() in helpers.py is missing an additional argument specifying the encoding should be utf-8
Orignial
def write_file(report_stream, path):
"""Writes a stream to a file"""
f = open(path, "w")
f.write(report_stream)
f.close()
Updated
def write_file(report_stream, path):
"""Writes a stream to a file"""
f = open(path, "w", encoding='utf-8')
f.write(report_stream)
f.close()
I have verified on my local machine that making this change and setting this additional parameter fixes this issue and allows me to properly write a new file with the desired data.

Describe Alternatives You've Considered

I've attempted to override or monkey patch this method, but am having difficulty getting it to work.

Additional Context

I need this library for an AWS Lambda function so an update to the library would be necessary for functionality.

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

No branches or pull requests

1 participant