Skip to content

CLI: Reading values from files does not support binary files #2752

Closed
@JohnVillalovos

Description

@JohnVillalovos

When using the @ prefix to specify a file that should be read, it will read the file as "utf-8" text. This fails with binary files such as a PNG.

This was discussed in #2751 as pointed out by @trafford-tbe

Code is:

python-gitlab/gitlab/cli.py

Lines 299 to 307 in d7bdb02

if isinstance(v, str) and v.startswith("@"):
# If the user-provided value starts with @, we try to read the file
# path provided after @ as the real value. Exit on any error.
try:
with open(v[1:], encoding="utf-8") as f:
return f.read()
except Exception as e:
sys.stderr.write(f"{e}\n")
sys.exit(1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions