From 2b654f74c23de18c25a9e0b36979322ef461223c Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Sun, 14 Oct 1990 20:03:32 +0000 Subject: New error handling in getattr(). --- Objects/fileobject.c | 3 ++- Objects/moduleobject.c | 7 +++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Objects/fileobject.c b/Objects/fileobject.c index 4879620..be4f300 100644 --- a/Objects/fileobject.c +++ b/Objects/fileobject.c @@ -9,6 +9,7 @@ #include "fileobject.h" #include "methodobject.h" #include "objimpl.h" +#include "errors.h" typedef struct { OB_HEAD @@ -248,7 +249,7 @@ filegetattr(f, name) return newmethodobject(ml->ml_name, ml->ml_meth, (object *)f); } - errno = ESRCH; + err_setstr(NameError, name); return NULL; } diff --git a/Objects/moduleobject.c b/Objects/moduleobject.c index 95dc094..7b9e0e9 100644 --- a/Objects/moduleobject.c +++ b/Objects/moduleobject.c @@ -8,6 +8,7 @@ #include "dictobject.h" #include "moduleobject.h" #include "objimpl.h" +#include "errors.h" typedef struct { OB_HEAD @@ -94,10 +95,8 @@ modulegetattr(m, name) char *name; { object *res = dictlookup(m->md_dict, name); - if (res == NULL) { - if (errno == ENOENT) - errno = ESRCH; - } + if (res == NULL) + err_setstr(NameError, name); else INCREF(res); return res; -- cgit v0.12