[Python-modules-commits] [python-regex] 01/05: Import python-regex_0.1.20160619.orig.tar.gz

Sandro Tosi morph at moszumanska.debian.org
Tue Jun 21 19:11:29 UTC 2016


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

morph pushed a commit to branch master
in repository python-regex.

commit 6065c8b27620cf4d6636856a7823774157cb8257
Author: Sandro Tosi <morph at debian.org>
Date:   Tue Jun 21 19:52:27 2016 +0100

    Import python-regex_0.1.20160619.orig.tar.gz
---
 PKG-INFO         |  2 +-
 Python2/_regex.c | 82 ++++++++++++++++++++++++++++++++++++++------------------
 Python2/regex.py |  2 +-
 Python3/_regex.c | 76 +++++++++++++++++++++++++++++++++++----------------
 Python3/regex.py |  2 +-
 setup.py         |  2 +-
 6 files changed, 113 insertions(+), 53 deletions(-)

diff --git a/PKG-INFO b/PKG-INFO
index f69aad8..6d9055e 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: regex
-Version: 2016.06.14
+Version: 2016.06.19
 Summary: Alternative regular expression module, to replace re.
 Home-page: https://bitbucket.org/mrabarnett/mrab-regex
 Author: Matthew Barnett
diff --git a/Python2/_regex.c b/Python2/_regex.c
index 5f66511..fddf67f 100644
--- a/Python2/_regex.c
+++ b/Python2/_regex.c
@@ -103,6 +103,7 @@ typedef RE_UINT32 RE_STATUS_T;
 #define RE_MODULE "regex"
 
 /* Error codes. */
+#define RE_ERROR_INITIALISING 2 /* Initialising object. */
 #define RE_ERROR_SUCCESS 1 /* Successful match. */
 #define RE_ERROR_FAILURE 0 /* Unsuccessful match. */
 #define RE_ERROR_ILLEGAL -1 /* Illegal code. */
@@ -2099,6 +2100,8 @@ Py_LOCAL_INLINE(PyObject*) get_object(char* module_name, char* object_name);
 Py_LOCAL_INLINE(void) set_error(int status, PyObject* object) {
     TRACE(("<<set_error>>\n"))
 
+    PyErr_Clear();
+
     if (!error_exception)
         error_exception = get_object("_" RE_MODULE "_core", "error");
 
@@ -17534,13 +17537,13 @@ Py_LOCAL_INLINE(Py_ssize_t) as_string_index(PyObject* obj, Py_ssize_t def) {
         return def;
 
     value = PyInt_AsSsize_t(obj);
-    if (value != -1 || !PyErr_Occurred())
+    if (!(value == -1 && PyErr_Occurred()))
         return value;
 
     PyErr_Clear();
 
     value = PyLong_AsLong(obj);
-    if (value != -1 || !PyErr_Occurred())
+    if (!(value == -1 && PyErr_Occurred()))
         return value;
 
     set_error(RE_ERROR_INDEX, NULL);
@@ -17933,13 +17936,13 @@ Py_LOCAL_INLINE(Py_ssize_t) as_group_index(PyObject* obj) {
     Py_ssize_t value;
 
     value = PyInt_AsSsize_t(obj);
-    if (value != -1 || !PyErr_Occurred())
+    if (!(value == -1 && PyErr_Occurred()))
         return value;
 
     PyErr_Clear();
 
     value = PyLong_AsLong(obj);
-    if (value != -1 || !PyErr_Occurred())
+    if (!(value == -1 && PyErr_Occurred()))
         return value;
 
     set_error(RE_ERROR_INDEX, NULL);
@@ -17956,7 +17959,7 @@ Py_LOCAL_INLINE(Py_ssize_t) match_get_group_index(MatchObject* self, PyObject*
 
     /* Is the index an integer? */
     group = as_group_index(index);
-    if (group != -1 || !PyErr_Occurred()) {
+    if (!(group == -1 && PyErr_Occurred())) {
         Py_ssize_t min_group = 0;
 
         /* Adjust negative indices where valid and allowed. */
@@ -17971,17 +17974,17 @@ Py_LOCAL_INLINE(Py_ssize_t) match_get_group_index(MatchObject* self, PyObject*
         return -1;
     }
 
+    PyErr_Clear();
+
     /* The index might be a group name. */
     if (self->pattern->groupindex) {
         /* Look up the name. */
-        PyErr_Clear();
-
         index = PyObject_GetItem(self->pattern->groupindex, index);
         if (index) {
             /* Check that we have an integer. */
             group = as_group_index(index);
             Py_DECREF(index);
-            if (group != -1 || !PyErr_Occurred())
+            if (!(group == -1 && PyErr_Occurred()))
                 return group;
         }
     }
@@ -18786,6 +18789,12 @@ static PyObject* match_regs(MatchObject* self) {
     PyObject* item;
     size_t g;
 
+    if (self->regs) {
+        Py_INCREF(self->regs);
+
+        return self->regs;
+    }
+
     regs = PyTuple_New((Py_ssize_t)self->group_count + 1);
     if (!regs)
         return NULL;
@@ -18809,10 +18818,11 @@ static PyObject* match_regs(MatchObject* self) {
         PyTuple_SET_ITEM(regs, g + 1, item);
     }
 
-    Py_INCREF(regs);
     self->regs = regs;
 
-    return regs;
+    Py_INCREF(self->regs);
+
+    return self->regs;
 
 error:
     Py_DECREF(regs);
@@ -19250,11 +19260,26 @@ Py_LOCAL_INLINE(PyObject*) make_match_copy(MatchObject* self) {
     if (!match)
         return NULL;
 
-    Py_MEMCPY(match, self, sizeof(MatchObject));
-
+    match->string = self->string;
+    match->substring = self->substring;
+    match->substring_offset = self->substring_offset;
+    match->pattern = self->pattern;
+    match->pos = self->pos;
+    match->endpos = self->endpos;
+    match->match_start = self->match_start;
+    match->match_end = self->match_end;
+    match->lastindex = self->lastindex;
+    match->lastgroup = self->lastgroup;
+    match->group_count = self->group_count;
+    match->groups = NULL; /* Copy them later. */
+    match->regs = self->regs;
+    Py_MEMCPY(match->fuzzy_counts, self->fuzzy_counts,
+      sizeof(self->fuzzy_counts));
+    match->partial = self->partial;
     Py_INCREF(match->string);
     Py_INCREF(match->substring);
     Py_INCREF(match->pattern);
+    Py_XINCREF(match->regs);
 
     /* Copy the groups to the MatchObject. */
     if (self->group_count > 0) {
@@ -19561,7 +19586,8 @@ static void scanner_dealloc(PyObject* self_) {
 
     self = (ScannerObject*)self_;
 
-    state_fini(&self->state);
+    if (self->status != RE_ERROR_INITIALISING)
+        state_fini(&self->state);
     Py_DECREF(self->pattern);
     PyObject_DEL(self);
 }
@@ -19657,11 +19683,12 @@ static PyObject* pattern_scanner(PatternObject* pattern, PyObject* args,
 
     self->pattern = pattern;
     Py_INCREF(self->pattern);
+    self->status = RE_ERROR_INITIALISING;
 
     /* The MatchObject, and therefore repeated captures, will be visible. */
     if (!state_init(&self->state, pattern, string, start, end, overlapped != 0,
       conc, part, TRUE, TRUE, FALSE)) {
-        PyObject_DEL(self);
+        Py_DECREF(self);
         return NULL;
     }
 
@@ -19903,7 +19930,8 @@ static void splitter_dealloc(PyObject* self_) {
 
     self = (SplitterObject*)self_;
 
-    state_fini(&self->state);
+    if (self->status != RE_ERROR_INITIALISING)
+        state_fini(&self->state);
     Py_DECREF(self->pattern);
     PyObject_DEL(self);
 }
@@ -19918,13 +19946,13 @@ Py_LOCAL_INLINE(Py_ssize_t) index_to_integer(PyObject* item) {
     Py_ssize_t value;
 
     value = PyInt_AsSsize_t(item);
-    if (value != -1 || !PyErr_Occurred())
+    if (!(value == -1 && PyErr_Occurred()))
         return value;
 
     PyErr_Clear();
 
     value = PyLong_AsLong(item);
-    if (value != -1 || !PyErr_Occurred())
+    if (!(value == -1 && PyErr_Occurred()))
         return value;
 
     PyErr_Clear();
@@ -19961,6 +19989,7 @@ Py_LOCAL_INLINE(Py_ssize_t) index_to_integer(PyObject* item) {
     }
 
 error:
+    PyErr_Clear();
     PyErr_Format(PyExc_TypeError, "list indices must be integers, not %.200s",
       item->ob_type->tp_name);
 
@@ -20080,7 +20109,6 @@ Py_LOCAL_INLINE(PyObject*) pattern_splitter(PatternObject* pattern, PyObject*
     /* Create split state object. */
     int conc;
     SplitterObject* self;
-    RE_State* state;
 
     PyObject* string;
     Py_ssize_t maxsplit = 0;
@@ -20101,25 +20129,24 @@ Py_LOCAL_INLINE(PyObject*) pattern_splitter(PatternObject* pattern, PyObject*
 
     self->pattern = pattern;
     Py_INCREF(self->pattern);
+    self->status = RE_ERROR_INITIALISING;
 
     if (maxsplit == 0)
         maxsplit = PY_SSIZE_T_MAX;
 
-    state = &self->state;
-
     /* The MatchObject, and therefore repeated captures, will not be visible.
      */
-    if (!state_init(state, pattern, string, 0, PY_SSIZE_T_MAX, FALSE, conc,
-      FALSE, TRUE, FALSE, FALSE)) {
-        PyObject_DEL(self);
+    if (!state_init(&self->state, pattern, string, 0, PY_SSIZE_T_MAX, FALSE,
+      conc, FALSE, TRUE, FALSE, FALSE)) {
+        Py_DECREF(self);
         return NULL;
     }
 
     self->maxsplit = maxsplit;
-    self->last_pos = state->reverse ? state->text_length : 0;
+    self->last_pos = self->state.reverse ? self->state.text_length : 0;
     self->split_count = 0;
     self->index = 0;
-    self->status = 1;
+    self->status = RE_ERROR_SUCCESS;
 
     return (PyObject*) self;
 }
@@ -21118,7 +21145,10 @@ static PyObject* pattern_finditer(PatternObject* pattern, PyObject* args,
     return pattern_scanner(pattern, args, kwargs);
 }
 
-/* Makes a copy of a PatternObject. */
+/* Makes a copy of a PatternObject.
+ *
+ * It actually doesn't make a copy, just returns the original object.
+ */
 Py_LOCAL_INLINE(PyObject*) make_pattern_copy(PatternObject* self) {
     Py_INCREF(self);
     return (PyObject*)self;
diff --git a/Python2/regex.py b/Python2/regex.py
index a992728..fd53918 100644
--- a/Python2/regex.py
+++ b/Python2/regex.py
@@ -239,7 +239,7 @@ __all__ = ["compile", "escape", "findall", "finditer", "fullmatch", "match",
   "U", "UNICODE", "V0", "VERSION0", "V1", "VERSION1", "X", "VERBOSE", "W",
   "WORD", "error", "Regex"]
 
-__version__ = "2.4.102"
+__version__ = "2.4.103"
 
 # --------------------------------------------------------------------
 # Public interface.
diff --git a/Python3/_regex.c b/Python3/_regex.c
index 1450cb4..3f97839 100644
--- a/Python3/_regex.c
+++ b/Python3/_regex.c
@@ -93,6 +93,7 @@ typedef RE_UINT32 RE_STATUS_T;
 #define RE_MODULE "regex"
 
 /* Error codes. */
+#define RE_ERROR_INITIALISING 2 /* Initialising object. */
 #define RE_ERROR_SUCCESS 1 /* Successful match. */
 #define RE_ERROR_FAILURE 0 /* Unsuccessful match. */
 #define RE_ERROR_ILLEGAL -1 /* Illegal code. */
@@ -2088,6 +2089,8 @@ Py_LOCAL_INLINE(PyObject*) get_object(char* module_name, char* object_name);
 Py_LOCAL_INLINE(void) set_error(int status, PyObject* object) {
     TRACE(("<<set_error>>\n"))
 
+    PyErr_Clear();
+
     if (!error_exception)
         error_exception = get_object("_" RE_MODULE "_core", "error");
 
@@ -17563,7 +17566,7 @@ Py_LOCAL_INLINE(Py_ssize_t) as_string_index(PyObject* obj, Py_ssize_t def) {
         return def;
 
     value = PyLong_AsLong(obj);
-    if (value != -1 || !PyErr_Occurred())
+    if (!(value == -1 && PyErr_Occurred()))
         return value;
 
     set_error(RE_ERROR_INDEX, NULL);
@@ -17987,7 +17990,7 @@ Py_LOCAL_INLINE(Py_ssize_t) as_group_index(PyObject* obj) {
     Py_ssize_t value;
 
     value = PyLong_AsLong(obj);
-    if (value != -1 || !PyErr_Occurred())
+    if (!(value == -1 && PyErr_Occurred()))
         return value;
 
     set_error(RE_ERROR_INDEX, NULL);
@@ -18004,7 +18007,7 @@ Py_LOCAL_INLINE(Py_ssize_t) match_get_group_index(MatchObject* self, PyObject*
 
     /* Is the index an integer? */
     group = as_group_index(index);
-    if (group != -1 || !PyErr_Occurred()) {
+    if (!(group == -1 && PyErr_Occurred())) {
         Py_ssize_t min_group = 0;
 
         /* Adjust negative indices where valid and allowed. */
@@ -18019,17 +18022,17 @@ Py_LOCAL_INLINE(Py_ssize_t) match_get_group_index(MatchObject* self, PyObject*
         return -1;
     }
 
+    PyErr_Clear();
+
     /* The index might be a group name. */
     if (self->pattern->groupindex) {
         /* Look up the name. */
-        PyErr_Clear();
-
         index = PyObject_GetItem(self->pattern->groupindex, index);
         if (index) {
             /* Check that we have an integer. */
             group = as_group_index(index);
             Py_DECREF(index);
-            if (group != -1 || !PyErr_Occurred())
+            if (!(group == -1 && PyErr_Occurred()))
                 return group;
         }
     }
@@ -18840,6 +18843,12 @@ static PyObject* match_regs(MatchObject* self) {
     PyObject* item;
     size_t g;
 
+    if (self->regs) {
+        Py_INCREF(self->regs);
+
+        return self->regs;
+    }
+
     regs = PyTuple_New((Py_ssize_t)self->group_count + 1);
     if (!regs)
         return NULL;
@@ -18863,10 +18872,11 @@ static PyObject* match_regs(MatchObject* self) {
         PyTuple_SET_ITEM(regs, g + 1, item);
     }
 
-    Py_INCREF(regs);
     self->regs = regs;
 
-    return regs;
+    Py_INCREF(self->regs);
+
+    return self->regs;
 
 error:
     Py_DECREF(regs);
@@ -19283,11 +19293,26 @@ Py_LOCAL_INLINE(PyObject*) make_match_copy(MatchObject* self) {
     if (!match)
         return NULL;
 
-    Py_MEMCPY(match, self, sizeof(MatchObject));
-
+    match->string = self->string;
+    match->substring = self->substring;
+    match->substring_offset = self->substring_offset;
+    match->pattern = self->pattern;
+    match->pos = self->pos;
+    match->endpos = self->endpos;
+    match->match_start = self->match_start;
+    match->match_end = self->match_end;
+    match->lastindex = self->lastindex;
+    match->lastgroup = self->lastgroup;
+    match->group_count = self->group_count;
+    match->groups = NULL; /* Copy them later. */
+    match->regs = self->regs;
+    Py_MEMCPY(match->fuzzy_counts, self->fuzzy_counts,
+      sizeof(self->fuzzy_counts));
+    match->partial = self->partial;
     Py_INCREF(match->string);
     Py_INCREF(match->substring);
     Py_INCREF(match->pattern);
+    Py_XINCREF(match->regs);
 
     /* Copy the groups to the MatchObject. */
     if (self->group_count > 0) {
@@ -19577,7 +19602,8 @@ static void scanner_dealloc(PyObject* self_) {
 
     self = (ScannerObject*)self_;
 
-    state_fini(&self->state);
+    if (self->status != RE_ERROR_INITIALISING)
+        state_fini(&self->state);
     Py_DECREF(self->pattern);
     PyObject_DEL(self);
 }
@@ -19672,11 +19698,12 @@ static PyObject* pattern_scanner(PatternObject* pattern, PyObject* args,
 
     self->pattern = pattern;
     Py_INCREF(self->pattern);
+    self->status = RE_ERROR_INITIALISING;
 
     /* The MatchObject, and therefore repeated captures, will be visible. */
     if (!state_init(&self->state, pattern, string, start, end, overlapped != 0,
       conc, part, TRUE, TRUE, FALSE)) {
-        PyObject_DEL(self);
+        Py_DECREF(self);
         return NULL;
     }
 
@@ -19901,7 +19928,8 @@ static void splitter_dealloc(PyObject* self_) {
 
     self = (SplitterObject*)self_;
 
-    state_fini(&self->state);
+    if (self->status != RE_ERROR_INITIALISING)
+        state_fini(&self->state);
     Py_DECREF(self->pattern);
     PyObject_DEL(self);
 }
@@ -19915,7 +19943,7 @@ Py_LOCAL_INLINE(Py_ssize_t) index_to_integer(PyObject* item) {
     Py_ssize_t value;
 
     value = PyLong_AsLong(item);
-    if (value != -1 || !PyErr_Occurred())
+    if (!(value == -1 && PyErr_Occurred()))
         return value;
 
     PyErr_Clear();
@@ -19958,6 +19986,7 @@ Py_LOCAL_INLINE(Py_ssize_t) index_to_integer(PyObject* item) {
     }
 
 error:
+    PyErr_Clear();
     PyErr_Format(PyExc_TypeError, "list indices must be integers, not %.200s",
       item->ob_type->tp_name);
 
@@ -20075,7 +20104,6 @@ Py_LOCAL_INLINE(PyObject*) pattern_splitter(PatternObject* pattern, PyObject*
     /* Create split state object. */
     int conc;
     SplitterObject* self;
-    RE_State* state;
 
     PyObject* string;
     Py_ssize_t maxsplit = 0;
@@ -20096,25 +20124,24 @@ Py_LOCAL_INLINE(PyObject*) pattern_splitter(PatternObject* pattern, PyObject*
 
     self->pattern = pattern;
     Py_INCREF(self->pattern);
+    self->status = RE_ERROR_INITIALISING;
 
     if (maxsplit == 0)
         maxsplit = PY_SSIZE_T_MAX;
 
-    state = &self->state;
-
     /* The MatchObject, and therefore repeated captures, will not be visible.
      */
-    if (!state_init(state, pattern, string, 0, PY_SSIZE_T_MAX, FALSE, conc,
-      FALSE, TRUE, FALSE, FALSE)) {
-        PyObject_DEL(self);
+    if (!state_init(&self->state, pattern, string, 0, PY_SSIZE_T_MAX, FALSE,
+      conc, FALSE, TRUE, FALSE, FALSE)) {
+        Py_DECREF(self);
         return NULL;
     }
 
     self->maxsplit = maxsplit;
-    self->last_pos = state->reverse ? state->text_length : 0;
+    self->last_pos = self->state.reverse ? self->state.text_length : 0;
     self->split_count = 0;
     self->index = 0;
-    self->status = 1;
+    self->status = RE_ERROR_SUCCESS;
 
     return (PyObject*) self;
 }
@@ -21102,7 +21129,10 @@ static PyObject* pattern_finditer(PatternObject* pattern, PyObject* args,
     return pattern_scanner(pattern, args, kwargs);
 }
 
-/* Makes a copy of a PatternObject. */
+/* Makes a copy of a PatternObject.
+ *
+ * It actually doesn't make a copy, just returns the original object.
+ */
 Py_LOCAL_INLINE(PyObject*) make_pattern_copy(PatternObject* self) {
     Py_INCREF(self);
     return (PyObject*)self;
diff --git a/Python3/regex.py b/Python3/regex.py
index 3238c19..a040d45 100644
--- a/Python3/regex.py
+++ b/Python3/regex.py
@@ -239,7 +239,7 @@ __all__ = ["compile", "escape", "findall", "finditer", "fullmatch", "match",
   "U", "UNICODE", "V0", "VERSION0", "V1", "VERSION1", "X", "VERBOSE", "W",
   "WORD", "error", "Regex"]
 
-__version__ = "2.4.102"
+__version__ = "2.4.103"
 
 # --------------------------------------------------------------------
 # Public interface.
diff --git a/setup.py b/setup.py
index 31e7552..5a5b196 100644
--- a/setup.py
+++ b/setup.py
@@ -13,7 +13,7 @@ DOCS_DIR = os.path.join(BASE_DIR, 'docs')
 
 setup(
     name='regex',
-    version='2016.06.14',
+    version='2016.06.19',
     description='Alternative regular expression module, to replace re.',
     long_description=open(os.path.join(DOCS_DIR, 'Features.rst')).read(),
 

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



More information about the Python-modules-commits mailing list