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

Unified Diff: Modules/parsermodule.c

Issue 11619: On Windows, don't encode filenames in the import machinery
Patch Set: Created 6 years ago
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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Include/warnings.h ('k') | Modules/symtablemodule.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Modules/parsermodule.c Mon Aug 26 14:05:19 2013 +0200
+++ b/Modules/parsermodule.c Mon Aug 26 16:10:52 2013 +0200
@@ -477,33 +477,46 @@ parser_st2list(PyST_Object *self, PyObje
static PyObject*
parser_compilest(PyST_Object *self, PyObject *args, PyObject *kw)
{
- PyObject* res = 0;
- PyArena* arena;
+ PyObject* res = NULL;
+ PyArena* arena = NULL;
mod_ty mod;
- char* str = "<syntax-tree>";
+ PyObject* filename = NULL;
int ok;
static char *keywords[] = {"st", "filename", NULL};
if (self == NULL || PyModule_Check(self))
- ok = PyArg_ParseTupleAndKeywords(args, kw, "O!|s:compilest", keywords,
- &PyST_Type, &self, &str);
+ ok = PyArg_ParseTupleAndKeywords(args, kw, "O!|O&:compilest", keywords,
+ &PyST_Type, &self,
+ PyUnicode_FSDecoder, &filename);
else
- ok = PyArg_ParseTupleAndKeywords(args, kw, "|s:compile", &keywords[1],
- &str);
-
- if (ok) {
- arena = PyArena_New();
- if (arena) {
- mod = PyAST_FromNode(self->st_node, &(self->st_flags), str, arena);
- if (mod) {
- res = (PyObject *)PyAST_Compile(mod, str, &(self->st_flags), arena);
- }
- PyArena_Free(arena);
- }
+ ok = PyArg_ParseTupleAndKeywords(args, kw, "|O&:compile", &keywords[1],
+ PyUnicode_FSDecoder, &filename);
+ if (!ok)
+ goto error;
+
+ if (filename == NULL) {
+ filename = PyUnicode_FromString("<syntax-tree>");
+ if (filename == NULL)
+ goto error;
}
- return (res);
+ arena = PyArena_New();
+ if (!arena)
+ goto error;
+
+ mod = PyAST_FromNodeObject(self->st_node, &self->st_flags,
+ filename, arena);
+ if (!mod)
+ goto error;
+
+ res = (PyObject *)PyAST_CompileObject(mod, filename,
+ &self->st_flags, -1, arena);
+error:
+ Py_XDECREF(filename);
+ if (arena != NULL)
+ PyArena_Free(arena);
+ return res;
}
« 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+