Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port to Python 3 #72

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Port to Python 3 #72

wants to merge 1 commit into from

Conversation

nodeg
Copy link
Member

@nodeg nodeg commented Feb 3, 2023

First attempt to port twopence to Python 3. Fixes #69.

TODO

  • replace removed PyFile_Check
  • Fix compiler warnings regarding the port:
$ make

make -C python all
cc -fPIC -I/usr/local/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/include/python3.9 -I../library -Wall -O2 -g3   -c -o extension.o extension.c
extension.c:175:1: warning: non-void function does not return a value [-Wreturn-type]
}                                                                                                                                                               
^                                                                               
1 warning generated.                                                            
cc -fPIC -I/usr/local/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/include/python3.9 -I../library -Wall -O2 -g3   -c -o command.o command.c
command.c:80:2: warning: suggest braces around initialization of subobject [-Wmissing-braces]
        PyObject_HEAD_INIT(NULL)                                                
        ^~~~~~~~~~~~~~~~~~~~~~~~ 
/usr/local/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/include/python3.9/object.h:86:5: note: expanded from macro 'PyObject_HEAD_INIT'
    1, type },         
    ^~~~~~~                                                                                                                                                     
command.c:194:10: warning: assigning to 'char *' from 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
                if ((s = PyUnicode_AsUTF8(stdinObject)) == NULL)
                       ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
command.c:248:6: error: implicit declaration of function 'PyFile_Check' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        if (PyFile_Check(object)) {
            ^
command.c:333:6: warning: incompatible pointer types assigning to 'FILE *' (aka 'struct __sFILE *') from 'PyObject *' (aka 'struct _object *') [-Wincompatible-p
ointer-types]
                fp = PySys_GetObject("stdin");
                   ^ ~~~~~~~~~~~~~~~~~~~~~~~~
command.c:435:28: warning: incompatible integer to pointer conversion passing 'long' to parameter of type 'const char *' [-Wint-conversion]
                return PyLong_FromString(self->timeout, NULL, 0);
                                         ^~~~~~~~~~~~~
/usr/local/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/include/python3.9/longobject.h:103:54: note: passing argument to parameter here
PyAPI_FUNC(PyObject *) PyLong_FromString(const char *, char **, int);
                                                     ^
command.c:441:28: warning: incompatible integer to pointer conversion passing 'unsigned int' to parameter of type 'const char *' [-Wint-conversion]
                return PyLong_FromString(self->pid, NULL, 0);
                                        ^~~~~~~~~
/usr/local/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/include/python3.9/longobject.h:103:54: note: passing argument to parameter here
PyAPI_FUNC(PyObject *) PyLong_FromString(const char *, char **, int);
                                                     ^
command.c:474:33: warning: incompatible pointer types passing 'twopence_Command *' to parameter of type 'PyObject *' (aka 'struct _object *') [-Wincompatible-po
inter-types]
        return PyObject_GenericGetAttr(self, PyUnicode_FromString(name));
                                       ^~~~
/usr/local/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/include/python3.9/object.h:254:58: note: passing argument to parameter here
PyAPI_FUNC(PyObject *) PyObject_GenericGetAttr(PyObject *, PyObject *);
                                                         ^
command.c:495:33: warning: assigning to 'char *' from 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
                if (!PyUnicode_Check(v) || (s = PyUnicode_AsUTF8(v)) == NULL)
                                              ^ ~~~~~~~~~~~~~~~~~~~
7 warnings and 1 error generated.
make[1]: *** [command.o] Error 1
make: *** [all] Error 1

Links

@nodeg nodeg self-assigned this Feb 3, 2023
Fixes openSUSE#69

Signed-off-by: Dominik Gedon <dgedon@suse.de>
@nodeg nodeg mentioned this pull request Mar 15, 2023
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Port to Python 3
1 participant