Skip to content

Commit

Permalink
Patch #734231: Update RiscOS support. In particular, correct
Browse files Browse the repository at this point in the history
riscospath.extsep, and use os.extsep throughout.


git-svn-id: http://svn.python.org/projects/python/trunk@32720 6015fed2-1504-0410-9fe1-9d1591cc4771
  • Loading branch information
loewis committed May 10, 2003
1 parent 76186cd commit 3faae1b
Show file tree
Hide file tree
Showing 27 changed files with 482 additions and 59 deletions.
1 change: 1 addition & 0 deletions Include/pyport.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ typedef PY_LONG_LONG Py_intptr_t;

#ifdef RISCOS
#include <sys/types.h>
#include "unixstuff.h"
#endif

#ifndef DONT_HAVE_SYS_STAT_H
Expand Down
2 changes: 1 addition & 1 deletion Lib/plat-riscos/riscospath.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# strings representing various path-related bits and pieces
curdir = '@'
pardir = '^'
extsep = '.'
extsep = '/'
sep = '.'
pathsep = ','
defpath = '<Run$Dir>'
Expand Down
2 changes: 1 addition & 1 deletion Lib/site.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def addpackage(sitedir, name):
prefixes.append(sys.exec_prefix)
for prefix in prefixes:
if prefix:
if sys.platform == 'os2emx':
if sys.platform in ('os2emx', 'riscos'):
sitedirs = [os.path.join(prefix, "Lib", "site-packages")]
elif os.sep == '/':
sitedirs = [os.path.join(prefix,
Expand Down
4 changes: 3 additions & 1 deletion Lib/socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ def ssl(sock, keyfile=None, certfile=None):
errorTab[10065] = "The host is unreachable."
__all__.append("errorTab")

del os, sys


def getfqdn(name=''):
Expand Down Expand Up @@ -139,6 +138,9 @@ def getfqdn(name=''):
'sendall', 'setblocking',
'settimeout', 'gettimeout', 'shutdown')

if sys.platform == "riscos":
_socketmethods = _socketmethods + ('sleeptaskw',)

class _closedsocket(object):
__slots__ = []
def _dummy(*args):
Expand Down
2 changes: 2 additions & 0 deletions Lib/test/regrtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -726,8 +726,10 @@ def printlist(x, width=70, indent=4):
"""
test_al
test_asynchat
test_atexit
test_bsddb
test_bsddb185
test_bsddb3
test_cd
test_cl
test_commands
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_bz2.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import bz2
from bz2 import BZ2File, BZ2Compressor, BZ2Decompressor

has_cmdline_bunzip2 = sys.platform not in ("win32", "os2emx")
has_cmdline_bunzip2 = sys.platform not in ("win32", "os2emx", "riscos")

class BaseTest(unittest.TestCase):
"Base for other testcases."
Expand Down
6 changes: 3 additions & 3 deletions Lib/test/test_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from test.test_support import TestFailed, TESTFN, unlink
from types import ClassType
import warnings
import sys, traceback
import sys, traceback, os

print '5. Built-in exceptions'
# XXX This is not really enough, each *operation* should be tested!
Expand Down Expand Up @@ -185,7 +185,7 @@ def test_capi1():
exc, err, tb = sys.exc_info()
co = tb.tb_frame.f_code
assert co.co_name == "test_capi1"
assert co.co_filename.endswith('test_exceptions.py')
assert co.co_filename.endswith('test_exceptions'+os.extsep+'py')
else:
print "Expected exception"

Expand All @@ -197,7 +197,7 @@ def test_capi2():
exc, err, tb = sys.exc_info()
co = tb.tb_frame.f_code
assert co.co_name == "__init__"
assert co.co_filename.endswith('test_exceptions.py')
assert co.co_filename.endswith('test_exceptions'+os.extsep+'py')
co2 = tb.tb_frame.f_back.f_code
assert co2.co_name == "test_capi2"
else:
Expand Down
6 changes: 3 additions & 3 deletions Lib/test/test_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def test_with_extension(ext): # ext normally ".py"; perhaps ".pyw"

def test_module_with_large_stack(module):
# create module w/list of 65000 elements to test bug #561858
filename = module + '.py'
filename = module + os.extsep + 'py'

# create a file with a list of 65000 elements
f = open(filename, 'w+')
Expand All @@ -102,8 +102,8 @@ def test_module_with_large_stack(module):

# cleanup
del sys.path[-1]
for ext in '.pyc', '.pyo':
fname = module + ext
for ext in 'pyc', 'pyo':
fname = module + os.extsep + ext
if os.path.exists(fname):
os.unlink(fname)

Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_normalization.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os
from unicodedata import normalize

TESTDATAFILE = "NormalizationTest.txt"
TESTDATAFILE = "NormalizationTest" + os.extsep + "txt"

# This search allows using a build directory just inside the source
# directory, and saving just one copy of the test data in the source
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_select.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def fileno(self):

def test():
import sys
if sys.platform[:3] in ('win', 'mac', 'os2'):
if sys.platform[:3] in ('win', 'mac', 'os2', 'riscos'):
if verbose:
print "Can't test select easily on", sys.platform
return
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_shelve.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class TestCase(unittest.TestCase):

fn = "shelftemp.db"
fn = "shelftemp" + os.extsep + "db"

def test_ascii_file_shelf(self):
try:
Expand Down
10 changes: 5 additions & 5 deletions Lib/test/test_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ def forget(modname):
import os
for dirname in sys.path:
try:
os.unlink(os.path.join(dirname, modname + '.pyc'))
os.unlink(os.path.join(dirname, modname + os.extsep + 'pyc'))
except os.error:
pass
# Deleting the .pyo file cannot be within the 'try' for the .pyc since
# the chance exists that there is no .pyc (and thus the 'try' statement
# is exited) but there is a .pyo file.
try:
os.unlink(os.path.join(dirname, modname + '.pyo'))
os.unlink(os.path.join(dirname, modname + os.extsep + 'pyo'))
except os.error:
pass

Expand Down Expand Up @@ -118,7 +118,9 @@ def fcmp(x, y): # fuzzy comparison function
if os.name == 'java':
# Jython disallows @ in module names
TESTFN = '$test'
elif os.name != 'riscos':
elif os.name == 'riscos':
TESTFN = 'testfile'
else:
TESTFN = '@test'
# Unicode name only used if TEST_FN_ENCODING exists for the platform.
if have_unicode:
Expand All @@ -129,8 +131,6 @@ def fcmp(x, y): # fuzzy comparison function
else:
TESTFN_UNICODE=unicode("@test-\xe0\xf2", "latin-1") # 2 latin characters.
TESTFN_ENCODING=sys.getfilesystemencoding()
else:
TESTFN = 'test'

# Make sure we can write to TESTFN, try in /tmp if we can't
fp = None
Expand Down
8 changes: 4 additions & 4 deletions Lib/test/test_tarfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@
def path(path):
return test_support.findfile(path)

testtar = path("testtar.tar")
tempdir = path("testtar.dir")
tempname = path("testtar.tmp")
testtar = path("testtar" + os.extsep + "tar")
tempdir = path("testtar" + os.extsep + "dir")
tempname = path("testtar" + os.extsep + "tmp")
membercount = 10

def tarname(comp=""):
if not comp:
return testtar
return "%s.%s" % (testtar, comp)
return "%s%s%s" % (testtar, os.extsep, comp)

def dirname():
if not os.path.exists(tempdir):
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_zipimport.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def make_pyc(co, mtime):
TESTMOD = "ziptestmodule"
TESTPACK = "ziptestpackage"
TESTPACK2 = "ziptestpackage2"
TEMP_ZIP = os.path.abspath("junk95142.zip")
TEMP_ZIP = os.path.abspath("junk95142" + os.extsep + "zip")

class UncompressedZipImportTestCase(ImportHooksBaseTestCase):

Expand Down
44 changes: 36 additions & 8 deletions Modules/socketmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,11 @@ typedef size_t socklen_t;
# ifndef RISCOS
# include <fcntl.h>
# else
# include <sys/fcntl.h>
# include <sys/ioctl.h>
# include <socklib.h>
# define NO_DUP
int h_errno; /* not used */
# define INET_ADDRSTRLEN 16
# endif

#else
Expand Down Expand Up @@ -464,6 +466,18 @@ set_error(void)
}
#endif

#if defined(RISCOS)
if (_inet_error.errnum != NULL) {
PyObject *v;
v = Py_BuildValue("(is)", errno, _inet_err());
if (v != NULL) {
PyErr_SetObject(socket_error, v);
Py_DECREF(v);
}
return NULL;
}
#endif

return PyErr_SetFromErrno(socket_error);
}

Expand Down Expand Up @@ -548,8 +562,11 @@ internal_setblocking(PySocketSockObject *s, int block)
block = !block;
ioctlsocket(s->sock_fd, FIONBIO, (u_long*)&block);
#endif /* MS_WINDOWS */
#endif /* __BEOS__ */
#else /* RISCOS */
block = !block;
socketioctl(s->sock_fd, FIONBIO, (u_long*)&block);
#endif /* RISCOS */
#endif /* __BEOS__ */
Py_END_ALLOW_THREADS

/* Since these don't return anything */
Expand Down Expand Up @@ -1211,11 +1228,11 @@ operations are disabled.");
/* s.sleeptaskw(1 | 0) method */

static PyObject *
sock_sleeptaskw(PySocketSockObject *s,PyObject *args)
sock_sleeptaskw(PySocketSockObject *s,PyObject *arg)
{
int block;
int delay_flag;
if (!PyArg_Parse(args, "i", &block))
block = PyInt_AsLong(arg);
if (block == -1 && PyErr_Occurred())
return NULL;
Py_BEGIN_ALLOW_THREADS
socketioctl(s->sock_fd, 0x80046679, (u_long*)&block);
Expand Down Expand Up @@ -2056,7 +2073,7 @@ static PyMethodDef sock_methods[] = {
{"shutdown", (PyCFunction)sock_shutdown, METH_O,
shutdown_doc},
#ifdef RISCOS
{"sleeptaskw", (PyCFunction)sock_sleeptaskw, METH_VARARGS,
{"sleeptaskw", (PyCFunction)sock_sleeptaskw, METH_O,
sleeptaskw_doc},
#endif
{NULL, NULL} /* sentinel */
Expand Down Expand Up @@ -2858,8 +2875,11 @@ socket_inet_pton(PyObject *self, PyObject *args)
int af;
char* ip;
int retval;
#ifdef ENABLE_IPV6
char packed[MAX(sizeof(struct in_addr), sizeof(struct in6_addr))];

#else
char packed[sizeof(struct in_addr)];
#endif
if (!PyArg_ParseTuple(args, "is:inet_pton", &af, &ip)) {
return NULL;
}
Expand All @@ -2875,9 +2895,11 @@ socket_inet_pton(PyObject *self, PyObject *args)
} else if (af == AF_INET) {
return PyString_FromStringAndSize(packed,
sizeof(struct in_addr));
#ifdef ENABLE_IPV6
} else if (af == AF_INET6) {
return PyString_FromStringAndSize(packed,
sizeof(struct in6_addr));
#endif
} else {
PyErr_SetString(socket_error, "unknown address family");
return NULL;
Expand All @@ -2896,7 +2918,11 @@ socket_inet_ntop(PyObject *self, PyObject *args)
char* packed;
int len;
const char* retval;
#ifdef ENABLE_IPV6
char ip[MAX(INET_ADDRSTRLEN, INET6_ADDRSTRLEN) + 1];
#else
char ip[INET_ADDRSTRLEN + 1];
#endif

/* Guarantee NUL-termination for PyString_FromString() below */
memset((void *) &ip[0], '\0', sizeof(ip) + 1);
Expand All @@ -2911,12 +2937,14 @@ socket_inet_ntop(PyObject *self, PyObject *args)
"invalid length of packed IP address string");
return NULL;
}
#ifdef ENABLE_IPV6
} else if (af == AF_INET6) {
if (len != sizeof(struct in6_addr)) {
PyErr_SetString(PyExc_ValueError,
"invalid length of packed IP address string");
return NULL;
}
#endif
} else {
PyErr_Format(PyExc_ValueError,
"unknown address family %d", af);
Expand Down Expand Up @@ -3235,7 +3263,7 @@ os_init(void)
_kernel_swi(0x43380, &r, &r);
taskwindow = r.r[0];

return 0;
return 1;
}

#endif /* RISCOS */
Expand Down
6 changes: 5 additions & 1 deletion Modules/timemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ static long main_thread;
#include <kernel/OS.h>
#endif

#ifdef RISCOS
extern int riscos_sleep(double);
#endif

/* Forward declarations */
static int floatsleep(double);
static double floattime(void);
Expand Down Expand Up @@ -944,7 +948,7 @@ floatsleep(double secs)
return 0;
Py_BEGIN_ALLOW_THREADS
/* This sleep *CAN BE* interrupted. */
if ( sleep(secs) )
if ( riscos_sleep(secs) )
return -1;
Py_END_ALLOW_THREADS
#elif defined(PLAN9)
Expand Down
10 changes: 10 additions & 0 deletions Modules/zipimport.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ zipimporter_init(ZipImporter *self, PyObject *args, PyObject *kwds)
path = NULL;
prefix = NULL;
for (;;) {
#ifndef RISCOS
struct stat statbuf;
int rv;

Expand All @@ -102,6 +103,15 @@ zipimporter_init(ZipImporter *self, PyObject *args, PyObject *kwds)
path = buf;
break;
}
#else
if (object_exists(buf)) {
/* it exists */
if (isfile(buf))
/* it's a file */
path = buf;
break;
}
#endif
/* back up one path element */
p = strrchr(buf, SEP);
if (prefix != NULL)
Expand Down
2 changes: 1 addition & 1 deletion Objects/typeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -5086,7 +5086,7 @@ update_one_slot(PyTypeObject *type, slotdef *p)
sanity checks and constructing a new argument
list. Cut all that nonsense short -- this speeds
up instance creation tremendously. */
specific = type->tp_new;
specific = (void *)type->tp_new;
/* XXX I'm not 100% sure that there isn't a hole
in this reasoning that requires additional
sanity checks. I'll buy the first person to
Expand Down
4 changes: 4 additions & 0 deletions Parser/grammar.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
#include "token.h"
#include "grammar.h"

#ifdef RISCOS
#include <unixlib.h>
#endif

extern int Py_DebugFlag;

grammar *
Expand Down
Loading

0 comments on commit 3faae1b

Please sign in to comment.