Skip to content

datetime: Tests for potential crashes due to non-UTF-8-encodable strings #78663

Closed

Description

@izbyshev
mannequin
BPO 34482
Nosy @abalkin, @vstinner, @taleinat, @serhiy-storchaka, @pganssle, @izbyshev, @miss-islington
PRs
  • bpo-34482: Add tests for proper handling of non-UTF-8-encodable strin… #8878
  • bpo-34454: datetime: Fix crash on PyUnicode_AsUTF8AndSize() failure #8850
  • [3.7] bpo-34482: test datetime classes' handling of non-UTF-8-encodable strings (GH-8878) #10049
  • 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 2018-10-23.07:06:16.562>
    created_at = <Date 2018-08-23.17:41:50.810>
    labels = ['type-security', 'extension-modules', '3.7', '3.8']
    title = 'datetime: Tests for potential crashes due to non-UTF-8-encodable strings'
    updated_at = <Date 2018-11-27.16:17:11.783>
    user = 'https://github.com/izbyshev'

    bugs.python.org fields:

    activity = <Date 2018-11-27.16:17:11.783>
    actor = 'izbyshev'
    assignee = 'none'
    closed = True
    closed_date = <Date 2018-10-23.07:06:16.562>
    closer = 'taleinat'
    components = ['Extension Modules']
    creation = <Date 2018-08-23.17:41:50.810>
    creator = 'izbyshev'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 34482
    keywords = ['patch']
    message_count = 8.0
    messages = ['323964', '324201', '324264', '328282', '328288', '328289', '330484', '330535']
    nosy_count = 7.0
    nosy_names = ['belopolsky', 'vstinner', 'taleinat', 'serhiy.storchaka', 'p-ganssle', 'izbyshev', 'miss-islington']
    pr_nums = ['8878', '8850', '10049']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'security'
    url = 'https://bugs.python.org/issue34482'
    versions = ['Python 3.7', 'Python 3.8']

    Activity

    1. izbyshev commented on Aug 23, 2018

      izbyshevmannequin
      MannequinAuthor

      This is a follow-up of bpo-34454. 'datetime' extension module attempts to encode input strings into UTF-8 in several places, which requires special care because some valid Python strings can't be represented in UTF-8. It makes sense to add more tests for methods dealing with strings.

      Note that my PR doesn't attempt to deal with bpo-34481. In cases where behavior differs between C and Python datetime impls the tests check only for absence of crashes.

    2. pganssle commented on Aug 27, 2018

      @pganssle
      Member

      Somewhat related: bpo-6697.

      Turns out there are already some tests here for this, specifically for the C version only: https://github.com/python/cpython/blob/master/Lib/test/datetimetester.py#L3328

    3. izbyshev commented on Aug 28, 2018

      izbyshevmannequin
      MannequinAuthor

      Yes, I've referenced the relevant message from bpo-6697 in bpo-34454.

      The specific test you've referenced should be changed after bpo-34481 is fixed -- it highlights inconsistency between C and Python implementations.

    4. taleinat commented on Oct 23, 2018

      @taleinat
      Contributor

      New changeset 3b0047d by Tal Einat (Alexey Izbyshev) in branch 'master':
      bpo-34482: test datetime classes' handling of non-UTF-8-encodable strings (GH-8878)
      3b0047d

    5. miss-islington commented on Oct 23, 2018

      @miss-islington
      Contributor

      New changeset 313e501 by Miss Islington (bot) in branch '3.7':
      bpo-34482: test datetime classes' handling of non-UTF-8-encodable strings (GH-8878)
      313e501

    6. taleinat commented on Oct 23, 2018

      @taleinat
      Contributor

      Thanks for the PR, Alexey!

    7. vstinner commented on Nov 27, 2018

      @vstinner
      Member

      It seems like thie issue introduced a memory leak: bpo-35322 .

    8. izbyshev commented on Nov 27, 2018

      izbyshevmannequin
      MannequinAuthor

      The added test exposed a leak in unicode_encode_locale(). See msg330534.

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

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions