Skip to content

Commit

Permalink
[opy] -emit-docstring=0 will also remove the module docstring.
Browse files Browse the repository at this point in the history
For some reason this workgs on demo/docstring.py, but not on
core/args.py.

I'm still looking into that bug.  It might be a good use case for the
ddmin algorithm, since I have a minimal test case that works and a
real-world one that doesn't.
  • Loading branch information
Andy Chu committed Oct 6, 2018
1 parent 6c6cf55 commit 4884bac
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion opy/compiler2/pycodegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -1319,7 +1319,7 @@ def _Start(self):
self.set_lineno(self.klass)
self.emit("LOAD_GLOBAL", "__name__")
self.storeName("__module__")
if self.klass.doc:
if self.klass.doc and self.ctx.comp_opt.emit_docstring:
self.emit("LOAD_CONST", self.klass.doc)
self.storeName('__doc__')

Expand Down
6 changes: 3 additions & 3 deletions opy/demo/docstring.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/python
"""
docstring.py
module DOCSTRING
"""
class Foo(object):
"""class."""
"""class DOCSTRING"""
def inc(self, x):
"""inc by one"""
"""func DOCSTRING"""
return x + 1
6 changes: 3 additions & 3 deletions opy/opy_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ def OpyCommandMain(argv):
with open(py_path) as f:
co = compiler.Compile(f, opt, 'exec')

log("Compiled to %d bytes of bytecode", len(co.co_code))
log("Compiled to %d bytes of top-level bytecode", len(co.co_code))

# Write the .pyc file
with open(out_path, 'wb') as out_f:
Expand All @@ -355,7 +355,7 @@ def OpyCommandMain(argv):
with open(py_path) as f:
co = compiler.Compile(f, opt, 'ovm')

log("Compiled to %d bytes of bytecode", len(co.co_code))
log("Compiled to %d bytes of top-level bytecode", len(co.co_code))
# Write the .pyc file
with open(out_path, 'wb') as out_f:
if 1:
Expand Down Expand Up @@ -412,7 +412,7 @@ def OpyCommandMain(argv):
with open(path) as f:
co = compiler.Compile(f, opt, 'exec')

log("Compiled to %d bytes of bytecode", len(co.co_code))
log("Compiled to %d bytes of top-level bytecode", len(co.co_code))
v.show_code(co)

else: # assume pyc_path
Expand Down

0 comments on commit 4884bac

Please sign in to comment.