diff --git a/Lib/dos-8x3/simpleht.py b/Lib/dos-8x3/simpleht.py
index 8a7775856c9..4cfedbc9fe9 100755
--- a/Lib/dos-8x3/simpleht.py
+++ b/Lib/dos-8x3/simpleht.py
@@ -6,7 +6,7 @@ and HEAD requests in a fairly straightforward manner.
"""
-__version__ = "0.4"
+__version__ = "0.5"
import os
@@ -99,6 +99,7 @@ class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
return None
list.sort(lambda a, b: cmp(a.lower(), b.lower()))
f = StringIO()
+ f.write("
Directory listing for %s\n" % self.path)
f.write("Directory listing for %s
\n" % self.path)
f.write("
\n\n")
for name in list:
@@ -107,7 +108,7 @@ class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
# Append / for directories or @ for symbolic links
if os.path.isdir(fullname):
displayname = name + "/"
- linkname = name + os.sep
+ linkname = name + "/"
if os.path.islink(fullname):
displayname = name + "@"
# Note: a link to a directory displays with @ and links with /
diff --git a/Lib/dos-8x3/sre_pars.py b/Lib/dos-8x3/sre_pars.py
index a50191ec9b0..55de24c5c1b 100644
--- a/Lib/dos-8x3/sre_pars.py
+++ b/Lib/dos-8x3/sre_pars.py
@@ -15,9 +15,9 @@ from sre_constants import *
MAXREPEAT = 65535
SPECIAL_CHARS = ".\\[{()*+?^$|"
-REPEAT_CHARS = "*+?{"
+REPEAT_CHARS = "*+?{"
-DIGITS = tuple("012345689")
+DIGITS = tuple("0123456789")
OCTDIGITS = tuple("01234567")
HEXDIGITS = tuple("0123456789abcdefABCDEF")
@@ -259,13 +259,12 @@ def _escape(source, escape, state):
# hexadecimal escape
while source.next in HEXDIGITS and len(escape) < 4:
escape = escape + source.get()
- escape = escape[2:]
- if len(escape) != 2:
- raise error, "bogus escape: %s" % repr("\\" + escape)
- return LITERAL, int(escape, 16) & 0xff
+ if len(escape) != 4:
+ raise ValueError
+ return LITERAL, int(escape[2:], 16) & 0xff
elif escape[1:2] == "0":
# octal escape
- while source.next in OCTDIGITS and len(escape) < 5:
+ while source.next in OCTDIGITS and len(escape) < 4:
escape = escape + source.get()
return LITERAL, int(escape[1:], 8) & 0xff
elif escape[1:2] in DIGITS:
@@ -273,7 +272,8 @@ def _escape(source, escape, state):
here = source.tell()
if source.next in DIGITS:
escape = escape + source.get()
- if escape[2] in OCTDIGITS and source.next in OCTDIGITS:
+ if (escape[1] in OCTDIGITS and escape[2] in OCTDIGITS and
+ source.next in OCTDIGITS):
# got three octal digits; this is an octal escape
escape = escape + source.get()
return LITERAL, int(escape[1:], 8) & 0xff
@@ -281,7 +281,7 @@ def _escape(source, escape, state):
group = _group(escape, state.groups)
if group:
return GROUPREF, group
- raise error, "bogus escape: %s" % repr(escape)
+ raise ValueError
if len(escape) == 2:
return LITERAL, ord(escape[1])
except ValueError:
diff --git a/Lib/dos-8x3/test_mma.py b/Lib/dos-8x3/test_mma.py
index 73c1a15b16d..449c674119d 100644
--- a/Lib/dos-8x3/test_mma.py
+++ b/Lib/dos-8x3/test_mma.py
@@ -40,7 +40,7 @@ def test_both():
assert m[0] == '3'
print ' Contents of first 3 bytes:', repr(m[0:3])
assert m[0:3] == '3\0\0'
- print ' Contents of second page:', m[PAGESIZE-1 : PAGESIZE + 7]
+ print ' Contents of second page:', repr(m[PAGESIZE-1 : PAGESIZE + 7])
assert m[PAGESIZE-1 : PAGESIZE + 7] == '\0foobar\0'
m.flush()
@@ -119,4 +119,3 @@ def test_both():
print ' Test passed'
test_both()
-
diff --git a/Lib/dos-8x3/test_pop.py b/Lib/dos-8x3/test_pop.py
index 26ef9d933ed..1215847bbcd 100644
--- a/Lib/dos-8x3/test_pop.py
+++ b/Lib/dos-8x3/test_pop.py
@@ -28,16 +28,20 @@ def _test():
print "Testing os module:"
import popen2
cmd = "cat"
- teststr = "abc\n"
- resultstr = teststr
+ teststr = "ab cd\n"
if os.name == "nt":
cmd = "more"
- resultstr = "\n" + resultstr
+ # "more" doesn't act the same way across Windows flavors,
+ # sometimes adding an extra newline at the start or the
+ # end. So we strip whitespace off both ends for comparison.
+ expected = teststr.strip()
print "testing popen2..."
w, r = os.popen2(cmd)
w.write(teststr)
w.close()
- assert r.read() == resultstr
+ got = r.read()
+ if got.strip() != expected:
+ raise ValueError("wrote %s read %s" % (`teststr`, `got`))
print "testing popen3..."
try:
w, r, e = os.popen3([cmd])
@@ -45,11 +49,16 @@ def _test():
w, r, e = os.popen3(cmd)
w.write(teststr)
w.close()
- assert r.read() == resultstr
- assert e.read() == ""
+ got = r.read()
+ if got.strip() != expected:
+ raise ValueError("wrote %s read %s" % (`teststr`, `got`))
+ got = e.read()
+ if got:
+ raise ValueError("unexected %s on stderr" % `got`)
for inst in popen2._active[:]:
inst.wait()
- assert not popen2._active
+ if popen2._active:
+ raise ValueError("_active not empty")
print "All OK"
main()
diff --git a/Lib/dos-8x3/webbrows.py b/Lib/dos-8x3/webbrows.py
index 5a4a80fa4e9..66cdbffc93e 100644
--- a/Lib/dos-8x3/webbrows.py
+++ b/Lib/dos-8x3/webbrows.py
@@ -183,9 +183,7 @@ register("grail", Grail)
class WindowsDefault:
def open(self, url, new=0):
- import win32api, win32con
- win32api.ShellExecute(0, "open", url, None, ".",
- win32con.SW_SHOWNORMAL)
+ self.junk = os.popen("start " + url)
def open_new(self, url):
self.open(url)