@@ -4000,33 +4000,36 @@ compiler_import_as(struct compiler *c, location loc,
4000
4000
*/
4001
4001
Py_ssize_t len = PyUnicode_GET_LENGTH (name );
4002
4002
Py_ssize_t dot = PyUnicode_FindChar (name , '.' , 0 , len , 1 );
4003
- if (dot == -2 )
4004
- return 0 ;
4003
+ if (dot == -2 ) {
4004
+ return ERROR ;
4005
+ }
4005
4006
if (dot != -1 ) {
4006
4007
/* Consume the base module name to get the first attribute */
4007
4008
while (1 ) {
4008
4009
Py_ssize_t pos = dot + 1 ;
4009
4010
PyObject * attr ;
4010
4011
dot = PyUnicode_FindChar (name , '.' , pos , len , 1 );
4011
- if (dot == -2 )
4012
- return 0 ;
4012
+ if (dot == -2 ) {
4013
+ return ERROR ;
4014
+ }
4013
4015
attr = PyUnicode_Substring (name , pos , (dot != -1 ) ? dot : len );
4014
- if (!attr )
4015
- return 0 ;
4016
- _ADDOP_N (c , loc , IMPORT_FROM , attr , names );
4016
+ if (!attr ) {
4017
+ return ERROR ;
4018
+ }
4019
+ ADDOP_N (c , loc , IMPORT_FROM , attr , names );
4017
4020
if (dot == -1 ) {
4018
4021
break ;
4019
4022
}
4020
- _ADDOP_I (c , loc , SWAP , 2 );
4021
- _ADDOP (c , loc , POP_TOP );
4023
+ ADDOP_I (c , loc , SWAP , 2 );
4024
+ ADDOP (c , loc , POP_TOP );
4022
4025
}
4023
4026
if (!compiler_nameop (c , loc , asname , Store )) {
4024
- return 0 ;
4027
+ return ERROR ;
4025
4028
}
4026
- _ADDOP (c , loc , POP_TOP );
4027
- return 1 ;
4029
+ ADDOP (c , loc , POP_TOP );
4030
+ return SUCCESS ;
4028
4031
}
4029
- return compiler_nameop (c , loc , asname , Store );
4032
+ return compiler_nameop (c , loc , asname , Store ) ? SUCCESS : ERROR ;
4030
4033
}
4031
4034
4032
4035
static int
@@ -4047,33 +4050,36 @@ compiler_import(struct compiler *c, stmt_ty s)
4047
4050
alias_ty alias = (alias_ty )asdl_seq_GET (s -> v .Import .names , i );
4048
4051
int r ;
4049
4052
4050
- _ADDOP_LOAD_CONST (c , loc , zero );
4051
- _ADDOP_LOAD_CONST (c , loc , Py_None );
4052
- _ADDOP_NAME (c , loc , IMPORT_NAME , alias -> name , names );
4053
+ ADDOP_LOAD_CONST (c , loc , zero );
4054
+ ADDOP_LOAD_CONST (c , loc , Py_None );
4055
+ ADDOP_NAME (c , loc , IMPORT_NAME , alias -> name , names );
4053
4056
4054
4057
if (alias -> asname ) {
4055
4058
r = compiler_import_as (c , loc , alias -> name , alias -> asname );
4056
- if (! r )
4059
+ if (r == ERROR ) {
4057
4060
return r ;
4061
+ }
4058
4062
}
4059
4063
else {
4060
4064
identifier tmp = alias -> name ;
4061
4065
Py_ssize_t dot = PyUnicode_FindChar (
4062
4066
alias -> name , '.' , 0 , PyUnicode_GET_LENGTH (alias -> name ), 1 );
4063
4067
if (dot != -1 ) {
4064
4068
tmp = PyUnicode_Substring (alias -> name , 0 , dot );
4065
- if (tmp == NULL )
4066
- return 0 ;
4069
+ if (tmp == NULL ) {
4070
+ return ERROR ;
4071
+ }
4067
4072
}
4068
4073
r = compiler_nameop (c , loc , tmp , Store );
4069
4074
if (dot != -1 ) {
4070
4075
Py_DECREF (tmp );
4071
4076
}
4072
- if (!r )
4073
- return r ;
4077
+ if (!r ) {
4078
+ return ERROR ;
4079
+ }
4074
4080
}
4075
4081
}
4076
- return 1 ;
4082
+ return SUCCESS ;
4077
4083
}
4078
4084
4079
4085
static int
@@ -4250,7 +4256,7 @@ compiler_visit_stmt(struct compiler *c, stmt_ty s)
4250
4256
case Assert_kind :
4251
4257
return compiler_assert (c , s ) == SUCCESS ? 1 : 0 ;
4252
4258
case Import_kind :
4253
- return compiler_import (c , s );
4259
+ return compiler_import (c , s ) == SUCCESS ? 1 : 0 ;
4254
4260
case ImportFrom_kind :
4255
4261
return compiler_from_import (c , s );
4256
4262
case Global_kind :
0 commit comments