Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python py_compile error message inconsistent and missing newline #67999

Closed
akshetp mannequin opened this issue Mar 30, 2015 · 6 comments
Closed

Python py_compile error message inconsistent and missing newline #67999

akshetp mannequin opened this issue Mar 30, 2015 · 6 comments
Labels
easy stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@akshetp
Copy link
Mannequin

akshetp mannequin commented Mar 30, 2015

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']

    @akshetp
    Copy link
    Mannequin Author

    akshetp mannequin commented Mar 30, 2015

    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.

    @akshetp akshetp mannequin added type-feature A feature request or enhancement interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Mar 30, 2015
    @bitdancer
    Copy link
    Member

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

    @bitdancer bitdancer added easy type-bug An unexpected behavior, bug, or error stdlib Python modules in the Lib dir and removed type-feature A feature request or enhancement interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Mar 30, 2015
    @ashkop
    Copy link
    Mannequin

    ashkop mannequin commented Apr 7, 2015

    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.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Apr 14, 2015

    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

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Apr 14, 2015

    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

    @berkerpeksag
    Copy link
    Member

    Thank you Alex.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    easy stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants