diff options
-rw-r--r-- | Lib/test/test_ioctl.py | 10 | ||||
-rw-r--r-- | Lib/test/test_urllib2_localnet.py | 24 | ||||
-rw-r--r-- | Misc/NEWS | 5 | ||||
-rw-r--r-- | Objects/stringlib/fastsearch.h | 4 | ||||
-rwxr-xr-x | Tools/scripts/2to3 | 3 |
5 files changed, 41 insertions, 5 deletions
diff --git a/Lib/test/test_ioctl.py b/Lib/test/test_ioctl.py index 7fc9c08..51da6a3 100644 --- a/Lib/test/test_ioctl.py +++ b/Lib/test/test_ioctl.py @@ -7,9 +7,17 @@ get_attribute(termios, 'TIOCGPGRP') #Can't run tests without this feature try: tty = open("/dev/tty", "r") - tty.close() except IOError: raise unittest.SkipTest("Unable to open /dev/tty") +else: + # Skip if another process is in foreground + r = fcntl.ioctl(tty, termios.TIOCGPGRP, " ") + tty.close() + rpgrp = struct.unpack("i", r)[0] + if rpgrp not in (os.getpgrp(), os.getsid(0)): + raise unittest.SkipTest("Neither the process group nor the session " + "are attached to /dev/tty") + del tty, r, rpgrp try: import pty diff --git a/Lib/test/test_urllib2_localnet.py b/Lib/test/test_urllib2_localnet.py index ef2614bc..5d8a484 100644 --- a/Lib/test/test_urllib2_localnet.py +++ b/Lib/test/test_urllib2_localnet.py @@ -501,6 +501,30 @@ class TestUrlopen(BaseTestCase): # parameterize the framework with a mock resolver. urllib2.urlopen, "http://sadflkjsasf.i.nvali.d./") + def test_iteration(self): + expected_response = "pycon 2008..." + handler = self.start_server([(200, [], expected_response)]) + try: + data = urllib2.urlopen("http://localhost:%s" % handler.port) + for line in data: + self.assertEqual(line, expected_response) + finally: + self.server.stop() + + def ztest_line_iteration(self): + lines = ["We\n", "got\n", "here\n", "verylong " * 8192 + "\n"] + expected_response = "".join(lines) + handler = self.start_server([(200, [], expected_response)]) + try: + data = urllib2.urlopen("http://localhost:%s" % handler.port) + for index, line in enumerate(data): + self.assertEqual(line, lines[index], + "Fetched line number %s doesn't match expected:\n" + " Expected length was %s, got %s" % + (index, len(lines[index]), len(line))) + finally: + self.server.stop() + self.assertEqual(index + 1, len(lines)) def test_main(): # We will NOT depend on the network resource flag @@ -12,6 +12,9 @@ What's New in Python 2.7.1? Core and Builtins ----------------- +- Issue #8530: Prevent stringlib fastsearch from reading beyond the front + of an array. + - Issue #83755: Implicit set-to-frozenset conversion was not thread-safe. - Issue #9416: Fix some issues with complex formatting where the @@ -203,6 +206,8 @@ Build Tests ----- +- Issue #7564: Skip test_ioctl if another process is attached to /dev/tty. + - Issue #8433: Fix test_curses failure with newer versions of ncurses. - Issue #9496: Provide a test suite for the rlcompleter module. Patch by diff --git a/Objects/stringlib/fastsearch.h b/Objects/stringlib/fastsearch.h index 7525951..e231c58 100644 --- a/Objects/stringlib/fastsearch.h +++ b/Objects/stringlib/fastsearch.h @@ -140,13 +140,13 @@ fastsearch(const STRINGLIB_CHAR* s, Py_ssize_t n, /* got a match! */ return i; /* miss: check if previous character is part of pattern */ - if (!STRINGLIB_BLOOM(mask, s[i-1])) + if (i > 0 && !STRINGLIB_BLOOM(mask, s[i-1])) i = i - m; else i = i - skip; } else { /* skip: check if previous character is part of pattern */ - if (!STRINGLIB_BLOOM(mask, s[i-1])) + if (i > 0 && !STRINGLIB_BLOOM(mask, s[i-1])) i = i - m; } } diff --git a/Tools/scripts/2to3 b/Tools/scripts/2to3 index 2a447cf..fbd4aa6 100755 --- a/Tools/scripts/2to3 +++ b/Tools/scripts/2to3 @@ -1,6 +1,5 @@ #!/usr/bin/env python -from lib2to3.main import main import sys -import os +from lib2to3.main import main sys.exit(main("lib2to3.fixes")) |