Skip to content

Commit 87ea23a

Browse files
author
HalaAli198
committed
Fix: Open TOML files in binary mode as required by tomllib
Fixed two instances where TOML files were opened in text mode instead of binary mode: - Line 650: process_pyproject() method - Line 716: process_pylock() method The tomllib parser requires files to be opened in binary mode ('rb'). This fixes the TypeError when processing pyproject.toml and poetry.lock files.
1 parent 2ec02e5 commit 87ea23a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

sbom4python/scanner.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ def process_pyproject(self, filename):
647647
filePath = pathlib.Path(filename)
648648
# Check path exists and is a valid file
649649
if filePath.exists() and filePath.is_file():
650-
with open(filename) as file:
650+
with open(filename, "rb") as file:
651651
pyproject_data = toml.load(file)
652652
if "project" in pyproject_data:
653653
if "dependencies" in pyproject_data["project"]:
@@ -713,7 +713,7 @@ def process_pylock(self, filename):
713713
filePath = pathlib.Path(filename)
714714
# Check path exists and is a valid file
715715
if filePath.exists() and filePath.is_file():
716-
with open(filename) as file:
716+
with open(filename, "rb") as file:
717717
pylock_data = toml.load(file)
718718
if "lock-version" in pylock_data:
719719
if self.debug:

0 commit comments

Comments
 (0)