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
992eee47
Commit
992eee47
authored
Mar 25, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #409 from undingen/fix_pip_search2
Misc fixes for pip search part 2
parents
2c1b4069
abdf99d3
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
62 additions
and
4 deletions
+62
-4
src/runtime/descr.cpp
src/runtime/descr.cpp
+5
-4
src/runtime/import.cpp
src/runtime/import.cpp
+27
-0
src/runtime/types.cpp
src/runtime/types.cpp
+8
-0
test/tests/imp_test.py
test/tests/imp_test.py
+3
-0
test/tests/property.py
test/tests/property.py
+19
-0
No files found.
src/runtime/descr.cpp
View file @
992eee47
...
@@ -91,9 +91,7 @@ static Box* propertyDel(Box* self, Box* obj) {
...
@@ -91,9 +91,7 @@ static Box* propertyDel(Box* self, Box* obj) {
}
}
static
Box
*
property_copy
(
BoxedProperty
*
old
,
Box
*
get
,
Box
*
set
,
Box
*
del
)
{
static
Box
*
property_copy
(
BoxedProperty
*
old
,
Box
*
get
,
Box
*
set
,
Box
*
del
)
{
// In CPython, I think this can take a subclass of property, and will call the subclass's
RELEASE_ASSERT
(
isSubclass
(
old
->
cls
,
property_cls
),
""
);
// constructor... for now just enforce that it's a property object and inline the constructor:
RELEASE_ASSERT
(
old
->
cls
==
property_cls
,
""
);
if
(
!
get
)
if
(
!
get
)
get
=
old
->
prop_get
;
get
=
old
->
prop_get
;
...
@@ -102,7 +100,10 @@ static Box* property_copy(BoxedProperty* old, Box* get, Box* set, Box* del) {
...
@@ -102,7 +100,10 @@ static Box* property_copy(BoxedProperty* old, Box* get, Box* set, Box* del) {
if
(
!
del
)
if
(
!
del
)
del
=
old
->
prop_del
;
del
=
old
->
prop_del
;
// Optimization for the case when the old propery is not subclassed
if
(
old
->
cls
==
property_cls
)
return
new
BoxedProperty
(
get
,
set
,
del
,
old
->
prop_doc
);
return
new
BoxedProperty
(
get
,
set
,
del
,
old
->
prop_doc
);
return
runtimeCall
(
old
->
cls
,
ArgPassSpec
(
4
),
get
,
set
,
del
,
&
old
->
prop_doc
,
NULL
);
}
}
static
Box
*
propertyGetter
(
Box
*
self
,
Box
*
obj
)
{
static
Box
*
propertyGetter
(
Box
*
self
,
Box
*
obj
)
{
...
...
src/runtime/import.cpp
View file @
992eee47
...
@@ -684,6 +684,26 @@ Box* impLoadModule(Box* _name, Box* _file, Box* _pathname, Box** args) {
...
@@ -684,6 +684,26 @@ Box* impLoadModule(Box* _name, Box* _file, Box* _pathname, Box** args) {
Py_FatalError
(
"unimplemented"
);
Py_FatalError
(
"unimplemented"
);
}
}
Box
*
impGetSuffixes
()
{
BoxedList
*
list
=
new
BoxedList
;
// For now only add *.py
listAppendInternal
(
list
,
new
BoxedTuple
({
new
BoxedString
(
".py"
),
new
BoxedString
(
"U"
),
boxInt
(
SearchResult
::
PY_SOURCE
)
}));
return
list
;
}
Box
*
impAcquireLock
()
{
_PyImport_AcquireLock
();
checkAndThrowCAPIException
();
return
None
;
}
Box
*
impReleaseLock
()
{
_PyImport_ReleaseLock
();
checkAndThrowCAPIException
();
return
None
;
}
void
setupImport
()
{
void
setupImport
()
{
BoxedModule
*
imp_module
BoxedModule
*
imp_module
=
createModule
(
"imp"
,
"__builtin__"
,
"'This module provides the components needed to build your own
\n
"
=
createModule
(
"imp"
,
"__builtin__"
,
"'This module provides the components needed to build your own
\n
"
...
@@ -714,5 +734,12 @@ void setupImport() {
...
@@ -714,5 +734,12 @@ void setupImport() {
ParamNames
({
"name"
,
"file"
,
"pathname"
,
"description"
},
""
,
""
));
ParamNames
({
"name"
,
"file"
,
"pathname"
,
"description"
},
""
,
""
));
imp_module
->
giveAttr
(
"load_module"
,
new
BoxedBuiltinFunctionOrMethod
(
load_module_func
,
"load_module"
));
imp_module
->
giveAttr
(
"load_module"
,
new
BoxedBuiltinFunctionOrMethod
(
load_module_func
,
"load_module"
));
imp_module
->
giveAttr
(
"get_suffixes"
,
new
BoxedBuiltinFunctionOrMethod
(
boxRTFunction
((
void
*
)
impGetSuffixes
,
UNKNOWN
,
0
),
"get_suffixes"
));
imp_module
->
giveAttr
(
"acquire_lock"
,
new
BoxedBuiltinFunctionOrMethod
(
boxRTFunction
((
void
*
)
impAcquireLock
,
NONE
,
0
),
"acquire_lock"
));
imp_module
->
giveAttr
(
"release_lock"
,
new
BoxedBuiltinFunctionOrMethod
(
boxRTFunction
((
void
*
)
impReleaseLock
,
NONE
,
0
),
"release_lock"
));
}
}
}
}
src/runtime/types.cpp
View file @
992eee47
...
@@ -497,6 +497,8 @@ static void typeSetDict(Box* obj, Box* val, void* context) {
...
@@ -497,6 +497,8 @@ static void typeSetDict(Box* obj, Box* val, void* context) {
Box
*
dict_descr
=
NULL
;
Box
*
dict_descr
=
NULL
;
extern
"C"
void
instancemethodGCHandler
(
GCVisitor
*
v
,
Box
*
b
)
{
extern
"C"
void
instancemethodGCHandler
(
GCVisitor
*
v
,
Box
*
b
)
{
boxGCHandler
(
v
,
b
);
BoxedInstanceMethod
*
im
=
(
BoxedInstanceMethod
*
)
b
;
BoxedInstanceMethod
*
im
=
(
BoxedInstanceMethod
*
)
b
;
if
(
im
->
obj
)
{
if
(
im
->
obj
)
{
...
@@ -506,6 +508,8 @@ extern "C" void instancemethodGCHandler(GCVisitor* v, Box* b) {
...
@@ -506,6 +508,8 @@ extern "C" void instancemethodGCHandler(GCVisitor* v, Box* b) {
}
}
extern
"C"
void
propertyGCHandler
(
GCVisitor
*
v
,
Box
*
b
)
{
extern
"C"
void
propertyGCHandler
(
GCVisitor
*
v
,
Box
*
b
)
{
boxGCHandler
(
v
,
b
);
BoxedProperty
*
prop
=
(
BoxedProperty
*
)
b
;
BoxedProperty
*
prop
=
(
BoxedProperty
*
)
b
;
if
(
prop
->
prop_get
)
if
(
prop
->
prop_get
)
...
@@ -519,6 +523,8 @@ extern "C" void propertyGCHandler(GCVisitor* v, Box* b) {
...
@@ -519,6 +523,8 @@ extern "C" void propertyGCHandler(GCVisitor* v, Box* b) {
}
}
extern
"C"
void
staticmethodGCHandler
(
GCVisitor
*
v
,
Box
*
b
)
{
extern
"C"
void
staticmethodGCHandler
(
GCVisitor
*
v
,
Box
*
b
)
{
boxGCHandler
(
v
,
b
);
BoxedStaticmethod
*
sm
=
(
BoxedStaticmethod
*
)
b
;
BoxedStaticmethod
*
sm
=
(
BoxedStaticmethod
*
)
b
;
if
(
sm
->
sm_callable
)
if
(
sm
->
sm_callable
)
...
@@ -526,6 +532,8 @@ extern "C" void staticmethodGCHandler(GCVisitor* v, Box* b) {
...
@@ -526,6 +532,8 @@ extern "C" void staticmethodGCHandler(GCVisitor* v, Box* b) {
}
}
extern
"C"
void
classmethodGCHandler
(
GCVisitor
*
v
,
Box
*
b
)
{
extern
"C"
void
classmethodGCHandler
(
GCVisitor
*
v
,
Box
*
b
)
{
boxGCHandler
(
v
,
b
);
BoxedClassmethod
*
cm
=
(
BoxedClassmethod
*
)
b
;
BoxedClassmethod
*
cm
=
(
BoxedClassmethod
*
)
b
;
if
(
cm
->
cm_callable
)
if
(
cm
->
cm_callable
)
...
...
test/tests/imp_test.py
View file @
992eee47
...
@@ -13,3 +13,6 @@ for a in (1, "", "/proc", "nonexisting_dir"):
...
@@ -13,3 +13,6 @@ for a in (1, "", "/proc", "nonexisting_dir"):
except
Exception
as
e
:
except
Exception
as
e
:
print
e
print
e
imp
.
acquire_lock
()
imp
.
release_lock
()
test/tests/property.py
View file @
992eee47
...
@@ -63,3 +63,22 @@ try:
...
@@ -63,3 +63,22 @@ try:
except
AttributeError
,
e
:
except
AttributeError
,
e
:
print
e
print
e
c
.
x
=
1
c
.
x
=
1
class
MyProperty
(
property
):
pass
class
C
(
object
):
v
=
"empty"
@
MyProperty
def
p
(
self
):
print
"get"
return
self
.
v
@
p
.
setter
def
p
(
self
,
value
):
print
"set"
self
.
v
=
"it "
+
value
c
=
C
()
c
.
p
=
"worked"
print
c
.
p
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