Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
Pyston
Commits
cc5974c9
Commit
cc5974c9
authored
Apr 12, 2016
by
Kevin Modzelewski
Committed by
Kevin Modzelewski
Apr 13, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Register a bunch of ctypes static constants
parent
e6d24149
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
15 additions
and
16 deletions
+15
-16
from_cpython/Include/Python.h
from_cpython/Include/Python.h
+1
-1
from_cpython/Modules/_ctypes/_ctypes.c
from_cpython/Modules/_ctypes/_ctypes.c
+11
-11
src/runtime/types.cpp
src/runtime/types.cpp
+3
-2
test/tests/ctypes_import.py
test/tests/ctypes_import.py
+0
-1
test/tests/ctypes_test.py
test/tests/ctypes_test.py
+0
-1
No files found.
from_cpython/Include/Python.h
View file @
cc5974c9
...
...
@@ -129,7 +129,7 @@ PyAPI_FUNC(int) PyObject_ClearHcAttrs(PyHcAttrs*) PYSTON_NOEXCEPT;
PyAPI_FUNC
(
int
)
PyObject_TraverseHcAttrs
(
PyHcAttrs
*
,
visitproc
visit
,
void
*
arg
)
PYSTON_NOEXCEPT
;
// Workaround: call this instead of setting tp_dict.
PyAPI_FUNC
(
void
)
PyType_SetDict
(
PyTypeObject
*
,
PyObject
*
)
PYSTON_NOEXCEPT
;
PyAPI_FUNC
(
void
)
PyType_SetDict
(
PyTypeObject
*
,
STOLEN
(
PyObject
*
)
)
PYSTON_NOEXCEPT
;
// Pyston addition: register an object as a "static constant". Current purpose is that this will
// get decref'd when the interpreter shuts down. This functions returns its argument.
...
...
from_cpython/Modules/_ctypes/_ctypes.c
View file @
cc5974c9
...
...
@@ -424,8 +424,8 @@ StructUnionType_new(PyTypeObject *type, PyObject *args, PyObject *kwds, int isSt
Py_DECREF
((
PyObject
*
)
dict
);
return
NULL
;
}
Py_DECREF
(
result
->
tp_dict
);
// Pyston change:
//Py_DECREF(result->tp_dict);
//result->tp_dict = (PyObject *)dict;
PyType_SetDict
(
result
,
(
PyObject
*
)
dict
);
dict
->
format
=
_ctypes_alloc_format_string
(
NULL
,
"B"
);
...
...
@@ -996,8 +996,8 @@ PyCPointerType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
Py_DECREF
((
PyObject
*
)
stgdict
);
return
NULL
;
}
Py_DECREF
(
result
->
tp_dict
);
// Pyston change:
//Py_DECREF(result->tp_dict);
//result->tp_dict = (PyObject *)stgdict;
PyType_SetDict
(
result
,
(
PyObject
*
)
stgdict
);
...
...
@@ -1464,8 +1464,8 @@ PyCArrayType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
Py_DECREF
((
PyObject
*
)
stgdict
);
return
NULL
;
}
Py_DECREF
(
result
->
tp_dict
);
// Pyston change:
//Py_DECREF(result->tp_dict);
//result->tp_dict = (PyObject *)stgdict;
PyType_SetDict
(
result
,
(
PyObject
*
)
stgdict
);
...
...
@@ -1845,9 +1845,9 @@ static PyObject *CreateSwappedType(PyTypeObject *type, PyObject *args, PyObject
if
(
suffix
==
NULL
)
#ifdef WORDS_BIGENDIAN
suffix
=
Py
String_InternFromString
(
"_le"
);
suffix
=
Py
GC_RegisterStaticConstant
(
PyString_InternFromString
(
"_le"
)
);
#else
suffix
=
Py
String_InternFromString
(
"_be"
);
suffix
=
Py
GC_RegisterStaticConstant
(
PyString_InternFromString
(
"_be"
)
);
#endif
Py_INCREF
(
name
);
...
...
@@ -1890,8 +1890,8 @@ static PyObject *CreateSwappedType(PyTypeObject *type, PyObject *args, PyObject
Py_DECREF
((
PyObject
*
)
stgdict
);
return
NULL
;
}
Py_DECREF
(
result
->
tp_dict
);
// Pyston change:
//Py_DECREF(result->tp_dict);
//result->tp_dict = (PyObject *)stgdict;
PyType_SetDict
(
result
,
(
PyObject
*
)
stgdict
);
...
...
@@ -2021,8 +2021,8 @@ PyCSimpleType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
Py_DECREF
((
PyObject
*
)
stgdict
);
return
NULL
;
}
Py_DECREF
(
result
->
tp_dict
);
// Pyston change:
//Py_DECREF(result->tp_dict);
//result->tp_dict = (PyObject *)stgdict;
PyType_SetDict
(
result
,
(
PyObject
*
)
stgdict
);
...
...
@@ -2404,8 +2404,8 @@ PyCFuncPtrType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
Py_DECREF
((
PyObject
*
)
stgdict
);
return
NULL
;
}
Py_DECREF
(
result
->
tp_dict
);
// Pyston change:
//Py_DECREF(result->tp_dict);
//result->tp_dict = (PyObject *)stgdict;
PyType_SetDict
(
result
,
(
PyObject
*
)
stgdict
);
...
...
@@ -4722,7 +4722,7 @@ PyCArrayType_from_ctype(PyObject *itemtype, Py_ssize_t length)
PyObject
*
len
;
if
(
cache
==
NULL
)
{
cache
=
Py
Dict_New
(
);
cache
=
Py
GC_RegisterStaticConstant
(
PyDict_New
()
);
if
(
cache
==
NULL
)
return
NULL
;
}
...
...
@@ -4882,7 +4882,7 @@ Simple_repr(CDataObject *self)
}
if
(
format
==
NULL
)
{
format
=
Py
String_InternFromString
(
"%s(%r)"
);
format
=
Py
GC_RegisterStaticConstant
(
PyString_InternFromString
(
"%s(%r)"
)
);
if
(
format
==
NULL
)
return
NULL
;
}
...
...
@@ -5587,7 +5587,7 @@ init_ctypes(void)
PyModule_AddObject
(
m
,
"_pointer_type_cache"
,
(
PyObject
*
)
_ctypes_ptrtype_cache
);
_unpickle
=
Py
Object_GetAttrString
(
m
,
"_unpickle"
);
_unpickle
=
Py
GC_RegisterStaticConstant
(
PyObject_GetAttrString
(
m
,
"_unpickle"
)
);
if
(
_unpickle
==
NULL
)
return
;
...
...
src/runtime/types.cpp
View file @
cc5974c9
...
...
@@ -1429,10 +1429,11 @@ static void typeSubSetDict(BORROWED(Box*) obj, BORROWED(Box*) val, void* context
abort
();
}
extern
"C"
void
PyType_SetDict
(
PyTypeObject
*
type
,
PyObject
*
dict
)
noexcept
{
assert
(
0
&&
"check refcounting"
);
extern
"C"
void
PyType_SetDict
(
PyTypeObject
*
type
,
STOLEN
(
PyObject
*
)
dict
)
noexcept
{
typeSubSetDict
(
type
,
dict
,
NULL
);
Box
*
old_dict
=
type
->
tp_dict
;
type
->
tp_dict
=
dict
;
Py_DECREF
(
old_dict
);
}
Box
*
dict_descr
=
NULL
;
...
...
test/tests/ctypes_import.py
View file @
cc5974c9
# expected: reffail
# We can only import ctypes for now - it would be nice to have tests later,
# which will probably involve running the existing test suite for ctype rather
# than add our own here (unless there's special Pyston-related edge cases).
...
...
test/tests/ctypes_test.py
View file @
cc5974c9
# expected: reffail
from
ctypes
import
*
s
=
"tmp"
ap
=
create_string_buffer
(
s
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment