kuuko pushed a commit to branch python-efl-1.14.

http://git.enlightenment.org/bindings/python/python-efl.git/commit/?id=73938af391e61985c8fa687cb571bf8cd759f4d5

commit 73938af391e61985c8fa687cb571bf8cd759f4d5
Author: Kai Huuhko <kai.huu...@gmail.com>
Date:   Sat May 9 20:16:45 2015 +0300

    Elm: Fix module init from embedded interpreter
    
    sys.argv doesn't exist there
---
 efl/elementary/general.pyx | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/efl/elementary/general.pyx b/efl/elementary/general.pyx
index f449785..3584b7c 100644
--- a/efl/elementary/general.pyx
+++ b/efl/elementary/general.pyx
@@ -366,20 +366,20 @@ def init():
     # FIXME: Why are we passing the cl args to elm_init here?
 
     cdef:
-        int argc, i, arg_len
-        char **argv
+        int argc = 0, i, arg_len
+        char **argv = NULL
         char *arg
-        int ret
-
-    argc = len(sys.argv)
-    argv = <char **>PyMem_Malloc(argc * sizeof(char *))
-    for i in range(argc):
-        t = sys.argv[i]
-        if isinstance(t, unicode): t = PyUnicode_AsUTF8String(t)
-        arg = t
-        arg_len = len(arg)
-        argv[i] = <char *>PyMem_Malloc(arg_len + 1)
-        memcpy(argv[i], arg, arg_len + 1)
+
+    if hasattr(sys, "argv"):
+        argc = len(sys.argv)
+        argv = <char **>PyMem_Malloc(argc * sizeof(char *))
+        for i in range(argc):
+            t = sys.argv[i]
+            if isinstance(t, unicode): t = PyUnicode_AsUTF8String(t)
+            arg = t
+            arg_len = len(arg)
+            argv[i] = <char *>PyMem_Malloc(arg_len + 1)
+            memcpy(argv[i], arg, arg_len + 1)
 
     return elm_init(argc, argv)
 

-- 


Reply via email to