Skip to content

2to3 raise can silently remove code from old 2.4 string exceptions #84727

Closed

Description

@remyoudompheng
BPO 40547
Nosy @benjaminp, @remyoudompheng
Superseder
  • bpo-45544: Close 2to3 issues and list them here
  • 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-20.22:55:32.776>
    created_at = <Date 2020-05-07.16:37:14.395>
    labels = ['3.7', '3.8', 'type-bug', 'expert-2to3']
    title = '2to3 raise can silently remove code from old 2.4 string exceptions'
    updated_at = <Date 2021-10-20.22:55:32.776>
    user = 'https://github.com/remyoudompheng'

    bugs.python.org fields:

    activity = <Date 2021-10-20.22:55:32.776>
    actor = 'iritkatriel'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-10-20.22:55:32.776>
    closer = 'iritkatriel'
    components = ['2to3 (2.x to 3.x conversion tool)']
    creation = <Date 2020-05-07.16:37:14.395>
    creator = 'R\xc3\xa9my Oudompheng'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 40547
    keywords = []
    message_count = 1.0
    messages = ['368355']
    nosy_count = 2.0
    nosy_names = ['benjamin.peterson', 'R\xc3\xa9my Oudompheng']
    pr_nums = []
    priority = 'normal'
    resolution = 'wont fix'
    stage = 'resolved'
    status = 'closed'
    superseder = '45544'
    type = 'behavior'
    url = 'https://bugs.python.org/issue40547'
    versions = ['Python 3.7', 'Python 3.8']

    Activity

    1. remyoudompheng commented on May 7, 2020

      remyoudomphengmannequin
      MannequinAuthor

      When running "2to3 -f raise" on the following code, which uses an old Python 2.4 raise of a string:

      def f():
          raise ("message %s %s" % (1, 2))

      try:
      f()
      finally:
      pass

      I obtain the following quite surprising result. I would have expected to get either an error or leave the original file unchanged, because "raise (s)" is syntactically valid although incorrect.

      $ 2to3 -f raise w.py
      RefactoringTool: Refactored w.py
      --- w.py	(original)
      +++ w.py	(refactored)
      @@ -1,5 +1,5 @@
       def f():
      -    raise ("message %s %s" % (1, 2))
      +    raise "message %s %s"
       
       try:
           f()
    2. 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

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions