Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

bpo-46716: Use strict unsigned long conversion for DWORD values#32081

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
jkloth wants to merge1 commit intopython:main
base:main
Choose a base branch
Loading
fromjkloth:issue46716_dword

Conversation

jkloth
Copy link
Contributor

@jklothjkloth commentedMar 23, 2022
edited by bedevere-bot
Loading

The second part of the fix for negative timeouts.

This PR shouldnot be backported for the reasons I state here:#32079 (comment)
To further emphasize this, see the additional change required in this PR for use of-1 to denoteINFINITE.

https://bugs.python.org/issue46716

@eryksun
Copy link
Contributor

Maybe we should start to gradually add test cases for_winapi in "Lib/test/test_os.py", even if it's only an internal module. For example:

@unittest.skipUnless(sys.platform=="win32","Win32 specific tests")classWin32APITests(unittest.TestCase):deftest_dword_convert_negative(self):withself.assertRaises(ValueError):forhin_winapi.CreatePipe(None,-1):_winapi.CloseHandle(h)deftest_dword_convert_overflow(self):withself.assertRaises(OverflowError):forhin_winapi.CreatePipe(None,1<<32):_winapi.CloseHandle(h)

Copy link
Member

@serhiy-storchakaserhiy-storchaka left a comment

Choose a reason for hiding this comment

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

The DWORD converter is also used inwinreg.c andoverlapped.c.

Comment on lines +212 to +213
class DWORD_converter(unsigned_long_converter):
type = 'DWORD'

Choose a reason for hiding this comment

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

You can useDWORD(bitwise=True) instead ofDWORD in places where you want to keep the old behavior.

Or you can define non-strict by default completely compatible converter:

classDWORD_converter(unsigned_long_converter):type='DWORD'defconverter_init(self,*,bitwise:bool=True)->None:super().converter_init(bitwise=bitwise)

and useDWORD(bitwise=False) if you need a strict conversion.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@serhiy-storchakaserhiy-storchakaserhiy-storchaka left review comments

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

6 participants
@jkloth@eryksun@serhiy-storchaka@the-knights-who-say-ni@ezio-melotti@bedevere-bot

[8]ページ先頭

©2009-2025 Movatter.jp