Skip to content

"embedded NUL character" exceptions #66411

Closed

Description

@serhiy-storchaka
BPO 22215
Nosy @vstinner, @serhiy-storchaka
Files
  • valueerror_embedded_nul_character.diff
  • valueerror_embedded_nul_character_2.patch
  • valueerror_embedded_nul_character_3.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/serhiy-storchaka'
    closed_at = <Date 2014-09-06.17:31:30.354>
    created_at = <Date 2014-08-17.14:43:54.964>
    labels = ['interpreter-core', 'type-feature']
    title = '"embedded NUL character" exceptions'
    updated_at = <Date 2014-09-06.17:31:30.353>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2014-09-06.17:31:30.353>
    actor = 'serhiy.storchaka'
    assignee = 'serhiy.storchaka'
    closed = True
    closed_date = <Date 2014-09-06.17:31:30.354>
    closer = 'serhiy.storchaka'
    components = ['Interpreter Core']
    creation = <Date 2014-08-17.14:43:54.964>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = ['36394', '36546', '36557']
    hgrepos = []
    issue_num = 22215
    keywords = ['patch']
    message_count = 10.0
    messages = ['225447', '225518', '226403', '226410', '226411', '226413', '226472', '226478', '226495', '226497']
    nosy_count = 3.0
    nosy_names = ['vstinner', 'python-dev', 'serhiy.storchaka']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue22215'
    versions = ['Python 3.5']

    Activity

    1. serhiy-storchaka commented on Aug 17, 2014

      @serhiy-storchaka
      MemberAuthor

      Currently most functions which accepts string only without embedded NUL character, raise TypeError. Proposed patch change exception type to more consistent ValueError. It also unifies error messages.

      I have opened a discussion on Python-Dev.

    2. serhiy-storchaka commented on Aug 19, 2014

      @serhiy-storchaka
      MemberAuthor

      BDFL have approved the idea (http://permalink.gmane.org/gmane.comp.python.devel/149000). Could anyone please make the review of concrete patch?

    3. serhiy-storchaka commented on Sep 5, 2014

      @serhiy-storchaka
      MemberAuthor

      If there are no objections I'll commit the patch soon.

    4. vstinner commented on Sep 5, 2014

      @vstinner
      Member

      If there are no objections I'll commit the patch soon.

      Replacing TypeError with ValueError is fine. TypeError was a bad choice. If an application relies on TypeError to check for null character, it's easy to replace "except TypeError:" with "except (TypeError, ValueError):" to stay compatible with Python < 3.5.

      Instead of "NUL character" (and "NUL byte), I had prefer "null character" (and "null byte"):
      http://en.wikipedia.org/wiki/Null_character

      I talking about the error message because you changed it in a few places.

    5. vstinner commented on Sep 5, 2014

      @vstinner
      Member

      You may also take a look at these 2 issues: bpo-13617 and bpo-21147 (not directly related to this oe).

    6. serhiy-storchaka commented on Sep 5, 2014

      @serhiy-storchaka
      MemberAuthor

      Thank you Victor. Here is a patch which is synchronized with the tip and addresses your comment about a null character.

    7. serhiy-storchaka commented on Sep 6, 2014

      @serhiy-storchaka
      MemberAuthor

      Simplified a code in getargs.c as suggested by Victor.

    8. vstinner commented on Sep 6, 2014

      @vstinner
      Member

      The latest patch looks good to me.

    9. python-dev commented on Sep 6, 2014

      python-devmannequin
      Mannequin

      New changeset 25032ec29315 by Serhiy Storchaka in branch 'default':
      Issue bpo-22215: Now ValueError is raised instead of TypeError when str or bytes
      http://hg.python.org/cpython/rev/25032ec29315

    10. serhiy-storchaka commented on Sep 6, 2014

      @serhiy-storchaka
      MemberAuthor

      Thank you for your review Victor.

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

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions