Skip to content

Python py_compile error message inconsistent and missing newline #67999

Closed

Description

@akshetp
mannequin
BPO 23811
Nosy @bitdancer, @berkerpeksag, @ashkop
Files
  • issue23811.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2015-04-14.16:03:33.402>
    created_at = <Date 2015-03-30.11:58:58.030>
    labels = ['easy', 'type-bug', 'library']
    title = 'Python py_compile error message inconsistent and missing newline'
    updated_at = <Date 2015-04-14.16:03:33.400>
    user = 'https://bugs.python.org/akshetp'

    bugs.python.org fields:

    activity = <Date 2015-04-14.16:03:33.400>
    actor = 'berker.peksag'
    assignee = 'none'
    closed = True
    closed_date = <Date 2015-04-14.16:03:33.402>
    closer = 'berker.peksag'
    components = ['Library (Lib)']
    creation = <Date 2015-03-30.11:58:58.030>
    creator = 'akshetp'
    dependencies = []
    files = ['38858']
    hgrepos = []
    issue_num = 23811
    keywords = ['patch', 'easy']
    message_count = 6.0
    messages = ['239598', '239618', '240211', '240921', '240923', '240924']
    nosy_count = 5.0
    nosy_names = ['r.david.murray', 'python-dev', 'berker.peksag', 'ashkop', 'akshetp']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue23811'
    versions = ['Python 2.7', 'Python 3.4', 'Python 3.5']

    Activity

    1. akshetp commented on Mar 30, 2015

      akshetpmannequin
      MannequinAuthor

      On the following test file (test.py):

      class Solution:
        def repeatedNumber(self, A):
          test = 1
            return []

      Running python -m py_compile test.py return the following error message:
      Sorry: IndentationError: unexpected indent (test.py, line 6)

      But without a newline on stderr at the end of the message. This causes some problems with scripts that expect a newline and new my particular case with reading stderr on docker where docker just ignore the line if it doesn't end in a newline.

      Also, this message differs from the runtime error message:

        File "test.py", line 6
          return []
          ^
      IndentationError: unexpected indent
      

      Would it be possible to at least add in a newline and at best, change the message to be consistent with the runtime error message?

      I will trying to look at the code and see if I can write a patch but it will take me some time.

    2. bitdancer commented on Mar 30, 2015

      @bitdancer
      Member

      I can confirm that the bugs is demonstrated by copying the text below into a normal unix text file.

    3. added
      type-bugAn unexpected behavior, bug, or error
      stdlibStandard Library Python modules in the Lib/ directory
      and removed
      type-featureA feature request or enhancement
      interpreter-core(Objects, Python, Grammar, and Parser dirs)
      on Mar 30, 2015
    4. ashkop commented on Apr 7, 2015

      ashkopmannequin
      Mannequin

      This patch adds new line symbol. For some reason py_compile module prints only SyntaxErrors with traceback. All other exceptions are printed with "Sorry:" and in one line.

    5. python-dev commented on Apr 14, 2015

      python-devmannequin
      Mannequin

      New changeset 1e139b3c489e by Berker Peksag in branch '3.4':
      Issue bpo-23811: Add missing newline to the PyCompileError error message.
      https://hg.python.org/cpython/rev/1e139b3c489e

      New changeset d39fe1e112a3 by Berker Peksag in branch 'default':
      Issue bpo-23811: Add missing newline to the PyCompileError error message.
      https://hg.python.org/cpython/rev/d39fe1e112a3

    6. python-dev commented on Apr 14, 2015

      python-devmannequin
      Mannequin

      New changeset 22790c4f3b16 by Berker Peksag in branch '2.7':
      Issue bpo-23811: Add missing newline to the PyCompileError error message.
      https://hg.python.org/cpython/rev/22790c4f3b16

    7. berkerpeksag commented on Apr 14, 2015

      @berkerpeksag
      Member

      Thank you Alex.

    8. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      easystdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions