From 5f6861df9300f455d600b6cd237faf429d9a06b0 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Sun, 28 May 2006 21:57:35 +0000 Subject: [PATCH] Correct None refcount issue in Mac modules. (Are they still used?) --- Mac/Modules/dlg/_Dlgmodule.c | 2 +- Mac/Modules/dlg/dlgsupport.py | 2 +- Mac/Modules/file/_Filemodule.c | 2 +- Mac/Modules/file/filesupport.py | 2 +- Python/import.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Mac/Modules/dlg/_Dlgmodule.c b/Mac/Modules/dlg/_Dlgmodule.c index 64ddac8d339..46009a8c67a 100644 --- a/Mac/Modules/dlg/_Dlgmodule.c +++ b/Mac/Modules/dlg/_Dlgmodule.c @@ -139,7 +139,7 @@ typedef struct DialogObject { PyObject *DlgObj_New(DialogPtr itself) { DialogObject *it; - if (itself == NULL) return Py_None; + if (itself == NULL) { Py_INCREF(Py_None); return Py_None; } it = PyObject_NEW(DialogObject, &Dialog_Type); if (it == NULL) return NULL; it->ob_itself = itself; diff --git a/Mac/Modules/dlg/dlgsupport.py b/Mac/Modules/dlg/dlgsupport.py index 1c0cc6a9f94..fa1442ec37b 100644 --- a/Mac/Modules/dlg/dlgsupport.py +++ b/Mac/Modules/dlg/dlgsupport.py @@ -202,7 +202,7 @@ class MyObjectDefinition(PEP253Mixin, GlobalObjectDefinition): Output("SetWRefCon(GetDialogWindow(itself), (long)it);") def outputCheckNewArg(self): - Output("if (itself == NULL) return Py_None;") + Output("if (itself == NULL) { Py_INCREF(Py_None); return Py_None; }") def outputCheckConvertArg(self): Output("if (v == Py_None) { *p_itself = NULL; return 1; }") diff --git a/Mac/Modules/file/_Filemodule.c b/Mac/Modules/file/_Filemodule.c index c211de136fa..07bd3412976 100644 --- a/Mac/Modules/file/_Filemodule.c +++ b/Mac/Modules/file/_Filemodule.c @@ -153,7 +153,7 @@ typedef struct FSCatalogInfoObject { static PyObject *FSCatalogInfo_New(FSCatalogInfo *itself) { FSCatalogInfoObject *it; - if (itself == NULL) return Py_None; + if (itself == NULL) { Py_INCREF(Py_None); return Py_None; } it = PyObject_NEW(FSCatalogInfoObject, &FSCatalogInfo_Type); if (it == NULL) return NULL; it->ob_itself = *itself; diff --git a/Mac/Modules/file/filesupport.py b/Mac/Modules/file/filesupport.py index f2d419328b2..37aeb508a09 100644 --- a/Mac/Modules/file/filesupport.py +++ b/Mac/Modules/file/filesupport.py @@ -475,7 +475,7 @@ class FSCatalogInfoDefinition(PEP253Mixin, ObjectDefinition): self.argref = "*" # Store FSSpecs, but pass them by address def outputCheckNewArg(self): - Output("if (itself == NULL) return Py_None;") + Output("if (itself == NULL) { Py_INCREF(Py_None); return Py_None; }") def output_tp_newBody(self): Output("PyObject *self;"); diff --git a/Python/import.c b/Python/import.c index 1a71b5cf6b3..c49a91fc6a6 100644 --- a/Python/import.c +++ b/Python/import.c @@ -2059,7 +2059,7 @@ PyImport_ImportModuleLevel(char *name, PyObject *globals, PyObject *locals, /* Return the package that an import is being performed in. If globals comes from the module foo.bar.bat (not itself a package), this returns the sys.modules entry for foo.bar. If globals is from a package's __init__.py, - the package's entry in sys.modules is returned. + the package's entry in sys.modules is returned, as a borrowed reference. The *name* of the returned package is returned in buf, with the length of the name in *p_buflen.