Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit df62e44

Browse files
committed
Changed many calls to dict stufff to dict2 variants.
*** Somehow the call to printobject was changed back to fwrite?!?! ***
1 parent 4f4a55b commit df62e44

1 file changed

Lines changed: 35 additions & 31 deletions

File tree

Python/ceval.c

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ static object *build_class();
6161
static int testbool();
6262
static int assign_subscript PROTO((object *, object *, object *));
6363
static int assign_slice PROTO((object *, object *, object *, object *));
64-
static int import_from PROTO((object *, object *, char *));
64+
static int import_from PROTO((object *, object *, object *));
6565

6666

6767
static frameobject *current_frame;
@@ -442,8 +442,8 @@ eval_code(co, globals, locals, arg)
442442
if (is_stringobject(v)) {
443443
char *s = getstringvalue(v);
444444
int len = getstringsize(v);
445-
err = printobject(v, fp, PRINT_RAW);
446-
if (err == 0 && len > 0 && s[len-1] == '\n')
445+
fwrite(s, 1, len, fp);
446+
if (len > 0 && s[len-1] == '\n')
447447
softspace(sysget("stdout"), 0);
448448
}
449449
else {
@@ -560,9 +560,9 @@ eval_code(co, globals, locals, arg)
560560
break;
561561

562562
case DELETE_NAME:
563-
name = GETNAME(oparg);
564-
if ((err = dictremove(f->f_locals, name)) != 0)
565-
err_setstr(NameError, name);
563+
w = GETNAMEV(oparg);
564+
if ((err = dict2remove(f->f_locals, w)) != 0)
565+
err_setstr(NameError, getstringvalue(w));
566566
break;
567567

568568
case UNPACK_TUPLE:
@@ -631,14 +631,17 @@ eval_code(co, globals, locals, arg)
631631
break;
632632

633633
case LOAD_NAME:
634-
name = GETNAME(oparg);
635-
x = dictlookup(f->f_locals, name);
634+
w = GETNAMEV(oparg);
635+
x = dict2lookup(f->f_locals, w);
636636
if (x == NULL) {
637-
x = dictlookup(f->f_globals, name);
637+
err_clear();
638+
x = dict2lookup(f->f_globals, w);
638639
if (x == NULL) {
639-
x = getbuiltin(name);
640+
err_clear();
641+
x = getbuiltin(w);
640642
if (x == NULL) {
641-
err_setstr(NameError, name);
643+
err_setstr(NameError,
644+
getstringvalue(w));
642645
break;
643646
}
644647
}
@@ -648,12 +651,14 @@ eval_code(co, globals, locals, arg)
648651
break;
649652

650653
case LOAD_GLOBAL:
651-
name = GETNAME(oparg);
652-
x = dictlookup(f->f_globals, name);
654+
w = GETNAMEV(oparg);
655+
x = dict2lookup(f->f_globals, w);
653656
if (x == NULL) {
654-
x = getbuiltin(name);
657+
err_clear();
658+
x = getbuiltin(w);
655659
if (x == NULL) {
656-
err_setstr(NameError, name);
660+
err_setstr(NameError,
661+
getstringvalue(w));
657662
break;
658663
}
659664
}
@@ -662,10 +667,10 @@ eval_code(co, globals, locals, arg)
662667
break;
663668

664669
case LOAD_LOCAL:
665-
name = GETNAME(oparg);
666-
x = dictlookup(f->f_locals, name);
670+
w = GETNAMEV(oparg);
671+
x = dict2lookup(f->f_locals, w);
667672
if (x == NULL) {
668-
err_setstr(NameError, name);
673+
err_setstr(NameError, getstringvalue(w));
669674
break;
670675
}
671676
INCREF(x);
@@ -728,9 +733,9 @@ eval_code(co, globals, locals, arg)
728733
break;
729734

730735
case IMPORT_FROM:
731-
name = GETNAME(oparg);
736+
w = GETNAMEV(oparg);
732737
v = TOP();
733-
err = import_from(f->f_locals, v, name);
738+
err = import_from(f->f_locals, v, w);
734739
break;
735740

736741
case JUMP_FORWARD:
@@ -1131,7 +1136,6 @@ not(v)
11311136
INCREF(w);
11321137
return w;
11331138
}
1134-
11351139
/* External interface to call any callable object. The arg may be NULL. */
11361140

11371141
object *
@@ -1464,36 +1468,36 @@ static int
14641468
import_from(locals, v, name)
14651469
object *locals;
14661470
object *v;
1467-
char *name;
1471+
object *name;
14681472
{
14691473
object *w, *x;
14701474
w = getmoduledict(v);
1471-
if (name[0] == '*') {
1475+
if (getstringvalue(name)[0] == '*') {
14721476
int i;
14731477
int n = getdictsize(w);
14741478
for (i = 0; i < n; i++) {
1475-
name = getdictkey(w, i);
1476-
if (name == NULL || name[0] == '_')
1479+
name = getdict2key(w, i);
1480+
if (name == NULL || getstringvalue(name)[0] == '_')
14771481
continue;
1478-
x = dictlookup(w, name);
1482+
x = dict2lookup(w, name);
14791483
if (x == NULL) {
14801484
/* XXX can't happen? */
1481-
err_setstr(NameError, name);
1485+
err_setstr(NameError, getstringvalue(name));
14821486
return -1;
14831487
}
1484-
if (dictinsert(locals, name, x) != 0)
1488+
if (dict2insert(locals, name, x) != 0)
14851489
return -1;
14861490
}
14871491
return 0;
14881492
}
14891493
else {
1490-
x = dictlookup(w, name);
1494+
x = dict2lookup(w, name);
14911495
if (x == NULL) {
1492-
err_setstr(NameError, name);
1496+
err_setstr(NameError, getstringvalue(name));
14931497
return -1;
14941498
}
14951499
else
1496-
return dictinsert(locals, name, x);
1500+
return dict2insert(locals, name, x);
14971501
}
14981502
}
14991503

0 commit comments

Comments
 (0)