GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Update doctect SyntaxErrors for location range · Issue #89412 · python/cpython

Update doctect SyntaxErrors for location range #89412

New issue
Copy link
New issue
Copy link
Closed
Closed
Update doctect SyntaxErrors for location range#89412
Copy link
Labels
3.10 (EOL)end of lifeend of life3.11only security fixesonly security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@akulakov
akulakov
opened on Sep 20, 2021
Issue body actions
BPO 45249
Nosy @terryjreedy, @blueyed, @pablogsal, @miss-islington, @Fidget-Spinner, @akulakov
PRs
  • bpo-45249: Add regression test for display of SyntaxError range indicator in doctests #28567
  • bpo-45249: Ensure the traceback module prints correctly syntax errors with ranges #28575
  • [3.10] bpo-45249: Ensure the traceback module prints correctly syntax errors with ranges (GH-28575) #28587
  • bpo-45249: Fix caret location when end_offset is set to 0 #28854
  • bpo-45249: Fix caret location when end_offset is set to 0 #28855
  • [3.10] bpo-45249: Fix caret location when end_offset is set to 0 (GH-28855) #28994
  • 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 2021-10-16.17:37:28.444>
    created_at = <Date 2021-09-20.16:30:58.559>
    labels = ['type-bug', 'library', '3.10', '3.11']
    title = 'Update doctect SyntaxErrors for location range'
    updated_at = <Date 2021-10-16.17:51:11.950>
    user = 'https://github.com/akulakov'

    bugs.python.org fields:

    activity = <Date 2021-10-16.17:51:11.950>
    actor = 'miss-islington'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-10-16.17:37:28.444>
    closer = 'pablogsal'
    components = ['Library (Lib)']
    creation = <Date 2021-09-20.16:30:58.559>
    creator = 'andrei.avk'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 45249
    keywords = ['patch']
    message_count = 18.0
    messages = ['402257', '402258', '402260', '402263', '402268', '402269', '402271', '402284', '402589', '402652', '402662', '402670', '402739', '402742', '403157', '403588', '404103', '404106']
    nosy_count = 6.0
    nosy_names = ['terry.reedy', 'blueyed', 'pablogsal', 'miss-islington', 'kj', 'andrei.avk']
    pr_nums = ['28567', '28575', '28587', '28854', '28855', '28994']
    priority = 'low'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue45249'
    versions = ['Python 3.10', 'Python 3.11']

    Linked PRs

    • gh-89412: Add missing attributes (added in 3.10) to traceback module docs #105046
    • [3.12] gh-89412: Add missing attributes (added in 3.10) to traceback module docs (GH-105046) #105327
    • [3.11] gh-89412: Add missing attributes (added in 3.10) to traceback module docs (GH-105046) #105328
    • [3.10] gh-89412: Add missing attributes (added in 3.10) to traceback module docs (GH-105046) #105329

    Activity

    Next
    1. akulakov commented on Sep 20, 2021

      @akulakov
      akulakov
      on Sep 20, 2021
      ContributorAuthor
      More actions

      It seems like fine grained error locations do not work in failed doctest traceback output:

      version 3.11.0a0

      file contents:
      ------------------

      def a(x):
          """
          >>> 1 1
          1
          """
      import doctest
      doctest.testmod()

      OUTPUT
      -------

      Failed example:
          1 1
      Exception raised:
          Traceback (most recent call last):
            File "/Users/ak/opensource/cpython/Lib/doctest.py", line 1348, in __run
              exec(compile(example.source, filename, "single",
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            File "<doctest __main__.a[0]>", line 1
              1 1
              ^
          SyntaxError: invalid syntax. Perhaps you forgot a comma?

      The location in doctests that causes this:

      cpython/Lib/doctest.py

      Line 1348 in 5846c9b

      exec(compile(example.source, filename, "single",

    2. akulakov
      added
      interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
      testsTests in the Lib/test dirTests in the Lib/test dir
      3.11only security fixesonly security fixes
      type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
      on Sep 20, 2021
    3. akulakov commented on Sep 20, 2021

      @akulakov
      akulakov
      on Sep 20, 2021
      ContributorAuthor
      More actions

      I've ran into this when looking at doctest docs, the issue is that they use the old example where a single column is highlighted, I want to update it to explain why doctest output differs from the one you get from REPL, but I probably need to understand why it happens to provide a good explanation.

      Alternatively this may be fixed to be consistent if it's easy enough to do.

    4. pablogsal commented on Sep 20, 2021

      @pablogsal
      pablogsal
      on Sep 20, 2021
      Member
      More actions

      Hummmm, could you explain a bit more in detail what is the expected output? I can see highlighting in the exec call that you pasted:

          exec(compile(example.source, filename, "single",
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      

      The fact that you see those "^^^^^^" indicate that is working no? What is missing?

    5. akulakov commented on Sep 20, 2021

      @akulakov
      akulakov
      on Sep 20, 2021
      ContributorAuthor
      More actions

      Sorry, I should have noted I’m referring to the line 1 1
      Which is underlined by a single caret, but on the command line it has 3
      carets as expected.

    6. pablogsal commented on Sep 20, 2021

      @pablogsal
      pablogsal
      on Sep 20, 2021
      Member
      More actions

      Ah, but that is a different issue. This is not PEP-657, this is a SyntaxError, so is related how those are printed, which I think is separared.

    7. pablogsal commented on Sep 20, 2021

      @pablogsal
      pablogsal
      on Sep 20, 2021
      Member
      More actions

      Can you try a doctest that fails on something that is not a SyntaxError.

      Something like:

      >>> def foo(x):
      ...    return x + 42

      >> foo(None)

    8. akulakov commented on Sep 20, 2021

      @akulakov
      akulakov
      on Sep 20, 2021
      ContributorAuthor
      More actions

      Pablo: that works fine, thanks!

      I will look into updating the doctest docs, and will close this issue later
      today ( or you can close it if you like).

    9. 26 remaining items

    10. pablogsal
      reopened this on Oct 10, 2021
    11. miss-islington commented on Oct 16, 2021

      @miss-islington
      miss-islington
      on Oct 16, 2021
      Contributor
      More actions

      New changeset fe0d9e2 by Pablo Galindo Salgado in branch 'main':
      bpo-45249: Fix caret location when end_offset is set to 0 (GH-28855)
      fe0d9e2

    12. pablogsal
      closed this as completedon Oct 16, 2021
    13. pablogsal
      closed this as completedon Oct 16, 2021
    14. miss-islington commented on Oct 16, 2021

      @miss-islington
      miss-islington
      on Oct 16, 2021
      Contributor
      More actions

      New changeset 5df35fa by Miss Islington (bot) in branch '3.10':
      bpo-45249: Fix caret location when end_offset is set to 0 (GH-28855)
      5df35fa

    15. ezio-melotti
      transferred this issue fromon Apr 10, 2022
    16. Jackenmen
      added 2 commits that reference this issue on May 28, 2023

      pythongh-89412: Add missing 3.10/11 attributes to traceback module docs

      cc2c85c

      pythongh-89412: Add missing 3.10 attributes to traceback module docs

      6ef0700
    17. ambv
      added a commit that references this issue on Jun 5, 2023

      gh-89412: Add missing attributes (added in 3.10) to traceback module …

      a4f72fa
    18. miss-islington
      added 3 commits that reference this issue on Jun 5, 2023

      pythongh-89412: Add missing attributes (added in 3.10) to traceback m…

      fd4875c

      pythongh-89412: Add missing attributes (added in 3.10) to traceback m…

      077b26c

      pythongh-89412: Add missing attributes (added in 3.10) to traceback m…

      cda57fd
    19. ambv
      added 3 commits that reference this issue on Jun 5, 2023

      [3.11] gh-89412: Add missing attributes (added in 3.10) to traceback …

      faae548

      [3.12] gh-89412: Add missing attributes (added in 3.10) to traceback …

      ab660e9

      [3.10] gh-89412: Add missing attributes (added in 3.10) to traceback …

      b7fd286
    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

      3.10 (EOL)end of lifeend of life3.11only security fixesonly security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions

        You are visitor 01402520 — GeezerVison does not store the pages you look up.
        Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.