]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
New error handling in getattr().
authorGuido van Rossum <guido@python.org>
Sun, 14 Oct 1990 20:03:32 +0000 (20:03 +0000)
committerGuido van Rossum <guido@python.org>
Sun, 14 Oct 1990 20:03:32 +0000 (20:03 +0000)
Objects/fileobject.c
Objects/moduleobject.c

index 487962085a6b02f6d6ffa8f1613eb8e17873b43b..be4f3005ec9710f3dfdddf78b1a2c704d070e0bb 100644 (file)
@@ -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;
 }
 
index 95dc094421be17351df17860ce85e0036bf02857..7b9e0e919f989480381718a87db7d8aa45b949e5 100644 (file)
@@ -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;