Skip to content

Commit 90e507e

Browse files
committed
Fixed introduced error with double encoding
1 parent 1227750 commit 90e507e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

minio/minioadmin.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -458,13 +458,13 @@ def policy_add(self,
458458
policy_file: str | None = None,
459459
policy: dict | None = None) -> str:
460460
"""Add new policy."""
461-
if not (policy_file is not None) ^ (policy is not None):
462-
raise ValueError("either policy or policy_file must be specified")
463-
if policy:
464-
body = json.dumps(policy).encode()
465461
if policy_file:
466462
with Path(policy_file).open(encoding='utf-8') as file:
467463
body = file.read().encode()
464+
elif policy:
465+
body = json.dumps(policy).encode()
466+
else:
467+
raise ValueError("either policy or policy_file must be specified")
468468

469469
response = self._url_open(
470470
"PUT",
@@ -473,7 +473,7 @@ def policy_add(self,
473473
# Disabled check because this code is never reached if body is not
474474
# defined.
475475
# pylint: disable-next=possibly-used-before-assignment
476-
body=json.dumps(body).encode(),
476+
body=body,
477477
)
478478
return response.data.decode()
479479

0 commit comments

Comments
 (0)