Skip to content

bpo-30184: Add tests for invalid use of PyArg_ParseTupleAndKeywords. #1316

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

serhiy-storchaka
Copy link
Member

No description provided.

@mention-bot
Copy link

@serhiy-storchaka, thanks for your PR! By analyzing the history of the files in this pull request, we identified @benjaminp, @tim-one and @larryhastings to be potential reviewers.

Copy link
Contributor

@louisom louisom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May add some test case

self.assertRaises(SystemError, _testcapi.parse_tuple_and_keywords,
(), {}, '|$O', [''])
self.assertRaises(SystemError, _testcapi.parse_tuple_and_keywords,
(), {}, '|OO', ['a', ''])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May add test case for misuse of ; and :

        self.assertRaises(SystemError, _testcapi.parse_tuple_and_keywords,
                          (1,), {}, ':O', ['a'])
        self.assertRaises(SystemError, _testcapi.parse_tuple_and_keywords,
                          (1,), {}, ';O', ['a'])

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests don't trigger any error that is not tested.


def test_bad_use(self):
# Test handling invalid format and keywords in
# PyArg_ParseTupleAndKeywords()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this use the method below parser = _testcapi.parse_tuple_and_keywords to reduce the length?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't matter, in any case the line is wrapped.

@serhiy-storchaka serhiy-storchaka merged commit 5f161fd into python:master May 3, 2017
@serhiy-storchaka serhiy-storchaka deleted the test-PyArg_ParseTupleAndKeywords-bad-use branch May 3, 2017 21:03
serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this pull request May 3, 2017
serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this pull request May 3, 2017
serhiy-storchaka added a commit that referenced this pull request May 4, 2017
serhiy-storchaka added a commit that referenced this pull request May 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Tests in the Lib/test dir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants