Commits

lgautier  committed e44579a

Much less warnings when building under Python3.
Unit tests are running, although with many failures and errors

  • Participants
  • Parent commits ce43229

Comments (0)

Files changed (1)

 
 diff -r 089949fdede1 rpy/rinterface/buffer.c
 --- a/rpy/rinterface/buffer.c	Sun Jun 27 09:47:32 2010 +0200
-+++ b/rpy/rinterface/buffer.c	Sun Jul 18 12:42:42 2010 +0200
++++ b/rpy/rinterface/buffer.c	Sun Jul 18 16:38:29 2010 +0200
 @@ -220,10 +220,12 @@
  }
  
  	(releasebufferproc)0,
 diff -r 089949fdede1 rpy/rinterface/na_values.c
 --- a/rpy/rinterface/na_values.c	Sun Jun 27 09:47:32 2010 +0200
-+++ b/rpy/rinterface/na_values.c	Sun Jul 18 12:42:42 2010 +0200
++++ b/rpy/rinterface/na_values.c	Sun Jul 18 16:38:29 2010 +0200
 @@ -11,7 +11,11 @@
  {
    static PyObject* repr = NULL;
 +#if (PY_VERSION_HEX < 0x03010000)
    (unaryfunc) NA_unaryfunc, /* nb_long; */
 +#else
-+  0, /* reserved */
++  NULL, /* reserved */
 +#endif
    (unaryfunc) NA_unaryfunc, /* nb_float; */
 +#if (PY_VERSION_HEX < 0x03010000)
    0, /* nb_inplace_remainder; */
    0, /* nb_inplace_power; */
    0, /* nb_inplace_lshift; */
-@@ -132,7 +152,11 @@
+@@ -111,8 +131,12 @@
+ static PyTypeObject NAInteger_Type = {
+         /* The ob_type field must be initialized in the module init function
+          * to be portable to Windows without using C++. */
++#if (PY_VERSION_HEX < 0x03010000)
+         PyObject_HEAD_INIT(NULL)
+         0,                      /*ob_size*/
++#else
++	PyVarObject_HEAD_INIT(NULL, 0)
++#endif
+         "rpy2.rinterface.NAIntegerType",       /*tp_name*/
+         sizeof(PyObject),   /*tp_basicsize*/
+         0,                      /*tp_itemsize*/
+@@ -123,7 +147,7 @@
+         0,                      /*tp_setattr*/
+         0,                      /*tp_compare*/
+         NAInteger_repr,                      /*tp_repr*/
+-        &NAInteger_NumberMethods,                      /*tp_as_number*/
++        &NAInteger_NumberMethods,            /*tp_as_number*/
+         0,                      /*tp_as_sequence*/
+         0,                      /*tp_as_mapping*/
+         0,                      /*tp_hash*/
+@@ -132,7 +156,11 @@
          0,                      /*tp_getattro*/
          0,                      /*tp_setattro*/
          0,                      /*tp_as_buffer*/
          NAInteger_Type_doc,                      /*tp_doc*/
          0,                      /*tp_traverse*/
          0,                      /*tp_clear*/
-@@ -225,7 +249,11 @@
+@@ -225,7 +253,11 @@
  {
    static PyObject* repr = NULL;
    if (repr == NULL) {
    }
    Py_XINCREF(repr);
    return repr;
-@@ -235,7 +263,9 @@
+@@ -235,7 +267,9 @@
    0, /* nb_add */
    0, /* nb_subtract; */
    0, /* nb_multiply; */
    0, /* nb_remainder; */
    0, /* nb_divmod; */
    0, /* nb_power; */
-@@ -249,17 +279,27 @@
+@@ -249,17 +283,27 @@
    (binaryfunc) NA_binaryfunc, /*  nb_and; */
    (binaryfunc) NA_binaryfunc, /*  nb_xor; */
    (binaryfunc) NA_binaryfunc, /* nb_or; */
 +#if (PY_VERSION_HEX < 0x03010000)
    0, /* nb_long; */
 +#else
-+  0, /* reserved */
++  NULL, /* reserved */
 +#endif
    0, /* nb_float; */
 +#if (PY_VERSION_HEX < 0x03010000)
    0, /* nb_inplace_remainder; */
    0, /* nb_inplace_power; */
    0, /* nb_inplace_lshift; */
-@@ -302,7 +342,11 @@
+@@ -281,8 +325,12 @@
+ static PyTypeObject NALogical_Type = {
+         /* The ob_type field must be initialized in the module init function
+          * to be portable to Windows without using C++. */
++#if (PY_VERSION_HEX < 0x03010000)
+         PyObject_HEAD_INIT(NULL)
+         0,                      /*ob_size*/
++#else
++	PyVarObject_HEAD_INIT(NULL, 0)
++#endif
+         "rpy2.rinterface.NALogicalType",       /*tp_name*/
+         sizeof(PyObject),   /*tp_basicsize*/
+         0,                      /*tp_itemsize*/
+@@ -302,7 +350,11 @@
          0,                      /*tp_getattro*/
          0,                      /*tp_setattro*/
          0,                      /*tp_as_buffer*/
          NALogical_Type_doc,                      /*tp_doc*/
          0,                      /*tp_traverse*/
          0,                      /*tp_clear*/
-@@ -349,7 +393,11 @@
+@@ -349,7 +401,11 @@
  {
    static PyObject* repr = NULL;
    if (repr == NULL) {
    }
    Py_XINCREF(repr);
    return repr;
-@@ -360,7 +408,9 @@
+@@ -360,7 +416,9 @@
    (binaryfunc)NA_binaryfunc, /* nb_add */
    (binaryfunc)NA_binaryfunc, /* nb_subtract; */
    (binaryfunc)NA_binaryfunc, /* nb_multiply; */
    (binaryfunc)NA_binaryfunc, /* nb_remainder; */
    (binaryfunc)NA_binaryfunc, /* nb_divmod; */
    (ternaryfunc)NA_ternaryfunc, /* nb_power; */
-@@ -374,17 +424,27 @@
+@@ -374,17 +432,27 @@
    0, /*  nb_and; */
    0, /*  nb_xor; */
    0, /* nb_or; */
 +#if (PY_VERSION_HEX < 0x03010000)
    (unaryfunc) NA_unaryfunc, /* nb_long; */
 +#else
-+  0, /* reserved */
++  NULL, /* reserved */
 +#endif
    (unaryfunc) NA_unaryfunc, /* nb_float; */
 +#if (PY_VERSION_HEX < 0x03010000)
    0, /* nb_inplace_remainder; */
    0, /* nb_inplace_power; */
    0, /* nb_inplace_lshift; */
-@@ -428,7 +488,11 @@
+@@ -407,8 +475,12 @@
+ static PyTypeObject NAReal_Type = {
+         /* The ob_type field must be initialized in the module init function
+          * to be portable to Windows without using C++. */
++#if (PY_VERSION_HEX < 0x03010000)
+         PyObject_HEAD_INIT(NULL)
+         0,                      /*ob_size*/
++#else
++	PyVarObject_HEAD_INIT(NULL, 0)
++#endif
+         "rpy2.rinterface.NARealType",       /*tp_name*/
+         sizeof(PyObject),   /*tp_basicsize*/
+         0,                      /*tp_itemsize*/
+@@ -428,7 +500,11 @@
          0,                      /*tp_getattro*/
          0,                      /*tp_setattro*/
          0,                      /*tp_as_buffer*/
          NAReal_Type_doc,                      /*tp_doc*/
          0,                      /*tp_traverse*/
          0,                      /*tp_clear*/
-@@ -460,7 +524,11 @@
+@@ -460,7 +536,11 @@
  static PyObject*
  NACharacter_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
  {
  }
  
  static PyObject*
-@@ -475,7 +543,11 @@
+@@ -475,7 +555,11 @@
  {
    static PyObject* repr = NULL;
    if (repr == NULL) {
    }
    Py_XINCREF(repr);
    return repr;
-@@ -506,7 +578,11 @@
+@@ -485,8 +569,12 @@
+ static PyTypeObject NACharacter_Type = {
+         /* The ob_type field must be initialized in the module init function
+          * to be portable to Windows without using C++. */
++#if (PY_VERSION_HEX < 0x03010000)
+         PyObject_HEAD_INIT(NULL)
+         0,                      /*ob_size*/
++#else
++	PyVarObject_HEAD_INIT(NULL, 0)
++#endif
+         "rpy2.rinterface.NACharacterType",       /*tp_name*/
+         sizeof(PyObject),   /*tp_basicsize*/
+         0,                      /*tp_itemsize*/
+@@ -506,7 +594,11 @@
          0,                      /*tp_getattro*/
          0,                      /*tp_setattro*/
          0,                      /*tp_as_buffer*/
          NACharacter_Type_doc,                      /*tp_doc*/
          0,                      /*tp_traverse*/
          0,                      /*tp_clear*/
-@@ -517,7 +593,11 @@
+@@ -517,7 +609,11 @@
          0, //NAInteger_methods,           /*tp_methods*/
          0,                      /*tp_members*/
          0,                      /*tp_getset*/
          0,                      /*tp_dict*/
          0,                      /*tp_descr_get*/
          0,                      /*tp_descr_set*/
-@@ -574,7 +654,11 @@
+@@ -574,7 +670,11 @@
  {
    static PyObject* repr = NULL;
    if (repr == NULL) {
    }
    Py_XINCREF(repr);
    return repr;
-@@ -585,7 +669,9 @@
+@@ -585,7 +685,9 @@
    (binaryfunc)NA_binaryfunc, /* nb_add */
    (binaryfunc)NA_binaryfunc, /* nb_subtract; */
    (binaryfunc)NA_binaryfunc, /* nb_multiply; */
    (binaryfunc)NA_binaryfunc, /* nb_remainder; */
    (binaryfunc)NA_binaryfunc, /* nb_divmod; */
    (ternaryfunc)NA_ternaryfunc, /* nb_power; */
-@@ -599,17 +685,27 @@
+@@ -599,17 +701,27 @@
    0, /*  nb_and; */
    0, /*  nb_xor; */
    0, /* nb_or; */
 +#if (PY_VERSION_HEX < 0x03010000)
    (unaryfunc) NA_unaryfunc, /* nb_long; */
 +#else
-+  0, /* reserved */
++  NULL, /* reserved */
 +#endif
    (unaryfunc) NA_unaryfunc, /* nb_float; */
 +#if (PY_VERSION_HEX < 0x03010000)
    0, /* nb_inplace_remainder; */
    0, /* nb_inplace_power; */
    0, /* nb_inplace_lshift; */
-@@ -653,7 +749,11 @@
+@@ -632,8 +744,12 @@
+ static PyTypeObject NAComplex_Type = {
+         /* The ob_type field must be initialized in the module init function
+          * to be portable to Windows without using C++. */
++#if (PY_VERSION_HEX < 0x03010000)
+         PyObject_HEAD_INIT(NULL)
+         0,                      /*ob_size*/
++#else
++	PyVarObject_HEAD_INIT(NULL, 0)
++#endif
+         "rpy2.rinterface.NAComplexType",       /*tp_name*/
+         sizeof(PyObject),   /*tp_basicsize*/
+         0,                      /*tp_itemsize*/
+@@ -653,7 +769,11 @@
          0,                      /*tp_getattro*/
          0,                      /*tp_setattro*/
          0,                      /*tp_as_buffer*/
          NAComplex_Type_doc,                      /*tp_doc*/
          0,                      /*tp_traverse*/
          0,                      /*tp_clear*/
-@@ -683,7 +783,11 @@
+@@ -683,7 +803,11 @@
  "Missing argument (in a function call)."
  );
  
  
  static PyObject*
  MissingArgType_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-@@ -720,7 +824,11 @@
+@@ -720,7 +844,11 @@
  {
    static PyObject* repr = NULL;
    if (repr == NULL) {
    }
    Py_XINCREF(repr);
    return repr;
-@@ -731,7 +839,11 @@
+@@ -731,7 +859,11 @@
  {
    static PyObject* repr = NULL;
    if (repr == NULL) {
    }
    Py_XINCREF(repr);
    return repr;
-@@ -761,7 +873,11 @@
+@@ -740,8 +872,12 @@
+ static PyTypeObject MissingArg_Type = {
+         /* The ob_type field must be initialized in the module init function
+          * to be portable to Windows without using C++. */
++#if (PY_VERSION_HEX < 0x03010000)
+         PyObject_HEAD_INIT(NULL)
+         0,                      /*ob_size*/
++#else
++	PyVarObject_HEAD_INIT(NULL, 0)
++#endif
+         "rpy2.rinterface.MissingArgType",       /*tp_name*/
+         sizeof(PySexpObject),   /*tp_basicsize*/
+         0,                      /*tp_itemsize*/
+@@ -761,7 +897,11 @@
          0,                      /*tp_getattro*/
          0,                      /*tp_setattro*/
          0,                      /*tp_as_buffer*/
          0,                      /*tp_clear*/
 diff -r 089949fdede1 rpy/rinterface/rinterface.c
 --- a/rpy/rinterface/rinterface.c	Sun Jun 27 09:47:32 2010 +0200
-+++ b/rpy/rinterface/rinterface.c	Sun Jul 18 12:42:42 2010 +0200
++++ b/rpy/rinterface/rinterface.c	Sun Jul 18 16:38:29 2010 +0200
 @@ -83,7 +83,11 @@
  
  #define _RPY_RINTERFACE_MODULE_
        SET_TAG(c_R, install(argNameString));
      }
      c_R = CDR(c_R);
-@@ -1685,7 +1734,7 @@
+@@ -1565,8 +1614,12 @@
+ static PyTypeObject ClosureSexp_Type = {
+         /* The ob_type field must be initialized in the module init function
+          * to be portable to Windows without using C++. */
++#if (PY_VERSION_HEX < 0x03010000)
+         PyObject_HEAD_INIT(NULL)
+         0,                      /*ob_size*/
++#else
++	PyVarObject_HEAD_INIT(NULL, 0)
++#endif
+         "rpy2.rinterface.SexpClosure",       /*tp_name*/
+         sizeof(PySexpObject),   /*tp_basicsize*/
+         0,                      /*tp_itemsize*/
+@@ -1665,8 +1718,12 @@
+ static PyTypeObject VectorSexp_Type = {
+         /* The ob_type field must be initialized in the module init function
+          * to be portable to Windows without using C++. */
++#if (PY_VERSION_HEX < 0x03010000)
+         PyObject_HEAD_INIT(NULL)
+         0,                      /*ob_size*/
++#else
++	PyVarObject_HEAD_INIT(NULL, 0)
++#endif
+         "rpy2.rinterface.SexpVector",        /*tp_name*/
+         sizeof(PySexpObject),   /*tp_basicsize*/
+         0,                      /*tp_itemsize*/
+@@ -1685,7 +1742,7 @@
          0,              /*tp_str*/
          0,                      /*tp_getattro*/
          0,                      /*tp_setattro*/
          &VectorSexp_as_buffer,                      /*tp_as_buffer*/
          Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER,  /*tp_flags*/
  #else
-@@ -1927,12 +1976,20 @@
+@@ -1927,12 +1984,20 @@
    const char *name;
    SEXP res_R = NULL;
  
  
    if (strlen(name) == 0) {
      PyErr_Format(PyExc_KeyError, "%s", name);
-@@ -1966,9 +2023,13 @@
+@@ -1966,9 +2031,13 @@
  static int
  EnvironmentSexp_ass_subscript(PyObject *self, PyObject *key, PyObject *value)
  {
      PyErr_Format(PyExc_ValueError, "Keys must be string objects.");
      return -1;
    }
-@@ -1986,7 +2047,11 @@
+@@ -1986,7 +2055,11 @@
      return -1;
    }
  
  
    if (rpy_has_status(RPY_R_BUSY)) {
      PyErr_Format(PyExc_RuntimeError, "Concurrent access to R is not allowed.");
-@@ -2414,9 +2479,17 @@
+@@ -2095,8 +2168,12 @@
+ static PyTypeObject EnvironmentSexp_Type = {
+         /* The ob_type field must be initialized in the module init function
+          * to be portable to Windows without using C++. */
++#if (PY_VERSION_HEX < 0x03010000)
+         PyObject_HEAD_INIT(NULL)
+         0,                      /*ob_size*/
++#else
++	PyVarObject_HEAD_INIT(NULL, 0)
++#endif
+         "rpy2.rinterface.SexpEnvironment",   /*tp_name*/
+         sizeof(PySexpObject),   /*tp_basicsize*/
+         0,                      /*tp_itemsize*/
+@@ -2188,8 +2265,12 @@
+ static PyTypeObject S4Sexp_Type = {
+         /* The ob_type field must be initialized in the module init function
+          * to be portable to Windows without using C++. */
++#if (PY_VERSION_HEX < 0x03010000)
+         PyObject_HEAD_INIT(NULL)
+         0,                      /*ob_size*/
++#else
++	PyVarObject_HEAD_INIT(NULL, 0)
++#endif
+         "rpy2.rinterface.SexpS4",    /*tp_name*/
+         sizeof(PySexpObject),   /*tp_basicsize*/
+         0,                      /*tp_itemsize*/
+@@ -2241,8 +2322,12 @@
+ static PyTypeObject LangSexp_Type = {
+         /* The ob_type field must be initialized in the module init function
+          * to be portable to Windows without using C++. */
++#if (PY_VERSION_HEX < 0x03010000)
+         PyObject_HEAD_INIT(NULL)
+         0,                      /*ob_size*/
++#else
++	PyVarObject_HEAD_INIT(NULL, 0)
++#endif
+         "rpy2.rinterface.SexpLang",  /*tp_name*/
+         sizeof(PySexpObject),   /*tp_basicsize*/
+         0,                      /*tp_itemsize*/
+@@ -2414,9 +2499,17 @@
      integer_ptr = INTEGER(sexp);
      for (i = 0; i < length; ++i) {
        item = PySequence_Fast_GET_ITEM(seq_object, i);
  	  integer_ptr[i] = RPY_RINT_FROM_LONG(l);
        } else {
          PyErr_Clear();
-@@ -2454,7 +2527,11 @@
+@@ -2454,7 +2547,11 @@
        if (item == na) {
          str_R = NA_STRING;
        } else if((item_tmp = PyObject_Str(item))) {
          if (!str_R) {
              PyErr_NoMemory();
              UNPROTECT(1);
-@@ -2463,8 +2540,13 @@
+@@ -2463,8 +2560,13 @@
              break;
          }
          Py_DECREF(item_tmp);
          if (!str_R) {
            PyErr_NoMemory();
            UNPROTECT(1);
-@@ -2494,9 +2576,17 @@
+@@ -2494,9 +2596,17 @@
            tmp = allocVector(REALSXP, 1);
            REAL(tmp)[0] = PyFloat_AS_DOUBLE(item);
            SET_ELEMENT(sexp, i, tmp);
            SET_ELEMENT(sexp, i, tmp);
          } else if (PyLong_Check(item)) {
            tmp = allocVector(INTSXP, 1);
-@@ -2508,11 +2598,23 @@
+@@ -2508,11 +2618,23 @@
            SET_ELEMENT(sexp, i, tmp);
          } else if (PyBool_Check(item)) {
            tmp = allocVector(LGLSXP, 1);
            if (!tmp2) {
              PyErr_NoMemory();
              sexp = NULL;
-@@ -2617,7 +2719,11 @@
+@@ -2617,7 +2739,11 @@
      return NULL;
    }
    /* FIXME: store python strings when initializing validSexpType instead */
    return res;
  
  }
-@@ -2752,7 +2858,11 @@
+@@ -2752,7 +2878,11 @@
      PyErr_Fetch(&exctype, &excvalue, &exctraceback);
      excstr = PyObject_Str(excvalue);
      if (excstr) {
        Py_DECREF(excstr);
      } 
      else {
-@@ -2796,13 +2906,29 @@
+@@ -2796,13 +2926,29 @@
  #define PYASSERT_ZERO(code) \
    if ((code) != 0) {return ; } \
  
  {
    /* PyMODINIT_FUNC */
    /* RPY_RINTERFACE_INIT(void) */
-@@ -2812,49 +2938,53 @@
+@@ -2812,49 +2958,53 @@
           * object; doing it here is required for portability to Windows 
           * without requiring C++. */
    if (PyType_Ready(&Sexp_Type) < 0)
    }
  
    ADD_SEXP_CONSTANT(m, NILSXP);
-@@ -2894,6 +3024,7 @@
+@@ -2894,6 +3044,7 @@
  
    initOptions = PyTuple_New(4);
  
    PYASSERT_ZERO(
                  PyTuple_SetItem(initOptions, 0, 
                                  PyString_FromString("rpy2"))
-@@ -2910,6 +3041,16 @@
+@@ -2910,6 +3061,16 @@
                  PyTuple_SetItem(initOptions, 3, 
                                  PyString_FromString("--no-save"))
                  );
  
    /* Add an extra ref. It should remain impossible to delete it */
    Py_INCREF(initOptions);
-@@ -2936,7 +3077,7 @@
+@@ -2936,7 +3097,7 @@
  
    /* Missing */
    if (PyType_Ready(&MissingArg_Type) < 0)
    PyModule_AddObject(m, "MissingArgType", (PyObject *)&MissingArg_Type);
    PyModule_AddObject(m, "MissingArg", MissingArg_Type_New(1));
  
-@@ -2944,7 +3085,7 @@
+@@ -2944,7 +3105,7 @@
      RPyExc_RuntimeError = PyErr_NewException("rpy2.rinterface.RRuntimeError", 
                                               NULL, NULL);
      if (RPyExc_RuntimeError == NULL)
    }
    
    Py_INCREF(RPyExc_RuntimeError);
-@@ -2954,7 +3095,7 @@
+@@ -2954,7 +3115,7 @@
    Py_INCREF(Py_False);
  
    if (PyModule_AddObject(m, "isInitialized", embeddedR_isInitialized) < 0)
  
    globalEnv = (PySexpObject *)Sexp_new(&EnvironmentSexp_Type, 
                                         Py_None, Py_None);
-@@ -2963,7 +3104,7 @@
+@@ -2963,7 +3124,7 @@
    if (PyDict_SetItemString(d, "globalenv", (PyObject *)globalEnv) < 0)
    {
      Py_DECREF(globalEnv);
    }
    Py_DECREF(globalEnv);
  
-@@ -2974,7 +3115,7 @@
+@@ -2974,7 +3135,7 @@
                             (PyObject *)baseNameSpaceEnv) < 0)
    {
      Py_DECREF(baseNameSpaceEnv);
    }
    Py_DECREF(baseNameSpaceEnv);
  
-@@ -2985,7 +3126,7 @@
+@@ -2985,7 +3146,7 @@
                             (PyObject *)emptyEnv) < 0)
    {
      Py_DECREF(emptyEnv);
    }
    Py_DECREF(emptyEnv);
  
-@@ -2994,10 +3135,10 @@
+@@ -2994,10 +3155,10 @@
    if (PyDict_SetItemString(d, "R_NilValue", (PyObject *)rpy_R_NilValue) < 0)
    {
      Py_DECREF(rpy_R_NilValue);
  }
 diff -r 089949fdede1 rpy/rinterface/rpy_device.c
 --- a/rpy/rinterface/rpy_device.c	Sun Jun 27 09:47:32 2010 +0200
-+++ b/rpy/rinterface/rpy_device.c	Sun Jul 18 12:42:42 2010 +0200
-@@ -703,7 +703,11 @@
++++ b/rpy/rinterface/rpy_device.c	Sun Jul 18 16:38:29 2010 +0200
+@@ -211,7 +211,11 @@
+ 
+   /* FIXME give the callback access to gc */
+   PyObject *self = (PyObject *)dd->deviceSpecific;
++#if (PY_VERSION_HEX < 0x03010000)
+   PyObject *py_str = PyString_FromString(str);
++#else
++  PyObject *py_str = PyUnicode_FromString(str);
++#endif
+   result = PyObject_CallMethodObjArgs(self, GrDev_strwidth_name, py_str);
+ 
+   rpy_printandclear_error();
+@@ -245,7 +249,11 @@
+   /* FIXME optimize ? */
+   PyObject *py_x = PyFloat_FromDouble(x);
+   PyObject *py_y = PyFloat_FromDouble(y);
++#if (PY_VERSION_HEX < 0x03010000)
+   PyObject *py_str = PyString_FromString(str);
++#else
++  PyObject *py_str = PyUnicode_FromString(str);
++#endif
+   PyObject *py_rot = PyFloat_FromDouble(rot);
+   PyObject *py_hadj = PyFloat_FromDouble(hadj);
+   /* FIXME pass gc ? */
+@@ -503,7 +511,11 @@
+   /* PyOS_setsig(SIGINT, python_sighandler); */
+ 
+   PyObject *self = (PyObject *)dd->deviceSpecific;
++#if (PY_VERSION_HEX < 0x03010000)
+   PyObject *py_mode = PyInt_FromLong((long)mode);
++#else
++  PyObject *py_mode = PyLong_FromLong((long)mode);
++#endif
+   result = PyObject_CallMethodObjArgs(self, GrDev_mode_name, 
+                                       py_mode,
+                                       NULL);
+@@ -536,7 +548,11 @@
+ #ifdef RPY_DEBUG_GRDEV
+   printf("FIXME: MetricInfo.\n");
+ #endif
++#if (PY_VERSION_HEX < 0x03010000)
+   PyObject *py_c = PyInt_FromLong((long)c);
++#else
++  PyObject *py_c = PyLong_FromLong((long)c);
++#endif
+   PyObject *py_ascent = PyFloat_FromDouble(*ascent);
+   PyObject *py_descent = PyFloat_FromDouble(*descent);
+   PyObject *py_width = PyFloat_FromDouble(*width);
+@@ -589,7 +605,11 @@
+ #ifdef RPY_DEBUG_GRDEV
+   printf("FIXME: MetricInfo.\n");
+ #endif
++#if (PY_VERSION_HEX < 0x03010000)
+   PyObject *py_prompt = PyString_FromString(prompt);
++#else
++  PyObject *py_prompt = PyUnicode_FromString(prompt);
++#endif
+   /* FIXME pass gc ? */
+   result = PyObject_CallMethodObjArgs(self, GrDev_getevent_name,
+                                       py_prompt,
+@@ -703,7 +723,11 @@
  #endif
    R_ReleaseObject(self->devnum);
    PyMem_Free(((PyGrDevObject *)self)->grdev);
  #ifdef RPY_DEBUG_GRDEV
    printf("  done.\n");
  #endif
-@@ -713,10 +717,17 @@
+@@ -713,10 +737,17 @@
  GrDev_repr(PyObject *self)
  {
    pDevDesc devdesc = ((PyGrDevObject *)self)->grdev;
                               self,
                               devdesc);
 +#else
-+  return PyString_FromFormat("<%s - Python:\%p / R graphical device:\%p>",
-+                             Py_TYPE(self)->tp_name,
-+                             self,
-+                             devdesc);
++  return PyUnicode_FromFormat("<%s - Python:\%p / R graphical device:\%p>",
++			      Py_TYPE(self)->tp_name,
++			      self,
++			      devdesc);
 +#endif
  }
  
  static PyMethodDef GrDev_methods[] = {
-@@ -1248,9 +1259,11 @@
+@@ -1150,7 +1181,11 @@
+     Py_INCREF(Py_None);
+     res = Py_None;
+   } else {
++#if (PY_VERSION_HEX < 0x03010000)
+     res = PyInt_FromLong((long)RPY_DEV_NUM(self));
++#else
++    res = PyLong_FromLong((long)RPY_DEV_NUM(self));
++#endif
+   }
+   return res;
+ 
+@@ -1248,9 +1283,11 @@
  
    configureDevice(dd, self);
    pGEDevDesc gdd = GEcreateDevDesc(dd);
    ((PyGrDevObject *)self)->devnum = ScalarInteger(ndevNumber(dd) + 1);
    R_PreserveObject(((PyGrDevObject *)self)->devnum);
    /* FIXME: protect device number ? */
+@@ -1268,8 +1305,12 @@
+ static PyTypeObject GrDev_Type = {
+         /* The ob_type field must be initialized in the module init function
+          * to be portable to Windows without using C++. */
++#if (PY_VERSION_HEX < 0x03010000)
+         PyObject_HEAD_INIT(NULL)
+         0,                      /*ob_size*/
++#else
++	PyVarObject_HEAD_INIT(NULL, 0)
++#endif
+         "rpy2.rinterface.GraphicalDevice",   /*tp_name*/
+         sizeof(PyGrDevObject),  /*tp_basicsize*/
+         0,                      /*tp_itemsize*/
+@@ -1278,7 +1319,11 @@
+         0,                      /*tp_print*/
+         0,                      /*tp_getattr*/
+         0,                      /*tp_setattr*/
++#if (PY_VERSION_HEX < 0x03010000)
+         0,                      /*tp_compare*/
++#else
++        0,                      /*tp_reserved*/
++#endif
+         GrDev_repr,             /*tp_repr*/
+         0,                      /*tp_as_number*/
+         0,                      /*tp_as_sequence*/
+@@ -1312,6 +1357,7 @@
+         0,                      /*tp_is_gc*/
+ };
+ 
++/* Additional methods for RpyDevice */
+ static PyMethodDef rpydevice_methods[] = {
+   {NULL,                NULL}           /* sentinel */
+ };
+@@ -1322,10 +1368,25 @@
+ #define PyMODINIT_FUNC void
+ #endif
+ 
++#if (PY_VERSION_HEX < 0x03010000)
++#else
++static struct PyModuleDef rpydevicemodule = {
++   PyModuleDef_HEAD_INIT,
++   "rpy_device",           /* name of module */
++   module_doc,             /* module documentation, may be NULL */
++   -1,                     /* size of per-interpreter state of the module */
++   NULL, NULL, NULL, NULL, NULL
++ };
++#endif
++
+ PyMODINIT_FUNC
++#if (PY_VERSION_HEX < 0x03010000)
+ initrpy_device(void)
++#else
++PyInit_rpy_device(void)
++#endif
+ {
+-
++#if (PY_VERSION_HEX < 0x03010000)
+   GrDev_close_name = PyString_FromString("close");
+   GrDev_activate_name = PyString_FromString("activate");
+   GrDev_deactivate_name = PyString_FromString("deactivate");
+@@ -1343,15 +1404,41 @@
+   GrDev_mode_name = PyString_FromString("mode");
+   GrDev_metricinfo_name = PyString_FromString("metricinfo");
+   GrDev_getevent_name = PyString_FromString("getevent");
+-
++#else
++  GrDev_close_name = PyUnicode_FromString("close");
++  GrDev_activate_name = PyUnicode_FromString("activate");
++  GrDev_deactivate_name = PyUnicode_FromString("deactivate");
++  GrDev_size_name = PyUnicode_FromString("size");
++  GrDev_newpage_name = PyUnicode_FromString("newpage");
++  GrDev_clip_name = PyUnicode_FromString("clip");
++  GrDev_strwidth_name = PyUnicode_FromString("strwidth");
++  GrDev_text_name = PyUnicode_FromString("text");
++  GrDev_rect_name = PyUnicode_FromString("rect");
++  GrDev_circle_name = PyUnicode_FromString("circle");
++  GrDev_line_name = PyUnicode_FromString("line");
++  GrDev_polyline_name = PyUnicode_FromString("polyline");
++  GrDev_polygon_name = PyUnicode_FromString("polygon");
++  GrDev_locator_name = PyUnicode_FromString("locator");
++  GrDev_mode_name = PyUnicode_FromString("mode");
++  GrDev_metricinfo_name = PyUnicode_FromString("metricinfo");
++  GrDev_getevent_name = PyUnicode_FromString("getevent");
++#endif
+   if (PyType_Ready(&GrDev_Type) < 0)
+-    return;
++    return NULL;
+   
+   PyObject *m, *d;
++#if (PY_VERSION_HEX < 0x03010000)
+   m = Py_InitModule3("rpy_device", rpydevice_methods, module_doc);
++#else
++  m = PyModule_Create(&rpydevicemodule);
++#endif
+   if (m == NULL)
+-    return;
++    return NULL;
+   d = PyModule_GetDict(m);
+-
++#if (PY_VERSION_HEX < 0x03010000)
+   PyModule_AddObject(m, "GraphicalDevice", (PyObject *)&GrDev_Type);  
++#else
++  PyModule_AddObject(m, "GraphicalDevice", (PyObject *)&GrDev_Type);
++  return m;
++#endif
+ }
 diff -r 089949fdede1 rpy/rinterface/rpy_rinterface.h
 --- a/rpy/rinterface/rpy_rinterface.h	Sun Jun 27 09:47:32 2010 +0200
-+++ b/rpy/rinterface/rpy_rinterface.h	Sun Jul 18 12:42:42 2010 +0200
++++ b/rpy/rinterface/rpy_rinterface.h	Sun Jul 18 16:38:29 2010 +0200
 @@ -76,7 +76,19 @@
      PyGILState_Release(gstate);                 \
    }
    } else if (PyLong_Check(py_obj)) {                                    \
 diff -r 089949fdede1 rpy/rinterface/sequence.c
 --- a/rpy/rinterface/sequence.c	Sun Jun 27 09:47:32 2010 +0200
-+++ b/rpy/rinterface/sequence.c	Sun Jul 18 12:42:42 2010 +0200
++++ b/rpy/rinterface/sequence.c	Sun Jul 18 16:38:29 2010 +0200
 @@ -53,7 +53,13 @@
    len_R = GET_LENGTH(*sexp);
    
      PyErr_Format(PyExc_ValueError, "NULL SEXP.");
 diff -r 089949fdede1 rpy/rinterface/sexp.c
 --- a/rpy/rinterface/sexp.c	Sun Jun 27 09:47:32 2010 +0200
-+++ b/rpy/rinterface/sexp.c	Sun Jul 18 12:42:42 2010 +0200
++++ b/rpy/rinterface/sexp.c	Sun Jul 18 16:38:29 2010 +0200
 @@ -48,8 +48,11 @@
  Sexp_dealloc(PySexpObject *self)
  {
    {"__getstate__", (PyCFunction)Sexp___getstate__, METH_NOARGS,
     Sexp___getstate___doc},
    {"__setstate__", (PyCFunction)Sexp___setstate__, METH_O,
+@@ -593,8 +631,12 @@
+ static PyTypeObject Sexp_Type = {
+         /* The ob_type field must be initialized in the module init function
+          * to be portable to Windows without using C++. */
++#if (PY_VERSION_HEX < 0x03010000)
+         PyObject_HEAD_INIT(NULL)
+         0,                      /*ob_size*/
++#else
++	PyVarObject_HEAD_INIT(NULL, 0)
++#endif
+         "rpy2.rinterface.Sexp",      /*tp_name*/
+         sizeof(PySexpObject),   /*tp_basicsize*/
+         0,                      /*tp_itemsize*/