Skip to content

Commit

Permalink
Implement iteration protocol on the Missing class
Browse files Browse the repository at this point in the history
This is a generalization of the fix proposed in PR #22 to the "RETURNS SETOF" without any
parameters: code may now assume that iterating over a Missing node will raise an immediate
StopIteration exception, thus basically doing nothing.
  • Loading branch information
lelit committed Apr 15, 2019
1 parent fdb52bf commit 9087d6e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pglast/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# :Created: mer 02 ago 2017 15:44:14 CEST
# :Author: Lele Gaifax <lele@metapensiero.it>
# :License: GNU General Public License version 3 or later
# :Copyright: © 2017, 2018 Lele Gaifax
# :Copyright: © 2017, 2018, 2019 Lele Gaifax
#

from enum import Enum
Expand All @@ -16,6 +16,12 @@ def __bool__(self):
def __repr__(self):
return "MISSING"

def __iter__(self):
return self

def __next__(self):
raise StopIteration()


NoneType = type(None)

Expand Down

0 comments on commit 9087d6e

Please sign in to comment.