From 17467639bb6401ae8f53da3cd6238cab960c9f61 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Wed, 15 Apr 2015 17:40:07 -0700 Subject: Remove spurious text from build instructions README. It said "New text", an apparent test edit by MvL ages ago. --- README | 2 -- 1 file changed, 2 deletions(-) diff --git a/README b/README index 0ea31be..f5e4b3a 100644 --- a/README +++ b/README @@ -15,8 +15,6 @@ Build Instructions On Unix, Linux, BSD, OSX, and Cygwin: -New text - ./configure make make test -- cgit v0.12 From 4ac54bb8202d7123a2471f7710831b0080796cfe Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Sun, 19 Apr 2015 19:40:09 -0700 Subject: Force the buildbots to clean up all externals. --- Tools/buildbot/build.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tools/buildbot/build.bat b/Tools/buildbot/build.bat index 1debfc1..511fa1d 100644 --- a/Tools/buildbot/build.bat +++ b/Tools/buildbot/build.bat @@ -10,7 +10,7 @@ call "%~dp0clean%PLAT%.bat" @rem a new version of an external library, especially Tcl/Tk): @rem 1) uncomment the following line: -@rem call "%~dp0..\..\PCbuild\get_externals.bat" --clean-only +call "%~dp0..\..\PCbuild\get_externals.bat" --clean-only @rem 2) commit and push @rem 3) wait for all Windows bots to start a build with that changeset -- cgit v0.12 From 3c28c6e4fb311e47dca067458acab234e5a87ad9 Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Sun, 19 Apr 2015 19:45:51 -0700 Subject: Backed out buildbot clean --- Tools/buildbot/build.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tools/buildbot/build.bat b/Tools/buildbot/build.bat index 511fa1d..1debfc1 100644 --- a/Tools/buildbot/build.bat +++ b/Tools/buildbot/build.bat @@ -10,7 +10,7 @@ call "%~dp0clean%PLAT%.bat" @rem a new version of an external library, especially Tcl/Tk): @rem 1) uncomment the following line: -call "%~dp0..\..\PCbuild\get_externals.bat" --clean-only +@rem call "%~dp0..\..\PCbuild\get_externals.bat" --clean-only @rem 2) commit and push @rem 3) wait for all Windows bots to start a build with that changeset -- cgit v0.12 From 777af30645432cacda5c9b5df940d8fb27a1479c Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Sun, 19 Apr 2015 19:50:35 -0700 Subject: Minor fixes to Windows build scripts --- Tools/msi/make_zip.py | 13 ++++++++++--- Tools/msi/testrelease.bat | 5 ++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Tools/msi/make_zip.py b/Tools/msi/make_zip.py index 0032956..56d6f38 100644 --- a/Tools/msi/make_zip.py +++ b/Tools/msi/make_zip.py @@ -30,9 +30,16 @@ def include_in_lib(p): return False return True - if name in {'_ctypes_test.pyd', '_testbuffer.pyd', '_testcapi.pyd', '_testimportmultiple.pyd', 'xxlimited.pyd'}: - return False - return p.suffix.lower() not in {'.pyc', '.pyo'} + suffix = p.suffix.lower() + if suffix == '.pyd': + return name not in { + '_ctypes_test.pyd', + '_testbuffer.pyd', + '_testcapi.pyd', + '_testimportmultiple.pyd', + 'xxlimited.pyd', + } + return suffix not in {'.pyc', '.pyo'} def include_in_tools(p): if p.is_dir() and p.name.lower() in {'scripts', 'i18n', 'pynche', 'demo', 'parser'}: diff --git a/Tools/msi/testrelease.bat b/Tools/msi/testrelease.bat index b93306a..a989575 100644 --- a/Tools/msi/testrelease.bat +++ b/Tools/msi/testrelease.bat @@ -1,4 +1,4 @@ -@setlocal +@setlocal enableextensions @echo off set D=%~dp0 @@ -51,6 +51,9 @@ exit /B 0 @if not exist "%~1" exit /B 1 +@set EXE=%~1 +@if not "%EXE:embed=%"=="%EXE%" exit /B 0 + @set EXITCODE=0 @echo Installing %1 into %2 "%~1" /passive /log "%~2\install\log.txt" TargetDir="%~2\Python" Include_debug=1 Include_symbols=1 %~3 -- cgit v0.12 From cdbe29902e39cc575204ae1ac13505f3a699b8ba Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Sun, 19 Apr 2015 23:14:37 -0400 Subject: fix grammar --- Doc/library/urllib.request.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/urllib.request.rst b/Doc/library/urllib.request.rst index d878aac..0532481 100644 --- a/Doc/library/urllib.request.rst +++ b/Doc/library/urllib.request.rst @@ -1067,7 +1067,7 @@ The following W3C document, http://www.w3.org/International/O-charset\ , lists the various ways in which a (X)HTML or a XML document could have specified its encoding information. -As the python.org website uses *utf-8* encoding as specified in it's meta tag, we +As the python.org website uses *utf-8* encoding as specified in its meta tag, we will use the same for decoding the bytes object. :: >>> with urllib.request.urlopen('http://www.python.org/') as f: -- cgit v0.12 From 16b2e4f5480bb46a025f9d3a917a923e7f7f59f1 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Mon, 20 Apr 2015 09:22:13 +0300 Subject: Issue #23842: Added tests for os.major(), os.minor() and os.makedev(). --- Lib/test/test_posix.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py index 72fdd16..ce8f0b3 100644 --- a/Lib/test/test_posix.py +++ b/Lib/test/test_posix.py @@ -443,6 +443,36 @@ class PosixTester(unittest.TestCase): else: self.assertTrue(stat.S_ISFIFO(posix.stat(support.TESTFN).st_mode)) + @unittest.skipUnless(hasattr(posix, 'stat'), 'test needs posix.stat()') + @unittest.skipUnless(hasattr(posix, 'makedev'), 'test needs posix.makedev()') + def test_makedev(self): + st = posix.stat(support.TESTFN) + dev = st.st_dev + self.assertIsInstance(dev, int) + self.assertGreaterEqual(dev, 0) + + major = posix.major(dev) + self.assertIsInstance(major, int) + self.assertGreaterEqual(major, 0) + self.assertEqual(posix.major(dev), major) + self.assertRaises(TypeError, posix.major, float(dev)) + self.assertRaises(TypeError, posix.major) + self.assertRaises((ValueError, OverflowError), posix.major, -1) + + minor = posix.minor(dev) + self.assertIsInstance(minor, int) + self.assertGreaterEqual(minor, 0) + self.assertEqual(posix.minor(dev), minor) + self.assertRaises(TypeError, posix.minor, float(dev)) + self.assertRaises(TypeError, posix.minor) + self.assertRaises((ValueError, OverflowError), posix.minor, -1) + + self.assertEqual(posix.makedev(major, minor), dev) + self.assertRaises(TypeError, posix.makedev, float(major), minor) + self.assertRaises(TypeError, posix.makedev, major, float(minor)) + self.assertRaises(TypeError, posix.makedev, major) + self.assertRaises(TypeError, posix.makedev) + def _test_all_chown_common(self, chown_func, first_param, stat_func): """Common code for chown, fchown and lchown tests.""" def check_stat(uid, gid): -- cgit v0.12 From 2ef7c478444f453a04ae63ecc3d3de07915ad2b0 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Mon, 20 Apr 2015 09:26:49 +0300 Subject: Issue #23728: binascii.crc_hqx() could return an integer outside of the range 0-0xffff for empty data. --- Lib/test/test_binascii.py | 12 ++++++++++++ Misc/NEWS | 3 +++ Modules/binascii.c | 16 ++++++++-------- Modules/clinic/binascii.c.h | 14 +++++++------- 4 files changed, 30 insertions(+), 15 deletions(-) diff --git a/Lib/test/test_binascii.py b/Lib/test/test_binascii.py index 22d53af..50ad56e 100644 --- a/Lib/test/test_binascii.py +++ b/Lib/test/test_binascii.py @@ -136,6 +136,18 @@ class BinASCIITest(unittest.TestCase): # Issue #7701 (crash on a pydebug build) self.assertEqual(binascii.b2a_uu(b'x'), b'!> \n') + def test_crc_hqx(self): + crc = binascii.crc_hqx(self.type2test(b"Test the CRC-32 of"), 0) + crc = binascii.crc_hqx(self.type2test(b" this string."), crc) + self.assertEqual(crc, 14290) + + self.assertRaises(TypeError, binascii.crc_hqx) + self.assertRaises(TypeError, binascii.crc_hqx, self.type2test(b'')) + + for crc in 0, 1, 0x1234, 0x12345, 0x12345678, -1: + self.assertEqual(binascii.crc_hqx(self.type2test(b''), crc), + crc & 0xffff) + def test_crc32(self): crc = binascii.crc32(self.type2test(b"Test the CRC-32 of")) crc = binascii.crc32(self.type2test(b" this string."), crc) diff --git a/Misc/NEWS b/Misc/NEWS index 9c90792..84bd2cc 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -29,6 +29,9 @@ Core and Builtins Library ------- +- Issue #23728: binascii.crc_hqx() could return an integer outside of the range + 0-0xffff for empty data. + - Issue #23811: Add missing newline to the PyCompileError error message. Patch by Alex Shkop. diff --git a/Modules/binascii.c b/Modules/binascii.c index 4e6953b..ea14d3c 100644 --- a/Modules/binascii.c +++ b/Modules/binascii.c @@ -909,31 +909,31 @@ binascii_rledecode_hqx_impl(PyModuleDef *module, Py_buffer *data) /*[clinic input] -binascii.crc_hqx -> int +binascii.crc_hqx -> unsigned_int data: Py_buffer - crc: int + crc: unsigned_int(bitwise=True) / Compute hqx CRC incrementally. [clinic start generated code]*/ -static int -binascii_crc_hqx_impl(PyModuleDef *module, Py_buffer *data, int crc) -/*[clinic end generated code: output=634dac18dfa863d7 input=68060931b2f51c8a]*/ +static unsigned int +binascii_crc_hqx_impl(PyModuleDef *module, Py_buffer *data, unsigned int crc) +/*[clinic end generated code: output=167c2dac62625717 input=add8c53712ccceda]*/ { unsigned char *bin_data; - unsigned int ucrc = (unsigned int)crc; Py_ssize_t len; + crc &= 0xffff; bin_data = data->buf; len = data->len; while(len-- > 0) { - ucrc=((ucrc<<8)&0xff00)^crctab_hqx[((ucrc>>8)&0xff)^*bin_data++]; + crc = ((crc<<8)&0xff00) ^ crctab_hqx[(crc>>8)^*bin_data++]; } - return (int)ucrc; + return crc; } #ifndef USE_ZLIB_CRC32 diff --git a/Modules/clinic/binascii.c.h b/Modules/clinic/binascii.c.h index f647032..ef646dd 100644 --- a/Modules/clinic/binascii.c.h +++ b/Modules/clinic/binascii.c.h @@ -267,25 +267,25 @@ PyDoc_STRVAR(binascii_crc_hqx__doc__, #define BINASCII_CRC_HQX_METHODDEF \ {"crc_hqx", (PyCFunction)binascii_crc_hqx, METH_VARARGS, binascii_crc_hqx__doc__}, -static int -binascii_crc_hqx_impl(PyModuleDef *module, Py_buffer *data, int crc); +static unsigned int +binascii_crc_hqx_impl(PyModuleDef *module, Py_buffer *data, unsigned int crc); static PyObject * binascii_crc_hqx(PyModuleDef *module, PyObject *args) { PyObject *return_value = NULL; Py_buffer data = {NULL, NULL}; - int crc; - int _return_value; + unsigned int crc; + unsigned int _return_value; if (!PyArg_ParseTuple(args, - "y*i:crc_hqx", + "y*I:crc_hqx", &data, &crc)) goto exit; _return_value = binascii_crc_hqx_impl(module, &data, crc); if ((_return_value == -1) && PyErr_Occurred()) goto exit; - return_value = PyLong_FromLong((long)_return_value); + return_value = PyLong_FromUnsignedLong((unsigned long)_return_value); exit: /* Cleanup for data */ @@ -543,4 +543,4 @@ exit: return return_value; } -/*[clinic end generated code: output=e46d29f8c9adae7e input=a9049054013a1b77]*/ +/*[clinic end generated code: output=22761b36f4f9e5bb input=a9049054013a1b77]*/ -- cgit v0.12 From 2b0d2007a1a51a15a67dc7297cf5e21c8767b563 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Mon, 20 Apr 2015 09:53:58 +0300 Subject: Issue #23908: os functions now reject paths with embedded null character on Windows instead of silently truncate them. --- Lib/test/test_posix.py | 36 ++++++++++++++++++++++++++++++++++++ Misc/NEWS | 3 +++ Modules/_io/fileio.c | 13 ++++++------- Modules/posixmodule.c | 5 +++++ 4 files changed, 50 insertions(+), 7 deletions(-) diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py index ce8f0b3..aeb8924 100644 --- a/Lib/test/test_posix.py +++ b/Lib/test/test_posix.py @@ -1169,6 +1169,42 @@ class PosixTester(unittest.TestCase): else: self.fail("No valid path_error2() test for os." + name) + def test_path_with_null_character(self): + fn = support.TESTFN + fn_with_NUL = fn + '\0' + self.addCleanup(support.unlink, fn) + support.unlink(fn) + fd = None + try: + with self.assertRaises(TypeError): + fd = os.open(fn_with_NUL, os.O_WRONLY | os.O_CREAT) # raises + finally: + if fd is not None: + os.close(fd) + self.assertFalse(os.path.exists(fn)) + self.assertRaises(TypeError, os.mkdir, fn_with_NUL) + self.assertFalse(os.path.exists(fn)) + open(fn, 'wb').close() + self.assertRaises(TypeError, os.stat, fn_with_NUL) + + def test_path_with_null_byte(self): + fn = os.fsencode(support.TESTFN) + fn_with_NUL = fn + b'\0' + self.addCleanup(support.unlink, fn) + support.unlink(fn) + fd = None + try: + with self.assertRaises(ValueError): + fd = os.open(fn_with_NUL, os.O_WRONLY | os.O_CREAT) # raises + finally: + if fd is not None: + os.close(fd) + self.assertFalse(os.path.exists(fn)) + self.assertRaises(ValueError, os.mkdir, fn_with_NUL) + self.assertFalse(os.path.exists(fn)) + open(fn, 'wb').close() + self.assertRaises(ValueError, os.stat, fn_with_NUL) + class PosixGroupsTester(unittest.TestCase): def setUp(self): diff --git a/Misc/NEWS b/Misc/NEWS index 84bd2cc..e384e58 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -29,6 +29,9 @@ Core and Builtins Library ------- +- Issue #23908: os functions now reject paths with embedded null character + on Windows instead of silently truncate them. + - Issue #23728: binascii.crc_hqx() could return an integer outside of the range 0-0xffff for empty data. diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c index 95bcb77..74508a7 100644 --- a/Modules/_io/fileio.c +++ b/Modules/_io/fileio.c @@ -275,15 +275,14 @@ fileio_init(PyObject *oself, PyObject *args, PyObject *kwds) #ifdef MS_WINDOWS if (PyUnicode_Check(nameobj)) { - int rv = _PyUnicode_HasNULChars(nameobj); - if (rv) { - if (rv != -1) - PyErr_SetString(PyExc_TypeError, "embedded NUL character"); - return -1; - } - widename = PyUnicode_AsUnicode(nameobj); + Py_ssize_t length; + widename = PyUnicode_AsUnicodeAndSize(nameobj, &length); if (widename == NULL) return -1; + if (wcslen(widename) != length) { + PyErr_SetString(PyExc_TypeError, "embedded NUL character"); + return -1; + } } else #endif if (fd < 0) diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index d45f59e..e538437 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -858,6 +858,11 @@ path_converter(PyObject *o, void *p) { Py_DECREF(unicode); return 0; } + if (wcslen(wide) != length) { + FORMAT_EXCEPTION(PyExc_TypeError, "embedded null character"); + Py_DECREF(unicode); + return 0; + } path->wide = wide; path->narrow = NULL; -- cgit v0.12