mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 21:51:50 +00:00 
			
		
		
		
	* 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
			
			
This commit is contained in:
		
							parent
							
								
									b2e358d433
								
							
						
					
					
						commit
						a3d78fb268
					
				
					 7 changed files with 51 additions and 9 deletions
				
			
		|  | @ -993,6 +993,18 @@ array_getattr(a, name) | ||||||
| 	if (strcmp(name, "itemsize") == 0) { | 	if (strcmp(name, "itemsize") == 0) { | ||||||
| 		return newintobject((long)a->ob_descr->itemsize); | 		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); | 	return findmethod(array_methods, (object *)a, name); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -1013,7 +1025,7 @@ array_print(a, fp, flags) | ||||||
| 	if (a->ob_descr->typecode == 'c') { | 	if (a->ob_descr->typecode == 'c') { | ||||||
| 		fprintf(fp, "array('c', "); | 		fprintf(fp, "array('c', "); | ||||||
| 		v = array_tostring(a, (object *)NULL); | 		v = array_tostring(a, (object *)NULL); | ||||||
| 		ok = printobject(v, fp, flags); | 		ok = printobject(v, fp, 0); | ||||||
| 		XDECREF(v); | 		XDECREF(v); | ||||||
| 		fprintf(fp, ")"); | 		fprintf(fp, ")"); | ||||||
| 		return ok; | 		return ok; | ||||||
|  | @ -1023,7 +1035,7 @@ array_print(a, fp, flags) | ||||||
| 		if (i > 0) | 		if (i > 0) | ||||||
| 			fprintf(fp, ", "); | 			fprintf(fp, ", "); | ||||||
| 		v = (a->ob_descr->getitem)(a, i); | 		v = (a->ob_descr->getitem)(a, i); | ||||||
| 		ok = printobject(v, fp, flags); | 		ok = printobject(v, fp, 0); | ||||||
| 		XDECREF(v); | 		XDECREF(v); | ||||||
| 	} | 	} | ||||||
| 	fprintf(fp, "])"); | 	fprintf(fp, "])"); | ||||||
|  |  | ||||||
|  | @ -865,6 +865,34 @@ posix_popen(self, args) | ||||||
| 	return newopenfileobject(fp, name, mode, pclose); | 	return newopenfileobject(fp, name, mode, pclose); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | 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 * | static object * | ||||||
| posix_waitpid(self, args) | posix_waitpid(self, args) | ||||||
| 	object *self; | 	object *self; | ||||||
|  | @ -1288,6 +1316,8 @@ static struct methodlist posix_methods[] = { | ||||||
| 	{"getuid",	posix_getuid}, | 	{"getuid",	posix_getuid}, | ||||||
| 	{"kill",	posix_kill}, | 	{"kill",	posix_kill}, | ||||||
| 	{"popen",	posix_popen}, | 	{"popen",	posix_popen}, | ||||||
|  | 	{"setuid",	posix_setuid}, | ||||||
|  | 	{"setgid",	posix_setgid}, | ||||||
| 	{"setpgrp",	posix_setpgrp}, | 	{"setpgrp",	posix_setpgrp}, | ||||||
| 	{"wait",	posix_wait}, | 	{"wait",	posix_wait}, | ||||||
| 	{"waitpid",	posix_waitpid}, | 	{"waitpid",	posix_waitpid}, | ||||||
|  |  | ||||||
|  | @ -395,10 +395,10 @@ mapping_print(mp, fp, flags) | ||||||
| 		if (ep->me_value != NULL) { | 		if (ep->me_value != NULL) { | ||||||
| 			if (any++ > 0) | 			if (any++ > 0) | ||||||
| 				fprintf(fp, ", "); | 				fprintf(fp, ", "); | ||||||
| 			if (printobject((object *)ep->me_key, fp, flags) != 0) | 			if (printobject((object *)ep->me_key, fp, 0) != 0) | ||||||
| 				return -1; | 				return -1; | ||||||
| 			fprintf(fp, ": "); | 			fprintf(fp, ": "); | ||||||
| 			if (printobject(ep->me_value, fp, flags) != 0) | 			if (printobject(ep->me_value, fp, 0) != 0) | ||||||
| 				return -1; | 				return -1; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | @ -200,7 +200,7 @@ list_print(op, fp, flags) | ||||||
| 	for (i = 0; i < op->ob_size; i++) { | 	for (i = 0; i < op->ob_size; i++) { | ||||||
| 		if (i > 0) | 		if (i > 0) | ||||||
| 			fprintf(fp, ", "); | 			fprintf(fp, ", "); | ||||||
| 		if (printobject(op->ob_item[i], fp, flags) != 0) | 		if (printobject(op->ob_item[i], fp, 0) != 0) | ||||||
| 			return -1; | 			return -1; | ||||||
| 	} | 	} | ||||||
| 	fprintf(fp, "]"); | 	fprintf(fp, "]"); | ||||||
|  |  | ||||||
|  | @ -395,10 +395,10 @@ mapping_print(mp, fp, flags) | ||||||
| 		if (ep->me_value != NULL) { | 		if (ep->me_value != NULL) { | ||||||
| 			if (any++ > 0) | 			if (any++ > 0) | ||||||
| 				fprintf(fp, ", "); | 				fprintf(fp, ", "); | ||||||
| 			if (printobject((object *)ep->me_key, fp, flags) != 0) | 			if (printobject((object *)ep->me_key, fp, 0) != 0) | ||||||
| 				return -1; | 				return -1; | ||||||
| 			fprintf(fp, ": "); | 			fprintf(fp, ": "); | ||||||
| 			if (printobject(ep->me_value, fp, flags) != 0) | 			if (printobject(ep->me_value, fp, 0) != 0) | ||||||
| 				return -1; | 				return -1; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | @ -167,7 +167,7 @@ tupleprint(op, fp, flags) | ||||||
| 	for (i = 0; i < op->ob_size; i++) { | 	for (i = 0; i < op->ob_size; i++) { | ||||||
| 		if (i > 0) | 		if (i > 0) | ||||||
| 			fprintf(fp, ", "); | 			fprintf(fp, ", "); | ||||||
| 		if (printobject(op->ob_item[i], fp, flags) != 0) | 		if (printobject(op->ob_item[i], fp, 0) != 0) | ||||||
| 			return -1; | 			return -1; | ||||||
| 	} | 	} | ||||||
| 	if (op->ob_size == 1) | 	if (op->ob_size == 1) | ||||||
|  |  | ||||||
|  | @ -529,7 +529,7 @@ parsestr(s) | ||||||
| 		return newsizedstringobject(s, len); | 		return newsizedstringobject(s, len); | ||||||
| 	v = newsizedstringobject((char *)NULL, len); | 	v = newsizedstringobject((char *)NULL, len); | ||||||
| 	p = buf = getstringvalue(v); | 	p = buf = getstringvalue(v); | ||||||
| 	while (*s != '\0' && *s != '\'') { | 	while (*s != '\0' && *s != quote) { | ||||||
| 		if (*s != '\\') { | 		if (*s != '\\') { | ||||||
| 			*p++ = *s++; | 			*p++ = *s++; | ||||||
| 			continue; | 			continue; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Guido van Rossum
						Guido van Rossum