diff options
Diffstat (limited to 'Python/pythonrun.c')
| -rw-r--r-- | Python/pythonrun.c | 44 | 
1 files changed, 24 insertions, 20 deletions
| diff --git a/Python/pythonrun.c b/Python/pythonrun.c index 90cb2de..8befa54 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -171,7 +171,7 @@ PyRun_InteractiveOneObject(FILE *fp, PyObject *filename, PyCompilerFlags *flags)          if (v && v != Py_None) {              oenc = _PyObject_GetAttrId(v, &PyId_encoding);              if (oenc) -                enc = _PyUnicode_AsString(oenc); +                enc = PyUnicode_AsUTF8(oenc);              if (!enc)                  PyErr_Clear();          } @@ -182,7 +182,7 @@ PyRun_InteractiveOneObject(FILE *fp, PyObject *filename, PyCompilerFlags *flags)          if (v == NULL)              PyErr_Clear();          else if (PyUnicode_Check(v)) { -            ps1 = _PyUnicode_AsString(v); +            ps1 = PyUnicode_AsUTF8(v);              if (ps1 == NULL) {                  PyErr_Clear();                  ps1 = ""; @@ -195,7 +195,7 @@ PyRun_InteractiveOneObject(FILE *fp, PyObject *filename, PyCompilerFlags *flags)          if (w == NULL)              PyErr_Clear();          else if (PyUnicode_Check(w)) { -            ps2 = _PyUnicode_AsString(w); +            ps2 = PyUnicode_AsUTF8(w);              if (ps2 == NULL) {                  PyErr_Clear();                  ps2 = ""; @@ -431,7 +431,7 @@ static int  parse_syntax_error(PyObject *err, PyObject **message, PyObject **filename,                     int *lineno, int *offset, PyObject **text)  { -    long hold; +    int hold;      PyObject *v;      _Py_IDENTIFIER(msg);      _Py_IDENTIFIER(filename); @@ -464,11 +464,11 @@ parse_syntax_error(PyObject *err, PyObject **message, PyObject **filename,      v = _PyObject_GetAttrId(err, &PyId_lineno);      if (!v)          goto finally; -    hold = PyLong_AsLong(v); +    hold = _PyLong_AsInt(v);      Py_DECREF(v);      if (hold < 0 && PyErr_Occurred())          goto finally; -    *lineno = (int)hold; +    *lineno = hold;      v = _PyObject_GetAttrId(err, &PyId_offset);      if (!v) @@ -477,11 +477,11 @@ parse_syntax_error(PyObject *err, PyObject **message, PyObject **filename,          *offset = -1;          Py_DECREF(v);      } else { -        hold = PyLong_AsLong(v); +        hold = _PyLong_AsInt(v);          Py_DECREF(v);          if (hold < 0 && PyErr_Occurred())              goto finally; -        *offset = (int)hold; +        *offset = hold;      }      v = _PyObject_GetAttrId(err, &PyId_text); @@ -514,7 +514,7 @@ print_error_text(PyObject *f, int offset, PyObject *text_obj)      char *text;      char *nl; -    text = _PyUnicode_AsString(text_obj); +    text = PyUnicode_AsUTF8(text_obj);      if (text == NULL)          return; @@ -630,8 +630,13 @@ PyErr_PrintEx(int set_sys_last_vars)      }      hook = _PySys_GetObjectId(&PyId_excepthook);      if (hook) { -        PyObject *args = PyTuple_Pack(3, exception, v, tb); -        PyObject *result = PyEval_CallObject(hook, args); +        PyObject* stack[3]; +        PyObject *result; + +        stack[0] = exception; +        stack[1] = v; +        stack[2] = tb; +        result = _PyObject_FastCall(hook, stack, 3);          if (result == NULL) {              PyObject *exception2, *v2, *tb2;              if (PyErr_ExceptionMatches(PyExc_SystemExit)) { @@ -660,7 +665,6 @@ PyErr_PrintEx(int set_sys_last_vars)              Py_XDECREF(tb2);          }          Py_XDECREF(result); -        Py_XDECREF(args);      } else {          PySys_WriteStderr("sys.excepthook is missing\n");          PyErr_Display(exception, v, tb); @@ -791,11 +795,11 @@ print_exception(PyObject *f, PyObject *value)          PyErr_Clear();  } -static const char *cause_message = +static const char cause_message[] =      "\nThe above exception was the direct cause "      "of the following exception:\n\n"; -static const char *context_message = +static const char context_message[] =      "\nDuring handling of the above exception, "      "another exception occurred:\n\n"; @@ -946,7 +950,7 @@ flush_io(void)      f = _PySys_GetObjectId(&PyId_stderr);      if (f != NULL) { -        r = _PyObject_CallMethodId(f, &PyId_flush, ""); +        r = _PyObject_CallMethodId(f, &PyId_flush, NULL);          if (r)              Py_DECREF(r);          else @@ -954,7 +958,7 @@ flush_io(void)      }      f = _PySys_GetObjectId(&PyId_stdout);      if (f != NULL) { -        r = _PyObject_CallMethodId(f, &PyId_flush, ""); +        r = _PyObject_CallMethodId(f, &PyId_flush, NULL);          if (r)              Py_DECREF(r);          else @@ -1144,8 +1148,8 @@ PyParser_ASTFromString(const char *s, const char *filename_str, int start,  mod_ty  PyParser_ASTFromFileObject(FILE *fp, PyObject *filename, const char* enc, -                           int start, char *ps1, -                           char *ps2, PyCompilerFlags *flags, int *errcode, +                           int start, const char *ps1, +                           const char *ps2, PyCompilerFlags *flags, int *errcode,                             PyArena *arena)  {      mod_ty mod; @@ -1177,8 +1181,8 @@ PyParser_ASTFromFileObject(FILE *fp, PyObject *filename, const char* enc,  mod_ty  PyParser_ASTFromFile(FILE *fp, const char *filename_str, const char* enc, -                     int start, char *ps1, -                     char *ps2, PyCompilerFlags *flags, int *errcode, +                     int start, const char *ps1, +                     const char *ps2, PyCompilerFlags *flags, int *errcode,                       PyArena *arena)  {      mod_ty mod; | 
