diff options
author | Guido van Rossum <guido@python.org> | 1993-11-10 09:23:53 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1993-11-10 09:23:53 (GMT) |
commit | a3d78fb268da5cf7cd4d990cf118bfc01650a8d9 (patch) | |
tree | 8b72efe5cef9a755ab55dd919f7e0591235b0345 | |
parent | b2e358d433e0ddbfc870d1a6ce12e7917388c2fe (diff) | |
download | cpython-a3d78fb268da5cf7cd4d990cf118bfc01650a8d9.zip cpython-a3d78fb268da5cf7cd4d990cf118bfc01650a8d9.tar.gz cpython-a3d78fb268da5cf7cd4d990cf118bfc01650a8d9.tar.bz2 |
* posixmodule.c: added set{uid,gid}.
* {tuple,list,mapping,array}object.c: call printobject with 0 for flags
* compile.c (parsestr): use quote instead of '\'' at one crucial point
* arraymodule.c (array_getattr): Added __members__ attribute
-rw-r--r-- | Modules/arraymodule.c | 16 | ||||
-rw-r--r-- | Modules/posixmodule.c | 30 | ||||
-rw-r--r-- | Objects/dictobject.c | 4 | ||||
-rw-r--r-- | Objects/listobject.c | 2 | ||||
-rw-r--r-- | Objects/mappingobject.c | 4 | ||||
-rw-r--r-- | Objects/tupleobject.c | 2 | ||||
-rw-r--r-- | Python/compile.c | 2 |
7 files changed, 51 insertions, 9 deletions
diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c index 248e431..5b62fee 100644 --- a/Modules/arraymodule.c +++ b/Modules/arraymodule.c @@ -993,6 +993,18 @@ array_getattr(a, name) if (strcmp(name, "itemsize") == 0) { return newintobject((long)a->ob_descr->itemsize); } + if (strcmp(name, "__members__") == 0) { + object *list = newlistobject(2); + if (list) { + setlistitem(list, 0, newstringobject("typecode")); + setlistitem(list, 1, newstringobject("itemsize")); + if (err_occurred()) { + DECREF(list); + list = NULL; + } + } + return list; + } return findmethod(array_methods, (object *)a, name); } @@ -1013,7 +1025,7 @@ array_print(a, fp, flags) if (a->ob_descr->typecode == 'c') { fprintf(fp, "array('c', "); v = array_tostring(a, (object *)NULL); - ok = printobject(v, fp, flags); + ok = printobject(v, fp, 0); XDECREF(v); fprintf(fp, ")"); return ok; @@ -1023,7 +1035,7 @@ array_print(a, fp, flags) if (i > 0) fprintf(fp, ", "); v = (a->ob_descr->getitem)(a, i); - ok = printobject(v, fp, flags); + ok = printobject(v, fp, 0); XDECREF(v); } fprintf(fp, "])"); diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index d84360b..00b8369 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -866,6 +866,34 @@ posix_popen(self, args) } static object * +posix_setuid(self, args) + object *self; + object *args; +{ + int uid; + if (!getargs(args, "i", &uid)) + return NULL; + if (setuid(uid) < 0) + return posix_error(); + INCREF(None); + return None; +} + +static object * +posix_setgid(self, args) + object *self; + object *args; +{ + int gid; + if (!getargs(args, "i", &gid)) + return NULL; + if (setgid(gid) < 0) + return posix_error(); + INCREF(None); + return None; +} + +static object * posix_waitpid(self, args) object *self; object *args; @@ -1288,6 +1316,8 @@ static struct methodlist posix_methods[] = { {"getuid", posix_getuid}, {"kill", posix_kill}, {"popen", posix_popen}, + {"setuid", posix_setuid}, + {"setgid", posix_setgid}, {"setpgrp", posix_setpgrp}, {"wait", posix_wait}, {"waitpid", posix_waitpid}, diff --git a/Objects/dictobject.c b/Objects/dictobject.c index b89b7b2..c1c1c19 100644 --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -395,10 +395,10 @@ mapping_print(mp, fp, flags) if (ep->me_value != NULL) { if (any++ > 0) fprintf(fp, ", "); - if (printobject((object *)ep->me_key, fp, flags) != 0) + if (printobject((object *)ep->me_key, fp, 0) != 0) return -1; fprintf(fp, ": "); - if (printobject(ep->me_value, fp, flags) != 0) + if (printobject(ep->me_value, fp, 0) != 0) return -1; } } diff --git a/Objects/listobject.c b/Objects/listobject.c index 22eab71..76d2a0e 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -200,7 +200,7 @@ list_print(op, fp, flags) for (i = 0; i < op->ob_size; i++) { if (i > 0) fprintf(fp, ", "); - if (printobject(op->ob_item[i], fp, flags) != 0) + if (printobject(op->ob_item[i], fp, 0) != 0) return -1; } fprintf(fp, "]"); diff --git a/Objects/mappingobject.c b/Objects/mappingobject.c index b89b7b2..c1c1c19 100644 --- a/Objects/mappingobject.c +++ b/Objects/mappingobject.c @@ -395,10 +395,10 @@ mapping_print(mp, fp, flags) if (ep->me_value != NULL) { if (any++ > 0) fprintf(fp, ", "); - if (printobject((object *)ep->me_key, fp, flags) != 0) + if (printobject((object *)ep->me_key, fp, 0) != 0) return -1; fprintf(fp, ": "); - if (printobject(ep->me_value, fp, flags) != 0) + if (printobject(ep->me_value, fp, 0) != 0) return -1; } } diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c index 68fed9e..6f122ea 100644 --- a/Objects/tupleobject.c +++ b/Objects/tupleobject.c @@ -167,7 +167,7 @@ tupleprint(op, fp, flags) for (i = 0; i < op->ob_size; i++) { if (i > 0) fprintf(fp, ", "); - if (printobject(op->ob_item[i], fp, flags) != 0) + if (printobject(op->ob_item[i], fp, 0) != 0) return -1; } if (op->ob_size == 1) diff --git a/Python/compile.c b/Python/compile.c index 565c65c..9ce3a33 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -529,7 +529,7 @@ parsestr(s) return newsizedstringobject(s, len); v = newsizedstringobject((char *)NULL, len); p = buf = getstringvalue(v); - while (*s != '\0' && *s != '\'') { + while (*s != '\0' && *s != quote) { if (*s != '\\') { *p++ = *s++; continue; |