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
6d9d1c3d
Commit
6d9d1c3d
authored
Dec 13, 2014
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add richcmp slotdef and a few other things to get the pwd module working
parent
90d27e6f
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
121 additions
and
32 deletions
+121
-32
Makefile
Makefile
+0
-1
include/abstract.h
include/abstract.h
+5
-0
include/object.h
include/object.h
+5
-2
src/capi/typeobject.cpp
src/capi/typeobject.cpp
+98
-25
src/runtime/capi.cpp
src/runtime/capi.cpp
+10
-0
src/runtime/types.cpp
src/runtime/types.cpp
+0
-4
test/tests/pwd_test.py
test/tests/pwd_test.py
+3
-0
No files found.
Makefile
View file @
6d9d1c3d
...
...
@@ -142,7 +142,6 @@ COMMON_CXXFLAGS += -fexceptions -fno-rtti
COMMON_CXXFLAGS
+=
-Wno-invalid-offsetof
# allow the use of "offsetof", and we'll just have to make sure to only use it legally.
COMMON_CXXFLAGS
+=
-DENABLE_INTEL_JIT_EVENTS
=
$(ENABLE_INTEL_JIT_EVENTS)
COMMON_CXXFLAGS
+=
-I
$(DEPS_DIR)
/pypa-install/include
COMMON_CXXFLAGS
+=
-Wno-comment
ifeq
($(ENABLE_VALGRIND),0)
COMMON_CXXFLAGS
+=
-DNVALGRIND
...
...
include/abstract.h
View file @
6d9d1c3d
...
...
@@ -847,10 +847,15 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
*/
// Pyston change: made this a function:
bool
_PyIndex_Check
(
PyObject
*
o
);
#define PyIndex_Check(obj) _PyIndex_Check((PyObject*)(obj))
#if 0
#define PyIndex_Check(obj) \
((obj)->ob_type->tp_as_number != NULL && \
PyType_HasFeature((obj)->ob_type, Py_TPFLAGS_HAVE_INDEX) && \
(obj)->ob_type->tp_as_number->nb_index != NULL)
#endif
PyAPI_FUNC
(
PyObject
*
)
PyNumber_Index
(
PyObject
*
o
);
...
...
include/object.h
View file @
6d9d1c3d
...
...
@@ -903,8 +903,11 @@ PyAPI_DATA(PyObject*) None;
Py_NotImplemented is a singleton used to signal that an operation is
not implemented for a given type combination.
*/
PyAPI_DATA
(
PyObject
)
_Py_NotImplementedStruct
;
/* Don't use this directly */
#define Py_NotImplemented (&_Py_NotImplementedStruct)
// Pyston change:
//PyAPI_DATA(PyObject) _Py_NotImplementedStruct; /* Don't use this directly */
//#define Py_NotImplemented (&_Py_NotImplementedStruct)
PyAPI_DATA
(
PyObject
*
)
NotImplemented
;
/* Don't use this directly */
#define Py_NotImplemented NotImplemented
/* Rich comparison opcodes */
#define Py_LT 0
...
...
src/capi/typeobject.cpp
View file @
6d9d1c3d
...
...
@@ -56,6 +56,29 @@ static PyObject* wrap_call(PyObject* self, PyObject* args, void* wrapped, PyObje
return
(
*
func
)(
self
,
args
,
kwds
);
}
static
PyObject
*
wrap_richcmpfunc
(
PyObject
*
self
,
PyObject
*
args
,
void
*
wrapped
,
int
op
)
{
richcmpfunc
func
=
(
richcmpfunc
)
wrapped
;
PyObject
*
other
;
if
(
!
check_num_args
(
args
,
1
))
return
NULL
;
other
=
PyTuple_GET_ITEM
(
args
,
0
);
return
(
*
func
)(
self
,
other
,
op
);
}
#undef RICHCMP_WRAPPER
#define RICHCMP_WRAPPER(NAME, OP) \
static PyObject* richcmp_##NAME(PyObject* self, PyObject* args, void* wrapped) { \
return wrap_richcmpfunc(self, args, wrapped, OP); \
}
RICHCMP_WRAPPER
(
lt
,
Py_LT
)
RICHCMP_WRAPPER
(
le
,
Py_LE
)
RICHCMP_WRAPPER
(
eq
,
Py_EQ
)
RICHCMP_WRAPPER
(
ne
,
Py_NE
)
RICHCMP_WRAPPER
(
gt
,
Py_GT
)
RICHCMP_WRAPPER
(
ge
,
Py_GE
)
static
PyObject
*
wrap_unaryfunc
(
PyObject
*
self
,
PyObject
*
args
,
void
*
wrapped
)
{
unaryfunc
func
=
(
unaryfunc
)
wrapped
;
...
...
@@ -307,30 +330,6 @@ static PyObject* call_method(PyObject* o, const char* name, PyObject** nameobj,
}
PyObject
*
slot_tp_new
(
PyTypeObject
*
self
,
PyObject
*
args
,
PyObject
*
kwds
)
noexcept
{
try
{
// TODO: runtime ICs?
Box
*
new_attr
=
typeLookup
(
self
,
_new_str
,
NULL
);
assert
(
new_attr
);
new_attr
=
processDescriptor
(
new_attr
,
None
,
self
);
return
runtimeCall
(
new_attr
,
ArgPassSpec
(
1
,
0
,
true
,
true
),
self
,
args
,
kwds
,
NULL
,
NULL
);
}
catch
(
Box
*
e
)
{
abort
();
}
}
PyObject
*
slot_tp_call
(
PyObject
*
self
,
PyObject
*
args
,
PyObject
*
kwds
)
noexcept
{
try
{
Py_FatalError
(
"this function is untested"
);
// TODO: runtime ICs?
return
runtimeCall
(
self
,
ArgPassSpec
(
0
,
0
,
true
,
true
),
args
,
kwds
,
NULL
,
NULL
,
NULL
);
}
catch
(
Box
*
e
)
{
abort
();
}
}
PyObject
*
slot_tp_repr
(
PyObject
*
self
)
noexcept
{
try
{
return
repr
(
self
);
...
...
@@ -376,6 +375,75 @@ static long slot_tp_hash(PyObject* self) noexcept {
return
h
;
}
PyObject
*
slot_tp_call
(
PyObject
*
self
,
PyObject
*
args
,
PyObject
*
kwds
)
noexcept
{
try
{
Py_FatalError
(
"this function is untested"
);
// TODO: runtime ICs?
return
runtimeCall
(
self
,
ArgPassSpec
(
0
,
0
,
true
,
true
),
args
,
kwds
,
NULL
,
NULL
,
NULL
);
}
catch
(
Box
*
e
)
{
abort
();
}
}
static
const
char
*
name_op
[]
=
{
"__lt__"
,
"__le__"
,
"__eq__"
,
"__ne__"
,
"__gt__"
,
"__ge__"
,
};
static
PyObject
*
half_richcompare
(
PyObject
*
self
,
PyObject
*
other
,
int
op
)
{
PyObject
*
func
,
*
args
,
*
res
;
static
PyObject
*
op_str
[
6
];
func
=
lookup_method
(
self
,
name_op
[
op
],
&
op_str
[
op
]);
if
(
func
==
NULL
)
{
PyErr_Clear
();
Py_INCREF
(
Py_NotImplemented
);
return
Py_NotImplemented
;
}
args
=
PyTuple_Pack
(
1
,
other
);
if
(
args
==
NULL
)
res
=
NULL
;
else
{
res
=
PyObject_Call
(
func
,
args
,
NULL
);
Py_DECREF
(
args
);
}
Py_DECREF
(
func
);
return
res
;
}
static
PyObject
*
slot_tp_richcompare
(
PyObject
*
self
,
PyObject
*
other
,
int
op
)
{
PyObject
*
res
;
if
(
Py_TYPE
(
self
)
->
tp_richcompare
==
slot_tp_richcompare
)
{
res
=
half_richcompare
(
self
,
other
,
op
);
if
(
res
!=
Py_NotImplemented
)
return
res
;
Py_DECREF
(
res
);
}
if
(
Py_TYPE
(
other
)
->
tp_richcompare
==
slot_tp_richcompare
)
{
res
=
half_richcompare
(
other
,
self
,
_Py_SwappedOp
[
op
]);
if
(
res
!=
Py_NotImplemented
)
{
return
res
;
}
Py_DECREF
(
res
);
}
Py_INCREF
(
Py_NotImplemented
);
return
Py_NotImplemented
;
}
PyObject
*
slot_tp_new
(
PyTypeObject
*
self
,
PyObject
*
args
,
PyObject
*
kwds
)
noexcept
{
try
{
// TODO: runtime ICs?
Box
*
new_attr
=
typeLookup
(
self
,
_new_str
,
NULL
);
assert
(
new_attr
);
new_attr
=
processDescriptor
(
new_attr
,
None
,
self
);
return
runtimeCall
(
new_attr
,
ArgPassSpec
(
1
,
0
,
true
,
true
),
self
,
args
,
kwds
,
NULL
,
NULL
);
}
catch
(
Box
*
e
)
{
abort
();
}
}
PyObject
*
slot_sq_item
(
PyObject
*
self
,
Py_ssize_t
i
)
noexcept
{
try
{
return
getitem
(
self
,
boxInt
(
i
));
...
...
@@ -585,6 +653,12 @@ static slotdef slotdefs[] = {
TPSLOT
(
"__hash__"
,
tp_hash
,
slot_tp_hash
,
wrap_hashfunc
,
"x.__hash__() <==> hash(x)"
),
FLSLOT
(
"__call__"
,
tp_call
,
slot_tp_call
,
(
wrapperfunc
)
wrap_call
,
"x.__call__(...) <==> x(...)"
,
PyWrapperFlag_KEYWORDS
),
TPSLOT
(
"__lt__"
,
tp_richcompare
,
slot_tp_richcompare
,
richcmp_lt
,
"x.__lt__(y) <==> x<y"
),
TPSLOT
(
"__le__"
,
tp_richcompare
,
slot_tp_richcompare
,
richcmp_le
,
"x.__le__(y) <==> x<=y"
),
TPSLOT
(
"__eq__"
,
tp_richcompare
,
slot_tp_richcompare
,
richcmp_eq
,
"x.__eq__(y) <==> x==y"
),
TPSLOT
(
"__ne__"
,
tp_richcompare
,
slot_tp_richcompare
,
richcmp_ne
,
"x.__ne__(y) <==> x!=y"
),
TPSLOT
(
"__gt__"
,
tp_richcompare
,
slot_tp_richcompare
,
richcmp_gt
,
"x.__gt__(y) <==> x>y"
),
TPSLOT
(
"__ge__"
,
tp_richcompare
,
slot_tp_richcompare
,
richcmp_ge
,
"x.__ge__(y) <==> x>=y"
),
TPSLOT
(
"__new__"
,
tp_new
,
slot_tp_new
,
NULL
,
""
),
MPSLOT
(
"__len__"
,
mp_length
,
slot_mp_length
,
wrap_lenfunc
,
"x.__len__() <==> len(x)"
),
...
...
@@ -736,7 +810,6 @@ extern "C" int PyType_Ready(PyTypeObject* cls) {
int
ALLOWABLE_FLAGS
=
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_BASETYPE
|
Py_TPFLAGS_HAVE_GC
;
RELEASE_ASSERT
((
cls
->
tp_flags
&
~
ALLOWABLE_FLAGS
)
==
0
,
""
);
RELEASE_ASSERT
(
cls
->
tp_richcompare
==
NULL
,
""
);
RELEASE_ASSERT
(
cls
->
tp_iter
==
NULL
,
""
);
RELEASE_ASSERT
(
cls
->
tp_iternext
==
NULL
,
""
);
RELEASE_ASSERT
(
cls
->
tp_base
==
NULL
,
""
);
...
...
src/runtime/capi.cpp
View file @
6d9d1c3d
...
...
@@ -38,6 +38,7 @@ MAKE_CHECK(Long, long_cls)
MAKE_CHECK
(
List
,
list_cls
)
MAKE_CHECK
(
Tuple
,
tuple_cls
)
MAKE_CHECK
(
Dict
,
dict_cls
)
MAKE_CHECK
(
Slice
,
slice_cls
)
#ifdef Py_USING_UNICODE
MAKE_CHECK
(
Unicode
,
unicode_cls
)
...
...
@@ -45,6 +46,11 @@ MAKE_CHECK(Unicode, unicode_cls)
#undef MAKE_CHECK
extern
"C"
bool
_PyIndex_Check
(
PyObject
*
op
)
{
// TODO this is wrong (the CPython version checks for things that can be coerced to a number):
return
PyInt_Check
(
op
);
}
extern
"C"
{
int
Py_Py3kWarningFlag
;
}
...
...
@@ -299,6 +305,10 @@ extern "C" PyObject* PyObject_RichCompare(PyObject* o1, PyObject* o2, int opid)
Py_FatalError
(
"unimplemented"
);
}
extern
"C"
{
int
_Py_SwappedOp
[]
=
{
Py_GT
,
Py_GE
,
Py_EQ
,
Py_NE
,
Py_LT
,
Py_LE
};
}
extern
"C"
long
PyObject_Hash
(
PyObject
*
o
)
{
try
{
return
hash
(
o
)
->
n
;
...
...
src/runtime/types.cpp
View file @
6d9d1c3d
...
...
@@ -595,10 +595,6 @@ Box* sliceRepr(BoxedSlice* self) {
return
new
BoxedString
(
std
::
move
(
s
));
}
extern
"C"
bool
PySlice_Check
(
PyObject
*
)
{
Py_FatalError
(
"unimplemented"
);
}
extern
"C"
int
PySlice_GetIndices
(
PySliceObject
*
r
,
Py_ssize_t
length
,
Py_ssize_t
*
start
,
Py_ssize_t
*
stop
,
Py_ssize_t
*
step
)
{
Py_FatalError
(
"unimplemented"
);
...
...
test/tests/pwd_test.py
View file @
6d9d1c3d
# expected: fail
# - wip
import
pwd
import
os
print
pwd
.
getpwuid
(
os
.
getuid
())[
5
]
==
os
.
environ
[
"HOME"
]
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