This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Const(None) in compiler.ast.Return.value
Type: Stage:
Components: Library (Lib) Versions: Python 2.5
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: collinwinter Nosy List: aligrudi, collinwinter
Priority: normal Keywords:

Created on 2007-05-09 09:53 by aligrudi, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg31990 - (view) Author: Ali Gholami Rudi (aligrudi) Date: 2007-05-09 09:53
The problem happens when::

  import compiler

  class Visitor(object):
      def visitReturn(self, node):
          print node.value

  source = """
  def f():
      return
  """
  compiler.walk(compiler.parse(source), Visitor())

I think the value of `node.value` should have been `None` instead of
`Const(None)` as it is for most other nodes when an optional part is
missing.  The same problem (getting `Const(None)` instead of `None`)
exists for `Sliceobj.nodes[i]` and `Discard.expr`.
msg31991 - (view) Author: Collin Winter (collinwinter) * (Python committer) Date: 2007-06-05 17:47
"return" is syntactic shorthand for "return None", so Const(None) is the right value; same thing for Sliceobj. This isn't a bug.
History
Date User Action Args
2022-04-11 14:56:24adminsetgithub: 44945
2007-05-09 09:53:29aligrudicreate