Update pipreqs.py

UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 1477: character maps to <undefined>
Ignore cp1252 encoding error (cp850 works as default but isnt recommended so ignoring the error is preferred and will successfully write requirement file)
This commit is contained in:
Moooog 2022-10-20 15:02:53 +01:00 committed by GitHub
parent b033d75d60
commit b6e0e3a711
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -111,7 +111,7 @@ def get_all_imports(
candidates += [os.path.splitext(fn)[0] for fn in files]
for file_name in files:
file_name = os.path.join(root, file_name)
with open(file_name, "r", encoding=encoding) as f:
with open(file_name, "r", encoding=encoding, errors='ignore') as f:
contents = f.read()
try:
tree = ast.parse(contents)