Skip to content

Commit

Permalink
StaticFileSet: Fix os.walk for utf8_mode
Browse files Browse the repository at this point in the history
Bug: https://bugs.gentoo.org/916182
Signed-off-by: Zac Medico <zmedico@gentoo.org>
  • Loading branch information
zmedico committed Oct 24, 2023
1 parent d7ff407 commit 92f34ea
Showing 1 changed file with 11 additions and 2 deletions.
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]
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

0 comments on commit 92f34ea

Please sign in to comment.