Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(5)

Side by Side Diff: Modules/parsermodule.c

Issue 11619: On Windows, don't encode filenames in the import machinery
Patch Set: Created 8 years, 10 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Include/warnings.h ('k') | Modules/symtablemodule.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* parsermodule.c 1 /* parsermodule.c
2 * 2 *
3 * Copyright 1995-1996 by Fred L. Drake, Jr. and Virginia Polytechnic 3 * Copyright 1995-1996 by Fred L. Drake, Jr. and Virginia Polytechnic
4 * Institute and State University, Blacksburg, Virginia, USA. 4 * Institute and State University, Blacksburg, Virginia, USA.
5 * Portions copyright 1991-1995 by Stichting Mathematisch Centrum, 5 * Portions copyright 1991-1995 by Stichting Mathematisch Centrum,
6 * Amsterdam, The Netherlands. Copying is permitted under the terms 6 * Amsterdam, The Netherlands. Copying is permitted under the terms
7 * associated with the main Python distribution, with the additional 7 * associated with the main Python distribution, with the additional
8 * restriction that this additional notice be included and maintained 8 * restriction that this additional notice be included and maintained
9 * on all distributed copies. 9 * on all distributed copies.
10 * 10 *
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 451
452 /* parser_compilest(PyObject* self, PyObject* args) 452 /* parser_compilest(PyObject* self, PyObject* args)
453 * 453 *
454 * This function creates code objects from the parse tree represented by 454 * This function creates code objects from the parse tree represented by
455 * the passed-in data object. An optional file name is passed in as well. 455 * the passed-in data object. An optional file name is passed in as well.
456 * 456 *
457 */ 457 */
458 static PyObject* 458 static PyObject*
459 parser_compilest(PyST_Object *self, PyObject *args, PyObject *kw) 459 parser_compilest(PyST_Object *self, PyObject *args, PyObject *kw)
460 { 460 {
461 PyObject* res = 0; 461 PyObject* res = NULL;
462 PyArena* arena; 462 PyArena* arena = NULL;
463 mod_ty mod; 463 mod_ty mod;
464 char* str = "<syntax-tree>"; 464 PyObject* filename = NULL;
465 int ok; 465 int ok;
466 466
467 static char *keywords[] = {"st", "filename", NULL}; 467 static char *keywords[] = {"st", "filename", NULL};
468 468
469 if (self == NULL || PyModule_Check(self)) 469 if (self == NULL || PyModule_Check(self))
470 ok = PyArg_ParseTupleAndKeywords(args, kw, "O!|s:compilest", keywords, 470 ok = PyArg_ParseTupleAndKeywords(args, kw, "O!|O&:compilest", keywords,
471 &PyST_Type, &self, &str); 471 &PyST_Type, &self,
472 PyUnicode_FSDecoder, &filename);
472 else 473 else
473 ok = PyArg_ParseTupleAndKeywords(args, kw, "|s:compile", &keywords[1], 474 ok = PyArg_ParseTupleAndKeywords(args, kw, "|O&:compile", &keywords[1],
474 &str); 475 PyUnicode_FSDecoder, &filename);
476 if (!ok)
477 goto error;
475 478
476 if (ok) { 479 if (filename == NULL) {
477 arena = PyArena_New(); 480 filename = PyUnicode_FromString("<syntax-tree>");
478 if (arena) { 481 if (filename == NULL)
479 mod = PyAST_FromNode(self->st_node, &(self->st_flags), str, arena); 482 goto error;
480 if (mod) {
481 res = (PyObject *)PyAST_Compile(mod, str, &(self->st_flags), aren a);
482 }
483 PyArena_Free(arena);
484 }
485 } 483 }
486 484
487 return (res); 485 arena = PyArena_New();
486 if (!arena)
487 goto error;
488
489 mod = PyAST_FromNodeObject(self->st_node, &self->st_flags,
490 filename, arena);
491 if (!mod)
492 goto error;
493
494 res = (PyObject *)PyAST_CompileObject(mod, filename,
495 &self->st_flags, -1, arena);
496 error:
497 Py_XDECREF(filename);
498 if (arena != NULL)
499 PyArena_Free(arena);
500 return res;
488 } 501 }
489 502
490 503
491 /* PyObject* parser_isexpr(PyObject* self, PyObject* args) 504 /* PyObject* parser_isexpr(PyObject* self, PyObject* args)
492 * PyObject* parser_issuite(PyObject* self, PyObject* args) 505 * PyObject* parser_issuite(PyObject* self, PyObject* args)
493 * 506 *
494 * Checks the passed-in ST object to determine if it is an expression or 507 * Checks the passed-in ST object to determine if it is an expression or
495 * a statement suite, respectively. The return is a Python truth value. 508 * a statement suite, respectively. The return is a Python truth value.
496 * 509 *
497 */ 510 */
(...skipping 2755 matching lines...) Expand 10 before | Expand all | Expand 10 after
3253 pickle_constructor, NULL); 3266 pickle_constructor, NULL);
3254 Py_XDECREF(res); 3267 Py_XDECREF(res);
3255 } 3268 }
3256 Py_XDECREF(func); 3269 Py_XDECREF(func);
3257 Py_XDECREF(pickle_constructor); 3270 Py_XDECREF(pickle_constructor);
3258 Py_XDECREF(pickler); 3271 Py_XDECREF(pickler);
3259 Py_DECREF(copyreg); 3272 Py_DECREF(copyreg);
3260 } 3273 }
3261 return module; 3274 return module;
3262 } 3275 }
OLDNEW
« no previous file with comments | « Include/warnings.h ('k') | Modules/symtablemodule.c » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+