File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# Implement (a subset of) Sun XDR -- RFC1014.
22
33
4- import struct
4+ try :
5+ import struct
6+ except ImportError :
7+ struct = None
58
69
710Long = type (0L )
@@ -23,7 +26,7 @@ def pack_uint(self, x):
2326 self .buf = self .buf + \
2427 (chr (int (x >> 24 & 0xff )) + chr (int (x >> 16 & 0xff )) + \
2528 chr (int (x >> 8 & 0xff )) + chr (int (x & 0xff )))
26- if struct .pack ('l' , 1 ) == '\0 \0 \0 \1 ' :
29+ if struct and struct .pack ('l' , 1 ) == '\0 \0 \0 \1 ' :
2730 def pack_uint (self , x ):
2831 if type (x ) == Long :
2932 x = int ((x + 0x80000000L ) % 0x100000000L \
@@ -92,7 +95,7 @@ def unpack_uint(self):
9295 # as a nonnegative Python int
9396 if x < 0x80000000L : x = int (x )
9497 return x
95- if struct .unpack ('l' , '\0 \0 \0 \1 ' ) == 1 :
98+ if struct and struct .unpack ('l' , '\0 \0 \0 \1 ' ) == 1 :
9699 def unpack_uint (self ):
97100 i = self .pos
98101 self .pos = j = i + 4
You can’t perform that action at this time.
0 commit comments