summaryrefslogtreecommitdiffstats
path: root/Modules/stdwinmodule.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1993-11-17 22:58:56 (GMT)
committerGuido van Rossum <guido@python.org>1993-11-17 22:58:56 (GMT)
commitc45611d0e33ddd96fb9fffa8dc42a96384d5d270 (patch)
tree343959ada4542b5d4abc0a50802f434072da8e8b /Modules/stdwinmodule.c
parent71e57d090d070686746ee63b855e38cb337dc5cc (diff)
downloadcpython-c45611d0e33ddd96fb9fffa8dc42a96384d5d270.zip
cpython-c45611d0e33ddd96fb9fffa8dc42a96384d5d270.tar.gz
cpython-c45611d0e33ddd96fb9fffa8dc42a96384d5d270.tar.bz2
* import.c (get_module): total rewrite, to ensure proper search order: for
each dir in sys.path, try each possible extension. (Note: C extensions are loaded before Python modules in the same directory, to allow having a C version used when dynamic loading is supported and a Python version as a back-up.) * import.c (reload_module): test for error from getmodulename() * moduleobject.c: implement module name as dict entry '__name__' instead of special-casing it in module_getattr(); this way a module (or function!) can access its own module name, and programs that know what they are doing can rename modules. * stdwinmodule.c (initstdwin): strip ".py" suffix of argv[0].
Diffstat (limited to 'Modules/stdwinmodule.c')
-rw-r--r--Modules/stdwinmodule.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/Modules/stdwinmodule.c b/Modules/stdwinmodule.c
index 1fff814..fc81cff 100644
--- a/Modules/stdwinmodule.c
+++ b/Modules/stdwinmodule.c
@@ -2598,6 +2598,7 @@ initstdwin()
{
object *m, *d;
static int inited = 0;
+ char buf[1000];
if (!inited) {
int argc = 0;
@@ -2607,6 +2608,18 @@ initstdwin()
if (!checkstringlist(sys_argv, &argv, &argc))
err_clear();
}
+ if (argc > 0) {
+ /* If argv[0] has a ".py" suffix, remove the suffix */
+ char *p = strrchr(argv[0], '.');
+ if (p != NULL && strcmp(p, ".py") == 0) {
+ int n = p - argv[0];
+ if (n >= sizeof(buf))
+ n = sizeof(buf)-1;
+ strncpy(buf, argv[0], n);
+ buf[n] = '\0';
+ argv[0] = buf;
+ }
+ }
winitargs(&argc, &argv);
if (argv != NULL) {
if (!putbackstringlist(sys_argv, argv, argc))