diff Lib/compiler/pycodegen.py @ 25637:42139abfdbe5 2.2

A couple of fixes for the compiler package: * always write the mtime to a .pyc in little endian format * ensure class's docstrings get attached to the class, not the enclosing scope! Rather more fixes are needed for the trunk; these will be done in due course.
author Michael W. Hudson <mwh@python.net>
date Mon, 07 Oct 2002 12:21:09 +0000
parents fcb649b1004d
children
line wrap: on
line diff
--- a/Lib/compiler/pycodegen.py	Mon Oct 07 11:57:04 2002 +0000
+++ b/Lib/compiler/pycodegen.py	Mon Oct 07 12:21:09 2002 +0000
@@ -136,7 +136,7 @@
         # to indicate the type of the value.  simplest way to get the
         # same effect is to call marshal and then skip the code.
         mtime = os.stat(self.filename)[stat.ST_MTIME]
-        mtime = struct.pack('i', mtime)
+        mtime = struct.pack('<i', mtime)
         return self.MAGIC + mtime
 
 class LocalNameFinder:
@@ -389,9 +389,6 @@
     def visitClass(self, node):
         gen = self.ClassGen(node, self.scopes,
                             self.get_module())
-        if node.doc:
-            self.emit('LOAD_CONST', node.doc)
-            self.storeName('__doc__')
         walk(node.code, gen)
         gen.finish()
         self.set_lineno(node)
@@ -1306,6 +1303,10 @@
         self.__super_init(klass, scopes, module)
         self.graph.setFreeVars(self.scope.get_free_vars())
         self.graph.setCellVars(self.scope.get_cell_vars())
+        self.set_lineno(klass)
+        if klass.doc:
+            self.emit("LOAD_CONST", klass.doc)
+            self.storeName("__doc__")
 
 def generateArgList(arglist):
     """Generate an arg list marking TupleArgs"""