[Python-modules-team] Bug#860986: python-iptables library did not work

Chris Lamb lamby at debian.org
Mon Apr 24 10:23:55 UTC 2017


retitle 860986 python-iptables: import raises AttributeError: 'NoneType' object has no attribute 'throw_exception'
thanks


I think the problem is actually deeper. Even after I "fix" the custom
library loading code with something like:

    --- a/iptc/util.py
    +++ b/iptc/util.py
    @@ -78,7 +78,8 @@ def _find_library(*names):
         if version_info > (3, ):
             ext = get_config_var("EXT_SUFFIX")
         else:
    -        ext = get_config_var('SO')
    +        import imp
    +        ext = [x for x, y, z in imp.get_suffixes() if z == imp.C_EXTENSION][0]
         for name in names:
             libnames = [name, "lib" + name, name + ext, "lib" + name + ext]
             libdir = os.environ.get('IPTABLES_LIBDIR', None)

… then I end up with:

 Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/iptc/__init__.py", line 10, in <module>
    from iptc.ip4tc import (is_table_available, Table, Chain, Rule, Match, Target,
  File "/usr/lib/python2.7/dist-packages/iptc/ip4tc.py", line 36, in <module>
    xtables(NFPROTO_IPV4)
  File "/usr/lib/python2.7/dist-packages/iptc/xtables.py", line 814, in __new__
    obj._xtinit(proto)
  File "/usr/lib/python2.7/dist-packages/iptc/xtables.py", line 829, in _xtinit
    (xtables_version))
iptc.xtables.XTablesError: unknown xtables version 12



Regards,

-- 
      ,''`.
     : :'  :     Chris Lamb
     `. `'`      lamby at debian.org / chris-lamb.co.uk
       `-
-------------- next part --------------
diff --git a/iptc/util.py b/iptc/util.py
index a587e7e..43f5ca8 100644
--- a/iptc/util.py
+++ b/iptc/util.py
@@ -78,7 +78,8 @@ def _find_library(*names):
     if version_info > (3, ):
         ext = get_config_var("EXT_SUFFIX")
     else:
-        ext = get_config_var('SO')
+        import imp
+        ext = [x for x, y, z in imp.get_suffixes() if z == imp.C_EXTENSION][0]
     for name in names:
         libnames = [name, "lib" + name, name + ext, "lib" + name + ext]
         libdir = os.environ.get('IPTABLES_LIBDIR', None)


More information about the Python-modules-team mailing list