summaryrefslogtreecommitdiffstats
path: root/Demo
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1992-12-17 17:32:24 (GMT)
committerGuido van Rossum <guido@python.org>1992-12-17 17:32:24 (GMT)
commit7271babcef777cd66e29dd88d555afe3bf37b692 (patch)
treeb8dc777222a808aa7aafb2cc7359c9778c49c43b /Demo
parent2f5dd888d197bfccb083d8db900bbbd81270e785 (diff)
downloadcpython-7271babcef777cd66e29dd88d555afe3bf37b692.zip
cpython-7271babcef777cd66e29dd88d555afe3bf37b692.tar.gz
cpython-7271babcef777cd66e29dd88d555afe3bf37b692.tar.bz2
Compatibility hack with Python 0.9.6.
Diffstat (limited to 'Demo')
-rw-r--r--Demo/rpc/xdr.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/Demo/rpc/xdr.py b/Demo/rpc/xdr.py
index 1d123dc..bee88b4 100644
--- a/Demo/rpc/xdr.py
+++ b/Demo/rpc/xdr.py
@@ -1,7 +1,10 @@
# Implement (a subset of) Sun XDR -- RFC1014.
-import struct
+try:
+ import struct
+except ImportError:
+ struct = None
Long = type(0L)
@@ -23,7 +26,7 @@ class Packer:
self.buf = self.buf + \
(chr(int(x>>24 & 0xff)) + chr(int(x>>16 & 0xff)) + \
chr(int(x>>8 & 0xff)) + chr(int(x & 0xff)))
- if struct.pack('l', 1) == '\0\0\0\1':
+ if struct and struct.pack('l', 1) == '\0\0\0\1':
def pack_uint(self, x):
if type(x) == Long:
x = int((x + 0x80000000L) % 0x100000000L \
@@ -92,7 +95,7 @@ class Unpacker:
# as a nonnegative Python int
if x < 0x80000000L: x = int(x)
return x
- if struct.unpack('l', '\0\0\0\1') == 1:
+ if struct and struct.unpack('l', '\0\0\0\1') == 1:
def unpack_uint(self):
i = self.pos
self.pos = j = i+4