aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKai Huuhko <kai.huuhko@gmail.com>2015-05-09 20:16:45 +0300
committerKai Huuhko <kai.huuhko@gmail.com>2015-05-09 20:19:35 +0300
commit73938af391e61985c8fa687cb571bf8cd759f4d5 (patch)
treef403029c8a3d33c58afce2eefacb2c6b27cb320c
parentBump version for 1.14.0 release (diff)
downloadpython-efl-1.14.tar.gz
Elm: Fix module init from embedded interpreterpython-efl-1.14
sys.argv doesn't exist there
-rw-r--r--efl/elementary/general.pyx26
1 files 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)