mirror of
https://github.com/python/cpython.git
synced 2025-10-03 05:35:59 +00:00
SF patch #474590 -- RISC OS support
This commit is contained in:
parent
c6ac8a78f6
commit
e2ae77b8b8
33 changed files with 256 additions and 188 deletions
|
@ -153,6 +153,10 @@ typedef LONG_LONG Py_intptr_t;
|
||||||
#define HAVE_FSTAT
|
#define HAVE_FSTAT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef RISCOS
|
||||||
|
#include <sys/types.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef DONT_HAVE_SYS_STAT_H
|
#ifndef DONT_HAVE_SYS_STAT_H
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#elif defined(HAVE_STAT_H)
|
#elif defined(HAVE_STAT_H)
|
||||||
|
|
|
@ -33,13 +33,9 @@ error = IOError # For anydbm
|
||||||
class _Database:
|
class _Database:
|
||||||
|
|
||||||
def __init__(self, file):
|
def __init__(self, file):
|
||||||
if _os.sep == '.':
|
self._dirfile = file + _os.extsep + 'dir'
|
||||||
endsep = '/'
|
self._datfile = file + _os.extsep + 'dat'
|
||||||
else:
|
self._bakfile = file + _os.extsep + 'bak'
|
||||||
endsep = '.'
|
|
||||||
self._dirfile = file + endsep + 'dir'
|
|
||||||
self._datfile = file + endsep + 'dat'
|
|
||||||
self._bakfile = file + endsep + 'bak'
|
|
||||||
# Mod by Jack: create data file if needed
|
# Mod by Jack: create data file if needed
|
||||||
try:
|
try:
|
||||||
f = _open(self._datfile, 'r')
|
f = _open(self._datfile, 'r')
|
||||||
|
|
|
@ -235,7 +235,7 @@ class FileInput:
|
||||||
else:
|
else:
|
||||||
if self._inplace:
|
if self._inplace:
|
||||||
self._backupfilename = (
|
self._backupfilename = (
|
||||||
self._filename + (self._backup or ".bak"))
|
self._filename + (self._backup or os.extsep+"bak"))
|
||||||
try: os.unlink(self._backupfilename)
|
try: os.unlink(self._backupfilename)
|
||||||
except os.error: pass
|
except os.error: pass
|
||||||
# The next few lines may raise IOError
|
# The next few lines may raise IOError
|
||||||
|
|
|
@ -7,6 +7,7 @@ This exports:
|
||||||
- os.curdir is a string representing the current directory ('.' or ':')
|
- os.curdir is a string representing the current directory ('.' or ':')
|
||||||
- os.pardir is a string representing the parent directory ('..' or '::')
|
- os.pardir is a string representing the parent directory ('..' or '::')
|
||||||
- os.sep is the (or a most common) pathname separator ('/' or ':' or '\\')
|
- os.sep is the (or a most common) pathname separator ('/' or ':' or '\\')
|
||||||
|
- os.extsep is the extension separator ('.' or '/')
|
||||||
- os.altsep is the alternate pathname separator (None or '/')
|
- os.altsep is the alternate pathname separator (None or '/')
|
||||||
- os.pathsep is the component separator used in $PATH etc
|
- os.pathsep is the component separator used in $PATH etc
|
||||||
- os.linesep is the line separator in text files ('\r' or '\n' or '\r\n')
|
- os.linesep is the line separator in text files ('\r' or '\n' or '\r\n')
|
||||||
|
@ -168,6 +169,12 @@ elif 'riscos' in _names:
|
||||||
else:
|
else:
|
||||||
raise ImportError, 'no os specific module found'
|
raise ImportError, 'no os specific module found'
|
||||||
|
|
||||||
|
|
||||||
|
if sep=='.':
|
||||||
|
extsep = '/'
|
||||||
|
else:
|
||||||
|
extsep = '.'
|
||||||
|
|
||||||
__all__.append("path")
|
__all__.append("path")
|
||||||
|
|
||||||
del _names
|
del _names
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
"""A more or less complete user-defined wrapper around dictionary objects."""
|
"""A more or less complete dictionary like interface for the RISC OS environment."""
|
||||||
|
|
||||||
import riscos
|
import riscos
|
||||||
|
|
||||||
|
@ -8,8 +8,7 @@ class _Environ:
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return repr(riscos.getenvdict())
|
return repr(riscos.getenvdict())
|
||||||
def __cmp__(self, dict):
|
def __cmp__(self, dict):
|
||||||
if isinstance(dict, UserDict):
|
return cmp(riscos.getenvdict(), dict)
|
||||||
return cmp(riscos.getenvdict(), dict)
|
|
||||||
def __len__(self):
|
def __len__(self):
|
||||||
return len(riscos.getenvdict())
|
return len(riscos.getenvdict())
|
||||||
def __getitem__(self, key):
|
def __getitem__(self, key):
|
||||||
|
|
|
@ -103,8 +103,10 @@ def join(a, *p):
|
||||||
j= a
|
j= a
|
||||||
for b in p:
|
for b in p:
|
||||||
(fs, drive, path)= _split(b)
|
(fs, drive, path)= _split(b)
|
||||||
if fs!='' or drive!='' or path[:1] in _roots:
|
if j=='' or fs!='' or drive!='' or path[:1] in _roots:
|
||||||
j= b
|
j= b
|
||||||
|
elif j[-1]==':':
|
||||||
|
j= j+b
|
||||||
else:
|
else:
|
||||||
j= j+'.'+b
|
j= j+'.'+b
|
||||||
return j
|
return j
|
||||||
|
|
|
@ -6,15 +6,26 @@ import string
|
||||||
import urllib
|
import urllib
|
||||||
import os
|
import os
|
||||||
|
|
||||||
def url2pathname(pathname):
|
__all__ = ["url2pathname","pathname2url"]
|
||||||
"Convert /-delimited pathname to mac pathname"
|
|
||||||
#
|
__slash_dot = string.maketrans("/.", "./")
|
||||||
# XXXX The .. handling should be fixed...
|
|
||||||
#
|
def url2pathname(url):
|
||||||
tp = urllib.splittype(pathname)[0]
|
"Convert URL to a RISC OS path."
|
||||||
|
tp = urllib.splittype(url)[0]
|
||||||
if tp and tp <> 'file':
|
if tp and tp <> 'file':
|
||||||
raise RuntimeError, 'Cannot convert non-local URL to pathname'
|
raise RuntimeError, 'Cannot convert non-local URL to pathname'
|
||||||
components = string.split(pathname, '/')
|
# Turn starting /// into /, an empty hostname means current host
|
||||||
|
if url[:3] == '///':
|
||||||
|
url = url[2:]
|
||||||
|
elif url[:2] == '//':
|
||||||
|
raise RuntimeError, 'Cannot convert non-local URL to pathname'
|
||||||
|
components = string.split(url, '/')
|
||||||
|
if not components[0]:
|
||||||
|
if '$' in components:
|
||||||
|
del components[0]
|
||||||
|
else:
|
||||||
|
components[0] = '$'
|
||||||
# Remove . and embedded ..
|
# Remove . and embedded ..
|
||||||
i = 0
|
i = 0
|
||||||
while i < len(components):
|
while i < len(components):
|
||||||
|
@ -23,59 +34,35 @@ def url2pathname(pathname):
|
||||||
elif components[i] == '..' and i > 0 and \
|
elif components[i] == '..' and i > 0 and \
|
||||||
components[i-1] not in ('', '..'):
|
components[i-1] not in ('', '..'):
|
||||||
del components[i-1:i+1]
|
del components[i-1:i+1]
|
||||||
i = i-1
|
i -= 1
|
||||||
|
elif components[i] == '..':
|
||||||
|
components[i] = '^'
|
||||||
|
i += 1
|
||||||
elif components[i] == '' and i > 0 and components[i-1] <> '':
|
elif components[i] == '' and i > 0 and components[i-1] <> '':
|
||||||
del components[i]
|
del components[i]
|
||||||
else:
|
else:
|
||||||
if components[i]<>'..' and string.find(components[i], '.')<>-1 :
|
i += 1
|
||||||
components[i] = string.join(string.split(components[i],'.'),'/')
|
components = map(lambda x: urllib.unquote(x).translate(__slash_dot), components)
|
||||||
i = i+1
|
return '.'.join(components)
|
||||||
if not components[0]:
|
|
||||||
# Absolute unix path, don't start with colon
|
|
||||||
return string.join(components[1:], '.')
|
|
||||||
else:
|
|
||||||
# relative unix path, start with colon. First replace
|
|
||||||
# leading .. by empty strings (giving ::file)
|
|
||||||
i = 0
|
|
||||||
while i < len(components) and components[i] == '..':
|
|
||||||
components[i] = '^'
|
|
||||||
i = i + 1
|
|
||||||
return string.join(components, '.')
|
|
||||||
|
|
||||||
def pathname2url(pathname):
|
def pathname2url(pathname):
|
||||||
"convert mac pathname to /-delimited pathname"
|
"Convert a RISC OS path name to a file url."
|
||||||
if '/' in pathname:
|
return urllib.quote('///' + pathname.translate(__slash_dot), "/$:")
|
||||||
raise RuntimeError, "Cannot convert pathname containing slashes"
|
|
||||||
components = string.split(pathname, ':')
|
|
||||||
# Replace empty string ('::') by .. (will result in '/../' later)
|
|
||||||
for i in range(1, len(components)):
|
|
||||||
if components[i] == '':
|
|
||||||
components[i] = '..'
|
|
||||||
# Truncate names longer than 31 bytes
|
|
||||||
components = map(lambda x: x[:31], components)
|
|
||||||
|
|
||||||
if os.path.isabs(pathname):
|
|
||||||
return '/' + string.join(components, '/')
|
|
||||||
else:
|
|
||||||
return string.join(components, '/')
|
|
||||||
|
|
||||||
def test():
|
def test():
|
||||||
for url in ["index.html",
|
for url in ["index.html",
|
||||||
"/SCSI::SCSI4/$/Anwendung/Comm/Apps/!Fresco/Welcome",
|
"/SCSI::SCSI4/$/Anwendung/Comm/Apps/!Fresco/Welcome",
|
||||||
|
"/SCSI::SCSI4/$/Anwendung/Comm/Apps/../!Fresco/Welcome",
|
||||||
"../index.html",
|
"../index.html",
|
||||||
"bar/index.html",
|
"bar/index.html",
|
||||||
"/foo/bar/index.html",
|
"/foo/bar/index.html",
|
||||||
"/foo/bar/",
|
"/foo/bar/",
|
||||||
"/"]:
|
"/"]:
|
||||||
print `url`, '->', `url2pathname(url)`
|
print `url`, '->', `url2pathname(url)`
|
||||||
for path in ["drive:",
|
print "*******************************************************"
|
||||||
"drive:dir:",
|
for path in ["SCSI::SCSI4.$.Anwendung",
|
||||||
"drive:dir:file",
|
"PythonApp:Lib",
|
||||||
"drive:file",
|
"PythonApp:Lib.rourl2path/py"]:
|
||||||
"file",
|
|
||||||
":file",
|
|
||||||
":dir:",
|
|
||||||
":dir:file"]:
|
|
||||||
print `path`, '->', `pathname2url(path)`
|
print `path`, '->', `pathname2url(path)`
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -59,11 +59,6 @@ ImportError exception, it is silently ignored.
|
||||||
|
|
||||||
import sys, os
|
import sys, os
|
||||||
|
|
||||||
if os.sep==".":
|
|
||||||
endsep = "/"
|
|
||||||
else:
|
|
||||||
endsep = "."
|
|
||||||
|
|
||||||
|
|
||||||
def makepath(*paths):
|
def makepath(*paths):
|
||||||
dir = os.path.abspath(os.path.join(*paths))
|
dir = os.path.abspath(os.path.join(*paths))
|
||||||
|
@ -129,7 +124,7 @@ def addsitedir(sitedir):
|
||||||
return
|
return
|
||||||
names.sort()
|
names.sort()
|
||||||
for name in names:
|
for name in names:
|
||||||
if name[-4:] == endsep + "pth":
|
if name[-4:] == os.extsep + "pth":
|
||||||
addpackage(sitedir, name)
|
addpackage(sitedir, name)
|
||||||
if reset:
|
if reset:
|
||||||
_dirs_in_sys_path = None
|
_dirs_in_sys_path = None
|
||||||
|
|
|
@ -48,7 +48,7 @@ __all__.extend(os._get_exports_list(_socket))
|
||||||
|
|
||||||
if (sys.platform.lower().startswith("win")
|
if (sys.platform.lower().startswith("win")
|
||||||
or (hasattr(os, 'uname') and os.uname()[0] == "BeOS")
|
or (hasattr(os, 'uname') and os.uname()[0] == "BeOS")
|
||||||
or (sys.platform=="RISCOS")):
|
or (sys.platform=="riscos")):
|
||||||
|
|
||||||
_realsocketcall = _socket.socket
|
_realsocketcall = _socket.socket
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,10 @@ def gettempdir():
|
||||||
attempdirs.insert(0, dirname)
|
attempdirs.insert(0, dirname)
|
||||||
except macfs.error:
|
except macfs.error:
|
||||||
pass
|
pass
|
||||||
|
elif os.name == 'riscos':
|
||||||
|
scrapdir = os.getenv('Wimp$ScrapDir')
|
||||||
|
if scrapdir:
|
||||||
|
attempdirs.insert(0, scrapdir)
|
||||||
for envname in 'TMPDIR', 'TEMP', 'TMP':
|
for envname in 'TMPDIR', 'TEMP', 'TMP':
|
||||||
if os.environ.has_key(envname):
|
if os.environ.has_key(envname):
|
||||||
attempdirs.insert(0, os.environ[envname])
|
attempdirs.insert(0, os.environ[envname])
|
||||||
|
@ -87,7 +91,7 @@ if os.name == "posix":
|
||||||
# string.
|
# string.
|
||||||
elif os.name == "nt":
|
elif os.name == "nt":
|
||||||
template = '~' + `os.getpid()` + '-'
|
template = '~' + `os.getpid()` + '-'
|
||||||
elif os.name == 'mac':
|
elif os.name in ('mac', 'riscos'):
|
||||||
template = 'Python-Tmp-'
|
template = 'Python-Tmp-'
|
||||||
else:
|
else:
|
||||||
template = 'tmp' # XXX might choose a better one
|
template = 'tmp' # XXX might choose a better one
|
||||||
|
|
|
@ -156,7 +156,7 @@ def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0,
|
||||||
pass
|
pass
|
||||||
for i in range(len(args)):
|
for i in range(len(args)):
|
||||||
# Strip trailing ".py" from arguments
|
# Strip trailing ".py" from arguments
|
||||||
if args[i][-3:] == '.py':
|
if args[i][-3:] == os.extsep+'py':
|
||||||
args[i] = args[i][:-3]
|
args[i] = args[i][:-3]
|
||||||
stdtests = STDTESTS[:]
|
stdtests = STDTESTS[:]
|
||||||
nottests = NOTTESTS[:]
|
nottests = NOTTESTS[:]
|
||||||
|
@ -272,7 +272,7 @@ def findtests(testdir=None, stdtests=STDTESTS, nottests=NOTTESTS):
|
||||||
names = os.listdir(testdir)
|
names = os.listdir(testdir)
|
||||||
tests = []
|
tests = []
|
||||||
for name in names:
|
for name in names:
|
||||||
if name[:5] == "test_" and name[-3:] == ".py":
|
if name[:5] == "test_" and name[-3:] == os.extsep+"py":
|
||||||
modname = name[:-3]
|
modname = name[:-3]
|
||||||
if modname not in stdtests and modname not in nottests:
|
if modname not in stdtests and modname not in nottests:
|
||||||
tests.append(modname)
|
tests.append(modname)
|
||||||
|
@ -576,6 +576,48 @@ _expectations = {
|
||||||
test_winreg
|
test_winreg
|
||||||
test_winsound
|
test_winsound
|
||||||
""",
|
""",
|
||||||
|
'riscos':
|
||||||
|
"""
|
||||||
|
test_al
|
||||||
|
test_asynchat
|
||||||
|
test_bsddb
|
||||||
|
test_cd
|
||||||
|
test_cl
|
||||||
|
test_commands
|
||||||
|
test_crypt
|
||||||
|
test_dbm
|
||||||
|
test_dl
|
||||||
|
test_fcntl
|
||||||
|
test_fork1
|
||||||
|
test_gdbm
|
||||||
|
test_gl
|
||||||
|
test_grp
|
||||||
|
test_imgfile
|
||||||
|
test_largefile
|
||||||
|
test_linuxaudiodev
|
||||||
|
test_locale
|
||||||
|
test_mmap
|
||||||
|
test_nis
|
||||||
|
test_ntpath
|
||||||
|
test_openpty
|
||||||
|
test_poll
|
||||||
|
test_popen2
|
||||||
|
test_pty
|
||||||
|
test_pwd
|
||||||
|
test_socket_ssl
|
||||||
|
test_socketserver
|
||||||
|
test_strop
|
||||||
|
test_sunaudiodev
|
||||||
|
test_sundry
|
||||||
|
test_thread
|
||||||
|
test_threaded_import
|
||||||
|
test_threadedtempfile
|
||||||
|
test_threading
|
||||||
|
test_timing
|
||||||
|
test_unicode_file
|
||||||
|
test_winreg
|
||||||
|
test_winsound
|
||||||
|
""",
|
||||||
}
|
}
|
||||||
|
|
||||||
class _ExpectedSkips:
|
class _ExpectedSkips:
|
||||||
|
|
|
@ -7,17 +7,17 @@
|
||||||
|
|
||||||
from test_support import verbose, unlink
|
from test_support import verbose, unlink
|
||||||
|
|
||||||
import imageop, uu
|
import imageop, uu, os
|
||||||
|
|
||||||
def main(use_rgbimg=1):
|
def main(use_rgbimg=1):
|
||||||
|
|
||||||
# Create binary test files
|
# Create binary test files
|
||||||
uu.decode(get_qualified_path('testrgb.uue'), 'test.rgb')
|
uu.decode(get_qualified_path('testrgb'+os.extsep+'uue'), 'test'+os.extsep+'rgb')
|
||||||
|
|
||||||
if use_rgbimg:
|
if use_rgbimg:
|
||||||
image, width, height = getrgbimage('test.rgb')
|
image, width, height = getrgbimage('test'+os.extsep+'rgb')
|
||||||
else:
|
else:
|
||||||
image, width, height = getimage('test.rgb')
|
image, width, height = getimage('test'+os.extsep+'rgb')
|
||||||
|
|
||||||
# Return the selected part of image, which should by width by height
|
# Return the selected part of image, which should by width by height
|
||||||
# in size and consist of pixels of psize bytes.
|
# in size and consist of pixels of psize bytes.
|
||||||
|
@ -114,7 +114,7 @@ def main(use_rgbimg=1):
|
||||||
image = imageop.grey22grey (grey2image, width, height)
|
image = imageop.grey22grey (grey2image, width, height)
|
||||||
|
|
||||||
# Cleanup
|
# Cleanup
|
||||||
unlink('test.rgb')
|
unlink('test'+os.extsep+'rgb')
|
||||||
|
|
||||||
def getrgbimage(name):
|
def getrgbimage(name):
|
||||||
"""return a tuple consisting of image (in 'imgfile' format but
|
"""return a tuple consisting of image (in 'imgfile' format but
|
||||||
|
|
|
@ -18,11 +18,11 @@ import double_const # don't blink -- that *was* the test
|
||||||
|
|
||||||
def test_with_extension(ext): # ext normally ".py"; perhaps ".pyw"
|
def test_with_extension(ext): # ext normally ".py"; perhaps ".pyw"
|
||||||
source = TESTFN + ext
|
source = TESTFN + ext
|
||||||
pyo = TESTFN + ".pyo"
|
pyo = TESTFN + os.extsep + "pyo"
|
||||||
if sys.platform.startswith('java'):
|
if sys.platform.startswith('java'):
|
||||||
pyc = TESTFN + "$py.class"
|
pyc = TESTFN + "$py.class"
|
||||||
else:
|
else:
|
||||||
pyc = TESTFN + ".pyc"
|
pyc = TESTFN + os.extsep + "pyc"
|
||||||
|
|
||||||
f = open(source, "w")
|
f = open(source, "w")
|
||||||
print >> f, "# This tests Python's ability to import a", ext, "file."
|
print >> f, "# This tests Python's ability to import a", ext, "file."
|
||||||
|
@ -63,7 +63,7 @@ def test_with_extension(ext): # ext normally ".py"; perhaps ".pyw"
|
||||||
|
|
||||||
sys.path.insert(0, os.curdir)
|
sys.path.insert(0, os.curdir)
|
||||||
try:
|
try:
|
||||||
test_with_extension(".py")
|
test_with_extension(os.extsep + "py")
|
||||||
if sys.platform.startswith("win"):
|
if sys.platform.startswith("win"):
|
||||||
for ext in ".PY", ".Py", ".pY", ".pyw", ".PYW", ".pYw":
|
for ext in ".PY", ".Py", ".pY", ".pyw", ".PYW", ".pYw":
|
||||||
test_with_extension(ext)
|
test_with_extension(ext)
|
||||||
|
|
|
@ -42,7 +42,7 @@ class MaildirTestCase(unittest.TestCase):
|
||||||
t = int(time.time() % 1000000)
|
t = int(time.time() % 1000000)
|
||||||
pid = self._counter
|
pid = self._counter
|
||||||
self._counter += 1
|
self._counter += 1
|
||||||
filename = "%s.%s.myhostname.mydomain" % (t, pid)
|
filename = os.extsep.join((str(t), str(pid), "myhostname", "mydomain"))
|
||||||
tmpname = os.path.join(self._dir, "tmp", filename)
|
tmpname = os.path.join(self._dir, "tmp", filename)
|
||||||
newname = os.path.join(self._dir, dir, filename)
|
newname = os.path.join(self._dir, dir, filename)
|
||||||
fp = open(tmpname, "w")
|
fp = open(tmpname, "w")
|
||||||
|
|
|
@ -12,8 +12,8 @@ import os, StringIO
|
||||||
import sys
|
import sys
|
||||||
import mhlib
|
import mhlib
|
||||||
|
|
||||||
if sys.platform.startswith("win"):
|
if sys.platform.startswith("win") or sys.platform=="riscos":
|
||||||
raise TestSkipped("test_mhlib skipped on Windows -- "
|
raise TestSkipped("test_mhlib skipped on %s -- "%sys.platform +
|
||||||
"too many Unix assumptions")
|
"too many Unix assumptions")
|
||||||
|
|
||||||
_mhroot = TESTFN+"_MH"
|
_mhroot = TESTFN+"_MH"
|
||||||
|
|
|
@ -4,7 +4,7 @@ from xml.dom.minidom import parse, Node, Document, parseString
|
||||||
from xml.dom import HierarchyRequestErr
|
from xml.dom import HierarchyRequestErr
|
||||||
import xml.parsers.expat
|
import xml.parsers.expat
|
||||||
|
|
||||||
import os.path
|
import os
|
||||||
import sys
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
from test_support import verbose
|
from test_support import verbose
|
||||||
|
@ -13,7 +13,7 @@ if __name__ == "__main__":
|
||||||
base = sys.argv[0]
|
base = sys.argv[0]
|
||||||
else:
|
else:
|
||||||
base = __file__
|
base = __file__
|
||||||
tstfile = os.path.join(os.path.dirname(base), "test.xml")
|
tstfile = os.path.join(os.path.dirname(base), "test"+os.extsep+"xml")
|
||||||
del base
|
del base
|
||||||
|
|
||||||
def confirm(test, testname = "Test"):
|
def confirm(test, testname = "Test"):
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# Test packages (dotted-name import)
|
# Test packages (dotted-name import)
|
||||||
|
|
||||||
import sys, os, tempfile, traceback
|
import sys, os, tempfile, traceback
|
||||||
from os import mkdir, rmdir # Can't test if these fail
|
from os import mkdir, rmdir, extsep # Can't test if these fail
|
||||||
del mkdir, rmdir
|
del mkdir, rmdir
|
||||||
from test_support import verify, verbose, TestFailed
|
from test_support import verify, verbose, TestFailed
|
||||||
|
|
||||||
|
@ -77,15 +77,15 @@ def runtest(hier, code):
|
||||||
# Test descriptions
|
# Test descriptions
|
||||||
|
|
||||||
tests = [
|
tests = [
|
||||||
("t1", [("t1", None), ("t1 __init__.py", "")], "import t1"),
|
("t1", [("t1", None), ("t1 __init__"+os.extsep+"py", "")], "import t1"),
|
||||||
|
|
||||||
("t2", [
|
("t2", [
|
||||||
("t2", None),
|
("t2", None),
|
||||||
("t2 __init__.py", "'doc for t2'; print __name__, 'loading'"),
|
("t2 __init__"+os.extsep+"py", "'doc for t2'; print __name__, 'loading'"),
|
||||||
("t2 sub", None),
|
("t2 sub", None),
|
||||||
("t2 sub __init__.py", ""),
|
("t2 sub __init__"+os.extsep+"py", ""),
|
||||||
("t2 sub subsub", None),
|
("t2 sub subsub", None),
|
||||||
("t2 sub subsub __init__.py", "print __name__, 'loading'; spam = 1"),
|
("t2 sub subsub __init__"+os.extsep+"py", "print __name__, 'loading'; spam = 1"),
|
||||||
],
|
],
|
||||||
"""
|
"""
|
||||||
import t2
|
import t2
|
||||||
|
@ -111,11 +111,11 @@ print dir()
|
||||||
|
|
||||||
("t3", [
|
("t3", [
|
||||||
("t3", None),
|
("t3", None),
|
||||||
("t3 __init__.py", "print __name__, 'loading'"),
|
("t3 __init__"+os.extsep+"py", "print __name__, 'loading'"),
|
||||||
("t3 sub", None),
|
("t3 sub", None),
|
||||||
("t3 sub __init__.py", ""),
|
("t3 sub __init__"+os.extsep+"py", ""),
|
||||||
("t3 sub subsub", None),
|
("t3 sub subsub", None),
|
||||||
("t3 sub subsub __init__.py", "print __name__, 'loading'; spam = 1"),
|
("t3 sub subsub __init__"+os.extsep+"py", "print __name__, 'loading'; spam = 1"),
|
||||||
],
|
],
|
||||||
"""
|
"""
|
||||||
import t3.sub.subsub
|
import t3.sub.subsub
|
||||||
|
@ -126,15 +126,15 @@ reload(t3.sub.subsub)
|
||||||
"""),
|
"""),
|
||||||
|
|
||||||
("t4", [
|
("t4", [
|
||||||
("t4.py", "print 'THIS SHOULD NOT BE PRINTED (t4.py)'"),
|
("t4"+os.extsep+"py", "print 'THIS SHOULD NOT BE PRINTED (t4"+os.extsep+"py)'"),
|
||||||
("t4", None),
|
("t4", None),
|
||||||
("t4 __init__.py", "print __name__, 'loading'"),
|
("t4 __init__"+os.extsep+"py", "print __name__, 'loading'"),
|
||||||
("t4 sub.py", "print 'THIS SHOULD NOT BE PRINTED (sub.py)'"),
|
("t4 sub"+os.extsep+"py", "print 'THIS SHOULD NOT BE PRINTED (sub"+os.extsep+"py)'"),
|
||||||
("t4 sub", None),
|
("t4 sub", None),
|
||||||
("t4 sub __init__.py", ""),
|
("t4 sub __init__"+os.extsep+"py", ""),
|
||||||
("t4 sub subsub.py", "print 'THIS SHOULD NOT BE PRINTED (subsub.py)'"),
|
("t4 sub subsub"+os.extsep+"py", "print 'THIS SHOULD NOT BE PRINTED (subsub"+os.extsep+"py)'"),
|
||||||
("t4 sub subsub", None),
|
("t4 sub subsub", None),
|
||||||
("t4 sub subsub __init__.py", "print __name__, 'loading'; spam = 1"),
|
("t4 sub subsub __init__"+os.extsep+"py", "print __name__, 'loading'; spam = 1"),
|
||||||
],
|
],
|
||||||
"""
|
"""
|
||||||
from t4.sub.subsub import *
|
from t4.sub.subsub import *
|
||||||
|
@ -143,9 +143,9 @@ print "t4.sub.subsub.spam =", spam
|
||||||
|
|
||||||
("t5", [
|
("t5", [
|
||||||
("t5", None),
|
("t5", None),
|
||||||
("t5 __init__.py", "import t5.foo"),
|
("t5 __init__"+os.extsep+"py", "import t5.foo"),
|
||||||
("t5 string.py", "print __name__, 'loading'; spam = 1"),
|
("t5 string"+os.extsep+"py", "print __name__, 'loading'; spam = 1"),
|
||||||
("t5 foo.py",
|
("t5 foo"+os.extsep+"py",
|
||||||
"print __name__, 'loading'; import string; print string.spam"),
|
"print __name__, 'loading'; import string; print string.spam"),
|
||||||
],
|
],
|
||||||
"""
|
"""
|
||||||
|
@ -160,10 +160,10 @@ print fixdir(dir(t5.string))
|
||||||
|
|
||||||
("t6", [
|
("t6", [
|
||||||
("t6", None),
|
("t6", None),
|
||||||
("t6 __init__.py", "__all__ = ['spam', 'ham', 'eggs']"),
|
("t6 __init__"+os.extsep+"py", "__all__ = ['spam', 'ham', 'eggs']"),
|
||||||
("t6 spam.py", "print __name__, 'loading'"),
|
("t6 spam"+os.extsep+"py", "print __name__, 'loading'"),
|
||||||
("t6 ham.py", "print __name__, 'loading'"),
|
("t6 ham"+os.extsep+"py", "print __name__, 'loading'"),
|
||||||
("t6 eggs.py", "print __name__, 'loading'"),
|
("t6 eggs"+os.extsep+"py", "print __name__, 'loading'"),
|
||||||
],
|
],
|
||||||
"""
|
"""
|
||||||
import t6
|
import t6
|
||||||
|
@ -174,15 +174,15 @@ print dir()
|
||||||
"""),
|
"""),
|
||||||
|
|
||||||
("t7", [
|
("t7", [
|
||||||
("t7.py", "print 'Importing t7.py'"),
|
("t7"+os.extsep+"py", "print 'Importing t7"+os.extsep+"py'"),
|
||||||
("t7", None),
|
("t7", None),
|
||||||
("t7 __init__.py", "print __name__, 'loading'"),
|
("t7 __init__"+os.extsep+"py", "print __name__, 'loading'"),
|
||||||
("t7 sub.py", "print 'THIS SHOULD NOT BE PRINTED (sub.py)'"),
|
("t7 sub"+os.extsep+"py", "print 'THIS SHOULD NOT BE PRINTED (sub"+os.extsep+"py)'"),
|
||||||
("t7 sub", None),
|
("t7 sub", None),
|
||||||
("t7 sub __init__.py", ""),
|
("t7 sub __init__"+os.extsep+"py", ""),
|
||||||
("t7 sub subsub.py", "print 'THIS SHOULD NOT BE PRINTED (subsub.py)'"),
|
("t7 sub subsub"+os.extsep+"py", "print 'THIS SHOULD NOT BE PRINTED (subsub"+os.extsep+"py)'"),
|
||||||
("t7 sub subsub", None),
|
("t7 sub subsub", None),
|
||||||
("t7 sub subsub __init__.py", "print __name__, 'loading'; spam = 1"),
|
("t7 sub subsub __init__"+os.extsep+"py", "print __name__, 'loading'; spam = 1"),
|
||||||
],
|
],
|
||||||
"""
|
"""
|
||||||
t7, sub, subsub = None, None, None
|
t7, sub, subsub = None, None, None
|
||||||
|
|
|
@ -23,8 +23,8 @@ class TestImport(unittest.TestCase):
|
||||||
self.package_dir = os.path.join(self.test_dir,
|
self.package_dir = os.path.join(self.test_dir,
|
||||||
self.package_name)
|
self.package_name)
|
||||||
os.mkdir(self.package_dir)
|
os.mkdir(self.package_dir)
|
||||||
open(os.path.join(self.package_dir, '__init__.py'), 'w')
|
open(os.path.join(self.package_dir, '__init__'+os.extsep+'py'), 'w')
|
||||||
self.module_path = os.path.join(self.package_dir, 'foo.py')
|
self.module_path = os.path.join(self.package_dir, 'foo'+os.extsep+'py')
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
for file in os.listdir(self.package_dir):
|
for file in os.listdir(self.package_dir):
|
||||||
|
|
|
@ -173,9 +173,9 @@ class LongReprTest(unittest.TestCase):
|
||||||
self.subpkgname = os.path.join(longname, longname)
|
self.subpkgname = os.path.join(longname, longname)
|
||||||
# Make the package and subpackage
|
# Make the package and subpackage
|
||||||
os.mkdir(self.pkgname)
|
os.mkdir(self.pkgname)
|
||||||
touch(os.path.join(self.pkgname, '__init__.py'))
|
touch(os.path.join(self.pkgname, '__init__'+os.extsep+'py'))
|
||||||
os.mkdir(self.subpkgname)
|
os.mkdir(self.subpkgname)
|
||||||
touch(os.path.join(self.subpkgname, '__init__.py'))
|
touch(os.path.join(self.subpkgname, '__init__'+os.extsep+'py'))
|
||||||
# Remember where we are
|
# Remember where we are
|
||||||
self.here = os.getcwd()
|
self.here = os.getcwd()
|
||||||
sys.path.insert(0, self.here)
|
sys.path.insert(0, self.here)
|
||||||
|
@ -195,14 +195,14 @@ class LongReprTest(unittest.TestCase):
|
||||||
|
|
||||||
def test_module(self):
|
def test_module(self):
|
||||||
eq = self.assertEquals
|
eq = self.assertEquals
|
||||||
touch(os.path.join(self.subpkgname, self.pkgname + '.py'))
|
touch(os.path.join(self.subpkgname, self.pkgname + os.extsep + 'py'))
|
||||||
from areallylongpackageandmodulenametotestreprtruncation.areallylongpackageandmodulenametotestreprtruncation import areallylongpackageandmodulenametotestreprtruncation
|
from areallylongpackageandmodulenametotestreprtruncation.areallylongpackageandmodulenametotestreprtruncation import areallylongpackageandmodulenametotestreprtruncation
|
||||||
eq(repr(areallylongpackageandmodulenametotestreprtruncation),
|
eq(repr(areallylongpackageandmodulenametotestreprtruncation),
|
||||||
"<module 'areallylongpackageandmodulenametotestreprtruncation.areallylongpackageandmodulenametotestreprtruncation.areallylongpackageandmodulenametotestreprtruncation' from '%s'>" % areallylongpackageandmodulenametotestreprtruncation.__file__)
|
"<module 'areallylongpackageandmodulenametotestreprtruncation.areallylongpackageandmodulenametotestreprtruncation.areallylongpackageandmodulenametotestreprtruncation' from '%s'>" % areallylongpackageandmodulenametotestreprtruncation.__file__)
|
||||||
|
|
||||||
def test_type(self):
|
def test_type(self):
|
||||||
eq = self.assertEquals
|
eq = self.assertEquals
|
||||||
touch(os.path.join(self.subpkgname, 'foo.py'), '''\
|
touch(os.path.join(self.subpkgname, 'foo'+os.extsep+'py'), '''\
|
||||||
class foo(object):
|
class foo(object):
|
||||||
pass
|
pass
|
||||||
''')
|
''')
|
||||||
|
@ -216,7 +216,7 @@ class foo(object):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def test_class(self):
|
def test_class(self):
|
||||||
touch(os.path.join(self.subpkgname, 'bar.py'), '''\
|
touch(os.path.join(self.subpkgname, 'bar'+os.extsep+'py'), '''\
|
||||||
class bar:
|
class bar:
|
||||||
pass
|
pass
|
||||||
''')
|
''')
|
||||||
|
@ -225,7 +225,7 @@ class bar:
|
||||||
"<class areallylongpackageandmodulenametotestreprtruncation.areallylongpackageandmodulenametotestreprtruncation.bar.bar at 0x"))
|
"<class areallylongpackageandmodulenametotestreprtruncation.areallylongpackageandmodulenametotestreprtruncation.bar.bar at 0x"))
|
||||||
|
|
||||||
def test_instance(self):
|
def test_instance(self):
|
||||||
touch(os.path.join(self.subpkgname, 'baz.py'), '''\
|
touch(os.path.join(self.subpkgname, 'baz'+os.extsep+'py'), '''\
|
||||||
class baz:
|
class baz:
|
||||||
pass
|
pass
|
||||||
''')
|
''')
|
||||||
|
@ -236,7 +236,7 @@ class baz:
|
||||||
|
|
||||||
def test_method(self):
|
def test_method(self):
|
||||||
eq = self.assertEquals
|
eq = self.assertEquals
|
||||||
touch(os.path.join(self.subpkgname, 'qux.py'), '''\
|
touch(os.path.join(self.subpkgname, 'qux'+os.extsep+'py'), '''\
|
||||||
class aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:
|
class aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:
|
||||||
def amethod(self): pass
|
def amethod(self): pass
|
||||||
''')
|
''')
|
||||||
|
|
|
@ -25,9 +25,9 @@ def testimg(rgb_file, raw_file):
|
||||||
os.unlink('@.rgb')
|
os.unlink('@.rgb')
|
||||||
|
|
||||||
table = [
|
table = [
|
||||||
('testrgb.uue', 'test.rgb'),
|
('testrgb'+os.extsep+'uue', 'test'+os.extsep+'rgb'),
|
||||||
('testimg.uue', 'test.rawimg'),
|
('testimg'+os.extsep+'uue', 'test'+os.extsep+'rawimg'),
|
||||||
('testimgr.uue', 'test.rawimg.rev'),
|
('testimgr'+os.extsep+'uue', 'test'+os.extsep+'rawimg'+os.extsep+'rev'),
|
||||||
]
|
]
|
||||||
for source, target in table:
|
for source, target in table:
|
||||||
source = findfile(source)
|
source = findfile(source)
|
||||||
|
@ -43,13 +43,13 @@ ttob = rgbimg.ttob(0)
|
||||||
if ttob != 0:
|
if ttob != 0:
|
||||||
raise error, 'ttob should start out as zero'
|
raise error, 'ttob should start out as zero'
|
||||||
|
|
||||||
testimg('test.rgb', 'test.rawimg')
|
testimg('test'+os.extsep+'rgb', 'test'+os.extsep+'rawimg')
|
||||||
|
|
||||||
ttob = rgbimg.ttob(1)
|
ttob = rgbimg.ttob(1)
|
||||||
if ttob != 0:
|
if ttob != 0:
|
||||||
raise error, 'ttob should be zero'
|
raise error, 'ttob should be zero'
|
||||||
|
|
||||||
testimg('test.rgb', 'test.rawimg.rev')
|
testimg('test'+os.extsep+'rgb', 'test'+os.extsep+'rawimg'+os.extsep+'rev')
|
||||||
|
|
||||||
ttob = rgbimg.ttob(0)
|
ttob = rgbimg.ttob(0)
|
||||||
if ttob != 1:
|
if ttob != 1:
|
||||||
|
|
|
@ -13,6 +13,7 @@ from xml.sax.expatreader import create_parser
|
||||||
from xml.sax.xmlreader import InputSource, AttributesImpl, AttributesNSImpl
|
from xml.sax.xmlreader import InputSource, AttributesImpl, AttributesNSImpl
|
||||||
from cStringIO import StringIO
|
from cStringIO import StringIO
|
||||||
from test_support import verify, verbose, TestFailed, findfile
|
from test_support import verify, verbose, TestFailed, findfile
|
||||||
|
import os
|
||||||
|
|
||||||
# ===== Utilities
|
# ===== Utilities
|
||||||
|
|
||||||
|
@ -228,7 +229,7 @@ def test_expat_file():
|
||||||
xmlgen = XMLGenerator(result)
|
xmlgen = XMLGenerator(result)
|
||||||
|
|
||||||
parser.setContentHandler(xmlgen)
|
parser.setContentHandler(xmlgen)
|
||||||
parser.parse(open(findfile("test.xml")))
|
parser.parse(open(findfile("test"+os.extsep+"xml")))
|
||||||
|
|
||||||
return result.getvalue() == xml_test_out
|
return result.getvalue() == xml_test_out
|
||||||
|
|
||||||
|
@ -349,7 +350,7 @@ def test_expat_nsattrs_wattr():
|
||||||
|
|
||||||
# ===== InputSource support
|
# ===== InputSource support
|
||||||
|
|
||||||
xml_test_out = open(findfile("test.xml.out")).read()
|
xml_test_out = open(findfile("test"+os.extsep+"xml"+os.extsep+"out")).read()
|
||||||
|
|
||||||
def test_expat_inpsource_filename():
|
def test_expat_inpsource_filename():
|
||||||
parser = create_parser()
|
parser = create_parser()
|
||||||
|
@ -357,7 +358,7 @@ def test_expat_inpsource_filename():
|
||||||
xmlgen = XMLGenerator(result)
|
xmlgen = XMLGenerator(result)
|
||||||
|
|
||||||
parser.setContentHandler(xmlgen)
|
parser.setContentHandler(xmlgen)
|
||||||
parser.parse(findfile("test.xml"))
|
parser.parse(findfile("test"+os.extsep+"xml"))
|
||||||
|
|
||||||
return result.getvalue() == xml_test_out
|
return result.getvalue() == xml_test_out
|
||||||
|
|
||||||
|
@ -367,7 +368,7 @@ def test_expat_inpsource_sysid():
|
||||||
xmlgen = XMLGenerator(result)
|
xmlgen = XMLGenerator(result)
|
||||||
|
|
||||||
parser.setContentHandler(xmlgen)
|
parser.setContentHandler(xmlgen)
|
||||||
parser.parse(InputSource(findfile("test.xml")))
|
parser.parse(InputSource(findfile("test"+os.extsep+"xml")))
|
||||||
|
|
||||||
return result.getvalue() == xml_test_out
|
return result.getvalue() == xml_test_out
|
||||||
|
|
||||||
|
@ -378,7 +379,7 @@ def test_expat_inpsource_stream():
|
||||||
|
|
||||||
parser.setContentHandler(xmlgen)
|
parser.setContentHandler(xmlgen)
|
||||||
inpsrc = InputSource()
|
inpsrc = InputSource()
|
||||||
inpsrc.setByteStream(open(findfile("test.xml")))
|
inpsrc.setByteStream(open(findfile("test"+os.extsep+"xml")))
|
||||||
parser.parse(inpsrc)
|
parser.parse(inpsrc)
|
||||||
|
|
||||||
return result.getvalue() == xml_test_out
|
return result.getvalue() == xml_test_out
|
||||||
|
@ -625,9 +626,9 @@ def make_test_output():
|
||||||
xmlgen = XMLGenerator(result)
|
xmlgen = XMLGenerator(result)
|
||||||
|
|
||||||
parser.setContentHandler(xmlgen)
|
parser.setContentHandler(xmlgen)
|
||||||
parser.parse(findfile("test.xml"))
|
parser.parse(findfile("test"+os.extsep+"xml"))
|
||||||
|
|
||||||
outf = open(findfile("test.xml.out"), "w")
|
outf = open(findfile("test"+os.extsep+"xml"+os.extsep+"out"), "w")
|
||||||
outf.write(result.getvalue())
|
outf.write(result.getvalue())
|
||||||
outf.close()
|
outf.close()
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,8 @@ import signal
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
if sys.platform[:3] in ('win', 'os2'):
|
if sys.platform[:3] in ('win', 'os2') or sys.platform=='riscos':
|
||||||
raise TestSkipped, "Can't test signal on %s" % sys.platform[:3]
|
raise TestSkipped, "Can't test signal on %s" % sys.platform
|
||||||
|
|
||||||
if verbose:
|
if verbose:
|
||||||
x = '-x'
|
x = '-x'
|
||||||
|
|
|
@ -3,7 +3,7 @@ import tokenize, os, sys
|
||||||
|
|
||||||
if verbose:
|
if verbose:
|
||||||
print 'starting...'
|
print 'starting...'
|
||||||
file = open(findfile('tokenize_tests.py'))
|
file = open(findfile('tokenize_tests'+os.extsep+'py'))
|
||||||
tokenize.tokenize(file.readline)
|
tokenize.tokenize(file.readline)
|
||||||
if verbose:
|
if verbose:
|
||||||
print 'finished'
|
print 'finished'
|
||||||
|
|
|
@ -19,6 +19,11 @@ if fname[1:2] == ":":
|
||||||
# urllib.pathname2url works, unfortunately...
|
# urllib.pathname2url works, unfortunately...
|
||||||
if os.name == 'mac':
|
if os.name == 'mac':
|
||||||
fname = '/' + fname.replace(':', '/')
|
fname = '/' + fname.replace(':', '/')
|
||||||
|
elif os.name == 'riscos':
|
||||||
|
import string
|
||||||
|
fname = os.expand(fname)
|
||||||
|
fname = fname.translate(string.maketrans("/.", "./"))
|
||||||
|
|
||||||
file_url = "file://%s" % fname
|
file_url = "file://%s" % fname
|
||||||
f = urllib2.urlopen(file_url)
|
f = urllib2.urlopen(file_url)
|
||||||
|
|
||||||
|
|
|
@ -2,19 +2,19 @@ import zlib # implied prerequisite
|
||||||
import zipfile, os, StringIO, tempfile
|
import zipfile, os, StringIO, tempfile
|
||||||
from test_support import TestFailed
|
from test_support import TestFailed
|
||||||
|
|
||||||
srcname = "junk9630.tmp"
|
srcname = "junk9630"+os.extsep+"tmp"
|
||||||
zipname = "junk9708.tmp"
|
zipname = "junk9708"+os.extsep+"tmp"
|
||||||
|
|
||||||
|
|
||||||
def zipTest(f, compression, srccontents):
|
def zipTest(f, compression, srccontents):
|
||||||
zip = zipfile.ZipFile(f, "w", compression) # Create the ZIP archive
|
zip = zipfile.ZipFile(f, "w", compression) # Create the ZIP archive
|
||||||
zip.write(srcname, "another.name")
|
zip.write(srcname, "another"+os.extsep+"name")
|
||||||
zip.write(srcname, srcname)
|
zip.write(srcname, srcname)
|
||||||
zip.close()
|
zip.close()
|
||||||
|
|
||||||
zip = zipfile.ZipFile(f, "r", compression) # Read the ZIP archive
|
zip = zipfile.ZipFile(f, "r", compression) # Read the ZIP archive
|
||||||
readData2 = zip.read(srcname)
|
readData2 = zip.read(srcname)
|
||||||
readData1 = zip.read("another.name")
|
readData1 = zip.read("another"+os.extsep+"name")
|
||||||
zip.close()
|
zip.close()
|
||||||
|
|
||||||
if readData1 != srccontents or readData2 != srccontents:
|
if readData1 != srccontents or readData2 != srccontents:
|
||||||
|
|
|
@ -2,11 +2,6 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
if os.sep==".":
|
|
||||||
endsep = "/"
|
|
||||||
else:
|
|
||||||
endsep = "."
|
|
||||||
|
|
||||||
def whichdb(filename):
|
def whichdb(filename):
|
||||||
"""Guess which db package to use to open a db file.
|
"""Guess which db package to use to open a db file.
|
||||||
|
|
||||||
|
@ -24,9 +19,9 @@ def whichdb(filename):
|
||||||
|
|
||||||
# Check for dbm first -- this has a .pag and a .dir file
|
# Check for dbm first -- this has a .pag and a .dir file
|
||||||
try:
|
try:
|
||||||
f = open(filename + endsep + "pag", "rb")
|
f = open(filename + os.extsep + "pag", "rb")
|
||||||
f.close()
|
f.close()
|
||||||
f = open(filename + endsep + "dir", "rb")
|
f = open(filename + os.extsep + "dir", "rb")
|
||||||
f.close()
|
f.close()
|
||||||
return "dbm"
|
return "dbm"
|
||||||
except IOError:
|
except IOError:
|
||||||
|
@ -34,9 +29,9 @@ def whichdb(filename):
|
||||||
|
|
||||||
# Check for dumbdbm next -- this has a .dir and and a .dat file
|
# Check for dumbdbm next -- this has a .dir and and a .dat file
|
||||||
try:
|
try:
|
||||||
f = open(filename + endsep + "dat", "rb")
|
f = open(filename + os.extsep + "dat", "rb")
|
||||||
f.close()
|
f.close()
|
||||||
f = open(filename + endsep + "dir", "rb")
|
f = open(filename + os.extsep + "dir", "rb")
|
||||||
try:
|
try:
|
||||||
if f.read(1) in ["'", '"']:
|
if f.read(1) in ["'", '"']:
|
||||||
return "dumbdbm"
|
return "dumbdbm"
|
||||||
|
|
|
@ -52,14 +52,6 @@ extern void bzero(void *, int);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef RISCOS
|
|
||||||
#define NO_DUP
|
|
||||||
#undef off_t
|
|
||||||
#undef uid_t
|
|
||||||
#undef gid_t
|
|
||||||
#undef errno
|
|
||||||
#include "socklib.h"
|
|
||||||
#endif /* RISCOS */
|
|
||||||
|
|
||||||
static PyObject *SelectError;
|
static PyObject *SelectError;
|
||||||
|
|
||||||
|
|
|
@ -130,20 +130,6 @@ Socket methods:
|
||||||
#include <os2.h>
|
#include <os2.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef RISCOS
|
|
||||||
#define NO_DUP
|
|
||||||
#undef off_t
|
|
||||||
#undef uid_t
|
|
||||||
#undef gid_t
|
|
||||||
#undef errno
|
|
||||||
#include <signal.h>
|
|
||||||
#include "socklib.h"
|
|
||||||
#include "inetlib.h"
|
|
||||||
#include "netdb.h"
|
|
||||||
#include "unixlib.h"
|
|
||||||
#include "netinet/in.h"
|
|
||||||
#include "sys/ioctl.h"
|
|
||||||
#else /*RISCOS*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
@ -165,13 +151,18 @@ Socket methods:
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef RISCOS
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#else
|
#else
|
||||||
|
#include <sys/fcntl.h>
|
||||||
|
#define NO_DUP
|
||||||
|
int h_errno; /* not used */
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
#include <winsock.h>
|
#include <winsock.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /*RISCOS*/
|
|
||||||
|
|
||||||
#ifdef HAVE_SYS_UN_H
|
#ifdef HAVE_SYS_UN_H
|
||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
|
@ -1804,7 +1795,11 @@ gethost_common(struct hostent *h, struct sockaddr *addr, int alen, int af)
|
||||||
|
|
||||||
if (h == NULL) {
|
if (h == NULL) {
|
||||||
/* Let's get real error message to return */
|
/* Let's get real error message to return */
|
||||||
|
#ifndef RISCOS
|
||||||
PyH_Err(h_errno);
|
PyH_Err(h_errno);
|
||||||
|
#else
|
||||||
|
PyErr_SetString(PySocket_Error, "host not found");
|
||||||
|
#endif
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (h->h_addrtype != af) {
|
if (h->h_addrtype != af) {
|
||||||
|
|
|
@ -53,19 +53,19 @@ static PyObject *StructError;
|
||||||
#endif
|
#endif
|
||||||
#endif /* __MWERKS__ */
|
#endif /* __MWERKS__ */
|
||||||
|
|
||||||
typedef struct { char c; short x; } s_short;
|
typedef struct { char c; short x; } st_short;
|
||||||
typedef struct { char c; int x; } s_int;
|
typedef struct { char c; int x; } st_int;
|
||||||
typedef struct { char c; long x; } s_long;
|
typedef struct { char c; long x; } st_long;
|
||||||
typedef struct { char c; float x; } s_float;
|
typedef struct { char c; float x; } st_float;
|
||||||
typedef struct { char c; double x; } s_double;
|
typedef struct { char c; double x; } st_double;
|
||||||
typedef struct { char c; void *x; } s_void_p;
|
typedef struct { char c; void *x; } st_void_p;
|
||||||
|
|
||||||
#define SHORT_ALIGN (sizeof(s_short) - sizeof(short))
|
#define SHORT_ALIGN (sizeof(st_short) - sizeof(short))
|
||||||
#define INT_ALIGN (sizeof(s_int) - sizeof(int))
|
#define INT_ALIGN (sizeof(st_int) - sizeof(int))
|
||||||
#define LONG_ALIGN (sizeof(s_long) - sizeof(long))
|
#define LONG_ALIGN (sizeof(st_long) - sizeof(long))
|
||||||
#define FLOAT_ALIGN (sizeof(s_float) - sizeof(float))
|
#define FLOAT_ALIGN (sizeof(st_float) - sizeof(float))
|
||||||
#define DOUBLE_ALIGN (sizeof(s_double) - sizeof(double))
|
#define DOUBLE_ALIGN (sizeof(st_double) - sizeof(double))
|
||||||
#define VOID_P_ALIGN (sizeof(s_void_p) - sizeof(void *))
|
#define VOID_P_ALIGN (sizeof(st_void_p) - sizeof(void *))
|
||||||
|
|
||||||
/* We can't support q and Q in native mode unless the compiler does;
|
/* We can't support q and Q in native mode unless the compiler does;
|
||||||
in std mode, they're 8 bytes on all platforms. */
|
in std mode, they're 8 bytes on all platforms. */
|
||||||
|
|
|
@ -17,9 +17,7 @@
|
||||||
#define GUSI_TO_MSL_EPOCH (4*365*24*60*60)
|
#define GUSI_TO_MSL_EPOCH (4*365*24*60*60)
|
||||||
#endif /* USE_GUSI2 */
|
#endif /* USE_GUSI2 */
|
||||||
#else
|
#else
|
||||||
#ifndef RISCOS
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#endif /* RISCOS */
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef QUICKWIN
|
#ifdef QUICKWIN
|
||||||
|
|
|
@ -610,6 +610,13 @@ float_int(PyObject *v)
|
||||||
long aslong; /* (long)wholepart */
|
long aslong; /* (long)wholepart */
|
||||||
|
|
||||||
(void)modf(x, &wholepart);
|
(void)modf(x, &wholepart);
|
||||||
|
#ifdef RISCOS
|
||||||
|
/* conversion from floating to integral type would raise exception */
|
||||||
|
if (wholepart>LONG_MAX || wholepart<LONG_MIN) {
|
||||||
|
PyErr_SetString(PyExc_OverflowError, "float too large to convert");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
/* doubles may have more bits than longs, or vice versa; and casting
|
/* doubles may have more bits than longs, or vice versa; and casting
|
||||||
to long may yield gibberish in either case. What really matters
|
to long may yield gibberish in either case. What really matters
|
||||||
is whether converting back to double again reproduces what we
|
is whether converting back to double again reproduces what we
|
||||||
|
|
|
@ -13,6 +13,10 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef RISCOS
|
||||||
|
#include "unixstuff.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/* The default encoding used by the platform file system APIs
|
/* The default encoding used by the platform file system APIs
|
||||||
Can remain NULL for all platforms that don't have such a concept
|
Can remain NULL for all platforms that don't have such a concept
|
||||||
*/
|
*/
|
||||||
|
@ -536,7 +540,9 @@ builtin_execfile(PyObject *self, PyObject *args)
|
||||||
FILE* fp = NULL;
|
FILE* fp = NULL;
|
||||||
PyCompilerFlags cf;
|
PyCompilerFlags cf;
|
||||||
int exists;
|
int exists;
|
||||||
|
#ifndef RISCOS
|
||||||
struct stat s;
|
struct stat s;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "s|O!O!:execfile",
|
if (!PyArg_ParseTuple(args, "s|O!O!:execfile",
|
||||||
&filename,
|
&filename,
|
||||||
|
@ -558,12 +564,21 @@ builtin_execfile(PyObject *self, PyObject *args)
|
||||||
|
|
||||||
exists = 0;
|
exists = 0;
|
||||||
/* Test for existence or directory. */
|
/* Test for existence or directory. */
|
||||||
|
#ifndef RISCOS
|
||||||
if (!stat(filename, &s)) {
|
if (!stat(filename, &s)) {
|
||||||
if (S_ISDIR(s.st_mode))
|
if (S_ISDIR(s.st_mode))
|
||||||
errno = EISDIR;
|
errno = EISDIR;
|
||||||
else
|
else
|
||||||
exists = 1;
|
exists = 1;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
if (object_exists(filename)) {
|
||||||
|
if (isdir(filename))
|
||||||
|
errno = EISDIR;
|
||||||
|
else
|
||||||
|
exists = 1;
|
||||||
|
}
|
||||||
|
#endif /* RISCOS */
|
||||||
|
|
||||||
if (exists) {
|
if (exists) {
|
||||||
Py_BEGIN_ALLOW_THREADS
|
Py_BEGIN_ALLOW_THREADS
|
||||||
|
|
|
@ -983,13 +983,10 @@ find_module(char *realname, PyObject *path, char *buf, size_t buflen,
|
||||||
#else
|
#else
|
||||||
/* XXX How are you going to test for directories? */
|
/* XXX How are you going to test for directories? */
|
||||||
#ifdef RISCOS
|
#ifdef RISCOS
|
||||||
{
|
if (isdir(buf) &&
|
||||||
static struct filedescr fd = {"", "", PKG_DIRECTORY};
|
find_init_module(buf) &&
|
||||||
if (isdir(buf)) {
|
case_ok(buf, len, namelen, name))
|
||||||
if (find_init_module(buf))
|
return &fd_package;
|
||||||
return &fd;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#ifdef macintosh
|
#ifdef macintosh
|
||||||
|
@ -1069,6 +1066,8 @@ find_module(char *realname, PyObject *path, char *buf, size_t buflen,
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
|
||||||
|
#elif defined(RISCOS)
|
||||||
|
#include "oslib/osfscontrol.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -1198,6 +1197,31 @@ case_ok(char *buf, int len, int namelen, char *name)
|
||||||
}
|
}
|
||||||
return 0 ; /* Not found */
|
return 0 ; /* Not found */
|
||||||
|
|
||||||
|
/* RISC OS */
|
||||||
|
#elif defined(RISCOS)
|
||||||
|
char canon[MAXPATHLEN+1]; /* buffer for the canonical form of the path */
|
||||||
|
char buf2[MAXPATHLEN+2];
|
||||||
|
char *nameWithExt = buf+len-namelen;
|
||||||
|
int canonlen;
|
||||||
|
os_error *e;
|
||||||
|
|
||||||
|
if (Py_GETENV("PYTHONCASEOK") != NULL)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
/* workaround:
|
||||||
|
append wildcard, otherwise case of filename wouldn't be touched */
|
||||||
|
strcpy(buf2, buf);
|
||||||
|
strcat(buf2, "*");
|
||||||
|
|
||||||
|
e = xosfscontrol_canonicalise_path(buf2,canon,0,0,MAXPATHLEN+1,&canonlen);
|
||||||
|
canonlen = MAXPATHLEN+1-canonlen;
|
||||||
|
if (e || canonlen<=0 || canonlen>(MAXPATHLEN+1) )
|
||||||
|
return 0;
|
||||||
|
if (strcmp(nameWithExt, canon+canonlen-strlen(nameWithExt))==0)
|
||||||
|
return 1; /* match */
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
/* assuming it's a case-sensitive filesystem, so there's nothing to do! */
|
/* assuming it's a case-sensitive filesystem, so there's nothing to do! */
|
||||||
#else
|
#else
|
||||||
return 1;
|
return 1;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue