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 terry.reedy
Date 2019-09-05.18:52:13
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1567709534.52.0.152965325603.issue38041@roundup.psfhosted.org>
In-reply-to
Content
Currently, Shell prints restart lines as 
=...= RESTART filename =...=
where filename is 'Shell' or the full pathname.  The code is 

        tag = 'RESTART: ' + (filename if filename else 'Shell')
        halfbar = ((int(console.width) -len(tag) - 4) // 2) * '='
        console.write("\n{0} {1} {0}".format(halfbar, tag))

The initial '\n' is needed because typically the cursor is sitting at a prompt.  The -4 is from #21192 when I added 'Shell' or filename.  It is -2 for the spaces plus a couple of extra spaces that were there before.  I believe -2 is sufficient but will have to test to be sure.

The number of '='s is the currently the same on both ends.  (Because this is easiest.)  It does not have to be, and would sometimes not be if we exactly filled the console width.  I think we should because it would show the actual non-printable margin and would allow 

The minimum number of '='s is 0.  The problem revealed in
https://stackoverflow.com/questions/57795679/why-is-this-code-printing-an-empty-line-when-run-under-idle
is that if console.width is exactly 10 + len(filename), the remaining trailing space wraps to the next line, making it look like a spurious print(' ') had occurred.

Possible solutions:

0. Do nothing.  I rejected this by opening this issue.  The SO beginner was apparently genuinely confused and might not be the only such person.  With no spec for the restart line, this is not an implementation bug but is a design glitch.  As I hinted above, some current details are the result of adding filenames with minimal change.

1. Delete the ' 's surrounding the tag when there are no '='s.  This looks strange because the '='s visually mark a restart line as much as 'RESTART'.

2. Print a minimum of 1 '=' on each end (by adding them to the format). This could result in a wrap of exactly ' =' or '=', either of which are bad.  If there is any wrap, it should be the filename, so the user can recognize it as such.

3. A hybrid solution with a minimum of 1 '=' on the front and 0 on the end, with no space if no '='.  I intend to try this after extracting the restart line into a testable function and writing tests that now fail.

4. Add a horizontal scrollbar to Shell.  This not happening now, might be made optional, and would still require specification decisions.
History
Date User Action Args
2019-09-05 18:52:14terry.reedysetrecipients: + terry.reedy
2019-09-05 18:52:14terry.reedysetmessageid: <1567709534.52.0.152965325603.issue38041@roundup.psfhosted.org>
2019-09-05 18:52:14terry.reedylinkissue38041 messages
2019-09-05 18:52:13terry.reedycreate