All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/2] sepolgen: Fix AttributeError: 'dict' object has no attribute 'attributes'
@ 2013-07-19 20:11 Sven Vermeulen
  2013-07-21 10:37 ` Daniel J Walsh
  0 siblings, 1 reply; 2+ messages in thread
From: Sven Vermeulen @ 2013-07-19 20:11 UTC (permalink / raw)
  To: selinux


While running the tests, the test_export one fails as follows:

======================================================================
ERROR: test_export (test_interfaces.TestInterfaceSet)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/var/portage/portage/dev-python/sepolgen-1.1.9-r1/work/sepolgen-1.1.9-2.7/tests/test_interfaces.py", line 263, in test_export
    i.add_headers(h)
  File "../src/./sepolgen/interfaces.py", line 412, in add_headers
    self.add(i, attributes)
  File "../src/./sepolgen/interfaces.py", line 407, in add
    ifv = InterfaceVector(interface, attributes)
  File "../src/./sepolgen/interfaces.py", line 257, in __init__
    self.from_interface(interface, attributes)
  File "../src/./sepolgen/interfaces.py", line 279, in from_interface
    if not attributes.attributes.has_key(attr):
AttributeError: 'dict' object has no attribute 'attributes'

The test does not declare the attributes parameter (it is optional) so it
becomes the empty dictionary object.

Changing "if attributes != None:" to "if attributes:" gets the tests to succeed
and the code still seems to function correctly (ran "sepolgen-ifgen" and
"sepolgen-ifgen -i /usr/share/selinux/strict/include" to trigger the code).

Signed-off-by: Sven Vermeulen <sven.vermeulen@siphos.be>
---
 sepolgen/src/sepolgen/interfaces.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sepolgen/src/sepolgen/interfaces.py b/sepolgen/src/sepolgen/interfaces.py
index ae1c9c5..88a6dc3 100644
--- a/sepolgen/src/sepolgen/interfaces.py
+++ b/sepolgen/src/sepolgen/interfaces.py
@@ -273,7 +273,7 @@ class InterfaceVector:
                 self.add_av(av)
 
         # Add typeattribute access
-        if attributes != None:
+        if attributes:
             for typeattribute in interface.typeattributes():
                 for attr in typeattribute.attributes:
                     if not attributes.attributes.has_key(attr):
-- 
1.8.1.5


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 2/2] sepolgen: Fix AttributeError: 'dict' object has no attribute 'attributes'
  2013-07-19 20:11 [PATCH 2/2] sepolgen: Fix AttributeError: 'dict' object has no attribute 'attributes' Sven Vermeulen
@ 2013-07-21 10:37 ` Daniel J Walsh
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel J Walsh @ 2013-07-21 10:37 UTC (permalink / raw)
  To: Sven Vermeulen; +Cc: selinux

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 07/19/2013 04:11 PM, Sven Vermeulen wrote:
> 
> While running the tests, the test_export one fails as follows:
> 
> ====================================================================== 
> ERROR: test_export (test_interfaces.TestInterfaceSet) 
> ---------------------------------------------------------------------- 
> Traceback (most recent call last): File
> "/var/portage/portage/dev-python/sepolgen-1.1.9-r1/work/sepolgen-1.1.9-2.7/tests/test_interfaces.py",
> line 263, in test_export i.add_headers(h) File
> "../src/./sepolgen/interfaces.py", line 412, in add_headers self.add(i,
> attributes) File "../src/./sepolgen/interfaces.py", line 407, in add ifv =
> InterfaceVector(interface, attributes) File
> "../src/./sepolgen/interfaces.py", line 257, in __init__ 
> self.from_interface(interface, attributes) File
> "../src/./sepolgen/interfaces.py", line 279, in from_interface if not
> attributes.attributes.has_key(attr): AttributeError: 'dict' object has no
> attribute 'attributes'
> 
> The test does not declare the attributes parameter (it is optional) so it 
> becomes the empty dictionary object.
> 
> Changing "if attributes != None:" to "if attributes:" gets the tests to
> succeed and the code still seems to function correctly (ran
> "sepolgen-ifgen" and "sepolgen-ifgen -i /usr/share/selinux/strict/include"
> to trigger the code).
> 
> Signed-off-by: Sven Vermeulen <sven.vermeulen@siphos.be> --- 
> sepolgen/src/sepolgen/interfaces.py | 2 +- 1 file changed, 1 insertion(+),
> 1 deletion(-)
> 
> diff --git a/sepolgen/src/sepolgen/interfaces.py
> b/sepolgen/src/sepolgen/interfaces.py index ae1c9c5..88a6dc3 100644 ---
> a/sepolgen/src/sepolgen/interfaces.py +++
> b/sepolgen/src/sepolgen/interfaces.py @@ -273,7 +273,7 @@ class
> InterfaceVector: self.add_av(av)
> 
> # Add typeattribute access -        if attributes != None: +        if
> attributes: for typeattribute in interface.typeattributes(): for attr in
> typeattribute.attributes: if not attributes.attributes.has_key(attr):
> 

Applied to Fedora.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.13 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEARECAAYFAlHrudwACgkQrlYvE4MpobM7nwCdGVBVL8av5U5vsNOlNqiXvdLi
C8kAoJY8camlRWXeTx9+bWgZQIfRgHTv
=InTW
-----END PGP SIGNATURE-----

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-07-21 10:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-19 20:11 [PATCH 2/2] sepolgen: Fix AttributeError: 'dict' object has no attribute 'attributes' Sven Vermeulen
2013-07-21 10:37 ` Daniel J Walsh

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.