aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/py
diff options
context:
space:
mode:
Diffstat (limited to 'externals/grill/py')
-rw-r--r--externals/grill/py/pd/builtins-1.pd14
-rw-r--r--externals/grill/py/pd/methods-1.pd22
-rw-r--r--externals/grill/py/pd/methods-2.pd24
-rw-r--r--externals/grill/py/source/pybase.cpp16
4 files changed, 38 insertions, 38 deletions
diff --git a/externals/grill/py/pd/builtins-1.pd b/externals/grill/py/pd/builtins-1.pd
index b5eb4eef..23088d9f 100644
--- a/externals/grill/py/pd/builtins-1.pd
+++ b/externals/grill/py/pd/builtins-1.pd
@@ -1,10 +1,9 @@
-#N canvas 602 394 710 425 12;
+#N canvas 602 394 714 429 12;
#X obj 36 241 py .range @py 1;
#X floatatom 35 356 5 0 0 0 - - -;
#X obj 35 323 py .sum;
#X obj 16 13 cnv 15 650 40 empty empty py/pyext 10 22 0 24 -260818
-1 0;
-#X text 235 16 Python script objects \, (C)2003-2005 Thomas Grill;
#X text 235 32 http://grrrr.org/ext;
#X obj 36 159 nbx 5 14 -1e+037 1e+037 0 1 empty empty min 0 -6 0 10
-262131 -1 -1 51 256;
@@ -39,15 +38,16 @@
#X connect 10 0 6 0;
#X connect 11 0 5 0;
#X restore 36 190 pd pak3;
-#X text 115 240 construct a Python list;
+#X text 169 239 construct a Python list;
#X text 78 282 Python object pointer is propagated to next object;
#X text 106 320 calculate sum over list elements;
#X text 21 73 Py can use built-in Python functions;
#X text 21 97 A . preceding the function name searches for the function
in either the pyext module or in __builtins__;
+#X text 235 16 Python script objects \, (C)2003-2006 Thomas Grill;
#X connect 0 0 2 1;
#X connect 2 0 1 0;
-#X connect 6 0 9 0;
-#X connect 7 0 9 1;
-#X connect 8 0 9 2;
-#X connect 9 0 0 1;
+#X connect 5 0 8 0;
+#X connect 6 0 8 1;
+#X connect 7 0 8 2;
+#X connect 8 0 0 1;
diff --git a/externals/grill/py/pd/methods-1.pd b/externals/grill/py/pd/methods-1.pd
index ab6b9842..5b85c43a 100644
--- a/externals/grill/py/pd/methods-1.pd
+++ b/externals/grill/py/pd/methods-1.pd
@@ -1,24 +1,24 @@
-#N canvas 540 469 722 357 12;
+#N canvas 540 469 734 369 12;
#X obj 16 13 cnv 15 650 40 empty empty py/pyext 10 22 0 24 -260818
-1 0;
-#X text 235 16 Python script objects \, (C)2003-2005 Thomas Grill;
#X text 235 32 http://grrrr.org/ext;
#X symbolatom 21 139 10 0 0 0 - - -;
#X symbolatom 25 298 10 0 0 0 - - -;
#X obj 22 179 py .str @py 1;
-#X text 93 167 convert the symbol to a Python string;
+#X text 145 170 convert the symbol to a Python string;
#X text 35 216 pass it as a true Python object;
#X symbolatom 364 295 10 0 0 0 - - -;
#X text 462 269 use module function;
#X text 23 119 enter some text;
-#X text 21 73 Py can act on Python objects in a object-oriented manner
-;
-#X text 93 184 using the built-in str function;
+#X text 145 187 using the built-in str function;
#X obj 25 252 pym swapcase;
#X text 63 270 use swapcase method;
#X obj 363 250 py string.swapcase;
-#X connect 3 0 5 1;
-#X connect 5 0 13 1;
-#X connect 5 0 15 1;
-#X connect 13 0 4 0;
-#X connect 15 0 8 0;
+#X text 235 16 Python script objects \, (C)2003-2006 Thomas Grill;
+#X text 21 73 Py can act on Python objects in an object-oriented manner
+;
+#X connect 2 0 4 1;
+#X connect 4 0 11 1;
+#X connect 4 0 13 1;
+#X connect 11 0 3 0;
+#X connect 13 0 7 0;
diff --git a/externals/grill/py/pd/methods-2.pd b/externals/grill/py/pd/methods-2.pd
index 0d0dd685..df967716 100644
--- a/externals/grill/py/pd/methods-2.pd
+++ b/externals/grill/py/pd/methods-2.pd
@@ -1,20 +1,17 @@
-#N canvas 540 469 738 343 12;
+#N canvas 540 469 746 351 12;
#X obj 16 13 cnv 15 650 40 empty empty py/pyext 10 22 0 24 -260818
-1 0;
-#X text 235 16 Python script objects \, (C)2003-2005 Thomas Grill;
#X text 235 32 http://grrrr.org/ext;
#X symbolatom 21 139 10 0 0 0 - #0-t -;
#X text 23 119 enter some text;
-#X text 21 73 Py can act on Python objects in a object-oriented manner
-;
#X obj 25 252 pym 2 *;
#X obj 213 183 t b f;
#X text 105 251 repeat text;
#X text 215 117 multiply it!;
#X symbolatom 25 283 80 0 0 0 - - -;
#X obj 214 139 nbx 5 14 1 100 0 1 empty empty empty 0 -6 0 10 -262131
--1 -1 16 256;
-#N canvas 0 0 458 308 init 0;
+-1 -1 6 256;
+#N canvas 0 0 462 312 init 0;
#X obj 61 116 s \$0-t;
#X obj 64 44 loadbang;
#X obj 64 81 symbol a;
@@ -22,9 +19,12 @@
#X connect 2 0 0 0;
#X restore 606 127 pd init;
#X obj 213 159 int;
-#X connect 3 0 6 1;
-#X connect 6 0 10 0;
-#X connect 7 0 6 0;
-#X connect 7 1 6 2;
-#X connect 11 0 13 0;
-#X connect 13 0 7 0;
+#X text 235 16 Python script objects \, (C)2003-2006 Thomas Grill;
+#X text 21 73 Py can act on Python objects in an object-oriented manner
+;
+#X connect 2 0 4 1;
+#X connect 4 0 8 0;
+#X connect 5 0 4 0;
+#X connect 5 1 4 2;
+#X connect 9 0 11 0;
+#X connect 11 0 5 0;
diff --git a/externals/grill/py/source/pybase.cpp b/externals/grill/py/source/pybase.cpp
index f4762fbf..c0f2bc44 100644
--- a/externals/grill/py/source/pybase.cpp
+++ b/externals/grill/py/source/pybase.cpp
@@ -454,6 +454,7 @@ static bool getmodulesub(const char *mod,char *dir,int len,char *ext)
// if dir is current working directory... name points to dir
if(dir == name) strcpy(dir,".");
+ return name != NULL;
#elif FLEXT_SYS == FLEXT_SYS_MAX
short path;
long type;
@@ -570,16 +571,15 @@ bool pybase::ReloadModule()
if(module)
newmod = PyImport_ReloadModule(module);
else {
- // search in module path
+ // search in module path (TODO: check before if module is already present to avoid costly searching)
char dir[1024];
- if(getmodulepath(modname.c_str(),dir,sizeof(dir))) {
- AddToPath(dir);
- newmod = PyImport_ImportModule((char *)modname.c_str());
- }
- else {
+ if(!getmodulepath(modname.c_str(),dir,sizeof(dir)))
PyErr_SetString(PyExc_ImportError,"Module not found in path");
- newmod = NULL;
- }
+ else
+ AddToPath(dir);
+
+ // module could also be loaded ok, even if it's not in the path (e.g. for internal stuff)
+ newmod = PyImport_ImportModule((char *)modname.c_str());
}
}
else {