* [PATCH] libselinux: selinux.py - use os.walk() instead of os.path.walk()
@ 2015-04-21 11:46 Petr Lautrbach
2015-04-21 12:22 ` Steve Lawrence
0 siblings, 1 reply; 4+ messages in thread
From: Petr Lautrbach @ 2015-04-21 11:46 UTC (permalink / raw)
To: selinux; +Cc: Miro Hrončok
From: Miro Hrončok <mhroncok@redhat.com>
os.path.walk() function is deprecated and has been removed in Python 3
Signed-off-by: Petr Lautrbach <plautrba@redhat.com>
---
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(-)
diff --git a/libselinux/src/selinuxswig_python.i b/libselinux/src/selinuxswig_python.i
index ae72246..c9a2341 100644
--- a/libselinux/src/selinuxswig_python.i
+++ b/libselinux/src/selinuxswig_python.i
@@ -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 """
--
2.3.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] libselinux: selinux.py - use os.walk() instead of os.path.walk()
2015-04-21 11:46 [PATCH] libselinux: selinux.py - use os.walk() instead of os.path.walk() Petr Lautrbach
@ 2015-04-21 12:22 ` Steve Lawrence
2015-04-21 12:47 ` Petr Lautrbach
0 siblings, 1 reply; 4+ messages in thread
From: Steve Lawrence @ 2015-04-21 12:22 UTC (permalink / raw)
To: Petr Lautrbach, selinux; +Cc: Miro Hrončok
On 04/21/2015 07:46 AM, Petr Lautrbach wrote:
> From: Miro Hrončok <mhroncok@redhat.com>
>
> os.path.walk() function is deprecated and has been removed in Python 3
>
> Signed-off-by: Petr Lautrbach <plautrba@redhat.com>
Acked-by: Steve Lawrence <slawrence@tresys.com>
Thanks!
> ---
>
> 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(-)
>
> diff --git a/libselinux/src/selinuxswig_python.i b/libselinux/src/selinuxswig_python.i
> index ae72246..c9a2341 100644
> --- a/libselinux/src/selinuxswig_python.i
> +++ b/libselinux/src/selinuxswig_python.i
> @@ -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 """
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] libselinux: selinux.py - use os.walk() instead of os.path.walk()
2015-04-21 12:22 ` Steve Lawrence
@ 2015-04-21 12:47 ` Petr Lautrbach
2015-04-21 12:51 ` Steve Lawrence
0 siblings, 1 reply; 4+ messages in thread
From: Petr Lautrbach @ 2015-04-21 12:47 UTC (permalink / raw)
To: Steve Lawrence, selinux
[-- Attachment #1: Type: text/plain, Size: 1846 bytes --]
On 04/21/2015 02:22 PM, Steve Lawrence wrote:
> On 04/21/2015 07:46 AM, Petr Lautrbach wrote:
>> From: Miro Hrončok <mhroncok@redhat.com>
>>
>> os.path.walk() function is deprecated and has been removed in Python 3
>>
>> Signed-off-by: Petr Lautrbach <plautrba@redhat.com>
>
> Acked-by: Steve Lawrence <slawrence@tresys.com>
>
> Thanks!
Might it be that you've accidentally edited a wrong ChangeLog?
Update libselinux ChangeLog
--- a/libsemanage/ChangeLog
+++ b/libsemanage/ChangeLog
@@ -1,3 +1,5 @@
+ * Use os.walk() instead of the deprecated os.path.walk(), from Petr
+ Lautrbach & Miro Hrončok
Petr
>
>> ---
>>
>> 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(-)
>>
>> diff --git a/libselinux/src/selinuxswig_python.i b/libselinux/src/selinuxswig_python.i
>> index ae72246..c9a2341 100644
>> --- a/libselinux/src/selinuxswig_python.i
>> +++ b/libselinux/src/selinuxswig_python.i
>> @@ -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 """
>>
>
--
Petr Lautrbach
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] libselinux: selinux.py - use os.walk() instead of os.path.walk()
2015-04-21 12:47 ` Petr Lautrbach
@ 2015-04-21 12:51 ` Steve Lawrence
0 siblings, 0 replies; 4+ messages in thread
From: Steve Lawrence @ 2015-04-21 12:51 UTC (permalink / raw)
To: Petr Lautrbach, selinux
On 04/21/2015 08:47 AM, Petr Lautrbach wrote:
> On 04/21/2015 02:22 PM, Steve Lawrence wrote:
>> On 04/21/2015 07:46 AM, Petr Lautrbach wrote:
>>> From: Miro Hrončok <mhroncok@redhat.com>
>>>
>>> os.path.walk() function is deprecated and has been removed in Python 3
>>>
>>> Signed-off-by: Petr Lautrbach <plautrba@redhat.com>
>>
>> Acked-by: Steve Lawrence <slawrence@tresys.com>
>>
>> Thanks!
>
> Might it be that you've accidentally edited a wrong ChangeLog?
>
> Update libselinux ChangeLog
>
Yep. Thanks. That's been fixed.
- Steve
> --- a/libsemanage/ChangeLog
> +++ b/libsemanage/ChangeLog
> @@ -1,3 +1,5 @@
> + * Use os.walk() instead of the deprecated os.path.walk(), from Petr
> + Lautrbach & Miro Hrončok
>
>
>
> Petr
>
>>
>>> ---
>>>
>>> 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(-)
>>>
>>> diff --git a/libselinux/src/selinuxswig_python.i b/libselinux/src/selinuxswig_python.i
>>> index ae72246..c9a2341 100644
>>> --- a/libselinux/src/selinuxswig_python.i
>>> +++ b/libselinux/src/selinuxswig_python.i
>>> @@ -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 """
>>>
>>
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-04-21 12:51 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-21 11:46 [PATCH] libselinux: selinux.py - use os.walk() instead of os.path.walk() Petr Lautrbach
2015-04-21 12:22 ` Steve Lawrence
2015-04-21 12:47 ` Petr Lautrbach
2015-04-21 12:51 ` Steve Lawrence
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.