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

Python3 support #5

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
276 changes: 0 additions & 276 deletions ez_setup.py

This file was deleted.

4 changes: 1 addition & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
import subprocess as sp
import sys
from distutils.dist import Distribution
import ez_setup
ez_setup.use_setuptools()
from setuptools import setup, Extension

DEBUG = "--debug" in sys.argv
Expand Down Expand Up @@ -72,7 +70,7 @@ def pkg_config(pkg_name, config=None):
"-D": ("extra_compile_args", 0),
"-Wl": ("extra_link_args", 0)
}
for flag in stdout.split():
for flag in stdout.decode().split():
for prefix in prefixes:
if not flag.startswith(prefix):
continue
Expand Down
6 changes: 3 additions & 3 deletions spidermonkey/context.c
Original file line number Diff line number Diff line change
Expand Up @@ -711,8 +711,7 @@ static PyMethodDef Context_methods[] = {
};

PyTypeObject _ContextType = {
PyObject_HEAD_INIT(NULL)
0, /*ob_size*/
PyVarObject_HEAD_INIT(NULL, 0)
"spidermonkey.Context", /*tp_name*/
sizeof(Context), /*tp_basicsize*/
0, /*tp_itemsize*/
Expand Down Expand Up @@ -768,7 +767,8 @@ Context_has_access(Context* pycx, JSContext* jscx, PyObject* obj, PyObject* key)
tpl = Py_BuildValue("(OO)", obj, key);
if(tpl == NULL) goto done;

tmp = PyObject_Call(pycx->access, tpl, NULL);
tmp = PyObject_CallObject(pycx->access, tpl);
if(tmp == NULL) goto done;
res = PyObject_IsTrue(tmp);

done:
Expand Down
2 changes: 1 addition & 1 deletion spidermonkey/convert.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ py2js(Context* cx, PyObject* obj)
{
return py2js_double(cx, obj);
}
else if(PyString_Check(obj) || PyUnicode_Check(obj))
else if(PyBytes_Check(obj) || PyUnicode_Check(obj))
{
return py2js_string(cx, obj);
}
Expand Down
23 changes: 6 additions & 17 deletions spidermonkey/error.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ add_frame(const char* srcfile, const char* funcname, int linenum)
PyCodeObject* code = NULL;
PyFrameObject* frame = NULL;

src = PyString_FromString(srcfile);
src = PyBytes_FromString(srcfile);
if(src == NULL) goto error;

func = PyString_FromString(funcname);
func = PyBytes_FromString(funcname);
if(func == NULL) goto error;

glbl = PyModule_GetDict(SpidermonkeyModule);
Expand All @@ -33,24 +33,13 @@ add_frame(const char* srcfile, const char* funcname, int linenum)
tpl = PyTuple_New(0);
if(tpl == NULL) goto error;

str = PyString_FromString("");
str = PyBytes_FromString("");
if(str == NULL) goto error;

code = PyCode_New(
0, /*co_argcount*/
0, /*co_nlocals*/
0, /*co_stacksize*/
0, /*co_flags*/
str, /*co_code*/
tpl, /*co_consts*/
tpl, /*co_names*/
tpl, /*co_varnames*/
tpl, /*co_freevars*/
tpl, /*co_cellvars*/
code = PyCode_NewEmpty(
src, /*co_filename*/
func, /*co_name*/
linenum, /*co_firstlineno*/
str /*co_lnotab*/
linenum /*co_firstlineno*/
);
if(code == NULL) goto error;

Expand Down Expand Up @@ -91,7 +80,7 @@ report_error_cb(JSContext* cx, const char* message, JSErrorReport* report)

if(!PyErr_Occurred())
{
PyErr_SetString(JSError, message);
PyErr_SetString(JSError, mesg);
}

add_frame(srcfile, "JavaScript code", report->lineno);
Expand Down
Loading