Commit 819424ee authored by Kevin Modzelewski's avatar Kevin Modzelewski

minor fixes

parent 410567bc
......@@ -26,7 +26,7 @@ PyAPI_FUNC(void) PySys_AddWarnOption(char *) PYSTON_NOEXCEPT;
PyAPI_FUNC(int) PySys_HasWarnOptions(void) PYSTON_NOEXCEPT;
// Pyston change: add this API to get sys modules dict
PyAPI_FUNC(PyObject *) PySys_GetModulesDict(void) PYSTON_NOEXCEPT;
PyAPI_FUNC(BORROWED(PyObject *)) PySys_GetModulesDict(void) PYSTON_NOEXCEPT;
#ifdef __cplusplus
}
......
......@@ -1020,7 +1020,7 @@ extern "C" void abort() {
// In case displaying the traceback recursively calls abort:
static bool recursive = false;
if (!recursive) {
if (!recursive && (uint64_t)PyTraceBack_Type.ob_refcnt > 0) {
recursive = true;
Stats::dump();
fprintf(stderr, "Someone called abort!\n");
......
......@@ -74,7 +74,7 @@ static Box* sysExit(Box* arg) {
raiseExc(exc);
}
BoxedDict* getSysModulesDict() {
BORROWED(BoxedDict*) getSysModulesDict() {
// PyPy's behavior: fetch from sys.modules each time:
// Box *_sys_modules = sys_module->getattr("modules");
// assert(_sys_modules);
......@@ -82,7 +82,7 @@ BoxedDict* getSysModulesDict() {
// return static_cast<BoxedDict*>(_sys_modules);
// CPython's behavior: return an internalized reference:
return incref(sys_modules_dict);
return sys_modules_dict;
}
BoxedList* getSysPath() {
......@@ -402,7 +402,7 @@ extern "C" const char* Py_GetPlatform() noexcept {
#endif
}
extern "C" PyObject* PySys_GetModulesDict() noexcept {
extern "C" BORROWED(PyObject*) PySys_GetModulesDict() noexcept {
return getSysModulesDict();
}
......@@ -760,6 +760,9 @@ void setupSysEnd() {
sys_module->giveAttr("builtin_module_names",
BoxedTuple::create(builtin_module_names.size(), &builtin_module_names[0]));
for (Box* b : builtin_module_names)
Py_DECREF(b);
#ifndef NDEBUG
for (const auto& p : *sys_modules_dict) {
assert(PyString_Check(p.first));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment