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
4376696b
Commit
4376696b
authored
Nov 18, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor refcounting fixes
parent
d7490eda
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
24 additions
and
12 deletions
+24
-12
from_cpython/Include/sysmodule.h
from_cpython/Include/sysmodule.h
+1
-1
src/codegen/unwinding.cpp
src/codegen/unwinding.cpp
+1
-0
src/runtime/builtin_modules/sys.cpp
src/runtime/builtin_modules/sys.cpp
+9
-6
src/runtime/exceptions.cpp
src/runtime/exceptions.cpp
+1
-0
src/runtime/import.cpp
src/runtime/import.cpp
+10
-3
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+1
-1
src/runtime/types.h
src/runtime/types.h
+1
-1
No files found.
from_cpython/Include/sysmodule.h
View file @
4376696b
...
...
@@ -9,7 +9,7 @@ extern "C" {
#endif
// Pyston change: changed most of these to const char*
PyAPI_FUNC
(
PyObject
*
)
PySys_GetObject
(
const
char
*
)
PYSTON_NOEXCEPT
;
PyAPI_FUNC
(
BORROWED
(
PyObject
*
)
)
PySys_GetObject
(
const
char
*
)
PYSTON_NOEXCEPT
;
PyAPI_FUNC
(
int
)
PySys_SetObject
(
const
char
*
,
PyObject
*
)
PYSTON_NOEXCEPT
;
PyAPI_FUNC
(
FILE
*
)
PySys_GetFile
(
char
*
,
FILE
*
)
PYSTON_NOEXCEPT
;
PyAPI_FUNC
(
void
)
PySys_SetArgv
(
int
,
char
**
)
PYSTON_NOEXCEPT
;
...
...
src/codegen/unwinding.cpp
View file @
4376696b
...
...
@@ -785,6 +785,7 @@ Box* getGlobals() {
auto
it
=
getTopPythonFrame
();
if
(
!
it
)
return
NULL
;
RELEASE_ASSERT
(
0
,
"check refcounting"
);
return
it
->
getGlobals
();
}
...
...
src/runtime/builtin_modules/sys.cpp
View file @
4376696b
...
...
@@ -87,7 +87,9 @@ BoxedDict* getSysModulesDict() {
BoxedList
*
getSysPath
()
{
// Unlike sys.modules, CPython handles sys.path by fetching it each time:
Box
*
_sys_path
=
sys_module
->
getattr
(
internStringMortal
(
"path"
));
auto
path_str
=
getStaticString
(
"path"
);
Box
*
_sys_path
=
sys_module
->
getattr
(
path_str
);
assert
(
_sys_path
);
if
(
_sys_path
->
cls
!=
list_cls
)
{
...
...
@@ -99,7 +101,8 @@ BoxedList* getSysPath() {
}
Box
*
getSysStdout
()
{
Box
*
sys_stdout
=
sys_module
->
getattr
(
internStringMortal
(
"stdout"
));
auto
stdout_str
=
getStaticString
(
"stdout"
);
Box
*
sys_stdout
=
sys_module
->
getattr
(
stdout_str
);
RELEASE_ASSERT
(
sys_stdout
,
"lost sys.stdout??"
);
return
sys_stdout
;
}
...
...
@@ -137,10 +140,10 @@ Box* sysGetRecursionLimit() {
extern
"C"
int
PySys_SetObject
(
const
char
*
name
,
PyObject
*
v
)
noexcept
{
try
{
if
(
!
v
)
{
if
(
sys_module
->
getattr
(
internStringMortal
(
name
)))
sys_module
->
delattr
(
internStringMortal
(
name
),
NULL
);
if
(
sys_module
->
getattr
(
autoDecref
(
internStringMortal
(
name
)
)))
sys_module
->
delattr
(
autoDecref
(
internStringMortal
(
name
)
),
NULL
);
}
else
sys_module
->
setattr
(
internStringMortal
(
name
),
v
,
NULL
);
sys_module
->
setattr
(
autoDecref
(
internStringMortal
(
name
)
),
v
,
NULL
);
}
catch
(
ExcInfo
e
)
{
abort
();
}
...
...
@@ -148,7 +151,7 @@ extern "C" int PySys_SetObject(const char* name, PyObject* v) noexcept {
}
extern
"C"
PyObject
*
PySys_GetObject
(
const
char
*
name
)
noexcept
{
return
sys_module
->
getattr
(
internStringMortal
(
name
));
return
sys_module
->
getattr
(
autoDecref
(
internStringMortal
(
name
)
));
}
extern
"C"
FILE
*
PySys_GetFile
(
char
*
name
,
FILE
*
def
)
noexcept
{
...
...
src/runtime/exceptions.cpp
View file @
4376696b
...
...
@@ -232,6 +232,7 @@ void raiseExcHelper(BoxedClass* cls, const char* msg, ...) {
BoxedString
*
message
=
boxString
(
buf
);
Box
*
exc_obj
=
runtimeCall
(
cls
,
ArgPassSpec
(
1
),
message
,
NULL
,
NULL
,
NULL
,
NULL
);
Py_DECREF
(
message
);
raiseExc
(
exc_obj
);
}
else
{
Box
*
exc_obj
=
runtimeCall
(
cls
,
ArgPassSpec
(
0
),
NULL
,
NULL
,
NULL
,
NULL
,
NULL
);
...
...
src/runtime/import.cpp
View file @
4376696b
...
...
@@ -428,7 +428,7 @@ static Box* importSub(const std::string& name, BoxedString* full_name, Box* pare
return
module
;
}
return
None
;
return
incref
(
None
)
;
}
static
void
markMiss
(
std
::
string
&
name
)
{
...
...
@@ -474,6 +474,7 @@ static bool loadNext(Box* mod, Box* altmod, std::string& name, std::string& buf,
result
=
importSub
(
subname
,
autoDecref
(
boxString
(
buf
)),
mod
);
if
(
result
==
None
&&
altmod
!=
mod
)
{
Py_DECREF
(
result
);
/* Here, altmod must be None and mod must not be None */
result
=
importSub
(
subname
,
autoDecref
(
boxString
(
subname
)),
altmod
);
if
(
result
!=
NULL
&&
result
!=
None
)
{
...
...
@@ -485,8 +486,10 @@ static bool loadNext(Box* mod, Box* altmod, std::string& name, std::string& buf,
if
(
result
==
NULL
)
throwCAPIException
();
if
(
result
==
None
)
if
(
result
==
None
)
{
Py_DECREF
(
result
);
raiseExcHelper
(
ImportError
,
"No module named %.200s"
,
local_name
.
c_str
());
}
*
rtn
=
result
;
return
call_again
;
...
...
@@ -517,12 +520,16 @@ Box* importModuleLevel(llvm::StringRef name, Box* globals, Box* from_imports, in
while
(
again
)
{
Box
*
next
;
again
=
loadNext
(
tail
,
tail
,
_name
,
buf
,
&
next
);
Py_DECREF
(
tail
);
if
(
next
==
NULL
)
{
Py_DECREF
(
head
);
return
NULL
;
}
tail
=
next
;
}
if
(
tail
==
None
)
{
Py_DECREF
(
tail
);
Py_DECREF
(
head
);
/* If tail is Py_None, both get_parent and load_next found
an empty module name: someone called __import__("") or
doctored faulty bytecode */
...
...
@@ -707,7 +714,7 @@ Box* nullImporterFindModule(Box* self, Box* fullname, Box* path) {
}
extern
"C"
Box
*
import
(
int
level
,
Box
*
from_imports
,
llvm
::
StringRef
module_name
)
{
return
importModuleLevel
(
module_name
,
getGlobals
(
),
from_imports
,
level
);
return
importModuleLevel
(
module_name
,
autoDecref
<
Box
,
true
>
(
getGlobals
()
),
from_imports
,
level
);
}
Box
*
impFindModule
(
Box
*
_name
,
BoxedList
*
path
)
{
...
...
src/runtime/objmodel.cpp
View file @
4376696b
...
...
@@ -3700,7 +3700,7 @@ void rearrangeArgumentsInternal(ParamReceiveSpec paramspec, const ParamNames* pa
(
paramspec
.
num_args
==
1
?
""
:
"s"
),
argspec
.
num_args
+
argspec
.
num_keywords
+
varargs_size
);
}
Py_DECREF
(
varargs
);
Py_
X
DECREF
(
varargs
);
////
// Second, apply any keywords:
...
...
src/runtime/types.h
View file @
4376696b
...
...
@@ -69,7 +69,7 @@ void setupAST();
void
setupSysEnd
();
BORROWED
(
BoxedDict
*
)
getSysModulesDict
();
B
oxedList
*
getSysPath
();
B
ORROWED
(
BoxedList
*
)
getSysPath
();
extern
"C"
Box
*
getSysStdout
();
extern
"C"
BoxedTuple
*
EmptyTuple
;
...
...
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