Patchwork [V2] manifest: drop Py_TPFLAGS_HAVE_SEQUENCE_IN from tp_flags in Python 3

login
register
mail settings
Submitter Gregory Szorc
Date Oct. 8, 2016, 4:05 p.m.
Message ID <f98e32b5c44fafb85bee.1475942712@gps-mbp.local>
Download mbox | patch
Permalink /patch/16940/
State Accepted
Headers show

Comments

Gregory Szorc - Oct. 8, 2016, 4:05 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1475942697 -7200
#      Sat Oct 08 18:04:57 2016 +0200
# Node ID f98e32b5c44fafb85bee108abe2a24595e59ddbc
# Parent  ece8e9fc1bf2effb388bbca7222d3c644996aa2b
manifest: drop Py_TPFLAGS_HAVE_SEQUENCE_IN from tp_flags in Python 3

This flag disappeared in Python 3. It is only necessary in Python 2,
apparently.
Augie Fackler - Oct. 8, 2016, 4:36 p.m.
On Sat, Oct 08, 2016 at 06:05:12PM +0200, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc@gmail.com>
> # Date 1475942697 -7200
> #      Sat Oct 08 18:04:57 2016 +0200
> # Node ID f98e32b5c44fafb85bee108abe2a24595e59ddbc
> # Parent  ece8e9fc1bf2effb388bbca7222d3c644996aa2b
> manifest: drop Py_TPFLAGS_HAVE_SEQUENCE_IN from tp_flags in Python 3

queued, thanks


>
> This flag disappeared in Python 3. It is only necessary in Python 2,
> apparently.
>
> diff --git a/mercurial/manifest.c b/mercurial/manifest.c
> --- a/mercurial/manifest.c
> +++ b/mercurial/manifest.c
> @@ -253,8 +253,15 @@ done:
>       Py_XDECREF(flags);
>       return ret;
>  }
>
> +#ifdef IS_PY3K
> +#define LAZYMANIFESTENTRIESITERATOR_TPFLAGS Py_TPFLAGS_DEFAULT
> +#else
> +#define LAZYMANIFESTENTRIESITERATOR_TPFLAGS Py_TPFLAGS_DEFAULT \
> +	| Py_TPFLAGS_HAVE_ITER
> +#endif
> +
>  static PyTypeObject lazymanifestEntriesIterator = {
>       PyObject_HEAD_INIT(NULL)
>       0,                               /*ob_size */
>       "parsers.lazymanifest.entriesiterator", /*tp_name */
> @@ -274,11 +281,9 @@ static PyTypeObject lazymanifestEntriesI
>       0,                               /*tp_str */
>       0,                               /*tp_getattro */
>       0,                               /*tp_setattro */
>       0,                               /*tp_as_buffer */
> -	/* tp_flags: Py_TPFLAGS_HAVE_ITER tells python to
> -        use tp_iter and tp_iternext fields. */
> -	Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_ITER,
> +	LAZYMANIFESTENTRIESITERATOR_TPFLAGS, /* tp_flags */
>       "Iterator for 3-tuples in a lazymanifest.",  /* tp_doc */
>       0,                               /* tp_traverse */
>       0,                               /* tp_clear */
>       0,                               /* tp_richcompare */
> @@ -297,8 +302,15 @@ static PyObject *lmiter_iterkeysnext(PyO
>       pl = pathlen(l);
>       return PyString_FromStringAndSize(l->start, pl);
>  }
>
> +#ifdef IS_PY3K
> +#define LAZYMANIFESTKEYSITERATOR_TPFLAGS Py_TPFLAGS_DEFAULT
> +#else
> +#define LAZYMANIFESTKEYSITERATOR_TPFLAGS Py_TPFLAGS_DEFAULT \
> +	| Py_TPFLAGS_HAVE_ITER
> +#endif
> +
>  static PyTypeObject lazymanifestKeysIterator = {
>       PyObject_HEAD_INIT(NULL)
>       0,                               /*ob_size */
>       "parsers.lazymanifest.keysiterator", /*tp_name */
> @@ -318,11 +330,9 @@ static PyTypeObject lazymanifestKeysIter
>       0,                               /*tp_str */
>       0,                               /*tp_getattro */
>       0,                               /*tp_setattro */
>       0,                               /*tp_as_buffer */
> -	/* tp_flags: Py_TPFLAGS_HAVE_ITER tells python to
> -        use tp_iter and tp_iternext fields. */
> -	Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_ITER,
> +	LAZYMANIFESTKEYSITERATOR_TPFLAGS, /* tp_flags */
>       "Keys iterator for a lazymanifest.",  /* tp_doc */
>       0,                               /* tp_traverse */
>       0,                               /* tp_clear */
>       0,                               /* tp_richcompare */
> @@ -872,8 +882,14 @@ static PyMethodDef lazymanifest_methods[
>        "Encode this manifest to text."},
>       {NULL},
>  };
>
> +#ifdef IS_PY3K
> +#define LAZYMANIFEST_TPFLAGS Py_TPFLAGS_DEFAULT
> +#else
> +#define LAZYMANIFEST_TPFLAGS Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_SEQUENCE_IN
> +#endif
> +
>  static PyTypeObject lazymanifestType = {
>       PyObject_HEAD_INIT(NULL)
>       0,                                                /* ob_size */
>       "parsers.lazymanifest",                           /* tp_name */
> @@ -893,9 +909,9 @@ static PyTypeObject lazymanifestType = {
>       0,                                                /* tp_str */
>       0,                                                /* tp_getattro */
>       0,                                                /* tp_setattro */
>       0,                                                /* tp_as_buffer */
> -	Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_SEQUENCE_IN, /* tp_flags */
> +	LAZYMANIFEST_TPFLAGS,                             /* tp_flags */
>       "TODO(augie)",                                    /* tp_doc */
>       0,                                                /* tp_traverse */
>       0,                                                /* tp_clear */
>       0,                                                /* tp_richcompare */
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/manifest.c b/mercurial/manifest.c
--- a/mercurial/manifest.c
+++ b/mercurial/manifest.c
@@ -253,8 +253,15 @@  done:
 	Py_XDECREF(flags);
 	return ret;
 }
 
+#ifdef IS_PY3K
+#define LAZYMANIFESTENTRIESITERATOR_TPFLAGS Py_TPFLAGS_DEFAULT
+#else
+#define LAZYMANIFESTENTRIESITERATOR_TPFLAGS Py_TPFLAGS_DEFAULT \
+	| Py_TPFLAGS_HAVE_ITER
+#endif
+
 static PyTypeObject lazymanifestEntriesIterator = {
 	PyObject_HEAD_INIT(NULL)
 	0,                               /*ob_size */
 	"parsers.lazymanifest.entriesiterator", /*tp_name */
@@ -274,11 +281,9 @@  static PyTypeObject lazymanifestEntriesI
 	0,                               /*tp_str */
 	0,                               /*tp_getattro */
 	0,                               /*tp_setattro */
 	0,                               /*tp_as_buffer */
-	/* tp_flags: Py_TPFLAGS_HAVE_ITER tells python to
-	   use tp_iter and tp_iternext fields. */
-	Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_ITER,
+	LAZYMANIFESTENTRIESITERATOR_TPFLAGS, /* tp_flags */
 	"Iterator for 3-tuples in a lazymanifest.",  /* tp_doc */
 	0,                               /* tp_traverse */
 	0,                               /* tp_clear */
 	0,                               /* tp_richcompare */
@@ -297,8 +302,15 @@  static PyObject *lmiter_iterkeysnext(PyO
 	pl = pathlen(l);
 	return PyString_FromStringAndSize(l->start, pl);
 }
 
+#ifdef IS_PY3K
+#define LAZYMANIFESTKEYSITERATOR_TPFLAGS Py_TPFLAGS_DEFAULT
+#else
+#define LAZYMANIFESTKEYSITERATOR_TPFLAGS Py_TPFLAGS_DEFAULT \
+	| Py_TPFLAGS_HAVE_ITER
+#endif
+
 static PyTypeObject lazymanifestKeysIterator = {
 	PyObject_HEAD_INIT(NULL)
 	0,                               /*ob_size */
 	"parsers.lazymanifest.keysiterator", /*tp_name */
@@ -318,11 +330,9 @@  static PyTypeObject lazymanifestKeysIter
 	0,                               /*tp_str */
 	0,                               /*tp_getattro */
 	0,                               /*tp_setattro */
 	0,                               /*tp_as_buffer */
-	/* tp_flags: Py_TPFLAGS_HAVE_ITER tells python to
-	   use tp_iter and tp_iternext fields. */
-	Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_ITER,
+	LAZYMANIFESTKEYSITERATOR_TPFLAGS, /* tp_flags */
 	"Keys iterator for a lazymanifest.",  /* tp_doc */
 	0,                               /* tp_traverse */
 	0,                               /* tp_clear */
 	0,                               /* tp_richcompare */
@@ -872,8 +882,14 @@  static PyMethodDef lazymanifest_methods[
 	 "Encode this manifest to text."},
 	{NULL},
 };
 
+#ifdef IS_PY3K
+#define LAZYMANIFEST_TPFLAGS Py_TPFLAGS_DEFAULT
+#else
+#define LAZYMANIFEST_TPFLAGS Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_SEQUENCE_IN
+#endif
+
 static PyTypeObject lazymanifestType = {
 	PyObject_HEAD_INIT(NULL)
 	0,                                                /* ob_size */
 	"parsers.lazymanifest",                           /* tp_name */
@@ -893,9 +909,9 @@  static PyTypeObject lazymanifestType = {
 	0,                                                /* tp_str */
 	0,                                                /* tp_getattro */
 	0,                                                /* tp_setattro */
 	0,                                                /* tp_as_buffer */
-	Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_SEQUENCE_IN, /* tp_flags */
+	LAZYMANIFEST_TPFLAGS,                             /* tp_flags */
 	"TODO(augie)",                                    /* tp_doc */
 	0,                                                /* tp_traverse */
 	0,                                                /* tp_clear */
 	0,                                                /* tp_richcompare */