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.

Author terry.reedy
Recipients cheryl.sabella, terry.reedy
Date 2018-02-20.03:29:31
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1519097371.8.0.467229070634.issue32880@psf.upfronthosting.co.za>
In-reply-to
Content
Let's consider the todo questions at the end of the class Parser code.
---
    # XXX - is this used?
    lastopenbracketpos = None

    def get_last_open_bracket_pos(self):
        "Return index of last open bracket or None."
        self._study2()
        return self.lastopenbracketpos

    # XXX - is this used?
    stmt_bracketing = None

    def get_last_stmt_bracketing(self):
        """Return a tuple of the structure of the bracketing of the last
        interesting statement.

        Tuple is in the format defined in _study2().
        """
        self._study2()
        return self.stmt_bracketing
---

get_last_open_bracket_pos is not called anywhere. TODO remove it.
get_last_stmt_bracketing is called once in hyperparser and could be replaced there by 'parser._study2(); parser.stmt_bracketing'. TODO?

Integer lastopenbracketpos is only conditionally set as an instance attribute, which masks the class attribute, in _study2 with
        if stack:  # of opener indices
            self.lastopenbracketpos = stack[-1]

However, self.lastopenbracketpos in only accessed (as 'j') in  compute_bracket_indent, which is only called when a statement is continued to the next line because of an open bracket.  Indeed, the call is guarded by 
        assert self.continuation == C_BRACKET  # TODO: move up
So the class binding is never used because it is always masked bebore being accessed.  Its value None would raise if it were. (That may have been intentional.)  TODO remove it.

Stopping here would break the current tests.  We could make _study2 return the index and change test according. Or we can make _study2 always set the attribute with (TODO this)
        self.lastopenbracketpos = stack[-1] if stack else None
and remove the workaround test lines:
            p.lastopenbracketpos = None

Since _study2 unconditionally sets stmt_bracketing as an instance attribute with
        self.stmt_bracketing = tuple(bracketing)
and self.stmt_bracketing is only accessed, in the get function above (or possibly directly in the future), after such a call, its class setting is also useless.  TODO remove it.  No test change needed.
History
Date User Action Args
2018-02-20 03:29:31terry.reedysetrecipients: + terry.reedy, cheryl.sabella
2018-02-20 03:29:31terry.reedysetmessageid: <1519097371.8.0.467229070634.issue32880@psf.upfronthosting.co.za>
2018-02-20 03:29:31terry.reedylinkissue32880 messages
2018-02-20 03:29:31terry.reedycreate