Skip to content

Replace unicode.__eq__ exceptions with a warning #43811

Closed

Description

@malemburg
BPO 1538956
Nosy @malemburg, @arigo
Files
  • Python-Patch-2006-08-11-225957.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 = 'https://github.com/malemburg'
    closed_at = <Date 2006-08-14.10:57:07.000>
    created_at = <Date 2006-08-11.21:09:53.000>
    labels = ['interpreter-core']
    title = 'Replace unicode.__eq__ exceptions with a warning'
    updated_at = <Date 2006-08-14.10:57:07.000>
    user = 'https://github.com/malemburg'

    bugs.python.org fields:

    activity = <Date 2006-08-14.10:57:07.000>
    actor = 'lemburg'
    assignee = 'lemburg'
    closed = True
    closed_date = None
    closer = None
    components = ['Interpreter Core']
    creation = <Date 2006-08-11.21:09:53.000>
    creator = 'lemburg'
    dependencies = []
    files = ['7462']
    hgrepos = []
    issue_num = 1538956
    keywords = ['patch']
    message_count = 4.0
    messages = ['50872', '50873', '50874', '50875']
    nosy_count = 3.0
    nosy_names = ['lemburg', 'nnorwitz', 'arigo']
    pr_nums = []
    priority = 'critical'
    resolution = 'accepted'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue1538956'
    versions = ['Python 2.5']

    Activity

    1. malemburg commented on Aug 11, 2006

      @malemburg
      MemberAuthor

      The attached patch is a first version of the change
      discussed on python-dev this and last week:

      It replaces UnicodeDecodeErrors raised during == and !=
      compares of Unicode and other objects with a new
      UnicodeWarning.

      All other comparisons continue to raise exceptions.
      Exceptions other than UnicodeDecodeErrors are also left
      untouched.

      The documentation part of the patch is still
      incomplete. Suggestions are welcome.

      Due to the change to only the == and != comparison
      operators, Unicode objects had to grow an
      implementation for rich comparisons (which now replaces
      the old tp_compare slot).

      Tests all pass.

      Aside:

      During testing I found that the warning registry
      defaults to only issueing warnings once per module and
      line number. I suppose this is enough for debugging
      code, but it feels weird when trying things in the
      interactive session, as you only get the warnings once
      in that context (and for the whole session), regardless
      of the fact that you're entereing new lines of code all
      the time.

      Maybe something to change for Python 2.6.

    2. self-assigned this
      on Aug 11, 2006
    3. self-assigned this
      on Aug 11, 2006
    4. arigo commented on Aug 12, 2006

      arigomannequin
      Mannequin

      Logged In: YES
      user_id=4771

      Getting rid of the special case for unicodes in
      default_3way_compare() - this alone would give the
      whole patch a +1 from me :-) Looks good to me.

    5. nnorwitz commented on Aug 13, 2006

      nnorwitzmannequin
      Mannequin

      Logged In: YES
      user_id=33168

      I don't know the intricasies of rich comparisons, but this
      looks pretty good. There are some typos: silcence (drop the
      first c, comment in unicodeobject.c). I think the doc
      (Doc/lib/libexcs.tex) is missing an \end{excdesc}. In
      Misc/NEWS, "can be then filtered" is awkward, drop the
      'then'. Misc/NEWS should mention the new public API
      PyUnicode_RichCompare (and point out that UnicodeWarning is
      new).

      Please check this in ASAP and report to python-dev. That
      way if there are any issues, we can try to resolve them
      quickly. People are more likely to review the checkin the
      patch on SF.

      Improving warnings in 2.6 would definitely be nice.

    6. malemburg commented on Aug 14, 2006

      @malemburg
      MemberAuthor

      Logged In: YES
      user_id=38388

      Thanks for the typo-checks, Neal.

      Checked in a slightly updated version as
      revision 51276.

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

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions