Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StaticFileSet: Fix os.walk for utf8_mode #1153

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions lib/portage/_sets/files.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Copyright 2007-2020 Gentoo Authors
# Copyright 2007-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

import errno
import re
from itertools import chain

import portage
from portage import os
from portage import _encodings
from portage import _unicode_decode
Expand Down Expand Up @@ -176,6 +177,14 @@ def multiBuilder(self, options, settings, trees):
directory = normalize_path(directory)

for parent, dirs, files in os.walk(directory):
if portage.utf8_mode:
dirs_orig = dirs
omit_dir = lambda d: dirs_orig.remove(os.fsdecode(d))
parent = os.fsencode(parent)
dirs = [os.fsencode(value) for value in dirs]
files = [os.fsencode(value) for value in files]
zmedico marked this conversation as resolved.
Show resolved Hide resolved
else:
omit_dir = lambda d: dirs.remove(d)
try:
parent = _unicode_decode(
parent, encoding=_encodings["fs"], errors="strict"
Expand All @@ -184,7 +193,7 @@ def multiBuilder(self, options, settings, trees):
continue
for d in dirs[:]:
if d in vcs_dirs or d.startswith(b".") or d.endswith(b"~"):
dirs.remove(d)
omit_dir(d)
for filename in files:
try:
filename = _unicode_decode(
Expand Down
Loading