Upgrade to current stable Python 3.x release

Overview

Current Python version = 2.7

Target Python version = 3.6

  • Using lib2to3:
    2to3 is a Python program that reads Python 2.x source code and applies a series of fixers to transform it into valid Python 3.x code. The standard library contains a rich set of fixers that will handle almost all code. 2to3 supporting library lib2to3 is, however, a flexible and generic library, so it is possible to write your own fixers for 2to3. lib2to3 could also be adapted to custom applications in which Python code needs to be edited automatically.
    Usage: /usr/bin/python3.6 -m lib2to3 -f all -f buffer -f idioms -f set_literal -f ws_comma -w -W <python file path>
                 -f all : Apply all default fixers
                 -f <name of fixer>: Apply a specific fixer
                 -w: Write changes to a file
                 -W: always write output files even if no changes were required to the file
  • A list python APIs which we have used in C files of PBSPro and have changes in Python 3 (Not a complete list):

API in Python 2

API in Python 3


PyObject* PyInt_FromSsize_t(Py_ssize_t ival)


PyObject* PyLong_FromSsize_t(Py_ssize_t v)

char* PyString_AsString(PyObject *string)

char* PyUnicode_AsUTF8(PyObject *unicode)

int PyString_Check(PyObject *o)

int PyUnicode_Check(PyObject *o)

PyObject* PyString_InternFromString(const char *v)

PyObject* PyUnicode_InternFromString(const char *v)

PyObject* PyString_FromString(const char *v)

PyObject *PyUnicode_FromString(const char *u)

PyObject* Py_InitModule3(char *name, PyMethodDef *methods, char *doc)

PyObject* PyModule_Create(PyModuleDef *def)

struct _inittab

    struct _inittab {
        char *name;
        void (*initfunc)(void);
    }

struct _inittab

    struct _inittab {
        const char *name;           /* ASCII encoded string */
        PyObject* (*initfunc)(void);
    };

PyObject* PyInt_FromLong(long ival)

PyObject* PyLong_FromLong(long v)

PyObject* PyFile_FromFile(FILE *fp, char *name, char *mode, int (*close)(FILE*))

 PyFile_FromFd(int fd, const char *name, const char *mode, int buffering, const char *encoding, const char *errors, const char *newline, int closefd)

unsigned PY_LONG_LONG PyInt_AsUnsignedLongLongMask(PyObject *io)

unsigned long long PyLong_AsUnsignedLongLongMask(PyObject *obj)

PyObject_HEAD_INIT(type)

PyVarObject_HEAD_INIT(type, size)

PyTypeObject *tp = obj->ob_type;

PyTypeObject *tp = Py_Type(obj);[3]

PyTypeObject structure

Some fields are deprecated and new fields are added to PyTypeObject structure.

void init_pbs_ifl(void)

PyObject * PyInit__pbs_ifl(void)





OSS Site Map

Project Documentation Main Page

Developer Guide Pages