New error handling in getattr().
This commit is contained in:
parent
0539ba2c74
commit
2b654f74c2
|
@ -9,6 +9,7 @@
|
||||||
#include "fileobject.h"
|
#include "fileobject.h"
|
||||||
#include "methodobject.h"
|
#include "methodobject.h"
|
||||||
#include "objimpl.h"
|
#include "objimpl.h"
|
||||||
|
#include "errors.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
OB_HEAD
|
OB_HEAD
|
||||||
|
@ -248,7 +249,7 @@ filegetattr(f, name)
|
||||||
return newmethodobject(ml->ml_name, ml->ml_meth,
|
return newmethodobject(ml->ml_name, ml->ml_meth,
|
||||||
(object *)f);
|
(object *)f);
|
||||||
}
|
}
|
||||||
errno = ESRCH;
|
err_setstr(NameError, name);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include "dictobject.h"
|
#include "dictobject.h"
|
||||||
#include "moduleobject.h"
|
#include "moduleobject.h"
|
||||||
#include "objimpl.h"
|
#include "objimpl.h"
|
||||||
|
#include "errors.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
OB_HEAD
|
OB_HEAD
|
||||||
|
@ -94,10 +95,8 @@ modulegetattr(m, name)
|
||||||
char *name;
|
char *name;
|
||||||
{
|
{
|
||||||
object *res = dictlookup(m->md_dict, name);
|
object *res = dictlookup(m->md_dict, name);
|
||||||
if (res == NULL) {
|
if (res == NULL)
|
||||||
if (errno == ENOENT)
|
err_setstr(NameError, name);
|
||||||
errno = ESRCH;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
INCREF(res);
|
INCREF(res);
|
||||||
return res;
|
return res;
|
||||||
|
|
Loading…
Reference in New Issue