summaryrefslogtreecommitdiffstats
path: root/Lib/compiler/pycodegen.py
diff options
context:
space:
mode:
authorMichael W. Hudson <mwh@python.net>2002-10-07 12:21:09 (GMT)
committerMichael W. Hudson <mwh@python.net>2002-10-07 12:21:09 (GMT)
commitb45532abd26a9752e42ca589b5b0e49552761811 (patch)
treeafec9e85aca150745c9a107dcfa4e871ace07d20 /Lib/compiler/pycodegen.py
parent2942d5e6dde5e12b08233bbd403491331623ca22 (diff)
downloadcpython-b45532abd26a9752e42ca589b5b0e49552761811.zip
cpython-b45532abd26a9752e42ca589b5b0e49552761811.tar.gz
cpython-b45532abd26a9752e42ca589b5b0e49552761811.tar.bz2
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.
Diffstat (limited to 'Lib/compiler/pycodegen.py')
-rw-r--r--Lib/compiler/pycodegen.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/Lib/compiler/pycodegen.py b/Lib/compiler/pycodegen.py
index 4194d27..88146cd 100644
--- a/Lib/compiler/pycodegen.py
+++ b/Lib/compiler/pycodegen.py
@@ -136,7 +136,7 @@ class Module(AbstractCompileMode):
# 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 @@ class CodeGenerator:
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 @@ class ClassCodeGenerator(NestedScopeMixin, AbstractClassCode, CodeGenerator):
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"""