Skip to content

AttributeErrors in statements split up into multiple linse with \ showing 'wrong' line as being responsible in error message #66763

Closed

Description

@dingodasher
BPO 22573
Nosy @bitdancer
Superseder
  • bpo-12458: Tracebacks should contain the first line of continuation lines
  • 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 2014-10-07.01:30:05.880>
    created_at = <Date 2014-10-06.23:53:13.308>
    labels = ['interpreter-core', 'type-bug']
    title = "AttributeErrors in statements split up into multiple linse with \\ showing 'wrong' line as being responsible in error message"
    updated_at = <Date 2014-10-07.01:30:05.828>
    user = 'https://bugs.python.org/dingodasher'

    bugs.python.org fields:

    activity = <Date 2014-10-07.01:30:05.828>
    actor = 'r.david.murray'
    assignee = 'none'
    closed = True
    closed_date = <Date 2014-10-07.01:30:05.880>
    closer = 'r.david.murray'
    components = ['Interpreter Core']
    creation = <Date 2014-10-06.23:53:13.308>
    creator = 'dingo_dasher'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 22573
    keywords = []
    message_count = 2.0
    messages = ['228749', '228752']
    nosy_count = 2.0
    nosy_names = ['r.david.murray', 'dingo_dasher']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '12458'
    type = 'behavior'
    url = 'https://bugs.python.org/issue22573'
    versions = ['Python 3.4']

    Activity

    1. dingodasher commented on Oct 6, 2014

      dingodashermannequin
      MannequinAuthor

      I am using Flask, and I had the following code:

              modules = models.Module.query.join(models.ModuleAccess).\
                               filter(models.Model.owner_id == current_user.id).\
                               filter(models.ModuleAccess.user_id == current_user.id).\
                               filter(models.ModuleAccess.module_id == models.Module.id).\
                               filter(models.ModuleAccess.write_access == True)

      This code had a bug -> "models.Model.owner_id" in the first line. This was a typo, and Python gave me an AttributeError, just as I would expect. However, this is the error I was given:

      Traceback (most recent call last):
        File "/usr/local/lib/python3.4/dist-packages/flask/app.py", line 1836, in __call__
          return self.wsgi_app(environ, start_response)
        File "/usr/local/lib/python3.4/dist-packages/flask/app.py", line 1820, in wsgi_app
          response = self.make_response(self.handle_exception(e))
        File "/usr/local/lib/python3.4/dist-packages/flask/app.py", line 1403, in handle_exception
          reraise(exc_type, exc_value, tb)
        File "/usr/local/lib/python3.4/dist-packages/flask/_compat.py", line 33, in reraise
          raise value
        File "/usr/local/lib/python3.4/dist-packages/flask/app.py", line 1817, in wsgi_app
          response = self.full_dispatch_request()
        File "/usr/local/lib/python3.4/dist-packages/flask/app.py", line 1477, in full_dispatch_request
          rv = self.handle_user_exception(e)
        File "/usr/local/lib/python3.4/dist-packages/flask/app.py", line 1381, in handle_user_exception
          reraise(exc_type, exc_value, tb)
        File "/usr/local/lib/python3.4/dist-packages/flask/_compat.py", line 33, in reraise
          raise value
        File "/usr/local/lib/python3.4/dist-packages/flask/app.py", line 1475, in full_dispatch_request
          rv = self.dispatch_request()
        File "/usr/local/lib/python3.4/dist-packages/flask/app.py", line 1461, in dispatch_request
          return self.view_functions[rule.endpoint](**req.view_args)
        File "/usr/local/lib/python3.4/dist-packages/flask_login.py", line 758, in decorated_view
          return func(*args, **kwargs)
        File "/home/dingo/UIM/app/views.py", line 175, in modules
          filter(models.ModuleAccess.write_access == True)
      AttributeError: 'module' object has no attribute 'Model'

      It shows me the last line of that long statement, "models.ModuleAccess.write_access == True" as the beginning of the trace. The trace doesn't show the models.Module.whatever line that actually caused the error.

      It seems to be like Python here takes the last line of the exception-causing statement and shows that along with the "actual" error message (which was on the money): AttributeError: 'module' object has no attribute 'Model'

      This seems to me slightly misleading. I submit that a better behaviour would be to show the line that caused the exception (I assume/hope that is possible since python knew it was accessing the Model attribute of the module object that caused the error).

      I classified this as a behaviour bug rather than an enhancement, because I believe this would not be intended behaviour. I don't know if that's the case.

      I apologise if this doesn't fit in "Intepreter core", but exceptions are builtins... I didn't know where else to put it.

    2. added
      interpreter-core
      type-bug
      on Oct 6, 2014
    3. changed the title [-]AttributeErrors in long lines showing 'wrong' line in error message[/-] [+]AttributeErrors in statements split up into multiple linse with \ showing 'wrong' line as being responsible in error message[/+] on Oct 7, 2014
    4. bitdancer commented on Oct 7, 2014

      @bitdancer
      Member

      This is a duplicate of bpo-12458.

    5. 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

      interpreter-coretype-bug

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions