* [PATCH] python/sepolicy: Use xml.etree.ElementTree.Element.iter()
@ 2020-06-08 12:18 Petr Lautrbach
2020-06-08 16:23 ` Stephen Smalley
0 siblings, 1 reply; 3+ messages in thread
From: Petr Lautrbach @ 2020-06-08 12:18 UTC (permalink / raw)
To: selinux; +Cc: Petr Lautrbach
xml.etree.ElementTree.Element.getiterator() was deprecated since Python 3.2 and
dropped in Python 3.9
Fixes:
Verify sepolicy interface -c -i works ... Traceback (most recent call last):
File "/usr/bin/sepolicy", line 691, in <module>
args = parser.parse_args(args=parser_args)
File "/usr/lib64/python3.9/argparse.py", line 1819, in parse_args
args, argv = self.parse_known_args(args, namespace)
File "/usr/lib64/python3.9/argparse.py", line 1852, in parse_known_args
namespace, args = self._parse_known_args(args, namespace)
File "/usr/lib64/python3.9/argparse.py", line 2043, in _parse_known_args
positionals_end_index = consume_positionals(start_index)
File "/usr/lib64/python3.9/argparse.py", line 2020, in consume_positionals
take_action(action, args)
File "/usr/lib64/python3.9/argparse.py", line 1929, in take_action
action(self, namespace, argument_values, option_string)
File "/usr/lib64/python3.9/argparse.py", line 1208, in __call__
subnamespace, arg_strings = parser.parse_known_args(arg_strings, None)
File "/usr/lib64/python3.9/argparse.py", line 1852, in parse_known_args
namespace, args = self._parse_known_args(args, namespace)
File "/usr/lib64/python3.9/argparse.py", line 2061, in _parse_known_args
start_index = consume_optional(start_index)
File "/usr/lib64/python3.9/argparse.py", line 2001, in consume_optional
take_action(action, args, option_string)
File "/usr/lib64/python3.9/argparse.py", line 1929, in take_action
action(self, namespace, argument_values, option_string)
File "/usr/bin/sepolicy", line 216, in __call__
interface_dict = get_interface_dict()
File "/usr/lib/python3.9/site-packages/sepolicy/interface.py", line 149, in get_interface_dict
for i in m.getiterator('interface'):
AttributeError: 'xml.etree.ElementTree.Element' object has no attribute 'getiterator'
Signed-off-by: Petr Lautrbach <plautrba@redhat.com>
---
python/sepolicy/sepolicy/interface.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/python/sepolicy/sepolicy/interface.py b/python/sepolicy/sepolicy/interface.py
index 7d4ebd7ecdba..bdffb770f364 100644
--- a/python/sepolicy/sepolicy/interface.py
+++ b/python/sepolicy/sepolicy/interface.py
@@ -146,12 +146,12 @@ def get_interface_dict(path="/usr/share/selinux/devel/policy.xml"):
tree = xml.etree.ElementTree.fromstring(xml_path)
for l in tree.findall("layer"):
for m in l.findall("module"):
- for i in m.getiterator('interface'):
+ for i in m.iter('interface'):
for e in i.findall("param"):
param_list.append(e.get('name'))
interface_dict[(i.get("name"))] = [param_list, (i.find('summary').text), "interface"]
param_list = []
- for i in m.getiterator('template'):
+ for i in m.iter('template'):
for e in i.findall("param"):
param_list.append(e.get('name'))
interface_dict[(i.get("name"))] = [param_list, (i.find('summary').text), "template"]
--
2.26.2
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] python/sepolicy: Use xml.etree.ElementTree.Element.iter()
2020-06-08 12:18 [PATCH] python/sepolicy: Use xml.etree.ElementTree.Element.iter() Petr Lautrbach
@ 2020-06-08 16:23 ` Stephen Smalley
2020-06-18 19:36 ` Petr Lautrbach
0 siblings, 1 reply; 3+ messages in thread
From: Stephen Smalley @ 2020-06-08 16:23 UTC (permalink / raw)
To: Petr Lautrbach; +Cc: SElinux list
On Mon, Jun 8, 2020 at 8:19 AM Petr Lautrbach <plautrba@redhat.com> wrote:
>
> xml.etree.ElementTree.Element.getiterator() was deprecated since Python 3.2 and
> dropped in Python 3.9
>
> Fixes:
> Verify sepolicy interface -c -i works ... Traceback (most recent call last):
> File "/usr/bin/sepolicy", line 691, in <module>
> args = parser.parse_args(args=parser_args)
> File "/usr/lib64/python3.9/argparse.py", line 1819, in parse_args
> args, argv = self.parse_known_args(args, namespace)
> File "/usr/lib64/python3.9/argparse.py", line 1852, in parse_known_args
> namespace, args = self._parse_known_args(args, namespace)
> File "/usr/lib64/python3.9/argparse.py", line 2043, in _parse_known_args
> positionals_end_index = consume_positionals(start_index)
> File "/usr/lib64/python3.9/argparse.py", line 2020, in consume_positionals
> take_action(action, args)
> File "/usr/lib64/python3.9/argparse.py", line 1929, in take_action
> action(self, namespace, argument_values, option_string)
> File "/usr/lib64/python3.9/argparse.py", line 1208, in __call__
> subnamespace, arg_strings = parser.parse_known_args(arg_strings, None)
> File "/usr/lib64/python3.9/argparse.py", line 1852, in parse_known_args
> namespace, args = self._parse_known_args(args, namespace)
> File "/usr/lib64/python3.9/argparse.py", line 2061, in _parse_known_args
> start_index = consume_optional(start_index)
> File "/usr/lib64/python3.9/argparse.py", line 2001, in consume_optional
> take_action(action, args, option_string)
> File "/usr/lib64/python3.9/argparse.py", line 1929, in take_action
> action(self, namespace, argument_values, option_string)
> File "/usr/bin/sepolicy", line 216, in __call__
> interface_dict = get_interface_dict()
> File "/usr/lib/python3.9/site-packages/sepolicy/interface.py", line 149, in get_interface_dict
> for i in m.getiterator('interface'):
> AttributeError: 'xml.etree.ElementTree.Element' object has no attribute 'getiterator'
>
> Signed-off-by: Petr Lautrbach <plautrba@redhat.com>
Acked-by: Stephen Smalley <stephen.smalley.work@gmail.com>
> ---
> python/sepolicy/sepolicy/interface.py | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/python/sepolicy/sepolicy/interface.py b/python/sepolicy/sepolicy/interface.py
> index 7d4ebd7ecdba..bdffb770f364 100644
> --- a/python/sepolicy/sepolicy/interface.py
> +++ b/python/sepolicy/sepolicy/interface.py
> @@ -146,12 +146,12 @@ def get_interface_dict(path="/usr/share/selinux/devel/policy.xml"):
> tree = xml.etree.ElementTree.fromstring(xml_path)
> for l in tree.findall("layer"):
> for m in l.findall("module"):
> - for i in m.getiterator('interface'):
> + for i in m.iter('interface'):
> for e in i.findall("param"):
> param_list.append(e.get('name'))
> interface_dict[(i.get("name"))] = [param_list, (i.find('summary').text), "interface"]
> param_list = []
> - for i in m.getiterator('template'):
> + for i in m.iter('template'):
> for e in i.findall("param"):
> param_list.append(e.get('name'))
> interface_dict[(i.get("name"))] = [param_list, (i.find('summary').text), "template"]
> --
> 2.26.2
>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] python/sepolicy: Use xml.etree.ElementTree.Element.iter()
2020-06-08 16:23 ` Stephen Smalley
@ 2020-06-18 19:36 ` Petr Lautrbach
0 siblings, 0 replies; 3+ messages in thread
From: Petr Lautrbach @ 2020-06-18 19:36 UTC (permalink / raw)
To: Stephen Smalley; +Cc: SElinux list
[-- Attachment #1: Type: text/plain, Size: 3697 bytes --]
On Mon, Jun 08, 2020 at 12:23:49PM -0400, Stephen Smalley wrote:
> On Mon, Jun 8, 2020 at 8:19 AM Petr Lautrbach <plautrba@redhat.com> wrote:
> >
> > xml.etree.ElementTree.Element.getiterator() was deprecated since Python 3.2 and
> > dropped in Python 3.9
> >
> > Fixes:
> > Verify sepolicy interface -c -i works ... Traceback (most recent call last):
> > File "/usr/bin/sepolicy", line 691, in <module>
> > args = parser.parse_args(args=parser_args)
> > File "/usr/lib64/python3.9/argparse.py", line 1819, in parse_args
> > args, argv = self.parse_known_args(args, namespace)
> > File "/usr/lib64/python3.9/argparse.py", line 1852, in parse_known_args
> > namespace, args = self._parse_known_args(args, namespace)
> > File "/usr/lib64/python3.9/argparse.py", line 2043, in _parse_known_args
> > positionals_end_index = consume_positionals(start_index)
> > File "/usr/lib64/python3.9/argparse.py", line 2020, in consume_positionals
> > take_action(action, args)
> > File "/usr/lib64/python3.9/argparse.py", line 1929, in take_action
> > action(self, namespace, argument_values, option_string)
> > File "/usr/lib64/python3.9/argparse.py", line 1208, in __call__
> > subnamespace, arg_strings = parser.parse_known_args(arg_strings, None)
> > File "/usr/lib64/python3.9/argparse.py", line 1852, in parse_known_args
> > namespace, args = self._parse_known_args(args, namespace)
> > File "/usr/lib64/python3.9/argparse.py", line 2061, in _parse_known_args
> > start_index = consume_optional(start_index)
> > File "/usr/lib64/python3.9/argparse.py", line 2001, in consume_optional
> > take_action(action, args, option_string)
> > File "/usr/lib64/python3.9/argparse.py", line 1929, in take_action
> > action(self, namespace, argument_values, option_string)
> > File "/usr/bin/sepolicy", line 216, in __call__
> > interface_dict = get_interface_dict()
> > File "/usr/lib/python3.9/site-packages/sepolicy/interface.py", line 149, in get_interface_dict
> > for i in m.getiterator('interface'):
> > AttributeError: 'xml.etree.ElementTree.Element' object has no attribute 'getiterator'
> >
> > Signed-off-by: Petr Lautrbach <plautrba@redhat.com>
>
> Acked-by: Stephen Smalley <stephen.smalley.work@gmail.com>
Applied.
> > ---
> > python/sepolicy/sepolicy/interface.py | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/python/sepolicy/sepolicy/interface.py b/python/sepolicy/sepolicy/interface.py
> > index 7d4ebd7ecdba..bdffb770f364 100644
> > --- a/python/sepolicy/sepolicy/interface.py
> > +++ b/python/sepolicy/sepolicy/interface.py
> > @@ -146,12 +146,12 @@ def get_interface_dict(path="/usr/share/selinux/devel/policy.xml"):
> > tree = xml.etree.ElementTree.fromstring(xml_path)
> > for l in tree.findall("layer"):
> > for m in l.findall("module"):
> > - for i in m.getiterator('interface'):
> > + for i in m.iter('interface'):
> > for e in i.findall("param"):
> > param_list.append(e.get('name'))
> > interface_dict[(i.get("name"))] = [param_list, (i.find('summary').text), "interface"]
> > param_list = []
> > - for i in m.getiterator('template'):
> > + for i in m.iter('template'):
> > for e in i.findall("param"):
> > param_list.append(e.get('name'))
> > interface_dict[(i.get("name"))] = [param_list, (i.find('summary').text), "template"]
> > --
> > 2.26.2
> >
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-06-18 19:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-06-08 12:18 [PATCH] python/sepolicy: Use xml.etree.ElementTree.Element.iter() Petr Lautrbach
2020-06-08 16:23 ` Stephen Smalley
2020-06-18 19:36 ` Petr Lautrbach
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox