Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 4c51507877252e0b783409e937341e81 > files > 16

firefox-10.0.12-1.el5_9.src.rpm

diff -up mozilla-esr10/config/expandlibs_exec.py.python mozilla-esr10/config/expandlibs_exec.py
--- mozilla-esr10/config/expandlibs_exec.py.python	2012-04-20 23:59:36.000000000 +0200
+++ mozilla-esr10/config/expandlibs_exec.py	2012-04-21 13:43:58.297026009 +0200
@@ -49,13 +49,11 @@ EXPAND_LIBS_LIST_STYLE variable: 'list' 
 or 'linkerscript' for GNU ld linker scripts.
 See https://bugzilla.mozilla.org/show_bug.cgi?id=584474#c59 for more details.
 '''
-from __future__ import with_statement
 import sys
 import os
 from expandlibs import ExpandArgs, relativize
 import expandlibs_config as conf
 from optparse import OptionParser
-import subprocess
 import tempfile
 import shutil
 
@@ -90,7 +88,11 @@ class ExpandArgsMore(ExpandArgs):
                 elif os.path.exists(arg) and len(ar_extract):
                     tmp = tempfile.mkdtemp(dir=os.curdir)
                     self.tmp.append(tmp)
-                    subprocess.call(ar_extract + [os.path.abspath(arg)], cwd=tmp)
+                    tmp_arg = ar_extract + [os.path.abspath(arg)]
+                    oldir = os.getcwd()
+                    os.chdir(tmp)
+                    os.system(' '.join(tmp_arg))
+                    os.chdir(oldir)
                     objs = []
                     for root, dirs, files in os.walk(tmp):
                         objs += [relativize(os.path.join(root, f)) for f in files if os.path.splitext(f)[1] in [conf.OBJ_SUFFIX, '.i_o']]
@@ -136,20 +138,26 @@ def main():
 
     (options, args) = parser.parse_args()
 
-    with ExpandArgsMore(args) as args:
+   
+    args2 = ExpandArgsMore(args)
+    args2.__enter__()
+    try:
         if options.extract:
-            args.extract()
+            args2.extract()
         if options.uselist:
-            args.makelist()
+            args2.makelist()
 
         if options.verbose:
-            print >>sys.stderr, "Executing: " + " ".join(args)
-            for tmp in [f for f in args.tmp if os.path.isfile(f)]:
+            print >>sys.stderr, "Executing: " + " ".join(args2)
+            for tmp in [f for f in args2.tmp if os.path.isfile(f)]:
                 print >>sys.stderr, tmp + ":"
-                with open(tmp) as file:
-                    print >>sys.stderr, "".join(["    " + l for l in file.readlines()])
+                ff = open(tmp)
+                print >>sys.stderr, "".join(["    " + l for l in ff.readlines()])
             sys.stderr.flush()
-        exit(subprocess.call(args))
+        ret = os.system(' '.join(args2))
+        sys.exit(ret)
+    finally:
+        args2.__exit__(0, 0, 0)
 
 if __name__ == '__main__':
     main()
diff -up mozilla-esr10/config/expandlibs.py.python mozilla-esr10/config/expandlibs.py
--- mozilla-esr10/config/expandlibs.py.python	2012-04-20 23:59:36.000000000 +0200
+++ mozilla-esr10/config/expandlibs.py	2012-04-21 13:43:58.298026009 +0200
@@ -59,7 +59,6 @@ ${LIB_PREFIX}${ROOT}.${LIB_SUFFIX} follo
   descriptor contains. And for each of these LIBS, also apply the same
   rules.
 '''
-from __future__ import with_statement
 import sys, os
 import expandlibs_config as conf
 
@@ -93,15 +92,15 @@ class LibDescriptor(dict):
         '''Creates an instance of a lib descriptor, initialized with contents
         from a list of strings when given. This is intended for use with
         file.readlines()'''
-        if isinstance(content, list) and all([isinstance(item, str) for item in content]):
-            pass
-        elif content is not None:
-            raise TypeError("LibDescriptor() arg 1 must be None or a list of strings")
         super(LibDescriptor, self).__init__()
         for key in self.KEYS:
             self[key] = []
-        if not content:
+        if content == None:
             return
+        if isinstance(content, list):
+           for item in content:
+              if not isinstance(item, str):
+                 raise TypeError("LibDescriptor() arg 1 must be None or a list of strings")
         for key, value in [(s.strip() for s in item.split('=', 2)) for item in content if item.find('=') >= 0]:
             if key in self.KEYS:
                 self[key] = value.split()
@@ -136,8 +135,8 @@ class ExpandArgs(list):
     def _expand_desc(self, arg):
         '''Internal function taking care of lib descriptor expansion only'''
         if os.path.exists(arg + conf.LIBS_DESC_SUFFIX):
-            with open(arg + conf.LIBS_DESC_SUFFIX, 'r') as f:
-                desc = LibDescriptor(f.readlines())
+            f = open(arg + conf.LIBS_DESC_SUFFIX, 'r')
+            desc = LibDescriptor(f.readlines())
             objs = [relativize(o) for o in desc['OBJS']]
             for lib in desc['LIBS']:
                 objs += self._expand(lib)
diff -up mozilla-esr10/config/optimizejars.py.python mozilla-esr10/config/optimizejars.py
--- mozilla-esr10/config/optimizejars.py.python	2012-04-20 23:59:36.000000000 +0200
+++ mozilla-esr10/config/optimizejars.py	2012-04-21 13:46:36.905029243 +0200
@@ -320,14 +320,17 @@ def optimizejar(jar, outjar, inlog = Non
         outfd.write(dirend_data)
 
     print "Stripped %d bytes" % total_stripped
-    print "%s %d/%d in %s" % (("Ordered" if inlog is not None else "Deoptimized"),
+    tmp_str = "Ordered"
+    if inlog is None:
+       tmp_str = "Deoptimized"
+    print "%s %d/%d in %s" % (tmp_str,
                               reordered_count, len(central_directory), outjar)
     outfd.close()
     return outlog
         
 if len(sys.argv) != 5:
     print "Usage: --optimize|--deoptimize %s JAR_LOG_DIR IN_JAR_DIR OUT_JAR_DIR" % sys.argv[0]
-    exit(1)
+    sys.exit(1)
 
 jar_regex = re.compile("\\.jar?$")
 
diff -up mozilla-esr10/configure.python mozilla-esr10/configure
--- mozilla-esr10/configure.python	2012-04-21 00:00:24.000000000 +0200
+++ mozilla-esr10/configure	2012-04-21 13:43:58.311026009 +0200
@@ -1094,7 +1094,7 @@ NSS_VERSION=3
 
 GLIB_VERSION=1.2.0
 PERL_VERSION=5.006
-PYTHON_VERSION=2.5
+PYTHON_VERSION=2.4
 CAIRO_VERSION=1.10
 PANGO_VERSION=1.14.0
 GTK2_VERSION=2.10.0
diff -up mozilla-esr10/config/writemozinfo.py.python mozilla-esr10/config/writemozinfo.py
--- mozilla-esr10/config/writemozinfo.py.python	2012-04-20 23:59:36.000000000 +0200
+++ mozilla-esr10/config/writemozinfo.py	2012-04-21 13:43:58.315026009 +0200
@@ -5,7 +5,6 @@
 # configuration, such as the target OS and CPU.
 #
 # The output file is intended to be used as input to the mozinfo package.
-from __future__ import with_statement
 import os, re, sys
 
 def build_dict(env=os.environ):
@@ -98,8 +97,9 @@ def write_json(file, env=os.environ):
     """
     s = jsonify(build_dict(env))
     if isinstance(file, basestring):
-        with open(file, "w") as f:
-            f.write(s)
+        f = open(file, "w")
+        f.write(s)
+        f.close()
     else:
         file.write(s)
 
diff -up mozilla-esr10/js/src/config/expandlibs_exec.py.python mozilla-esr10/js/src/config/expandlibs_exec.py
--- mozilla-esr10/js/src/config/expandlibs_exec.py.python	2012-04-20 23:59:44.000000000 +0200
+++ mozilla-esr10/js/src/config/expandlibs_exec.py	2012-04-21 13:43:58.317026009 +0200
@@ -49,13 +49,11 @@ EXPAND_LIBS_LIST_STYLE variable: 'list' 
 or 'linkerscript' for GNU ld linker scripts.
 See https://bugzilla.mozilla.org/show_bug.cgi?id=584474#c59 for more details.
 '''
-from __future__ import with_statement
 import sys
 import os
 from expandlibs import ExpandArgs, relativize
 import expandlibs_config as conf
 from optparse import OptionParser
-import subprocess
 import tempfile
 import shutil
 
@@ -90,7 +88,11 @@ class ExpandArgsMore(ExpandArgs):
                 elif os.path.exists(arg) and len(ar_extract):
                     tmp = tempfile.mkdtemp(dir=os.curdir)
                     self.tmp.append(tmp)
-                    subprocess.call(ar_extract + [os.path.abspath(arg)], cwd=tmp)
+                    tmp_arg = ar_extract + [os.path.abspath(arg)]
+                    oldir = os.getcwd()
+                    os.chdir(tmp)
+                    os.system(' '.join(tmp_arg))
+                    os.chdir(oldir)
                     objs = []
                     for root, dirs, files in os.walk(tmp):
                         objs += [relativize(os.path.join(root, f)) for f in files if os.path.splitext(f)[1] in [conf.OBJ_SUFFIX, '.i_o']]
@@ -136,20 +138,26 @@ def main():
 
     (options, args) = parser.parse_args()
 
-    with ExpandArgsMore(args) as args:
+   
+    args2 = ExpandArgsMore(args)
+    args2.__enter__()
+    try:
         if options.extract:
-            args.extract()
+            args2.extract()
         if options.uselist:
-            args.makelist()
+            args2.makelist()
 
         if options.verbose:
-            print >>sys.stderr, "Executing: " + " ".join(args)
-            for tmp in [f for f in args.tmp if os.path.isfile(f)]:
+            print >>sys.stderr, "Executing: " + " ".join(args2)
+            for tmp in [f for f in args2.tmp if os.path.isfile(f)]:
                 print >>sys.stderr, tmp + ":"
-                with open(tmp) as file:
-                    print >>sys.stderr, "".join(["    " + l for l in file.readlines()])
+                ff = open(tmp)
+                print >>sys.stderr, "".join(["    " + l for l in ff.readlines()])
             sys.stderr.flush()
-        exit(subprocess.call(args))
+        ret = os.system(' '.join(args2))
+        sys.exit(ret)
+    finally:
+        args2.__exit__(0, 0, 0)
 
 if __name__ == '__main__':
     main()
diff -up mozilla-esr10/js/src/config/expandlibs.py.python mozilla-esr10/js/src/config/expandlibs.py
--- mozilla-esr10/js/src/config/expandlibs.py.python	2012-04-20 23:59:44.000000000 +0200
+++ mozilla-esr10/js/src/config/expandlibs.py	2012-04-21 13:43:58.318026009 +0200
@@ -59,7 +59,6 @@ ${LIB_PREFIX}${ROOT}.${LIB_SUFFIX} follo
   descriptor contains. And for each of these LIBS, also apply the same
   rules.
 '''
-from __future__ import with_statement
 import sys, os
 import expandlibs_config as conf
 
@@ -93,15 +92,15 @@ class LibDescriptor(dict):
         '''Creates an instance of a lib descriptor, initialized with contents
         from a list of strings when given. This is intended for use with
         file.readlines()'''
-        if isinstance(content, list) and all([isinstance(item, str) for item in content]):
-            pass
-        elif content is not None:
-            raise TypeError("LibDescriptor() arg 1 must be None or a list of strings")
         super(LibDescriptor, self).__init__()
         for key in self.KEYS:
             self[key] = []
-        if not content:
+        if content == None:
             return
+        if isinstance(content, list):
+           for item in content:
+              if not isinstance(item, str):
+                 raise TypeError("LibDescriptor() arg 1 must be None or a list of strings")
         for key, value in [(s.strip() for s in item.split('=', 2)) for item in content if item.find('=') >= 0]:
             if key in self.KEYS:
                 self[key] = value.split()
@@ -136,8 +135,8 @@ class ExpandArgs(list):
     def _expand_desc(self, arg):
         '''Internal function taking care of lib descriptor expansion only'''
         if os.path.exists(arg + conf.LIBS_DESC_SUFFIX):
-            with open(arg + conf.LIBS_DESC_SUFFIX, 'r') as f:
-                desc = LibDescriptor(f.readlines())
+            f = open(arg + conf.LIBS_DESC_SUFFIX, 'r')
+            desc = LibDescriptor(f.readlines())
             objs = [relativize(o) for o in desc['OBJS']]
             for lib in desc['LIBS']:
                 objs += self._expand(lib)
diff -up mozilla-esr10/js/src/configure.python mozilla-esr10/js/src/configure
--- mozilla-esr10/js/src/configure.python	2012-04-21 00:00:24.000000000 +0200
+++ mozilla-esr10/js/src/configure	2012-04-21 13:43:58.325026009 +0200
@@ -863,7 +863,7 @@ _SUBDIR_CONFIG_ARGS="$ac_configure_args"
 NSPR_VERSION=4
 
 PERL_VERSION=5.006
-PYTHON_VERSION=2.5
+PYTHON_VERSION=2.4
 WINDRES_VERSION=2.14.90
 W32API_VERSION=3.14
 
diff -up mozilla-esr10/js/xpconnect/src/codegen.py.python mozilla-esr10/js/xpconnect/src/codegen.py
--- mozilla-esr10/js/xpconnect/src/codegen.py.python	2012-04-20 23:59:47.000000000 +0200
+++ mozilla-esr10/js/xpconnect/src/codegen.py	2012-04-21 13:43:58.327026009 +0200
@@ -508,8 +508,11 @@ def writeStub(f, customMethodCalls, memb
             argumentValues = (customMethodCall['additionalArgumentValues']
                               % header.methodNativeName(member))
             if isAttr:
+                strict_str = ""
+                if isSetter:
+                    strict_str = ", strict"
                 callTemplate += ("    return %s(cx, obj, id%s, %s, vp);\n"
-                                 % (templateName, ", strict" if isSetter else "", argumentValues))
+                                 % (templateName, strict_str, argumentValues))
             else:
                 callTemplate += ("    return %s(cx, argc, %s, vp);\n"
                                  % (templateName, argumentValues))
diff -up mozilla-esr10/js/xpconnect/src/dombindingsgen.py.python mozilla-esr10/js/xpconnect/src/dombindingsgen.py
--- mozilla-esr10/js/xpconnect/src/dombindingsgen.py.python	2012-04-20 23:59:47.000000000 +0200
+++ mozilla-esr10/js/xpconnect/src/dombindingsgen.py	2012-04-21 13:43:58.328026009 +0200
@@ -190,7 +190,10 @@ class DOMClass(UserDict.DictMixin):
 
         def ops(getterType, setterType):
             def opType(type):
-                return type + (" " if type.endswith('>') else "")
+                if type.endswith('>'):
+                    return type + " "
+                else:
+                    return type
 
             if getterType or setterType:
                 opsClass = ", Ops<"
@@ -209,7 +212,10 @@ class DOMClass(UserDict.DictMixin):
         if key == 'indexOps':
             return ops(self.indexGetter and self.indexGetterType, self.indexSetter and self.indexSetterType)
         if key == 'nameOps':
-            return ops(self.nameGetter and self.nameGetterType, self.nameSetter and self.nameSetterType) if self.nameGetter else ""
+            if self.nameGetter:
+                return ops(self.nameGetter and self.nameGetterType, self.nameSetter and self.nameSetterType)
+            else:
+                return ""
 
         if key == 'listClass':
             if self.base:
@@ -222,7 +228,10 @@ class DOMClass(UserDict.DictMixin):
 
     def __cmp__(x, y):
         if x.isBase != y.isBase:
-            return -1 if x.isBase else 1
+            if x.isBase:
+                return -1
+            else:
+                return 1;
         return cmp(x.name, y.name)
 
 class Configuration:
diff -up mozilla-esr10/js/xpconnect/src/qsgen.py.python mozilla-esr10/js/xpconnect/src/qsgen.py
--- mozilla-esr10/js/xpconnect/src/qsgen.py.python	2012-04-20 23:59:47.000000000 +0200
+++ mozilla-esr10/js/xpconnect/src/qsgen.py	2012-04-21 13:43:58.330026009 +0200
@@ -822,9 +822,12 @@ def writeQuickStub(f, customMethodCalls,
                           or header.firstCap(member.name))
             argumentValues = (customMethodCall['additionalArgumentValues']
                               % nativeName)
+            templateStrict = ", strict"
+            if not isSetter:
+                templateStrict = ""
             if isAttr:
                 callTemplate += ("    return %s(cx, obj, id%s, %s, vp);\n"
-                                 % (templateName, ", strict" if isSetter else "", argumentValues))
+                                 % (templateName, templateStrict, argumentValues))
             else:
                 callTemplate += ("    return %s(cx, argc, %s, vp);\n"
                                  % (templateName, argumentValues))
diff -up mozilla-esr10/xpcom/idl-parser/header.py.python mozilla-esr10/xpcom/idl-parser/header.py
--- mozilla-esr10/xpcom/idl-parser/header.py.python	2012-04-21 00:00:05.000000000 +0200
+++ mozilla-esr10/xpcom/idl-parser/header.py	2012-04-21 13:43:58.331026009 +0200
@@ -40,7 +40,7 @@
 
 """Print a C++ header file for the IDL files specified on the command line"""
 
-import sys, os.path, re, xpidl
+import sys, os.path, re, xpidl, string
 
 printdoccomments = False
 
@@ -198,7 +198,7 @@ forward_decl = """class %(name)s; /* for
 
 def idl_basename(f):
     """returns the base name of a file with the last extension stripped"""
-    return os.path.basename(f).rpartition('.')[0]
+    return string.split(os.path.basename(f), '.')[0]
 
 def print_header(idl, fd, filename):
     fd.write(header % {'filename': filename,
@@ -486,7 +486,9 @@ if __name__ == '__main__':
     o.add_option('--regen', action='store_true', dest='regen', default=False,
                  help="Regenerate IDL Parser cache")
     options, args = o.parse_args()
-    file = args[0] if args else None
+    file = None
+    if args:
+        file = args[0]
 
     if options.cachedir is not None:
         if not os.path.isdir(options.cachedir):
diff -up mozilla-esr10/xpcom/idl-parser/typelib.py.python mozilla-esr10/xpcom/idl-parser/typelib.py
--- mozilla-esr10/xpcom/idl-parser/typelib.py.python	2012-04-21 00:00:05.000000000 +0200
+++ mozilla-esr10/xpcom/idl-parser/typelib.py	2012-04-21 13:43:58.332026009 +0200
@@ -285,7 +285,9 @@ if __name__ == '__main__':
     o.add_option('--regen', action='store_true', dest='regen', default=False,
                  help="Regenerate IDL Parser cache")
     options, args = o.parse_args()
-    file = args[0] if args else None
+    file = None
+    if args:
+       file = args[0]
 
     if options.cachedir is not None:
         if not os.path.isdir(options.cachedir):
diff -up mozilla-esr10/xpcom/typelib/xpt/tools/xpt.py.python mozilla-esr10/xpcom/typelib/xpt/tools/xpt.py
--- mozilla-esr10/xpcom/typelib/xpt/tools/xpt.py.python	2012-04-21 00:00:05.000000000 +0200
+++ mozilla-esr10/xpcom/typelib/xpt/tools/xpt.py	2012-04-21 13:43:58.335026010 +0200
@@ -65,7 +65,6 @@ InterfaceType()        - construct a new
 
 """
 
-from __future__ import with_statement
 import os, sys
 import struct
 
@@ -101,7 +100,7 @@ class Type(object):
     this class directly. Rather, use one of its subclasses.
     
     """
-    _prefixdescriptor = struct.Struct(">B")
+    _prefixdescriptor = struct
     Tags = enum(
         # The first 18 entries are SimpleTypeDescriptor
         'int8',
@@ -183,13 +182,13 @@ class Type(object):
         
         """
         start = data_pool + offset - 1
-        (data,) = Type._prefixdescriptor.unpack(map[start:start + Type._prefixdescriptor.size])
+        (data,) = Type._prefixdescriptor.unpack(">B", map[start:start + Type._prefixdescriptor.calcsize(">B")])
         # first three bits are the flags
         flags = data & 0xE0
         flags = Type.decodeflags(flags)
         # last five bits is the tag
         tag = data & 0x1F
-        offset += Type._prefixdescriptor.size
+        offset += Type._prefixdescriptor.calcsize(">B")
         t = None
         if tag <= Type.Tags.wchar_t_ptr or tag >= Type.Tags.UTF8String:
             t = SimpleType.get(data, tag, flags)
@@ -213,7 +212,7 @@ class Type(object):
         and the subclass method must be called.
 
         """
-        file.write(Type._prefixdescriptor.pack(self.encodeflags() | self.tag))
+        file.write(Type._prefixdescriptor.pack(">B", self.encodeflags() | self.tag))
 
 class SimpleType(Type):
     """
@@ -262,7 +261,7 @@ class InterfaceType(Type):
     (InterfaceTypeDescriptor from the typelib specification.)
 
     """
-    _descriptor = struct.Struct(">H")
+    _descriptor = struct
 
     def __init__(self, iface, pointer=True, **kwargs):
         if not pointer:
@@ -284,8 +283,8 @@ class InterfaceType(Type):
         if not flags['pointer']:
             return None, offset
         start = data_pool + offset - 1
-        (iface_index,) = InterfaceType._descriptor.unpack(map[start:start + InterfaceType._descriptor.size])
-        offset += InterfaceType._descriptor.size
+        (iface_index,) = InterfaceType._descriptor.unpack(">H", map[start:start + InterfaceType._descriptor.calcsize(">H")])
+        offset += InterfaceType._descriptor.calcsize(">H")
         iface = None
         # interface indices are 1-based
         if iface_index > 0 and iface_index <= len(typelib.interfaces):
@@ -300,7 +299,7 @@ class InterfaceType(Type):
         """
         Type.write(self, typelib, file)
         # write out the interface index (1-based)
-        file.write(InterfaceType._descriptor.pack(typelib.interfaces.index(self.iface) + 1))
+        file.write(InterfaceType._descriptor.pack(">H", typelib.interfaces.index(self.iface) + 1))
 
     def __str__(self):
         if self.iface:
@@ -314,7 +313,7 @@ class InterfaceIsType(Type):
     typelib specification.)
     
     """
-    _descriptor = struct.Struct(">B")
+    _descriptor = struct
     _cache = {}
 
     def __init__(self, param_index, pointer=True, **kwargs):
@@ -338,8 +337,8 @@ class InterfaceIsType(Type):
         if not flags['pointer']:
             return None, offset
         start = data_pool + offset - 1
-        (param_index,) = InterfaceIsType._descriptor.unpack(map[start:start + InterfaceIsType._descriptor.size])
-        offset += InterfaceIsType._descriptor.size
+        (param_index,) = InterfaceIsType._descriptor.unpack(">B", map[start:start + InterfaceIsType._descriptor.calcsize(">B")])
+        offset += InterfaceIsType._descriptor.calcsize(">B")
         if param_index not in InterfaceIsType._cache:
             InterfaceIsType._cache[param_index] = InterfaceIsType(param_index, **flags)
         return InterfaceIsType._cache[param_index], offset
@@ -351,7 +350,7 @@ class InterfaceIsType(Type):
 
         """
         Type.write(self, typelib, file)
-        file.write(InterfaceIsType._descriptor.pack(self.param_index))
+        file.write(InterfaceIsType._descriptor.pack(">B", self.param_index))
 
     def __str__(self):
         return "InterfaceIs *"
@@ -363,7 +362,7 @@ class ArrayType(Type):
     (ArrayTypeDescriptor from the typelib specification.)
     
     """
-    _descriptor = struct.Struct(">BB")
+    _descriptor = struct
 
     def __init__(self, element_type, size_is_arg_num, length_is_arg_num,
                  pointer=True, **kwargs):
@@ -387,8 +386,8 @@ class ArrayType(Type):
         if not flags['pointer']:
             return None, offset
         start = data_pool + offset - 1
-        (size_is_arg_num, length_is_arg_num) = ArrayType._descriptor.unpack(map[start:start + ArrayType._descriptor.size])
-        offset += ArrayType._descriptor.size
+        (size_is_arg_num, length_is_arg_num) = ArrayType._descriptor.unpack(">BB", map[start:start + ArrayType._descriptor.calcsize(">BB")])
+        offset += ArrayType._descriptor.calcsize(">BB")
         t, offset = Type.read(typelib, map, data_pool, offset)
         return ArrayType(t, size_is_arg_num, length_is_arg_num, **flags), offset
 
@@ -399,7 +398,7 @@ class ArrayType(Type):
 
         """
         Type.write(self, typelib, file)
-        file.write(ArrayType._descriptor.pack(self.size_is_arg_num,
+        file.write(ArrayType._descriptor.pack(">BB", self.size_is_arg_num,
                                               self.length_is_arg_num))
         self.element_type.write(typelib, file)
 
@@ -413,7 +412,7 @@ class StringWithSizeType(Type):
     from the typelib specification.)
 
     """
-    _descriptor = struct.Struct(">BB")
+    _descriptor = struct
 
     def __init__(self, size_is_arg_num, length_is_arg_num,
                  pointer=True, **kwargs):
@@ -436,8 +435,8 @@ class StringWithSizeType(Type):
         if not flags['pointer']:
             return None, offset
         start = data_pool + offset - 1
-        (size_is_arg_num, length_is_arg_num) = StringWithSizeType._descriptor.unpack(map[start:start + StringWithSizeType._descriptor.size])
-        offset += StringWithSizeType._descriptor.size
+        (size_is_arg_num, length_is_arg_num) = StringWithSizeType._descriptor.unpack(">BB", map[start:start + StringWithSizeType._descriptor.calcsize(">BB")])
+        offset += StringWithSizeType._descriptor.calcsize(">BB")
         return StringWithSizeType(size_is_arg_num, length_is_arg_num, **flags), offset
     
     def write(self, typelib, file):
@@ -447,7 +446,7 @@ class StringWithSizeType(Type):
 
         """
         Type.write(self, typelib, file)
-        file.write(StringWithSizeType._descriptor.pack(self.size_is_arg_num,
+        file.write(StringWithSizeType._descriptor.pack(">BB", self.size_is_arg_num,
                                                        self.length_is_arg_num))
         
     def __str__(self):
@@ -460,7 +459,7 @@ class WideStringWithSizeType(Type):
     (WideStringWithSizeTypeDescriptor from the typelib specification.)
 
     """    
-    _descriptor = struct.Struct(">BB")
+    _descriptor = struct
 
     def __init__(self, size_is_arg_num, length_is_arg_num,
                  pointer=True, **kwargs):
@@ -483,8 +482,8 @@ class WideStringWithSizeType(Type):
         if not flags['pointer']:
             return None, offset
         start = data_pool + offset - 1
-        (size_is_arg_num, length_is_arg_num) = WideStringWithSizeType._descriptor.unpack(map[start:start + WideStringWithSizeType._descriptor.size])
-        offset += WideStringWithSizeType._descriptor.size
+        (size_is_arg_num, length_is_arg_num) = WideStringWithSizeType._descriptor.unpack(">BB", map[start:start + WideStringWithSizeType._descriptor.calcsize(">BB")])
+        offset += WideStringWithSizeType._descriptor.calcsize(">BB")
         return WideStringWithSizeType(size_is_arg_num, length_is_arg_num, **flags), offset
 
     def write(self, typelib, file):
@@ -494,7 +493,7 @@ class WideStringWithSizeType(Type):
 
         """
         Type.write(self, typelib, file)
-        file.write(WideStringWithSizeType._descriptor.pack(self.size_is_arg_num,
+        file.write(WideStringWithSizeType._descriptor.pack(">BB", self.size_is_arg_num,
                                                            self.length_is_arg_num))
 
     def __str__(self):
@@ -506,7 +505,7 @@ class Param(object):
     (ParamDescriptor from the typelib specification.)
 
     """
-    _descriptorstart = struct.Struct(">B")
+    _descriptorstart = struct
 
     def __init__(self, type, in_=True, out=False, retval=False,
                  shared=False, dipper=False, optional=False):
@@ -573,11 +572,11 @@ class Param(object):
         following this ParamDescriptor.
         """
         start = data_pool + offset - 1
-        (flags,) = Param._descriptorstart.unpack(map[start:start + Param._descriptorstart.size])
+        (flags,) = Param._descriptorstart.unpack(">B", map[start:start + Param._descriptorstart.calcsize(">B")])
         # only the first five bits are flags
         flags &= 0xFC
         flags = Param.decodeflags(flags)
-        offset += Param._descriptorstart.size
+        offset += Param._descriptorstart.calcsize(">B")
         t, offset = Type.read(typelib, map, data_pool, offset)
         p = Param(t, **flags)
         return p, offset
@@ -588,7 +587,7 @@ class Param(object):
         to the correct position.
 
         """
-        file.write(Param._descriptorstart.pack(self.encodeflags()))
+        file.write(Param._descriptorstart.pack(">B", self.encodeflags()))
         self.type.write(typelib, file)
 
     def prefix(self):
@@ -625,7 +624,7 @@ class Method(object):
     (MethodDescriptor from the typelib specification.)
     
     """
-    _descriptorstart = struct.Struct(">BIB")
+    _descriptorstart = struct
     
     def __init__(self, name, result,
                  params=[], getter=False, setter=False, notxpcom=False,
@@ -723,13 +722,13 @@ class Method(object):
         
         """
         start = data_pool + offset - 1
-        flags, name_offset, num_args = Method._descriptorstart.unpack(map[start:start + Method._descriptorstart.size])
+        flags, name_offset, num_args = Method._descriptorstart.unpack(">BIB", map[start:start + Method._descriptorstart.calcsize(">BIB")])
         # only the first seven bits are flags
         flags &= 0xFE
         flags = Method.decodeflags(flags)
         name = Typelib.read_string(map, data_pool, name_offset)
         m = Method(name, None, **flags)
-        offset += Method._descriptorstart.size
+        offset += Method._descriptorstart.calcsize(">BIB")
         offset = m.read_params(typelib, map, data_pool, offset, num_args)
         offset = m.read_result(typelib, map, data_pool, offset)
         return m, offset
@@ -740,7 +739,7 @@ class Method(object):
         seeked to the right position.
 
         """
-        file.write(Method._descriptorstart.pack(self.encodeflags(),
+        file.write(Method._descriptorstart.pack(">BIB", self.encodeflags(),
                                                 self._name_offset,
                                                 len(self.params)))
         for p in self.params:
@@ -766,7 +765,7 @@ class Constant(object):
     (ConstantDesciptor from the typelib specification.)
 
     """
-    _descriptorstart = struct.Struct(">I")
+    _descriptorstart = struct
     # Actual value is restricted to this set of types
     #XXX: the spec lies, the source allows a bunch more
     # http://hg.mozilla.org/mozilla-central/annotate/9c85f9aaec8c/xpcom/typelib/xpt/src/xpt_struct.c#l689
@@ -791,9 +790,9 @@ class Constant(object):
         
         """
         start = data_pool + offset - 1
-        (name_offset,) = Constant._descriptorstart.unpack(map[start:start + Constant._descriptorstart.size])
+        (name_offset,) = Constant._descriptorstart.unpack(">I", map[start:start + Constant._descriptorstart.calcsize(">I")])
         name = Typelib.read_string(map, data_pool, name_offset)
-        offset += Constant._descriptorstart.size
+        offset += Constant._descriptorstart.calcsize(">I")
         # Read TypeDescriptor
         t, offset = Type.read(typelib, map, data_pool, offset)
         c = None
@@ -811,7 +810,7 @@ class Constant(object):
         to be seeked to the proper position.
 
         """
-        file.write(Constant._descriptorstart.pack(self._name_offset))
+        file.write(Constant._descriptorstart.pack(">I", self._name_offset))
         self.type.write(typelib, file)
         tt = Constant.typemap[self.type.tag]
         file.write(struct.pack(tt, self.value))
@@ -839,8 +838,8 @@ class Interface(object):
     (InterfaceDescriptor from the typelib specification.)
     
     """
-    _direntry = struct.Struct(">16sIII")    
-    _descriptorstart = struct.Struct(">HH")
+    _direntry = struct
+    _descriptorstart = struct
 
     UNRESOLVED_IID = "00000000-0000-0000-0000-000000000000"
     
@@ -904,11 +903,11 @@ class Interface(object):
         if offset == 0:
             return
         start = data_pool + offset - 1
-        parent, num_methods = Interface._descriptorstart.unpack(map[start:start + Interface._descriptorstart.size])
+        parent, num_methods = Interface._descriptorstart.unpack(">HH", map[start:start + Interface._descriptorstart.calcsize(">HH")])
         if parent > 0 and parent <= len(typelib.interfaces):
             self.parent = typelib.interfaces[parent - 1]
         # Read methods
-        offset += Interface._descriptorstart.size
+        offset += Interface._descriptorstart.calcsize(">HH")
         for i in range(num_methods):
             m, offset = Method.read(typelib, map, data_pool, offset)
             self.methods.append(m)
@@ -939,7 +938,7 @@ class Interface(object):
         to |file|, which is assumed to be seeked to the correct offset.
 
         """
-        file.write(Interface._direntry.pack(Typelib.string_to_iid(self.iid),
+        file.write(Interface._direntry.pack(">16sIII", Typelib.string_to_iid(self.iid),
                                             self._name_offset,
                                             self._namespace_offset,
                                             self._descriptor_offset))
@@ -958,7 +957,7 @@ class Interface(object):
         parent_idx = 0
         if self.parent:
             parent_idx = typelib.interfaces.index(self.parent) + 1
-        file.write(Interface._descriptorstart.pack(parent_idx, len(self.methods)))
+        file.write(Interface._descriptorstart.pack(">HH", parent_idx, len(self.methods)))
         for m in self.methods:
             m.write(typelib, file)
         file.write(struct.pack(">H", len(self.constants)))
@@ -1006,7 +1005,7 @@ class Typelib(object):
     or the static Typelib.read method may be called to read one from a file.
 
     """
-    _header = struct.Struct(">16sBBHIII")
+    _header = struct
 
     def __init__(self, version=TYPELIB_VERSION, interfaces=[], annotations=[]):
         """
@@ -1049,15 +1048,15 @@ class Typelib(object):
     
     @staticmethod
     def read(filename):
-        """
-        Read a typelib from the file named |filename| and return
-        the constructed Typelib object.
-
-        """
-        with open(filename, "r+b") as f:
+            """
+            Read a typelib from the file named |filename| and return
+            the constructed Typelib object.
+     
+            """
+            f = open(filename, "r+b")
             st = os.fstat(f.fileno())
             map = f.read(st.st_size)
-            data = Typelib._header.unpack(map[:Typelib._header.size])
+            data = Typelib._header.unpack(">16sBBHIII", map[:Typelib._header.calcsize(">16sBBHIII")])
             if data[0] != XPT_MAGIC:
                 raise FileFormatError, "Bad magic: %s" % data[0]
             xpt = Typelib((data[1], data[2]))
@@ -1074,7 +1073,7 @@ class Typelib(object):
             data_pool_offset = data[6]
             # make a half-hearted attempt to read Annotations,
             # since XPIDL doesn't produce any anyway.
-            start = Typelib._header.size
+            start = Typelib._header.calcsize(">16sBBHIII")
             (anno, ) = struct.unpack(">B", map[start:start + struct.calcsize(">B")])
             islast = anno & 0x80
             tag = anno & 0x7F
@@ -1084,9 +1083,9 @@ class Typelib(object):
             
             for i in range(num_interfaces):
                 # iid, name, namespace, interface_descriptor
-                start = interface_directory_offset + i * Interface._direntry.size
-                end = interface_directory_offset + (i+1) * Interface._direntry.size
-                ide = Interface._direntry.unpack(map[start:end])
+                start = interface_directory_offset + i * Interface._direntry.calcsize(">16sIII")
+                end = interface_directory_offset + (i+1) * Interface._direntry.calcsize(">16sIII")
+                ide = Interface._direntry.unpack(">16sIII", map[start:end])
                 iid = Typelib.iid_to_string(ide[0])
                 name = Typelib.read_string(map, data_pool_offset, ide[1])
                 namespace = Typelib.read_string(map, data_pool_offset, ide[2])
@@ -1095,7 +1094,7 @@ class Typelib(object):
                 xpt.interfaces.append(iface)
             for iface in xpt.interfaces:
                 iface.read_descriptor(xpt, map, data_pool_offset)
-        return xpt
+            return xpt
     
     def __repr__(self):
         return "<Typelib with %d interfaces>" % len(self.interfaces)
@@ -1122,14 +1121,14 @@ class Typelib(object):
     def writefd(self, fd):
         # write out space for a header + one empty annotation,
         # padded to 4-byte alignment.
-        headersize = (Typelib._header.size + 1)
+        headersize = (Typelib._header.calcsize(">16sBBHIII") + 1)
         if headersize % 4:
             headersize += 4 - headersize % 4
         fd.write("\x00" * headersize)
         # save this offset, it's the interface directory offset.
         interface_directory_offset = fd.tell()
         # write out space for an interface directory
-        fd.write("\x00" * Interface._direntry.size * len(self.interfaces))
+        fd.write("\x00" * Interface._direntry.calcsize(">16sIII") * len(self.interfaces))
         # save this offset, it's the data pool offset.
         data_pool_offset = fd.tell()
         # write out all the interface descriptors to the data pool
@@ -1139,7 +1138,7 @@ class Typelib(object):
         # now, seek back and write the header
         file_len = fd.tell()
         fd.seek(0)
-        fd.write(Typelib._header.pack(XPT_MAGIC,
+        fd.write(Typelib._header.pack(">16sBBHIII", XPT_MAGIC,
                                       TYPELIB_VERSION[0],
                                       TYPELIB_VERSION[1],
                                       len(self.interfaces),
@@ -1161,8 +1160,8 @@ class Typelib(object):
 
         """
         self._sanityCheck()
-        with open(filename, "wb") as f:
-            self.writefd(f)
+        f = open(filename, "wb")
+        self.writefd(f)
 
     def merge(self, other, sanitycheck=True):
         """