libselinux: selinux.py - use os.walk() instead of os.path.walk()
PATCH 1/1 libselinux: selinux.py - use os.walk() instead of os.path.walk()
From: Miro Hrončok <[email protected]>
os.path.walk() function is deprecated and has been removed in Python 3
---
A simple fix which allows to use same construction in Python 2 and Python 3. It's reported and proposed in https://bugzilla.redhat.com/show_bug.cgi?id=1195004
libselinux/src/selinuxswig_python.i | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
libselinux/src/selinuxswig_python.i +3 -3
@@ -31,9 +31,9 @@ def restorecon(path, recursive=False): lsetfilecon(path, context) if recursive: - os.path.walk(path, lambda arg, dirname, fnames: - map(restorecon, [os.path.join(dirname, fname) - for fname in fnames]), None) + for root, dirs, files in os.walk(path): + for name in files + dirs: + restorecon(os.path.join(root, name)) def chcon(path, context, recursive=False): """ Set the SELinux context on a given path """
Signature · 1 line
2.3.5
Quoted 5 lines · Petr Lautrbach
From: Miro Hrončok <[email protected]>
os.path.walk()function is deprecated and has been removed in Python 3Signed-off-by Petr Lautrbach <[email protected]>
Thanks!
Quoted 27 lines
---
A simple fix which allows to use same construction in Python 2 and Python 3. It's reported and proposed in https://bugzilla.redhat.com/show_bug.cgi?id=1195004
libselinux/src/selinuxswig_python.i | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)libselinux/src/selinuxswig_python.i +3
-3@@ -31,9 +31,9 @@ def restorecon(path, recursive=False): lsetfilecon(path, context) if recursive: - os.path.walk(path, lambda arg, dirname, fnames: - map(restorecon, [os.path.join(dirname, fname) - for fname in fnames]), None) + for root, dirs, files in os.walk(path): + for name in files + dirs: + restorecon(os.path.join(root, name)) def chcon(path, context, recursive=False): """ Set the SELinux context on a given path """
Quoted 10 lines · Steve Lawrence
Quoted 5 lines · Petr Lautrbach
From: Miro Hrončok <[email protected]>
os.path.walk()function is deprecated and has been removed in Python 3Signed-off-by Petr Lautrbach <[email protected]>Acked-by Steve Lawrence <[email protected]>Thanks!
Might it be that you've accidentally edited a wrong ChangeLog?
Update libselinux ChangeLog
libsemanage/ChangeLog +2 -0
@@ -1,3 +1,5 @@ + * Use os.walk() instead of the deprecated os.path.walk(), from Petr + Lautrbach & Miro Hrončok
Petr
Quoted 29 lines
Quoted 28 lines
---
A simple fix which allows to use same construction in Python 2 and Python 3. It's reported and proposed in https://bugzilla.redhat.com/show_bug.cgi?id=1195004
libselinux/src/selinuxswig_python.i | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)libselinux/src/selinuxswig_python.i +3
-3@@ -31,9 +31,9 @@ def restorecon(path, recursive=False): lsetfilecon(path, context) if recursive: - os.path.walk(path, lambda arg, dirname, fnames: - map(restorecon, [os.path.join(dirname, fname) - for fname in fnames]), None) + for root, dirs, files in os.walk(path): + for name in files + dirs: + restorecon(os.path.join(root, name)) def chcon(path, context, recursive=False): """ Set the SELinux context on a given path """
Signature · 1 line
Petr Lautrbach
Quoted 8 lines · Petr Lautrbach
Quoted 7 lines · Steve Lawrence
Quoted 5 lines · Petr Lautrbach
From: Miro Hrončok <[email protected]>
os.path.walk()function is deprecated and has been removed in Python 3Signed-off-by Petr Lautrbach <[email protected]>
Quoted 8 lines
Quoted 3 lines
Acked-by Steve Lawrence <[email protected]>Thanks!
Might it be that you've accidentally edited a wrong ChangeLog?
Update libselinux ChangeLog
Yep. Thanks. That's been fixed.
- Steve
Quoted 41 lines
libsemanage/ChangeLog +2
-0@@ -1,3 +1,5 @@ + * Use os.walk() instead of the deprecated os.path.walk(), from Petr + Lautrbach & Miro HrončokPetr
Quoted 29 lines
Quoted 28 lines
---
A simple fix which allows to use same construction in Python 2 and Python 3. It's reported and proposed in https://bugzilla.redhat.com/show_bug.cgi?id=1195004
libselinux/src/selinuxswig_python.i | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)libselinux/src/selinuxswig_python.i +3
-3@@ -31,9 +31,9 @@ def restorecon(path, recursive=False): lsetfilecon(path, context) if recursive: - os.path.walk(path, lambda arg, dirname, fnames: - map(restorecon, [os.path.join(dirname, fname) - for fname in fnames]), None) + for root, dirs, files in os.walk(path): + for name in files + dirs: + restorecon(os.path.join(root, name)) def chcon(path, context, recursive=False): """ Set the SELinux context on a given path """