From 6b16afaa2eae926b95b6b7c325cf24e7139d93df Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone Date: Thu, 26 Apr 2018 15:16:00 -0400 Subject: [PATCH] Avoid using the list comprehension loop variable It works fine but it relies on leaky scopes. --- src/allmydata/util/encodingutil.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/allmydata/util/encodingutil.py b/src/allmydata/util/encodingutil.py index 65f5911a1..11ab942b6 100644 --- a/src/allmydata/util/encodingutil.py +++ b/src/allmydata/util/encodingutil.py @@ -335,8 +335,8 @@ def listdir_unicode_fallback(path): try: return [unicode(fn, filesystem_encoding) for fn in os.listdir(byte_path)] - except UnicodeDecodeError: - raise FilenameEncodingError(fn) + except UnicodeDecodeError as e: + raise FilenameEncodingError(e.object) def listdir_unicode(path): """