[prev in list] [next in list] [prev in thread] [next in thread] 

List:       uwsgi
Subject:    [uWSGI] [PATCH tip] if pyalias is a package: create empty module, add __path__, finally import code 
From:       anthony () xtfx ! me (C Anthony Risinger)
Date:       2012-03-30 4:15:26
Message-ID: 18f90331701c28cc248c.1333080926 () sta-notebook-m4300 ! xtfx ! net
[Download RAW message or body]

# HG changeset patch
# User C Anthony Risinger <anthony at xtfx.me>
# Date 1333080076 18000
# Node ID 18f90331701c28cc248c41898f7722d6ac1d9c3a
# Parent  f7d8b46166d7d6a896cf352b2ed089bfe3233b62
if pyalias is a package: create empty module, add __path__, finally import code \
object (net effect is reload(), ie. merge)

diff --git a/plugins/python/python_plugin.c b/plugins/python/python_plugin.c
--- a/plugins/python/python_plugin.c
+++ b/plugins/python/python_plugin.c
@@ -400,6 +400,14 @@
 		return NULL;
 	}
 
+	if (is_a_package) {
+		py_file_module = PyImport_AddModule(name);
+		if (py_file_module) {
+			PyModule_AddObject(py_file_module, "__path__", Py_BuildValue("[O]", \
PyString_FromString(filename))); +		}
+		free(real_filename);
+	}
+
 	py_file_module = PyImport_ExecCodeModule(name, py_compiled_node);
 	if (!py_file_module) {
 		PyErr_Print();
@@ -408,14 +416,6 @@
 
 	Py_DECREF(py_compiled_node);
 
-	if (is_a_package) {
-		PyObject *py_file_module_dict = PyModule_GetDict(py_file_module);
-		if (py_file_module_dict) {
-			PyDict_SetItemString(py_file_module_dict, "__path__", Py_BuildValue("[O]", \
                PyString_FromString(filename)));
-		}
-		free(real_filename);
-	}
-
 	return py_file_module;
 #endif
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic