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

Side by Side Diff: Modules/parsermodule.c

Issue 11619: On Windows, don't encode filenames in the import machinery
Patch Set: Created 6 years, 3 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 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 470
471 /* parser_compilest(PyObject* self, PyObject* args) 471 /* parser_compilest(PyObject* self, PyObject* args)
472 * 472 *
473 * This function creates code objects from the parse tree represented by 473 * This function creates code objects from the parse tree represented by
474 * the passed-in data object. An optional file name is passed in as well. 474 * the passed-in data object. An optional file name is passed in as well.
475 * 475 *
476 */ 476 */
477 static PyObject* 477 static PyObject*
478 parser_compilest(PyST_Object *self, PyObject *args, PyObject *kw) 478 parser_compilest(PyST_Object *self, PyObject *args, PyObject *kw)
479 { 479 {
480 PyObject* res = 0; 480 PyObject* res = NULL;
481 PyArena* arena; 481 PyArena* arena = NULL;
482 mod_ty mod; 482 mod_ty mod;
483 char* str = "<syntax-tree>"; 483 PyObject* filename = NULL;
484 int ok; 484 int ok;
485 485
486 static char *keywords[] = {"st", "filename", NULL}; 486 static char *keywords[] = {"st", "filename", NULL};
487 487
488 if (self == NULL || PyModule_Check(self)) 488 if (self == NULL || PyModule_Check(self))
489 ok = PyArg_ParseTupleAndKeywords(args, kw, "O!|s:compilest", keywords, 489 ok = PyArg_ParseTupleAndKeywords(args, kw, "O!|O&:compilest", keywords,
490 &PyST_Type, &self, &str); 490 &PyST_Type, &self,
491 PyUnicode_FSDecoder, &filename);
491 else 492 else
492 ok = PyArg_ParseTupleAndKeywords(args, kw, "|s:compile", &keywords[1], 493 ok = PyArg_ParseTupleAndKeywords(args, kw, "|O&:compile", &keywords[1],
493 &str); 494 PyUnicode_FSDecoder, &filename);
495 if (!ok)
496 goto error;
494 497
495 if (ok) { 498 if (filename == NULL) {
496 arena = PyArena_New(); 499 filename = PyUnicode_FromString("<syntax-tree>");
497 if (arena) { 500 if (filename == NULL)
498 mod = PyAST_FromNode(self->st_node, &(self->st_flags), str, arena); 501 goto error;
499 if (mod) {
500 res = (PyObject *)PyAST_Compile(mod, str, &(self->st_flags), aren a);
501 }
502 PyArena_Free(arena);
503 }
504 } 502 }
505 503
506 return (res); 504 arena = PyArena_New();
505 if (!arena)
506 goto error;
507
508 mod = PyAST_FromNodeObject(self->st_node, &self->st_flags,
509 filename, arena);
510 if (!mod)
511 goto error;
512
513 res = (PyObject *)PyAST_CompileObject(mod, filename,
514 &self->st_flags, -1, arena);
515 error:
516 Py_XDECREF(filename);
517 if (arena != NULL)
518 PyArena_Free(arena);
519 return res;
507 } 520 }
508 521
509 522
510 /* PyObject* parser_isexpr(PyObject* self, PyObject* args) 523 /* PyObject* parser_isexpr(PyObject* self, PyObject* args)
511 * PyObject* parser_issuite(PyObject* self, PyObject* args) 524 * PyObject* parser_issuite(PyObject* self, PyObject* args)
512 * 525 *
513 * Checks the passed-in ST object to determine if it is an expression or 526 * Checks the passed-in ST object to determine if it is an expression or
514 * a statement suite, respectively. The return is a Python truth value. 527 * a statement suite, respectively. The return is a Python truth value.
515 * 528 *
516 */ 529 */
(...skipping 2910 matching lines...) Expand 10 before | Expand all | Expand 10 after
3427 pickle_constructor, NULL); 3440 pickle_constructor, NULL);
3428 Py_XDECREF(res); 3441 Py_XDECREF(res);
3429 } 3442 }
3430 Py_XDECREF(func); 3443 Py_XDECREF(func);
3431 Py_XDECREF(pickle_constructor); 3444 Py_XDECREF(pickle_constructor);
3432 Py_XDECREF(pickler); 3445 Py_XDECREF(pickler);
3433 Py_DECREF(copyreg); 3446 Py_DECREF(copyreg);
3434 } 3447 }
3435 return module; 3448 return module;
3436 } 3449 }
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+