summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
Diffstat (limited to 'Python')
-rw-r--r--Python/_warnings.c2
-rw-r--r--Python/ast.c1
-rw-r--r--Python/ceval.c4
-rw-r--r--Python/getargs.c12
-rw-r--r--Python/peephole.c18
-rw-r--r--Python/pystate.c2
-rw-r--r--Python/sysmodule.c60
-rw-r--r--Python/thread.c2
8 files changed, 39 insertions, 62 deletions
diff --git a/Python/_warnings.c b/Python/_warnings.c
index 56e8b3a..543e0bb 100644
--- a/Python/_warnings.c
+++ b/Python/_warnings.c
@@ -732,7 +732,7 @@ PyErr_WarnEx(PyObject *category, const char *text, Py_ssize_t stack_level)
return 0;
}
-/* PyErr_Warn is only for backwards compatability and will be removed.
+/* PyErr_Warn is only for backwards compatibility and will be removed.
Use PyErr_WarnEx instead. */
#undef PyErr_Warn
diff --git a/Python/ast.c b/Python/ast.c
index 590bc90..d97e951 100644
--- a/Python/ast.c
+++ b/Python/ast.c
@@ -469,6 +469,7 @@ set_context(struct compiling *c, expr_ty e, expr_context_ty ctx, const node *n)
case Set_kind:
case Num_kind:
case Str_kind:
+ case Bytes_kind:
expr_name = "literal";
break;
case Ellipsis_kind:
diff --git a/Python/ceval.c b/Python/ceval.c
index f3433f1..d3ed871 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -27,7 +27,7 @@
typedef unsigned long long uint64;
-/* PowerPC suppport.
+/* PowerPC support.
"__ppc__" appears to be the preprocessor definition to detect on OS X, whereas
"__powerpc__" appears to be the correct one for Linux with GCC
*/
@@ -1169,7 +1169,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
if (--_Py_Ticker < 0) {
if (*next_instr == SETUP_FINALLY) {
/* Make the last opcode before
- a try: finally: block uninterruptable. */
+ a try: finally: block uninterruptible. */
goto fast_next_opcode;
}
_Py_Ticker = _Py_CheckInterval;
diff --git a/Python/getargs.c b/Python/getargs.c
index 686eac5..0009b35 100644
--- a/Python/getargs.c
+++ b/Python/getargs.c
@@ -613,7 +613,17 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
#define FETCH_SIZE int *q=NULL;Py_ssize_t *q2=NULL;\
if (flags & FLAG_SIZE_T) q2=va_arg(*p_va, Py_ssize_t*); \
else q=va_arg(*p_va, int*);
-#define STORE_SIZE(s) if (flags & FLAG_SIZE_T) *q2=s; else *q=s;
+#define STORE_SIZE(s) \
+ if (flags & FLAG_SIZE_T) \
+ *q2=s; \
+ else { \
+ if (INT_MAX < s) { \
+ PyErr_SetString(PyExc_OverflowError, \
+ "size does not fit in an int"); \
+ return converterr("", arg, msgbuf, bufsize); \
+ } \
+ *q=s; \
+ }
#define BUFFER_LEN ((flags & FLAG_SIZE_T) ? *q2:*q)
const char *format = *p_format;
diff --git a/Python/peephole.c b/Python/peephole.c
index 06e7fe6..c27878c 100644
--- a/Python/peephole.c
+++ b/Python/peephole.c
@@ -124,6 +124,24 @@ fold_binops_on_constants(unsigned char *codestr, PyObject *consts)
break;
case BINARY_SUBSCR:
newconst = PyObject_GetItem(v, w);
+ /* #5057: if v is unicode, there might be differences between
+ wide and narrow builds in cases like '\U00012345'[0].
+ Wide builds will return a non-BMP char, whereas narrow builds
+ will return a surrogate. In both the cases skip the
+ optimization in order to produce compatible pycs.
+ */
+ if (newconst != NULL &&
+ PyUnicode_Check(v) && PyUnicode_Check(newconst)) {
+ Py_UNICODE ch = PyUnicode_AS_UNICODE(newconst)[0];
+#ifdef Py_UNICODE_WIDE
+ if (ch > 0xFFFF) {
+#else
+ if (ch >= 0xD800 && ch <= 0xDFFF) {
+#endif
+ Py_DECREF(newconst);
+ return 0;
+ }
+ }
break;
case BINARY_LSHIFT:
newconst = PyNumber_Lshift(v, w);
diff --git a/Python/pystate.c b/Python/pystate.c
index f1eb6d9..ea0d05d 100644
--- a/Python/pystate.c
+++ b/Python/pystate.c
@@ -503,7 +503,7 @@ _PyThread_CurrentFrames(void)
/* for i in all interpreters:
* for t in all of i's thread states:
* if t's frame isn't NULL, map t's id to its frame
- * Because these lists can mutute even when the GIL is held, we
+ * Because these lists can mutate even when the GIL is held, we
* need to grab head_mutex for the duration.
*/
HEAD_LOCK();
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index f85cc55..c688172 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -1065,8 +1065,6 @@ settrace() -- set the global debug tracing function\n\
/* end of sys_doc */ ;
/* Subversion branch and revision management */
-static const char _patchlevel_revision[] = PY_PATCHLEVEL_REVISION;
-static const char headurl[] = "$HeadURL$";
static int svn_initialized;
static char patchlevel_revision[50]; /* Just the number */
static char branch[50];
@@ -1076,64 +1074,14 @@ static const char *svn_revision;
static void
svnversion_init(void)
{
- const char *python, *br_start, *br_end, *br_end2, *svnversion;
- Py_ssize_t len;
- int istag = 0;
-
if (svn_initialized)
return;
- python = strstr(headurl, "/python/");
- if (!python) {
- strcpy(branch, "unknown branch");
- strcpy(shortbranch, "unknown");
- }
- else {
- br_start = python + 8;
- br_end = strchr(br_start, '/');
- assert(br_end);
-
- /* Works even for trunk,
- as we are in trunk/Python/sysmodule.c */
- br_end2 = strchr(br_end+1, '/');
-
- istag = strncmp(br_start, "tags", 4) == 0;
- if (strncmp(br_start, "trunk", 5) == 0) {
- strcpy(branch, "trunk");
- strcpy(shortbranch, "trunk");
- }
- else if (istag || strncmp(br_start, "branches", 8) == 0) {
- len = br_end2 - br_start;
- strncpy(branch, br_start, len);
- branch[len] = '\0';
-
- len = br_end2 - (br_end + 1);
- strncpy(shortbranch, br_end + 1, len);
- shortbranch[len] = '\0';
- }
- else {
- Py_FatalError("bad HeadURL");
- return;
- }
- }
-
-
- svnversion = _Py_svnversion();
- if (strcmp(svnversion, "Unversioned directory") != 0 && strcmp(svnversion, "exported") != 0)
- svn_revision = svnversion;
- else if (istag) {
- len = strlen(_patchlevel_revision);
- assert(len >= 13);
- assert(len < (sizeof(patchlevel_revision) + 13));
- strncpy(patchlevel_revision, _patchlevel_revision + 11,
- len - 13);
- patchlevel_revision[len - 13] = '\0';
- svn_revision = patchlevel_revision;
- }
- else
- svn_revision = "";
-
svn_initialized = 1;
+ *patchlevel_revision = '\0';
+ strcpy(branch, "");
+ strcpy(shortbranch, "unknown");
+ svn_revision = "";
}
/* Return svnversion output if available.
diff --git a/Python/thread.c b/Python/thread.c
index b4e3ad0..4a9b436 100644
--- a/Python/thread.c
+++ b/Python/thread.c
@@ -46,7 +46,7 @@
#endif
/* Check if we're running on HP-UX and _SC_THREADS is defined. If so, then
- enough of the Posix threads package is implimented to support python
+ enough of the Posix threads package is implemented to support python
threads.
This is valid for HP-UX 11.23 running on an ia64 system. If needed, add