Commit 0e8e872e authored by Guido van Rossum's avatar Guido van Rossum

Raise KeyError instead of RuntimeError when a uid or name (etc) is not found.

parent 3ea7412d
...@@ -67,7 +67,7 @@ static object *pwd_getpwuid(self, args) ...@@ -67,7 +67,7 @@ static object *pwd_getpwuid(self, args)
if (!getintarg(args, &uid)) if (!getintarg(args, &uid))
return NULL; return NULL;
if ((p = getpwuid(uid)) == NULL) { if ((p = getpwuid(uid)) == NULL) {
err_setstr(RuntimeError, "getpwuid(): uid not found"); err_setstr(KeyError, "getpwuid(): uid not found");
return NULL; return NULL;
} }
return mkpwent(p); return mkpwent(p);
...@@ -81,7 +81,7 @@ static object *pwd_getpwnam(self, args) ...@@ -81,7 +81,7 @@ static object *pwd_getpwnam(self, args)
if (!getstrarg(args, &name)) if (!getstrarg(args, &name))
return NULL; return NULL;
if ((p = getpwnam(getstringvalue(name))) == NULL) { if ((p = getpwnam(getstringvalue(name))) == NULL) {
err_setstr(RuntimeError, "getpwnam(): name not found"); err_setstr(KeyError, "getpwnam(): name not found");
return NULL; return NULL;
} }
return mkpwent(p); return mkpwent(p);
...@@ -167,7 +167,7 @@ static object *grp_getgrgid(self, args) ...@@ -167,7 +167,7 @@ static object *grp_getgrgid(self, args)
if (!getintarg(args, &gid)) if (!getintarg(args, &gid))
return NULL; return NULL;
if ((p = getgrgid(gid)) == NULL) { if ((p = getgrgid(gid)) == NULL) {
err_setstr(RuntimeError, "getgrgid(): gid not found"); err_setstr(KeyError, "getgrgid(): gid not found");
return NULL; return NULL;
} }
return mkgrent(p); return mkgrent(p);
...@@ -181,7 +181,7 @@ static object *grp_getgrnam(self, args) ...@@ -181,7 +181,7 @@ static object *grp_getgrnam(self, args)
if (!getstrarg(args, &name)) if (!getstrarg(args, &name))
return NULL; return NULL;
if ((p = getgrnam(getstringvalue(name))) == NULL) { if ((p = getgrnam(getstringvalue(name))) == NULL) {
err_setstr(RuntimeError, "getgrnam(): name not found"); err_setstr(KeyError, "getgrnam(): name not found");
return NULL; return NULL;
} }
return mkgrent(p); return mkgrent(p);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment