Mercurial > cpython-lru_cache-weakref
comparison Python/Python-ast.c @ 54743:40c8c35492f1 legacy-trunk
when no module is given in a 'from' relative import, make ImportFrom.module NULL
| author | Benjamin Peterson <benjamin@python.org> |
|---|---|
| date | Sat, 13 Jun 2009 20:23:33 +0000 |
| parents | 2e38ca709b1d |
| children | 247f8d268d58 |
comparison
equal
deleted
inserted
replaced
| 54742:3eb8510808c9 | 54743:40c8c35492f1 |
|---|---|
| 1328 stmt_ty | 1328 stmt_ty |
| 1329 ImportFrom(identifier module, asdl_seq * names, int level, int lineno, int | 1329 ImportFrom(identifier module, asdl_seq * names, int level, int lineno, int |
| 1330 col_offset, PyArena *arena) | 1330 col_offset, PyArena *arena) |
| 1331 { | 1331 { |
| 1332 stmt_ty p; | 1332 stmt_ty p; |
| 1333 if (!module) { | |
| 1334 PyErr_SetString(PyExc_ValueError, | |
| 1335 "field module is required for ImportFrom"); | |
| 1336 return NULL; | |
| 1337 } | |
| 1338 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); | 1333 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1339 if (!p) | 1334 if (!p) |
| 1340 return NULL; | 1335 return NULL; |
| 1341 p->kind = ImportFrom_kind; | 1336 p->kind = ImportFrom_kind; |
| 1342 p->v.ImportFrom.module = module; | 1337 p->v.ImportFrom.module = module; |
| 4271 res = obj2ast_identifier(tmp, &module, arena); | 4266 res = obj2ast_identifier(tmp, &module, arena); |
| 4272 if (res != 0) goto failed; | 4267 if (res != 0) goto failed; |
| 4273 Py_XDECREF(tmp); | 4268 Py_XDECREF(tmp); |
| 4274 tmp = NULL; | 4269 tmp = NULL; |
| 4275 } else { | 4270 } else { |
| 4276 PyErr_SetString(PyExc_TypeError, "required field \"module\" missing from ImportFrom"); | 4271 module = NULL; |
| 4277 return 1; | |
| 4278 } | 4272 } |
| 4279 if (PyObject_HasAttrString(obj, "names")) { | 4273 if (PyObject_HasAttrString(obj, "names")) { |
| 4280 int res; | 4274 int res; |
| 4281 Py_ssize_t len; | 4275 Py_ssize_t len; |
| 4282 Py_ssize_t i; | 4276 Py_ssize_t i; |
