[Python-checkins] CVS: python/dist/src/Python ceval.c,2.225,2.226 compile.c,2.154,2.155
Jeremy Hylton
jhylton@users.sourceforge.net
Thu, 01 Feb 2001 12:20:47 -0800
Update of /cvsroot/python/python/dist/src/Python
In directory usw-pr-cvs1:/tmp/cvs-serv14180/Python
Modified Files:
ceval.c compile.c
Log Message:
Undo recent change that banned using import to bind a global, as per
discussion on python-dev. 'from mod import *' is still banned except
at the module level.
Fix value for special NOOPT entry in symtable. Initialze to 0 instead
of None, so that later uses of PyInt_AS_LONG() are valid. (Bug
reported by Donn Cave.)
replace local REPR macros with PyObject_REPR in object.h
Index: ceval.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v
retrieving revision 2.225
retrieving revision 2.226
diff -C2 -r2.225 -r2.226
*** ceval.c 2001/01/31 01:16:47 2.225
--- ceval.c 2001/02/01 20:20:45 2.226
***************
*** 32,37 ****
typedef PyObject *(*callproc)(PyObject *, PyObject *, PyObject *);
- #define REPR(ob) PyString_AS_STRING(PyObject_Repr(ob))
-
/* Forward declarations */
--- 32,35 ----
***************
*** 1457,1461 ****
PyErr_Format(PyExc_SystemError,
"no locals found when storing %s",
! REPR(w));
break;
}
--- 1455,1459 ----
PyErr_Format(PyExc_SystemError,
"no locals found when storing %s",
! PyObject_REPR(w));
break;
}
***************
*** 1469,1473 ****
PyErr_Format(PyExc_SystemError,
"no locals when deleting %s",
! REPR(w));
break;
}
--- 1467,1471 ----
PyErr_Format(PyExc_SystemError,
"no locals when deleting %s",
! PyObject_REPR(w));
break;
}
***************
*** 1564,1568 ****
PyErr_Format(PyExc_SystemError,
"no locals when loading %s",
! REPR(w));
break;
}
--- 1562,1566 ----
PyErr_Format(PyExc_SystemError,
"no locals when loading %s",
! PyObject_REPR(w));
break;
}
Index: compile.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v
retrieving revision 2.154
retrieving revision 2.155
diff -C2 -r2.154 -r2.155
*** compile.c 2001/01/30 01:24:43 2.154
--- compile.c 2001/02/01 20:20:45 2.155
***************
*** 20,25 ****
#include "structmember.h"
- #define REPR(O) PyString_AS_STRING(PyObject_Repr(O))
-
#include <ctype.h>
--- 20,23 ----
***************
*** 67,73 ****
"'from ... import *' may only occur in a module scope"
- #define ILLEGAL_IMPORT_GLOBAL \
- "may not import name '%.400s' because it is declared global"
-
#define MANGLE_LEN 256
--- 65,68 ----
***************
*** 2205,2209 ****
if (arg == -1) {
fprintf(stderr, "lookup %s in %s %d %d\n",
! REPR(name), c->c_name, reftype, arg);
Py_FatalError("com_make_closure()");
}
--- 2200,2204 ----
if (arg == -1) {
fprintf(stderr, "lookup %s in %s %d %d\n",
! PyObject_REPR(name), c->c_name, reftype, arg);
Py_FatalError("com_make_closure()");
}
***************
*** 3996,4000 ****
char buf[250];
sprintf(buf, "unknown scope for %.100s in %.100s (%s)",
! name, c->c_name, REPR(c->c_symtable->st_cur_id));
Py_FatalError(buf);
}
--- 3991,3996 ----
char buf[250];
sprintf(buf, "unknown scope for %.100s in %.100s (%s)",
! name, c->c_name,
! PyObject_REPR(c->c_symtable->st_cur_id));
Py_FatalError(buf);
}
***************
*** 4118,4128 ****
goto fail;
}
- if (info & DEF_IMPORT) {
- char buf[500];
- sprintf(buf, ILLEGAL_IMPORT_GLOBAL,
- PyString_AS_STRING(name));
- com_error(c, PyExc_SyntaxError, buf);
- goto fail;
- }
if (PyDict_SetItem(c->c_globals, name, Py_None) < 0)
goto fail;
--- 4114,4117 ----
***************
*** 4530,4534 ****
if ((flag & DEF_PARAM) && (val & DEF_PARAM)) {
PyErr_Format(PyExc_SyntaxError, DUPLICATE_ARGUMENT,
! name);
return -1;
}
--- 4519,4523 ----
if ((flag & DEF_PARAM) && (val & DEF_PARAM)) {
PyErr_Format(PyExc_SyntaxError, DUPLICATE_ARGUMENT,
! PyString_AsString(name));
return -1;
}
***************
*** 4627,4633 ****
symtable_import(st, n);
break;
! case exec_stmt:
! if (PyDict_SetItemString(st->st_cur, NOOPT, Py_None) < 0)
st->st_errors++;
symtable_node(st, CHILD(n, 1));
if (NCH(n) > 2)
--- 4616,4629 ----
symtable_import(st, n);
break;
! case exec_stmt: {
! PyObject *zero = PyInt_FromLong(0);
! if (zero == NULL)
st->st_errors++;
+ else {
+ if (PyDict_SetItemString(st->st_cur, NOOPT,
+ zero) < 0)
+ st->st_errors++;
+ Py_DECREF(zero);
+ }
symtable_node(st, CHILD(n, 1));
if (NCH(n) > 2)
***************
*** 4636,4639 ****
--- 4632,4637 ----
symtable_node(st, CHILD(n, 5));
break;
+
+ }
case except_clause:
if (NCH(n) == 4)
***************
*** 4849,4861 ****
{
int i;
! /*
! import_stmt: 'import' dotted_as_name (',' dotted_as_name)*
| 'from' dotted_name 'import'
('*' | import_as_name (',' import_as_name)*)
! import_as_name: NAME [NAME NAME]
*/
if (STR(CHILD(n, 0))[0] == 'f') { /* from */
if (TYPE(CHILD(n, 3)) == STAR) {
if (st->st_cur_type != TYPE_MODULE) {
PyErr_SetString(PyExc_SyntaxError,
--- 4847,4859 ----
{
int i;
! /* import_stmt: 'import' dotted_as_name (',' dotted_as_name)*
| 'from' dotted_name 'import'
('*' | import_as_name (',' import_as_name)*)
! import_as_name: NAME [NAME NAME]
*/
if (STR(CHILD(n, 0))[0] == 'f') { /* from */
if (TYPE(CHILD(n, 3)) == STAR) {
+ PyObject *zero = PyInt_FromLong(0);
if (st->st_cur_type != TYPE_MODULE) {
PyErr_SetString(PyExc_SyntaxError,
***************
*** 4864,4870 ****
return;
}
! if (PyDict_SetItemString(st->st_cur, NOOPT,
! Py_None) < 0)
st->st_errors++;
} else {
for (i = 3; i < NCH(n); i += 2) {
--- 4862,4873 ----
return;
}
! if (zero == NULL)
st->st_errors++;
+ else {
+ if (PyDict_SetItemString(st->st_cur, NOOPT,
+ zero) < 0)
+ st->st_errors++;
+ Py_DECREF(zero);
+ }
} else {
for (i = 3; i < NCH(n); i += 2) {