summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-07-10 08:30:03 (GMT)
committerGuido van Rossum <guido@python.org>2007-07-10 08:30:03 (GMT)
commita0982944464b94c2965e4776f376b66903f82764 (patch)
treeda605f1e21057be547c9e75b73261ae815f38b34 /Lib
parent6718062538e642d62c626fd033f2c3a2356c5505 (diff)
downloadcpython-a0982944464b94c2965e4776f376b66903f82764.zip
cpython-a0982944464b94c2965e4776f376b66903f82764.tar.gz
cpython-a0982944464b94c2965e4776f376b66903f82764.tar.bz2
Make test_urllib.py pass. Mostly str/bytes issues.
Also fix mac toolbox glue to accept str, str8, bytes for 255-byte strings.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_urllib.py6
-rw-r--r--Lib/urllib.py4
2 files changed, 5 insertions, 5 deletions
diff --git a/Lib/test/test_urllib.py b/Lib/test/test_urllib.py
index 7a3f207..e94fc22 100644
--- a/Lib/test/test_urllib.py
+++ b/Lib/test/test_urllib.py
@@ -30,7 +30,7 @@ class urlopen_FileTests(unittest.TestCase):
def setUp(self):
"""Setup of a temp file to use for testing"""
- self.text = "test_urllib: %s\n" % self.__class__.__name__
+ self.text = bytes("test_urllib: %s\n" % self.__class__.__name__)
FILE = open(test_support.TESTFN, 'wb')
try:
FILE.write(self.text)
@@ -57,7 +57,7 @@ class urlopen_FileTests(unittest.TestCase):
def test_readline(self):
self.assertEqual(self.text, self.returned_obj.readline())
- self.assertEqual('', self.returned_obj.readline(),
+ self.assertEqual(b'', self.returned_obj.readline(),
"calling readline() after exhausting the file did not"
" return an empty string")
@@ -150,7 +150,7 @@ class urlretrieve_FileTests(unittest.TestCase):
# Create a temporary file.
self.registerFileForCleanUp(test_support.TESTFN)
- self.text = 'testing urllib.urlretrieve'
+ self.text = b'testing urllib.urlretrieve'
try:
FILE = open(test_support.TESTFN, 'wb')
FILE.write(self.text)
diff --git a/Lib/urllib.py b/Lib/urllib.py
index c6bd87f..dcd906c 100644
--- a/Lib/urllib.py
+++ b/Lib/urllib.py
@@ -245,7 +245,7 @@ class URLopener:
reporthook(blocknum, bs, size)
while 1:
block = fp.read(bs)
- if block == "":
+ if not block:
break
read += len(block)
tfp.write(block)
@@ -976,7 +976,7 @@ def toBytes(url):
def unwrap(url):
"""unwrap('<URL:type://host/path>') --> 'type://host/path'."""
- url = url.strip()
+ url = str(url).strip()
if url[:1] == '<' and url[-1:] == '>':
url = url[1:-1].strip()
if url[:4] == 'URL:': url = url[4:].strip()