[Python-modules-commits] [pysubnettree] 02/04: Imported Upstream version 0.27

Scott Kitterman kitterman at moszumanska.debian.org
Sun Jan 14 08:08:19 UTC 2018


This is an automated email from the git hooks/post-receive script.

kitterman pushed a commit to branch debian/master
in repository pysubnettree.

commit c7bd6fc1112191cfb9666bf03a5af52d706b973c
Author: Scott Kitterman <scott at kitterman.com>
Date:   Sun Jan 14 03:04:32 2018 -0500

    Imported Upstream version 0.27
---
 CHANGES                             |  30 ++
 PKG-INFO                            |   2 +-
 README                              |   2 +-
 SubnetTree.cc                       |  75 ++++
 SubnetTree.h                        |   2 +
 SubnetTree.py                       | 126 ++++--
 SubnetTree_wrap.cc                  | 775 ++++++++++++++++++++++++------------
 VERSION                             |   2 +-
 patricia.c                          |   1 +
 pysubnettree.egg-info/PKG-INFO      |   2 +-
 pysubnettree.egg-info/SOURCES.txt   |   1 -
 pysubnettree.egg-info/pbr.json      |   1 -
 pysubnettree.egg-info/top_level.txt |   2 +-
 setup.py                            |   2 +-
 14 files changed, 724 insertions(+), 299 deletions(-)

diff --git a/CHANGES b/CHANGES
index ce1ce62..eaf5957 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,34 @@
 
+0.27 | 2017-05-26 08:28:10 -0500
+
+  * Release 0.27.
+
+0.26-2 | 2016-12-06 12:33:17 -0800
+
+  * Fix compiler warnings on OpenBSD, add missing include. (Daniel Thayer)
+
+0.26 | 2016-10-27 14:43:48 -0700
+
+ * Release 0.26.
+
+0.25-4 | 2016-10-06 09:08:48 -0700
+
+  * Fix the prefixes() function to compile and work on Python 3.
+    (Daniel Thayer)
+
+  * Cleanup tests for the prefixes() function and improved comments
+    and error messages. (Daniel Thayer)
+
+0.25 | 2016-08-12 13:19:45 -0700
+
+  * Release 0.25.
+
+0.24-7 | 2016-01-25 14:22:14 -0800
+
+  * Added prefixes() method to return all prefixes in the tree as a
+    set of strings, with or without length.  Also supports returning
+    IPv4 addresses in their "native" format. (James Royalty)
+
 0.24 | 2015-05-07 20:24:57 -0700
 
   * Release 0.24.
diff --git a/PKG-INFO b/PKG-INFO
index f5b6a34..2139ad8 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.0
 Name: pysubnettree
-Version: 0.24
+Version: 0.27
 Summary: 
 The PySubnetTree package provides a Python data structure SubnetTree
 that maps subnets given in CIDR notation (incl. corresponding IPv6
diff --git a/README b/README
index 8e40bb6..471a5ad 100644
--- a/README
+++ b/README
@@ -1,7 +1,7 @@
 ..	-*- mode: rst-mode -*-
 ..
 .. Version number is filled in automatically.
-.. |version| replace:: 0.24
+.. |version| replace:: 0.27
 
 ===============================================
 PySubnetTree - A Python Module for CIDR Lookups
diff --git a/SubnetTree.cc b/SubnetTree.cc
index f8ee7c0..4360fac 100644
--- a/SubnetTree.cc
+++ b/SubnetTree.cc
@@ -252,6 +252,81 @@ PyObject* SubnetTree::lookup(int family, inx_addr addr) const
     return data;
 }
 
+PyObject* SubnetTree::prefixes(bool ipv4_native /*=false*/, bool with_len /*=true*/) const
+{
+    char buf[INET6_ADDRSTRLEN];
+    char buffer[64];
+    bool wrote_buffer;
+    PyObject* set = PySet_New(NULL);
+
+    patricia_node_t *node;
+
+    PATRICIA_WALK (tree->head, node) {
+        prefix_t* pf = node->prefix;
+        PyObject* pstr = NULL;
+
+        wrote_buffer = false;
+
+        if ( ipv4_native ) {
+            // IPv4 addresses are stored mapped into the IPv6 space. (Xref:
+            // https://en.wikipedia.org/wiki/IPv6#IPv4-mapped_IPv6_addresses)
+            // We'll check the first 12 bytes (96 bits) of the stored address
+            // to see if they match v4_mapped_prefix.
+            uint8_t* addrstart = (uint8_t*) &pf->add.sin6;
+
+            if ( memcmp(&v4_mapped_prefix, addrstart, 12) == 0 ) {
+                // Skip over the mapped-prefix to the IPV4 addr part. And we
+                // need to correct the bitlen to make it valid for IPv4 (by
+                // subtracting the 96 mapped-prefix bits).
+                addrstart += 12;
+
+                if ( with_len ) {
+                    snprintf(buffer, sizeof buffer, "%d.%d.%d.%d/%d",
+                                               addrstart[0], addrstart[1],
+                                               addrstart[2], addrstart[3],
+                                               pf->bitlen - 96);
+                }
+
+                else {
+                    snprintf(buffer, sizeof buffer, "%d.%d.%d.%d",
+                                               addrstart[0], addrstart[1],
+                                               addrstart[2], addrstart[3]);
+                }
+
+                wrote_buffer = true;
+            }
+        }
+
+        if ( ! wrote_buffer ) {
+            // Format as IPv6 address.
+
+            const char* addrstr = inet_ntop(AF_INET6, &pf->add.sin6, buf, INET6_ADDRSTRLEN);
+
+            if ( ! addrstr ) {
+                PyErr_SetString(PyExc_ValueError, "Unable to string-ify IPv6 address.");
+                return NULL;
+            }
+
+            if ( with_len )
+                snprintf(buffer, sizeof buffer, "%s/%d", addrstr, pf->bitlen);
+            else
+                snprintf(buffer, sizeof buffer, "%s", addrstr);
+        }
+
+#if PY_MAJOR_VERSION >= 3
+        pstr = PyUnicode_FromString(buffer);
+#else
+        pstr = PyString_FromString(buffer);
+#endif
+
+        PySet_Add(set, pstr);
+        Py_DECREF(pstr);
+
+    } PATRICIA_WALK_END;
+
+    return set;
+}
+
 bool SubnetTree::get_binary_lookup_mode()
 {
     return binary_lookup_mode;
diff --git a/SubnetTree.h b/SubnetTree.h
index 2986306..187e9b3 100644
--- a/SubnetTree.h
+++ b/SubnetTree.h
@@ -71,6 +71,8 @@ public:
    PyObject* lookup(const char *cidr, int size) const;
    PyObject* lookup(unsigned long addr) const;
 
+   PyObject* prefixes(bool ipv4_native = false, bool with_len = true) const;
+
    bool get_binary_lookup_mode();
    void set_binary_lookup_mode(bool binary_lookup_mode = true);
 
diff --git a/SubnetTree.py b/SubnetTree.py
index 4f8e122..c9671c1 100644
--- a/SubnetTree.py
+++ b/SubnetTree.py
@@ -1,13 +1,15 @@
 # This file was automatically generated by SWIG (http://www.swig.org).
-# Version 2.0.4
+# Version 3.0.7
 #
 # Do not make changes to this file unless you know what you are doing--modify
 # the SWIG interface file instead.
 
 
 
+
+
 from sys import version_info
-if version_info >= (2,6,0):
+if version_info >= (2, 6, 0):
     def swig_import_helper():
         from os.path import dirname
         import imp
@@ -31,39 +33,60 @@ del version_info
 try:
     _swig_property = property
 except NameError:
-    pass # Python < 2.2 doesn't have 'property'.
-def _swig_setattr_nondynamic(self,class_type,name,value,static=1):
-    if (name == "thisown"): return self.this.own(value)
+    pass  # Python < 2.2 doesn't have 'property'.
+
+
+def _swig_setattr_nondynamic(self, class_type, name, value, static=1):
+    if (name == "thisown"):
+        return self.this.own(value)
     if (name == "this"):
         if type(value).__name__ == 'SwigPyObject':
             self.__dict__[name] = value
             return
-    method = class_type.__swig_setmethods__.get(name,None)
-    if method: return method(self,value)
+    method = class_type.__swig_setmethods__.get(name, None)
+    if method:
+        return method(self, value)
     if (not static):
-        self.__dict__[name] = value
+        if _newclass:
+            object.__setattr__(self, name, value)
+        else:
+            self.__dict__[name] = value
     else:
         raise AttributeError("You cannot add attributes to %s" % self)
 
-def _swig_setattr(self,class_type,name,value):
-    return _swig_setattr_nondynamic(self,class_type,name,value,0)
 
-def _swig_getattr(self,class_type,name):
-    if (name == "thisown"): return self.this.own()
-    method = class_type.__swig_getmethods__.get(name,None)
-    if method: return method(self)
-    raise AttributeError(name)
+def _swig_setattr(self, class_type, name, value):
+    return _swig_setattr_nondynamic(self, class_type, name, value, 0)
+
+
+def _swig_getattr_nondynamic(self, class_type, name, static=1):
+    if (name == "thisown"):
+        return self.this.own()
+    method = class_type.__swig_getmethods__.get(name, None)
+    if method:
+        return method(self)
+    if (not static):
+        return object.__getattr__(self, name)
+    else:
+        raise AttributeError(name)
+
+def _swig_getattr(self, class_type, name):
+    return _swig_getattr_nondynamic(self, class_type, name, 0)
+
 
 def _swig_repr(self):
-    try: strthis = "proxy of " + self.this.__repr__()
-    except: strthis = ""
+    try:
+        strthis = "proxy of " + self.this.__repr__()
+    except:
+        strthis = ""
     return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
 
 try:
     _object = object
     _newclass = 1
 except AttributeError:
-    class _object : pass
+    class _object:
+        pass
     _newclass = 0
 
 
@@ -75,16 +98,21 @@ class inx_addr(_object):
     __repr__ = _swig_repr
     __swig_setmethods__["sin"] = _SubnetTree.inx_addr_sin_set
     __swig_getmethods__["sin"] = _SubnetTree.inx_addr_sin_get
-    if _newclass:sin = _swig_property(_SubnetTree.inx_addr_sin_get, _SubnetTree.inx_addr_sin_set)
+    if _newclass:
+        sin = _swig_property(_SubnetTree.inx_addr_sin_get, _SubnetTree.inx_addr_sin_set)
     __swig_setmethods__["sin6"] = _SubnetTree.inx_addr_sin6_set
     __swig_getmethods__["sin6"] = _SubnetTree.inx_addr_sin6_get
-    if _newclass:sin6 = _swig_property(_SubnetTree.inx_addr_sin6_get, _SubnetTree.inx_addr_sin6_set)
-    def __init__(self): 
+    if _newclass:
+        sin6 = _swig_property(_SubnetTree.inx_addr_sin6_get, _SubnetTree.inx_addr_sin6_set)
+
+    def __init__(self):
         this = _SubnetTree.new_inx_addr()
-        try: self.this.append(this)
-        except: self.this = this
+        try:
+            self.this.append(this)
+        except:
+            self.this = this
     __swig_destroy__ = _SubnetTree.delete_inx_addr
-    __del__ = lambda self : None;
+    __del__ = lambda self: None
 inx_addr_swigregister = _SubnetTree.inx_addr_swigregister
 inx_addr_swigregister(inx_addr)
 
@@ -94,21 +122,45 @@ class SubnetTree(_object):
     __swig_getmethods__ = {}
     __getattr__ = lambda self, name: _swig_getattr(self, SubnetTree, name)
     __repr__ = _swig_repr
-    def __init__(self, binary_lookup_mode = False): 
+
+    def __init__(self, binary_lookup_mode=False):
         this = _SubnetTree.new_SubnetTree(binary_lookup_mode)
-        try: self.this.append(this)
-        except: self.this = this
+        try:
+            self.this.append(this)
+        except:
+            self.this = this
     __swig_destroy__ = _SubnetTree.delete_SubnetTree
-    __del__ = lambda self : None;
-    def insert(self, *args): return _SubnetTree.SubnetTree_insert(self, *args)
-    def remove(self, *args): return _SubnetTree.SubnetTree_remove(self, *args)
-    def lookup(self, *args): return _SubnetTree.SubnetTree_lookup(self, *args)
-    def get_binary_lookup_mode(self): return _SubnetTree.SubnetTree_get_binary_lookup_mode(self)
-    def set_binary_lookup_mode(self, binary_lookup_mode = True): return _SubnetTree.SubnetTree_set_binary_lookup_mode(self, binary_lookup_mode)
-    def __contains__(self, *args): return _SubnetTree.SubnetTree___contains__(self, *args)
-    def __getitem__(self, *args): return _SubnetTree.SubnetTree___getitem__(self, *args)
-    def __setitem__(self, *args): return _SubnetTree.SubnetTree___setitem__(self, *args)
-    def __delitem__(self, *args): return _SubnetTree.SubnetTree___delitem__(self, *args)
+    __del__ = lambda self: None
+
+    def insert(self, *args):
+        return _SubnetTree.SubnetTree_insert(self, *args)
+
+    def remove(self, *args):
+        return _SubnetTree.SubnetTree_remove(self, *args)
+
+    def lookup(self, *args):
+        return _SubnetTree.SubnetTree_lookup(self, *args)
+
+    def prefixes(self, ipv4_native=False, with_len=True):
+        return _SubnetTree.SubnetTree_prefixes(self, ipv4_native, with_len)
+
+    def get_binary_lookup_mode(self):
+        return _SubnetTree.SubnetTree_get_binary_lookup_mode(self)
+
+    def set_binary_lookup_mode(self, binary_lookup_mode=True):
+        return _SubnetTree.SubnetTree_set_binary_lookup_mode(self, binary_lookup_mode)
+
+    def __contains__(self, *args):
+        return _SubnetTree.SubnetTree___contains__(self, *args)
+
+    def __getitem__(self, cidr):
+        return _SubnetTree.SubnetTree___getitem__(self, cidr)
+
+    def __setitem__(self, cidr, data):
+        return _SubnetTree.SubnetTree___setitem__(self, cidr, data)
+
+    def __delitem__(self, cidr):
+        return _SubnetTree.SubnetTree___delitem__(self, cidr)
 SubnetTree_swigregister = _SubnetTree.SubnetTree_swigregister
 SubnetTree_swigregister(SubnetTree)
 
diff --git a/SubnetTree_wrap.cc b/SubnetTree_wrap.cc
index b3964e6..082ad3f 100644
--- a/SubnetTree_wrap.cc
+++ b/SubnetTree_wrap.cc
@@ -1,11 +1,11 @@
 /* ----------------------------------------------------------------------------
  * This file was automatically generated by SWIG (http://www.swig.org).
- * Version 2.0.4
- * 
- * This file is not intended to be easily readable and contains a number of 
+ * Version 3.0.7
+ *
+ * This file is not intended to be easily readable and contains a number of
  * coding conventions designed to improve portability and efficiency. Do not make
- * changes to this file unless you know what you are doing--modify the SWIG 
- * interface file instead. 
+ * changes to this file unless you know what you are doing--modify the SWIG
+ * interface file instead.
  * ----------------------------------------------------------------------------- */
 
 #define SWIGPYTHON
@@ -66,28 +66,28 @@ template <typename T> T SwigValueInit() {
 #ifndef SWIGUNUSED
 # if defined(__GNUC__)
 #   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
-#     define SWIGUNUSED __attribute__ ((__unused__)) 
+#     define SWIGUNUSED __attribute__ ((__unused__))
 #   else
 #     define SWIGUNUSED
 #   endif
 # elif defined(__ICC)
-#   define SWIGUNUSED __attribute__ ((__unused__)) 
+#   define SWIGUNUSED __attribute__ ((__unused__))
 # else
-#   define SWIGUNUSED 
+#   define SWIGUNUSED
 # endif
 #endif
 
 #ifndef SWIG_MSC_UNSUPPRESS_4505
 # if defined(_MSC_VER)
 #   pragma warning(disable : 4505) /* unreferenced local function has been removed */
-# endif 
+# endif
 #endif
 
 #ifndef SWIGUNUSEDPARM
 # ifdef __cplusplus
 #   define SWIGUNUSEDPARM(p)
 # else
-#   define SWIGUNUSEDPARM(p) p SWIGUNUSED 
+#   define SWIGUNUSEDPARM(p) p SWIGUNUSED
 # endif
 #endif
 
@@ -130,7 +130,7 @@ template <typename T> T SwigValueInit() {
 #   define SWIGSTDCALL __stdcall
 # else
 #   define SWIGSTDCALL
-# endif 
+# endif
 #endif
 
 /* Deal with Microsoft's attempt at deprecating C standard runtime functions */
@@ -143,10 +143,29 @@ template <typename T> T SwigValueInit() {
 # define _SCL_SECURE_NO_DEPRECATE
 #endif
 
+/* Deal with Apple's deprecated 'AssertMacros.h' from Carbon-framework */
+#if defined(__APPLE__) && !defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES)
+# define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0
+#endif
 
+/* Intel's compiler complains if a variable which was never initialised is
+ * cast to void, which is a common idiom which we use to indicate that we
+ * are aware a variable isn't used.  So we just silence that warning.
+ * See: https://github.com/swig/swig/issues/192 for more discussion.
+ */
+#ifdef __INTEL_COMPILER
+# pragma warning disable 592
+#endif
 
-/* Python.h has to appear first */
-#include <Python.h>
+
+#if defined(_DEBUG) && defined(SWIG_PYTHON_INTERPRETER_NO_DEBUG)
+/* Use debug wrappers with the Python release dll */
+# undef _DEBUG
+# include <Python.h>
+# define _DEBUG
+#else
+# include <Python.h>
+#endif
 
 /* -----------------------------------------------------------------------------
  * swigrun.swg
@@ -172,7 +191,7 @@ template <typename T> T SwigValueInit() {
   You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for
   creating a static or dynamic library from the SWIG runtime code.
   In 99.9% of the cases, SWIG just needs to declare them as 'static'.
-  
+
   But only do this if strictly necessary, ie, if you have problems
   with your compiler or suchlike.
 */
@@ -198,16 +217,16 @@ template <typename T> T SwigValueInit() {
 #define SWIG_POINTER_OWN           0x1
 
 
-/* 
+/*
    Flags/methods for returning states.
-   
-   The SWIG conversion methods, as ConvertPtr, return an integer 
+
+   The SWIG conversion methods, as ConvertPtr, return an integer
    that tells if the conversion was successful or not. And if not,
    an error code can be returned (see swigerrors.swg for the codes).
-   
+
    Use the following macros/flags to set or process the returning
    states.
-   
+
    In old versions of SWIG, code such as the following was usually written:
 
      if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) {
@@ -240,23 +259,23 @@ template <typename T> T SwigValueInit() {
     } else {
       // fail code
     }
-    
+
    I.e., now SWIG_ConvertPtr can return new objects and you can
    identify the case and take care of the deallocation. Of course that
    also requires SWIG_ConvertPtr to return new result values, such as
 
-      int SWIG_ConvertPtr(obj, ptr,...) {         
-        if (<obj is ok>) {			       
-          if (<need new object>) {		       
-            *ptr = <ptr to new allocated object>; 
-            return SWIG_NEWOBJ;		       
-          } else {				       
-            *ptr = <ptr to old object>;	       
-            return SWIG_OLDOBJ;		       
-          } 				       
-        } else {				       
-          return SWIG_BADOBJ;		       
-        }					       
+      int SWIG_ConvertPtr(obj, ptr,...) {
+        if (<obj is ok>) {
+          if (<need new object>) {
+            *ptr = <ptr to new allocated object>;
+            return SWIG_NEWOBJ;
+          } else {
+            *ptr = <ptr to old object>;
+            return SWIG_OLDOBJ;
+          }
+        } else {
+          return SWIG_BADOBJ;
+        }
       }
 
    Of course, returning the plain '0(success)/-1(fail)' still works, but you can be
@@ -270,17 +289,17 @@ template <typename T> T SwigValueInit() {
        int fooi(int);
 
    and you call
- 
+
       food(1)   // cast rank '1'  (1 -> 1.0)
       fooi(1)   // cast rank '0'
 
    just use the SWIG_AddCast()/SWIG_CheckState()
 */
 
-#define SWIG_OK                    (0) 
+#define SWIG_OK                    (0)
 #define SWIG_ERROR                 (-1)
 #define SWIG_IsOK(r)               (r >= 0)
-#define SWIG_ArgError(r)           ((r != SWIG_ERROR) ? r : SWIG_TypeError)  
+#define SWIG_ArgError(r)           ((r != SWIG_ERROR) ? r : SWIG_TypeError)
 
 /* The CastRankLimit says how many bits are used for the cast rank */
 #define SWIG_CASTRANKLIMIT         (1 << 8)
@@ -311,14 +330,14 @@ template <typename T> T SwigValueInit() {
 #  endif
 #  define SWIG_CASTRANKMASK          ((SWIG_CASTRANKLIMIT) -1)
 #  define SWIG_CastRank(r)           (r & SWIG_CASTRANKMASK)
-SWIGINTERNINLINE int SWIG_AddCast(int r) { 
+SWIGINTERNINLINE int SWIG_AddCast(int r) {
   return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r;
 }
-SWIGINTERNINLINE int SWIG_CheckState(int r) { 
-  return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; 
+SWIGINTERNINLINE int SWIG_CheckState(int r) {
+  return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0;
 }
 #else /* no cast-rank mode */
-#  define SWIG_AddCast
+#  define SWIG_AddCast(r) (r)
 #  define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0)
 #endif
 
@@ -362,7 +381,7 @@ typedef struct swig_module_info {
   void                    *clientdata;		/* Language specific module data */
 } swig_module_info;
 
-/* 
+/*
   Compare two type names skipping the space characters, therefore
   "char*" == "char *" and "Class<int>" == "Class<int >", etc.
 
@@ -382,18 +401,18 @@ SWIG_TypeNameComp(const char *f1, const char *l1,
 
 /*
   Check type equivalence in a name list like <name1>|<name2>|...
-  Return 0 if not equal, 1 if equal
+  Return 0 if equal, -1 if nb < tb, 1 if nb > tb
 */
 SWIGRUNTIME int
-SWIG_TypeEquiv(const char *nb, const char *tb) {
-  int equiv = 0;
+SWIG_TypeCmp(const char *nb, const char *tb) {
+  int equiv = 1;
   const char* te = tb + strlen(tb);
   const char* ne = nb;
-  while (!equiv && *ne) {
+  while (equiv != 0 && *ne) {
     for (nb = ne; *ne; ++ne) {
       if (*ne == '|') break;
     }
-    equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0;
+    equiv = SWIG_TypeNameComp(nb, ne, tb, te);
     if (*ne) ++ne;
   }
   return equiv;
@@ -401,24 +420,13 @@ SWIG_TypeEquiv(const char *nb, const char *tb) {
 
 /*
   Check type equivalence in a name list like <name1>|<name2>|...
-  Return 0 if equal, -1 if nb < tb, 1 if nb > tb
+  Return 0 if not equal, 1 if equal
 */
 SWIGRUNTIME int
-SWIG_TypeCompare(const char *nb, const char *tb) {
-  int equiv = 0;
-  const char* te = tb + strlen(tb);
-  const char* ne = nb;
-  while (!equiv && *ne) {
-    for (nb = ne; *ne; ++ne) {
-      if (*ne == '|') break;
-    }
-    equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0;
-    if (*ne) ++ne;
-  }
-  return equiv;
+SWIG_TypeEquiv(const char *nb, const char *tb) {
+  return SWIG_TypeCmp(nb, tb) == 0 ? 1 : 0;
 }
 
-
 /*
   Check the typename
 */
@@ -446,7 +454,7 @@ SWIG_TypeCheck(const char *c, swig_type_info *ty) {
   return 0;
 }
 
-/* 
+/*
   Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison
 */
 SWIGRUNTIME swig_cast_info *
@@ -481,7 +489,7 @@ SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) {
   return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory);
 }
 
-/* 
+/*
    Dynamic pointer casting. Down an inheritance hierarchy
 */
 SWIGRUNTIME swig_type_info *
@@ -525,7 +533,7 @@ SWIG_TypePrettyName(const swig_type_info *type) {
     return type->name;
 }
 
-/* 
+/*
    Set the clientdata field for a type
 */
 SWIGRUNTIME void
@@ -533,14 +541,14 @@ SWIG_TypeClientData(swig_type_info *ti, void *clientdata) {
   swig_cast_info *cast = ti->cast;
   /* if (ti->clientdata == clientdata) return; */
   ti->clientdata = clientdata;
-  
+
   while (cast) {
     if (!cast->converter) {
       swig_type_info *tc = cast->type;
       if (!tc->clientdata) {
 	SWIG_TypeClientData(tc, clientdata);
       }
-    }    
+    }
     cast = cast->next;
   }
 }
@@ -549,31 +557,31 @@ SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) {
   SWIG_TypeClientData(ti, clientdata);
   ti->owndata = 1;
 }
-  
+
 /*
   Search for a swig_type_info structure only by mangled name
   Search is a O(log #types)
-  
-  We start searching at module start, and finish searching when start == end.  
+
+  We start searching at module start, and finish searching when start == end.
   Note: if start == end at the beginning of the function, we go all the way around
   the circular list.
 */
 SWIGRUNTIME swig_type_info *
-SWIG_MangledTypeQueryModule(swig_module_info *start, 
-                            swig_module_info *end, 
+SWIG_MangledTypeQueryModule(swig_module_info *start,
+                            swig_module_info *end,
 		            const char *name) {
   swig_module_info *iter = start;
   do {
     if (iter->size) {
-      register size_t l = 0;
-      register size_t r = iter->size - 1;
+      size_t l = 0;
+      size_t r = iter->size - 1;
       do {
 	/* since l+r >= 0, we can (>> 1) instead (/ 2) */
-	register size_t i = (l + r) >> 1; 
+	size_t i = (l + r) >> 1;
 	const char *iname = iter->types[i]->name;
 	if (iname) {
-	  register int compare = strcmp(name, iname);
-	  if (compare == 0) {	    
+	  int compare = strcmp(name, iname);
+	  if (compare == 0) {
 	    return iter->types[i];
 	  } else if (compare < 0) {
 	    if (i) {
@@ -598,14 +606,14 @@ SWIG_MangledTypeQueryModule(swig_module_info *start,
   Search for a swig_type_info structure for either a mangled name or a human readable name.
   It first searches the mangled names of the types, which is a O(log #types)
   If a type is not found it then searches the human readable names, which is O(#types).
-  
-  We start searching at module start, and finish searching when start == end.  
+
+  We start searching at module start, and finish searching when start == end.
   Note: if start == end at the beginning of the function, we go all the way around
   the circular list.
 */
 SWIGRUNTIME swig_type_info *
-SWIG_TypeQueryModule(swig_module_info *start, 
-                     swig_module_info *end, 
+SWIG_TypeQueryModule(swig_module_info *start,
+                     swig_module_info *end,
 		     const char *name) {
   /* STEP 1: Search the name field using binary search */
   swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name);
@@ -616,7 +624,7 @@ SWIG_TypeQueryModule(swig_module_info *start,
        of the str field (the human readable name) */
     swig_module_info *iter = start;
     do {
-      register size_t i = 0;
+      size_t i = 0;
       for (; i < iter->size; ++i) {
 	if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name)))
 	  return iter->types[i];
@@ -624,56 +632,56 @@ SWIG_TypeQueryModule(swig_module_info *start,
       iter = iter->next;
     } while (iter != end);
   }
-  
+
   /* neither found a match */
   return 0;
 }
 
-/* 
+/*
    Pack binary data into a string
 */
 SWIGRUNTIME char *
 SWIG_PackData(char *c, void *ptr, size_t sz) {
   static const char hex[17] = "0123456789abcdef";
-  register const unsigned char *u = (unsigned char *) ptr;
-  register const unsigned char *eu =  u + sz;
+  const unsigned char *u = (unsigned char *) ptr;
+  const unsigned char *eu =  u + sz;
   for (; u != eu; ++u) {
-    register unsigned char uu = *u;
+    unsigned char uu = *u;
     *(c++) = hex[(uu & 0xf0) >> 4];
     *(c++) = hex[uu & 0xf];
   }
   return c;
 }
 
-/* 
+/*
    Unpack binary data from a string
 */
 SWIGRUNTIME const char *
 SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
-  register unsigned char *u = (unsigned char *) ptr;
-  register const unsigned char *eu = u + sz;
+  unsigned char *u = (unsigned char *) ptr;
+  const unsigned char *eu = u + sz;
   for (; u != eu; ++u) {
-    register char d = *(c++);
-    register unsigned char uu;
+    char d = *(c++);
+    unsigned char uu;
     if ((d >= '0') && (d <= '9'))
       uu = ((d - '0') << 4);
     else if ((d >= 'a') && (d <= 'f'))
       uu = ((d - ('a'-10)) << 4);
-    else 
+    else
       return (char *) 0;
     d = *(c++);
     if ((d >= '0') && (d <= '9'))
       uu |= (d - '0');
     else if ((d >= 'a') && (d <= 'f'))
       uu |= (d - ('a'-10));
-    else 
+    else
       return (char *) 0;
     *u = uu;
   }
   return c;
 }
 
-/* 
+/*
    Pack 'void *' into a string buffer.
 */
 SWIGRUNTIME char *
@@ -733,18 +741,18 @@ SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) {
 #endif
 
 /*  Errors in SWIG */
-#define  SWIG_UnknownError    	   -1 
-#define  SWIG_IOError        	   -2 
-#define  SWIG_RuntimeError   	   -3 
-#define  SWIG_IndexError     	   -4 
-#define  SWIG_TypeError      	   -5 
-#define  SWIG_DivisionByZero 	   -6 
-#define  SWIG_OverflowError  	   -7 
-#define  SWIG_SyntaxError    	   -8 
-#define  SWIG_ValueError     	   -9 
+#define  SWIG_UnknownError    	   -1
+#define  SWIG_IOError        	   -2
+#define  SWIG_RuntimeError   	   -3
+#define  SWIG_IndexError     	   -4
+#define  SWIG_TypeError      	   -5
+#define  SWIG_DivisionByZero 	   -6
+#define  SWIG_OverflowError  	   -7
+#define  SWIG_SyntaxError    	   -8
+#define  SWIG_ValueError     	   -9
 #define  SWIG_SystemError    	   -10
 #define  SWIG_AttributeError 	   -11
-#define  SWIG_MemoryError    	   -12 
+#define  SWIG_MemoryError    	   -12
 #define  SWIG_NullReferenceError   -13
 
 
@@ -756,6 +764,7 @@ SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) {
 #define PyInt_Check(x) PyLong_Check(x)
 #define PyInt_AsLong(x) PyLong_AsLong(x)
 #define PyInt_FromLong(x) PyLong_FromLong(x)
+#define PyInt_FromSize_t(x) PyLong_FromSize_t(x)
 #define PyString_Check(name) PyBytes_Check(name)
 #define PyString_FromString(x) PyUnicode_FromString(x)
 #define PyString_Format(fmt, args)  PyUnicode_Format(fmt, args)
@@ -925,6 +934,10 @@ static long PyNumber_AsSsize_t (PyObject *x, void *SWIGUNUSEDPARM(exc))
 }
 #endif
 
+#if PY_VERSION_HEX < 0x02050000
+#define PyInt_FromSize_t(x) PyInt_FromLong((long)x)
+#endif
+
 #if PY_VERSION_HEX < 0x02040000
 #define Py_VISIT(op)				\
   do { 						\
@@ -1196,7 +1209,7 @@ SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self),
 
 /* Runtime API */
 
-#define SWIG_GetModule(clientdata)                      SWIG_Python_GetModule()
+#define SWIG_GetModule(clientdata)                      SWIG_Python_GetModule(clientdata)
 #define SWIG_SetModule(clientdata, pointer)             SWIG_Python_SetModule(pointer)
 #define SWIG_NewClientData(obj)                         SwigPyClientData_New(obj)
 
@@ -1222,7 +1235,7 @@ SWIG_Python_SetErrorObj(PyObject *errtype, PyObject *obj) {
 SWIGINTERN void 
 SWIG_Python_SetErrorMsg(PyObject *errtype, const char *msg) {
   SWIG_PYTHON_THREAD_BEGIN_BLOCK;
-  PyErr_SetString(errtype, (char *) msg);
+  PyErr_SetString(errtype, msg);
   SWIG_PYTHON_THREAD_END_BLOCK;
 }
 
@@ -1241,7 +1254,11 @@ SwigPyBuiltin_AddPublicSymbol(PyObject *seq, const char *key) {
 
 SWIGINTERN void
 SWIG_Python_SetConstant(PyObject *d, PyObject *public_interface, const char *name, PyObject *obj) {   
+#if PY_VERSION_HEX < 0x02030000
   PyDict_SetItemString(d, (char *)name, obj);
+#else
+  PyDict_SetItemString(d, name, obj);
+#endif
   Py_DECREF(obj);
   if (public_interface)
     SwigPyBuiltin_AddPublicSymbol(public_interface, name);
@@ -1251,7 +1268,11 @@ SWIG_Python_SetConstant(PyObject *d, PyObject *public_interface, const char *nam
 
 SWIGINTERN void
 SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) {   
+#if PY_VERSION_HEX < 0x02030000
   PyDict_SetItemString(d, (char *)name, obj);
+#else
+  PyDict_SetItemString(d, name, obj);
+#endif
   Py_DECREF(obj);                            
 }
 
@@ -1318,7 +1339,7 @@ SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssi
   }  
   if (!PyTuple_Check(args)) {
     if (min <= 1 && max >= 1) {
-      register int i;
+      int i;
       objs[0] = args;
       for (i = 1; i < max; ++i) {
 	objs[i] = 0;
@@ -1328,7 +1349,7 @@ SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssi
     PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple");
     return 0;
   } else {
-    register Py_ssize_t l = PyTuple_GET_SIZE(args);
+    Py_ssize_t l = PyTuple_GET_SIZE(args);
     if (l < min) {
       PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", 
 		   name, (min == max ? "" : "at least "), (int)min, (int)l);
@@ -1338,7 +1359,7 @@ SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssi
 		   name, (min == max ? "" : "at most "), (int)max, (int)l);
       return 0;
     } else {
-      register int i;
+      int i;
       for (i = 0; i < l; ++i) {
 	objs[i] = PyTuple_GET_ITEM(args, i);
       }
@@ -1524,6 +1545,23 @@ typedef struct {
 #endif
 } SwigPyObject;
 
+
+#ifdef SWIGPYTHON_BUILTIN
+
+SWIGRUNTIME PyObject *
+SwigPyObject_get___dict__(PyObject *v, PyObject *SWIGUNUSEDPARM(args))
+{
+  SwigPyObject *sobj = (SwigPyObject *)v;
+
+  if (!sobj->dict)
+    sobj->dict = PyDict_New();
+
+  Py_INCREF(sobj->dict);
+  return sobj->dict;
+}
+
+#endif
+
 SWIGRUNTIME PyObject *
 SwigPyObject_long(SwigPyObject *v)
 {
@@ -1572,7 +1610,7 @@ SwigPyObject_repr(SwigPyObject *v, PyObject *args)
 #endif
 {
   const char *name = SWIG_TypePrettyName(v->ty);
-  PyObject *repr = SWIG_Python_str_FromFormat("<Swig Object of type '%s' at %p>", name, (void *)v);
+  PyObject *repr = SWIG_Python_str_FromFormat("<Swig Object of type '%s' at %p>", (name ? name : "unknown"), (void *)v);
   if (v->next) {
 # ifdef METH_NOARGS
     PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next);
@@ -1592,34 +1630,6 @@ SwigPyObject_repr(SwigPyObject *v, PyObject *args)
 }
 
 SWIGRUNTIME int
-SwigPyObject_print(SwigPyObject *v, FILE *fp, int SWIGUNUSEDPARM(flags))
-{
-  char *str;
-#ifdef METH_NOARGS
-  PyObject *repr = SwigPyObject_repr(v);
-#else
-  PyObject *repr = SwigPyObject_repr(v, NULL);
-#endif
-  if (repr) {
-    str = SWIG_Python_str_AsChar(repr); 
-    fputs(str, fp);
-    SWIG_Python_str_DelForPy3(str);
-    Py_DECREF(repr);
-    return 0; 
-  } else {
-    return 1; 
-  }
-}
-
-SWIGRUNTIME PyObject *
-SwigPyObject_str(SwigPyObject *v)
-{
-  char result[SWIG_BUFFER_SIZE];
-  return SWIG_PackVoidPtr(result, v->ptr, v->ty->name, sizeof(result)) ?
-    SWIG_Python_str_FromChar(result) : 0;
-}
... 1083 lines suppressed ...

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/pysubnettree.git



More information about the Python-modules-commits mailing list