diff -r a9680746ae4a -r f3c7f4243a04 Lib/json/tests/test_unicode.py --- a/Lib/json/tests/test_unicode.py Fri Jan 13 22:53:25 2012 +0100 +++ b/Lib/json/tests/test_unicode.py Fri Jan 13 17:37:18 2012 -0500 @@ -80,10 +80,6 @@ # Issue 10038. self.assertEqual(type(self.loads('"foo"')), unicode) - def test_bad_encoding(self): - self.assertRaises(UnicodeEncodeError, self.loads, '"a"', u"rat\xe9") - self.assertRaises(TypeError, self.loads, '"a"', 1) - class TestPyUnicode(TestUnicode, PyTest): pass class TestCUnicode(TestUnicode, CTest): pass diff -r a9680746ae4a -r f3c7f4243a04 Misc/NEWS --- a/Misc/NEWS Fri Jan 13 22:53:25 2012 +0100 +++ b/Misc/NEWS Fri Jan 13 17:37:18 2012 -0500 @@ -374,9 +374,6 @@ Extension Modules ----------------- -- Issue #13774: json: Fix a SystemError when a bogus encoding is passed to - json.loads(). - - Issue #9975: socket: Fix incorrect use of flowinfo and scope_id. Patch by Vilmos Nebehaj. diff -r a9680746ae4a -r f3c7f4243a04 Modules/_json.c --- a/Modules/_json.c Fri Jan 13 22:53:25 2012 +0100 +++ b/Modules/_json.c Fri Jan 13 17:37:18 2012 -0500 @@ -1725,15 +1725,8 @@ Py_DECREF(s->encoding); s->encoding = tmp; } - if (s->encoding == NULL) + if (s->encoding == NULL || !PyString_Check(s->encoding)) goto bail; - if (!PyString_Check(s->encoding)) { - PyErr_Format(PyExc_TypeError, - "encoding must be a string, not %.80s", - Py_TYPE(s->encoding)->tp_name); - goto bail; - } - /* All of these will fail "gracefully" so we don't need to verify them */ s->strict = PyObject_GetAttrString(ctx, "strict"); diff -r a9680746ae4a -r f3c7f4243a04 Python/import.c --- a/Python/import.c Fri Jan 13 22:53:25 2012 +0100 +++ b/Python/import.c Fri Jan 13 17:37:18 2012 -0500 @@ -114,6 +114,34 @@ }; #endif +#ifdef MS_WINDOWS +int isdir(char *path) { + DWORD rv; + /* see issue1293 and issue3677: + * stat() on Windows doesn't recognise paths like + * "e:\\shared\\" and "\\\\whiterab-c2znlh\\shared" as dirs. + * Also reference issue6727: + * stat() on Windows is broken and doesn't resolve symlinks properly. + */ + rv = GetFileAttributesA(path); + return rv != INVALID_FILE_ATTRIBUTES && rv & FILE_ATTRIBUTE_DIRECTORY; +} +#else +#if HAVE_STAT +int isdir(char *path) { + struct stat statbuf; + return stat(path, &statbuf) == 0 && S_ISDIR(statbuf.st_mode); +} +#else +#ifdef RISCOS +/* with RISCOS, isdir is in unixstuff */ +#else +int isdir(char *path) { + return 0; +} +#endif /* RISCOS */ +#endif /* HAVE_STAT */ +#endif /* MS_WINDOWS */ /* Initialize things */ @@ -1207,9 +1235,6 @@ char *filemode; FILE *fp = NULL; PyObject *path_hooks, *path_importer_cache; -#ifndef RISCOS - struct stat statbuf; -#endif static struct filedescr fd_frozen = {"", "", PY_FROZEN}; static struct filedescr fd_builtin = {"", "", C_BUILTIN}; static struct filedescr fd_package = {"", "", PKG_DIRECTORY}; @@ -1395,9 +1420,7 @@ /* Check for package import (buf holds a directory name, and there's an __init__ module in that directory */ -#ifdef HAVE_STAT - if (stat(buf, &statbuf) == 0 && /* it exists */ - S_ISDIR(statbuf.st_mode) && /* it's a directory */ + if (isdir(buf) && /* it's an existing directory */ case_ok(buf, len, namelen, name)) { /* case matches */ if (find_init_module(buf)) { /* and has __init__.py */ Py_XDECREF(copy); @@ -1415,28 +1438,6 @@ } } } -#else - /* XXX How are you going to test for directories? */ -#ifdef RISCOS - if (isdir(buf) && - case_ok(buf, len, namelen, name)) { - if (find_init_module(buf)) { - Py_XDECREF(copy); - return &fd_package; - } - else { - char warnstr[MAXPATHLEN+80]; - sprintf(warnstr, "Not importing directory " - "'%.*s': missing __init__.py", - MAXPATHLEN, buf); - if (PyErr_Warn(PyExc_ImportWarning, - warnstr)) { - Py_XDECREF(copy); - return NULL; - } - } -#endif -#endif #if defined(PYOS_OS2) /* take a snapshot of the module spec for restoration * after the 8 character DLL hackery @@ -3202,49 +3203,11 @@ PyErr_SetString(PyExc_ImportError, "empty pathname"); return -1; } else { -#ifndef RISCOS -#ifndef MS_WINDOWS - struct stat statbuf; - int rv; - - rv = stat(path, &statbuf); - if (rv == 0) { - /* it exists */ - if (S_ISDIR(statbuf.st_mode)) { - /* it's a directory */ - PyErr_SetString(PyExc_ImportError, - "existing directory"); - return -1; - } - } -#else /* MS_WINDOWS */ - DWORD rv; - /* see issue1293 and issue3677: - * stat() on Windows doesn't recognise paths like - * "e:\\shared\\" and "\\\\whiterab-c2znlh\\shared" as dirs. - */ - rv = GetFileAttributesA(path); - if (rv != INVALID_FILE_ATTRIBUTES) { - /* it exists */ - if (rv & FILE_ATTRIBUTE_DIRECTORY) { - /* it's a directory */ - PyErr_SetString(PyExc_ImportError, - "existing directory"); - return -1; - } - } -#endif -#else /* RISCOS */ - if (object_exists(path)) { - /* it exists */ - if (isdir(path)) { - /* it's a directory */ - PyErr_SetString(PyExc_ImportError, - "existing directory"); - return -1; - } - } -#endif + if(isdir(path)) { + PyErr_SetString(PyExc_ImportError, + "existing directory"); + return -1; + } } return 0; }