UnicodeDecodeError: đ. ž. ć. š. č while packaging code
MislavJaksic opened this issue · 3 comments
Description
The module throws an error when packaging Python code that contains UTF-8 characters.
Versions
- Module version [Required]:
5.2.0 - Terraform version:
1.5.0 - Provider version(s):
5.7.0
Reproduction Code [Required]
I'm trying to create a AWS Lambda function with code that contains UTF-8 characters:
đ
ž
ć
č
š
When I do terraform apply
the following error appears:
UnicodeDecodeError: 'charmap' codec can't decode byte 0x8d in position 653: character maps to <undefined>
.
I've solve it by adding encoding="utf-8"
to get_build_system_from_pyproject_toml()
in package.py
.
Expected behavior
terraform apply
doesn't throw an error while packaging the code.
Actual behavior
terraform apply
throws an error:
│ Error: External Program Execution Failed
│
│ with module.insert.data.external.archive_prepare[0],
│ on .terraform\modules\insert\package.tf line 10, in data "external" "archive_prepare":
│ 10: program = [local.python, "${path.module}/package.py", "prepare"]
│
│ The data source received an unexpected error while attempting to execute the program.
│
│ Program: C:\D\Programs\Python3.10\python.exe
│ Error Message: Traceback (most recent call last):
│ File "C:\XXX\.terraform\modules\insert\package.py", line 1628, in
<module>
│ main()
│ File "C:\XXX\.terraform\modules\insert\package.py", line 1624, in
main
│ exit(args.command(args))
│ File "C:\XXX\.terraform\modules\insert\package.py", line 1423, in
prepare_command
│ build_plan = bpm.plan(source_path, query)
│ File "C:\XXX\.terraform\modules\insert\package.py", line 775, in
plan
│ poetry_install_step(path)
│ File "C:\XXX\.terraform\modules\insert\package.py", line 687, in poetry_install_step
│ if get_build_system_from_pyproject_toml(pyproject_file) != "poetry":
│ File "C:\XXX\.terraform\modules\insert\package.py", line 623, in get_build_system_from_pyproject_toml
│ for line in f.readlines():
│ File "C:\D\Programs\Python3.10\lib\encodings\cp1252.py", line 23, in decode
│ return codecs.charmap_decode(input,self.errors,decoding_table)[0]
│ UnicodeDecodeError: 'charmap' codec can't decode byte 0x8d in position 653: character maps to <undefined>
│
│ State: exit status 1
╵
This issue has been automatically marked as stale because it has been open 30 days
with no activity. Remove stale label or comment or this issue will be closed in 10 days
This issue was automatically closed because of stale in 10 days
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.