Skip to content

[2.7] bpo-36234: test_os: check TypeError for invalid uid type #12235

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

Merged
merged 1 commit into from
Mar 11, 2019
Merged

[2.7] bpo-36234: test_os: check TypeError for invalid uid type #12235

merged 1 commit into from
Mar 11, 2019

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Mar 8, 2019

Patch written by David Malcolm.

Co-Authored-By: David Malcolm dmalcolm@redhat.com

https://bugs.python.org/issue36234

Copy link
Contributor

@eamanu eamanu left a comment

Choose a reason for hiding this comment

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

LGTM, I think that we could use context for some raises. What do you think @vstinner ?

self.assertRaises(OverflowError, os.setegid, 1<<32)

@unittest.skipUnless(hasattr(os, 'setreuid'), 'test needs os.setreuid()')
def test_setreuid(self):
if os.getuid() != 0:
self.assertRaises(os.error, os.setreuid, 0, 0)
self.assertRaises(TypeError, os.setreuid, 'not an int', 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

why don't use context?

Copy link
Member Author

Choose a reason for hiding this comment

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

Which context? Context of what?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, something like this:

with self.assertRaises(TypeError):
    os.setreuid(...)

Copy link
Member Author

Choose a reason for hiding this comment

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

It's basically the same. Both variants are used in Python test suite. Here I just applied David's patch to make it upstream.

@vstinner
Copy link
Member Author

vstinner commented Mar 8, 2019

See also PR #12234 for the mastesr branch.

Patch written by David Malcolm.

Co-Authored-By: David Malcolm <dmalcolm@redhat.com>
@vstinner
Copy link
Member Author

I modified the NEWS entry to add "Patch written by David Malcolm." I forgot to credit David there!

@vstinner vstinner merged commit 701af60 into python:2.7 Mar 11, 2019
@vstinner vstinner deleted the test_os_uid27 branch March 11, 2019 12:59
jua74470 pushed a commit to jua74470/python2.7 that referenced this pull request Nov 14, 2024
Upstreamed patches:

- 157: python/cpython#12235
- 168: python/cpython#12349

Rebased patches:

- 189: updated bundles setuptools/pip versions
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