Commits

Vertexwahn committed 800bf08

EmbeddedPython: Minior refactoring.

Comments (0)

Files changed (1)

EmbeddedPython/main.cpp

 	arguments[0] = "3";
 	arguments[1] = "2";
 
-	PyObject *pModule, *pDict, *pFunc;
-	PyObject *pArgs, *pValue;
-	int i;
-
 	Py_Initialize();
 	PyObject *pName = PyUnicode_FromString(moduleName);
 	// Error checking of pName left out
 
-	pModule = PyImport_Import(pName);
+	PyObject *pModule = PyImport_Import(pName);
 	Py_DECREF(pName);
 
 	if (pModule != nullptr) 
 	{
-		pFunc = PyObject_GetAttrString(pModule, functionName);
+		PyObject  *pFunc = PyObject_GetAttrString(pModule, functionName);
 		// pFunc is a new reference
 
 		if (pFunc && PyCallable_Check(pFunc)) 
 		{
-			pArgs = PyTuple_New(2);
+			PyObject *pArgs = PyTuple_New(2);
 
-			for (i = 0; i < 2; ++i) 
+			PyObject *pValue = nullptr;
+
+			for (int i = 0; i < 2; ++i) 
 			{
 				pValue = PyLong_FromLong(atoi(arguments[i]));
 				if (!pValue)