From webhook-mailer at python.org Sun May 1 00:02:56 2022 From: webhook-mailer at python.org (miss-islington) Date: Sun, 01 May 2022 04:02:56 -0000 Subject: [Python-checkins] gh-91611: Use example.com for documentation, not mydomain.com (GH-91613) Message-ID: https://github.com/python/cpython/commit/cef3a994c7c966511563edc45292ec8f69770268 commit: cef3a994c7c966511563edc45292ec8f69770268 branch: 3.9 author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com> committer: miss-islington <31488909+miss-islington at users.noreply.github.com> date: 2022-04-30T21:02:51-07:00 summary: gh-91611: Use example.com for documentation, not mydomain.com (GH-91613) example.com is reserved by the IANA as special-use domain name for documentation purposes. The domain names are used widely in books, tutorials, sample network configurations, and generally as examples for the use of domain name. On the other hand, mydomain.com is real Domain Name Registration service. (cherry picked from commit ea392467829d6e93f824bde8eb87bdb31d9e4c62) Co-authored-by: Motoki Naruse files: M Doc/library/secrets.rst M Doc/library/ssl.rst diff --git a/Doc/library/secrets.rst b/Doc/library/secrets.rst index afa8e2d385fa4..c22da727b55c9 100644 --- a/Doc/library/secrets.rst +++ b/Doc/library/secrets.rst @@ -193,7 +193,7 @@ suitable for password recovery applications: .. testcode:: import secrets - url = 'https://mydomain.com/reset=' + secrets.token_urlsafe() + url = 'https://example.com/reset=' + secrets.token_urlsafe() diff --git a/Doc/library/ssl.rst b/Doc/library/ssl.rst index f5446808cbdeb..af9bf798da3b4 100644 --- a/Doc/library/ssl.rst +++ b/Doc/library/ssl.rst @@ -2345,7 +2345,7 @@ waiting for clients to connect:: context.load_cert_chain(certfile="mycertfile", keyfile="mykeyfile") bindsocket = socket.socket() - bindsocket.bind(('myaddr.mydomain.com', 10023)) + bindsocket.bind(('myaddr.example.com', 10023)) bindsocket.listen(5) When a client connects, you'll call :meth:`accept` on the socket to get the From webhook-mailer at python.org Sun May 1 00:03:15 2022 From: webhook-mailer at python.org (miss-islington) Date: Sun, 01 May 2022 04:03:15 -0000 Subject: [Python-checkins] gh-91611: Use example.com for documentation, not mydomain.com (GH-91613) Message-ID: https://github.com/python/cpython/commit/31e35bef22e6cf21526b1099c650e97a0a5c6652 commit: 31e35bef22e6cf21526b1099c650e97a0a5c6652 branch: 3.10 author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com> committer: miss-islington <31488909+miss-islington at users.noreply.github.com> date: 2022-04-30T21:03:11-07:00 summary: gh-91611: Use example.com for documentation, not mydomain.com (GH-91613) example.com is reserved by the IANA as special-use domain name for documentation purposes. The domain names are used widely in books, tutorials, sample network configurations, and generally as examples for the use of domain name. On the other hand, mydomain.com is real Domain Name Registration service. (cherry picked from commit ea392467829d6e93f824bde8eb87bdb31d9e4c62) Co-authored-by: Motoki Naruse files: M Doc/library/secrets.rst M Doc/library/ssl.rst diff --git a/Doc/library/secrets.rst b/Doc/library/secrets.rst index afa8e2d385fa4..c22da727b55c9 100644 --- a/Doc/library/secrets.rst +++ b/Doc/library/secrets.rst @@ -193,7 +193,7 @@ suitable for password recovery applications: .. testcode:: import secrets - url = 'https://mydomain.com/reset=' + secrets.token_urlsafe() + url = 'https://example.com/reset=' + secrets.token_urlsafe() diff --git a/Doc/library/ssl.rst b/Doc/library/ssl.rst index d21d6122e0a80..19d983bcfe28d 100644 --- a/Doc/library/ssl.rst +++ b/Doc/library/ssl.rst @@ -2357,7 +2357,7 @@ waiting for clients to connect:: context.load_cert_chain(certfile="mycertfile", keyfile="mykeyfile") bindsocket = socket.socket() - bindsocket.bind(('myaddr.mydomain.com', 10023)) + bindsocket.bind(('myaddr.example.com', 10023)) bindsocket.listen(5) When a client connects, you'll call :meth:`accept` on the socket to get the From webhook-mailer at python.org Sun May 1 00:05:24 2022 From: webhook-mailer at python.org (JelleZijlstra) Date: Sun, 01 May 2022 04:05:24 -0000 Subject: [Python-checkins] gh-81488: Add recursive wording for issubclass docs (#92087) Message-ID: https://github.com/python/cpython/commit/1066ecb97042b8e89de554e6f9dc2e3d634208c0 commit: 1066ecb97042b8e89de554e6f9dc2e3d634208c0 branch: main author: slateny <46876382+slateny at users.noreply.github.com> committer: JelleZijlstra date: 2022-04-30T22:05:20-06:00 summary: gh-81488: Add recursive wording for issubclass docs (#92087) files: M Doc/library/functions.rst diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst index 394281462ded5..cb86296897082 100644 --- a/Doc/library/functions.rst +++ b/Doc/library/functions.rst @@ -917,7 +917,8 @@ are always available. They are listed here in alphabetical order. Return ``True`` if *class* is a subclass (direct, indirect, or :term:`virtual `) of *classinfo*. A class is considered a subclass of itself. *classinfo* may be a tuple of class - objects or a :ref:`types-union`, in which case return ``True`` if *class* is a + objects (or recursively, other such tuples) + or a :ref:`types-union`, in which case return ``True`` if *class* is a subclass of any entry in *classinfo*. In any other case, a :exc:`TypeError` exception is raised. From webhook-mailer at python.org Sun May 1 00:21:59 2022 From: webhook-mailer at python.org (miss-islington) Date: Sun, 01 May 2022 04:21:59 -0000 Subject: [Python-checkins] gh-81488: Add recursive wording for issubclass docs (GH-92087) Message-ID: https://github.com/python/cpython/commit/a48d31f204642c8b38e55dd78c4839bb7ae5dce9 commit: a48d31f204642c8b38e55dd78c4839bb7ae5dce9 branch: 3.10 author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com> committer: miss-islington <31488909+miss-islington at users.noreply.github.com> date: 2022-04-30T21:21:51-07:00 summary: gh-81488: Add recursive wording for issubclass docs (GH-92087) (cherry picked from commit 1066ecb97042b8e89de554e6f9dc2e3d634208c0) Co-authored-by: slateny <46876382+slateny at users.noreply.github.com> files: M Doc/library/functions.rst diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst index 42fbf4e6f969c..ff81558da14cf 100644 --- a/Doc/library/functions.rst +++ b/Doc/library/functions.rst @@ -913,7 +913,8 @@ are always available. They are listed here in alphabetical order. Return ``True`` if *class* is a subclass (direct, indirect, or :term:`virtual `) of *classinfo*. A class is considered a subclass of itself. *classinfo* may be a tuple of class - objects or a :ref:`types-union`, in which case return ``True`` if *class* is a + objects (or recursively, other such tuples) + or a :ref:`types-union`, in which case return ``True`` if *class* is a subclass of any entry in *classinfo*. In any other case, a :exc:`TypeError` exception is raised. From webhook-mailer at python.org Sun May 1 00:40:37 2022 From: webhook-mailer at python.org (JelleZijlstra) Date: Sun, 01 May 2022 04:40:37 -0000 Subject: [Python-checkins] typing docs: Add example for async functions (#20386) Message-ID: https://github.com/python/cpython/commit/9588f880a286a8cc5597188f6ab44108c8f18761 commit: 9588f880a286a8cc5597188f6ab44108c8f18761 branch: main author: Sam Bull committer: JelleZijlstra date: 2022-04-30T22:40:27-06:00 summary: typing docs: Add example for async functions (#20386) Fixes python/typing#424 files: M Doc/library/typing.rst diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst index 426cbf12b8c92..868ea1b81be42 100644 --- a/Doc/library/typing.rst +++ b/Doc/library/typing.rst @@ -221,6 +221,10 @@ For example:: on_error: Callable[[int, Exception], None]) -> None: # Body + async def on_update(value: str) -> None: + # Body + callback: Callable[[str], Awaitable[None]] = on_update + It is possible to declare the return type of a callable without specifying the call signature by substituting a literal ellipsis for the list of arguments in the type hint: ``Callable[..., ReturnType]``. From webhook-mailer at python.org Sun May 1 00:56:02 2022 From: webhook-mailer at python.org (miss-islington) Date: Sun, 01 May 2022 04:56:02 -0000 Subject: [Python-checkins] typing docs: Add example for async functions (GH-20386) Message-ID: https://github.com/python/cpython/commit/e7de54321952ebb58cc414f2160c9ad4f6510af2 commit: e7de54321952ebb58cc414f2160c9ad4f6510af2 branch: 3.10 author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com> committer: miss-islington <31488909+miss-islington at users.noreply.github.com> date: 2022-04-30T21:55:58-07:00 summary: typing docs: Add example for async functions (GH-20386) Fixes python/typingGH-424 (cherry picked from commit 9588f880a286a8cc5597188f6ab44108c8f18761) Co-authored-by: Sam Bull files: M Doc/library/typing.rst diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst index 36d637f366509..6a160af895c06 100644 --- a/Doc/library/typing.rst +++ b/Doc/library/typing.rst @@ -211,6 +211,10 @@ For example:: on_error: Callable[[int, Exception], None]) -> None: # Body + async def on_update(value: str) -> None: + # Body + callback: Callable[[str], Awaitable[None]] = on_update + It is possible to declare the return type of a callable without specifying the call signature by substituting a literal ellipsis for the list of arguments in the type hint: ``Callable[..., ReturnType]``. From webhook-mailer at python.org Sun May 1 00:59:30 2022 From: webhook-mailer at python.org (miss-islington) Date: Sun, 01 May 2022 04:59:30 -0000 Subject: [Python-checkins] typing docs: Add example for async functions (GH-20386) Message-ID: https://github.com/python/cpython/commit/fcbff77b26c44b8ee58c2ef2c3b25b3ffe7c20e9 commit: fcbff77b26c44b8ee58c2ef2c3b25b3ffe7c20e9 branch: 3.9 author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com> committer: miss-islington <31488909+miss-islington at users.noreply.github.com> date: 2022-04-30T21:59:26-07:00 summary: typing docs: Add example for async functions (GH-20386) Fixes python/typingGH-424 (cherry picked from commit 9588f880a286a8cc5597188f6ab44108c8f18761) Co-authored-by: Sam Bull files: M Doc/library/typing.rst diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst index 202f5b5e8fec4..c0af2ed7c429a 100644 --- a/Doc/library/typing.rst +++ b/Doc/library/typing.rst @@ -194,6 +194,10 @@ For example:: on_error: Callable[[int, Exception], None]) -> None: # Body + async def on_update(value: str) -> None: + # Body + callback: Callable[[str], Awaitable[None]] = on_update + It is possible to declare the return type of a callable without specifying the call signature by substituting a literal ellipsis for the list of arguments in the type hint: ``Callable[..., ReturnType]``. From webhook-mailer at python.org Sun May 1 02:04:54 2022 From: webhook-mailer at python.org (miss-islington) Date: Sun, 01 May 2022 06:04:54 -0000 Subject: [Python-checkins] bpo-39716: Raise on conflicting subparser names. (GH-18605) Message-ID: https://github.com/python/cpython/commit/ad5e8520f3e117f45481513014548a39879d30d2 commit: ad5e8520f3e117f45481513014548a39879d30d2 branch: main author: Antony Lee committer: miss-islington <31488909+miss-islington at users.noreply.github.com> date: 2022-04-30T23:04:50-07:00 summary: bpo-39716: Raise on conflicting subparser names. (GH-18605) Raise an ArgumentError when the same subparser name is added twice to an ArgumentParser. This is consistent with the (default) behavior when the same option string is added twice to an ArgumentParser. (Support for `conflict_handler="resolve"` could be considered as a followup feature, although real use cases seem even rarer than "resolve"ing option-strings.) Automerge-Triggered-By: GH:rhettinger files: A Misc/NEWS.d/next/Library/2020-02-22-12-02-11.bpo-39716.z2WhDQ.rst M Lib/argparse.py M Lib/test/test_argparse.py diff --git a/Lib/argparse.py b/Lib/argparse.py index 668e1d416231f..c47aeffc2c3f6 100644 --- a/Lib/argparse.py +++ b/Lib/argparse.py @@ -1171,6 +1171,13 @@ def add_parser(self, name, **kwargs): aliases = kwargs.pop('aliases', ()) + if name in self._name_parser_map: + raise ArgumentError(self, _('conflicting subparser: %s') % name) + for alias in aliases: + if alias in self._name_parser_map: + raise ArgumentError( + self, _('conflicting subparser alias: %s') % alias) + # create a pseudo-action to hold the choice help if 'help' in kwargs: help = kwargs.pop('help') diff --git a/Lib/test/test_argparse.py b/Lib/test/test_argparse.py index 5777cb50f7e53..794b9df3796df 100644 --- a/Lib/test/test_argparse.py +++ b/Lib/test/test_argparse.py @@ -4804,6 +4804,19 @@ def test_resolve_error(self): --spam NEW_SPAM ''')) + def test_subparser_conflict(self): + parser = argparse.ArgumentParser() + sp = parser.add_subparsers() + sp.add_parser('fullname', aliases=['alias']) + self.assertRaises(argparse.ArgumentError, + sp.add_parser, 'fullname') + self.assertRaises(argparse.ArgumentError, + sp.add_parser, 'alias') + self.assertRaises(argparse.ArgumentError, + sp.add_parser, 'other', aliases=['fullname']) + self.assertRaises(argparse.ArgumentError, + sp.add_parser, 'other', aliases=['alias']) + # ============================= # Help and Version option tests diff --git a/Misc/NEWS.d/next/Library/2020-02-22-12-02-11.bpo-39716.z2WhDQ.rst b/Misc/NEWS.d/next/Library/2020-02-22-12-02-11.bpo-39716.z2WhDQ.rst new file mode 100644 index 0000000000000..f122811e6bfe3 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2020-02-22-12-02-11.bpo-39716.z2WhDQ.rst @@ -0,0 +1,3 @@ +Raise an ArgumentError when the same subparser name is added twice to an +`argparse.ArgumentParser`. This is consistent with the (default) behavior +when the same option string is added twice to an ArgumentParser. From webhook-mailer at python.org Sun May 1 06:02:00 2022 From: webhook-mailer at python.org (serhiy-storchaka) Date: Sun, 01 May 2022 10:02:00 -0000 Subject: [Python-checkins] [3.9] gh-92049: Forbid pickling constants re._constants.SUCCESS etc (GH-92070) (GH-92073) (GH-92102) Message-ID: https://github.com/python/cpython/commit/54f06aeb74909f6c3b0727e73987639732428751 commit: 54f06aeb74909f6c3b0727e73987639732428751 branch: 3.9 author: Serhiy Storchaka committer: serhiy-storchaka date: 2022-05-01T13:01:56+03:00 summary: [3.9] gh-92049: Forbid pickling constants re._constants.SUCCESS etc (GH-92070) (GH-92073) (GH-92102) Previously, pickling did not fail, but the result could not be unpickled. (cherry picked from commit 6d0d547033e295f91f05030322acfbb0e280fc1f) (cherry picked from commit e8ff3c92f69b475aa20ba7c08efccbc329f9b42e) files: A Misc/NEWS.d/next/Library/2022-04-30-10-53-10.gh-issue-92049.5SEKoh.rst M Lib/sre_constants.py diff --git a/Lib/sre_constants.py b/Lib/sre_constants.py index 8e613cb3fa5dc..db3ca51e8306a 100644 --- a/Lib/sre_constants.py +++ b/Lib/sre_constants.py @@ -62,6 +62,8 @@ def __new__(cls, value, name): def __repr__(self): return self.name + __reduce__ = None + MAXREPEAT = _NamedIntConstant(MAXREPEAT, 'MAXREPEAT') def _makecodes(names): diff --git a/Misc/NEWS.d/next/Library/2022-04-30-10-53-10.gh-issue-92049.5SEKoh.rst b/Misc/NEWS.d/next/Library/2022-04-30-10-53-10.gh-issue-92049.5SEKoh.rst new file mode 100644 index 0000000000000..cad4621c65096 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2022-04-30-10-53-10.gh-issue-92049.5SEKoh.rst @@ -0,0 +1,2 @@ +Forbid pickling constants ``re._constants.SUCCESS`` etc. Previously, +pickling did not fail, but the result could not be unpickled. From webhook-mailer at python.org Sun May 1 16:38:15 2022 From: webhook-mailer at python.org (JelleZijlstra) Date: Sun, 01 May 2022 20:38:15 -0000 Subject: [Python-checkins] build(deps): bump actions/cache from 3.0.1 to 3.0.2 (#92111) Message-ID: https://github.com/python/cpython/commit/eefe6911f4f497e8b73e0690f9b3f47904fdb02a commit: eefe6911f4f497e8b73e0690f9b3f47904fdb02a branch: main author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> committer: JelleZijlstra date: 2022-05-01T14:37:52-06:00 summary: build(deps): bump actions/cache from 3.0.1 to 3.0.2 (#92111) Bumps [actions/cache](https://github.com/actions/cache) from 3.0.1 to 3.0.2. - [Release notes](https://github.com/actions/cache/releases) - [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md) - [Commits](https://github.com/actions/cache/compare/v3.0.1...v3.0.2) --- updated-dependencies: - dependency-name: actions/cache dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> files: M .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8956c2cfc4e70..1f48d6257e760 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -185,7 +185,7 @@ jobs: echo "LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/multissl/openssl/${OPENSSL_VER}/lib" >> $GITHUB_ENV - name: 'Restore OpenSSL build' id: cache-openssl - uses: actions/cache at v3.0.1 + uses: actions/cache at v3.0.2 with: path: ./multissl/openssl/${{ env.OPENSSL_VER }} key: ${{ runner.os }}-multissl-openssl-${{ env.OPENSSL_VER }} @@ -248,7 +248,7 @@ jobs: echo "LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/multissl/openssl/${OPENSSL_VER}/lib" >> $GITHUB_ENV - name: 'Restore OpenSSL build' id: cache-openssl - uses: actions/cache at v3.0.1 + uses: actions/cache at v3.0.2 with: path: ./multissl/openssl/${{ env.OPENSSL_VER }} key: ${{ runner.os }}-multissl-openssl-${{ env.OPENSSL_VER }} @@ -292,7 +292,7 @@ jobs: echo "LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/multissl/openssl/${OPENSSL_VER}/lib" >> $GITHUB_ENV - name: 'Restore OpenSSL build' id: cache-openssl - uses: actions/cache at v3.0.1 + uses: actions/cache at v3.0.2 with: path: ./multissl/openssl/${{ env.OPENSSL_VER }} key: ${{ runner.os }}-multissl-openssl-${{ env.OPENSSL_VER }} From webhook-mailer at python.org Sun May 1 16:40:03 2022 From: webhook-mailer at python.org (JelleZijlstra) Date: Sun, 01 May 2022 20:40:03 -0000 Subject: [Python-checkins] build(deps): bump actions/setup-node from 2 to 3 (#92110) Message-ID: https://github.com/python/cpython/commit/0d4fdb665e167d7641f2fb45a83376ba7ba2e4d6 commit: 0d4fdb665e167d7641f2fb45a83376ba7ba2e4d6 branch: main author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> committer: JelleZijlstra date: 2022-05-01T14:39:53-06:00 summary: build(deps): bump actions/setup-node from 2 to 3 (#92110) Bumps [actions/setup-node](https://github.com/actions/setup-node) from 2 to 3. - [Release notes](https://github.com/actions/setup-node/releases) - [Commits](https://github.com/actions/setup-node/compare/v2...v3) --- updated-dependencies: - dependency-name: actions/setup-node dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> files: M .github/workflows/new-bugs-announce-notifier.yml diff --git a/.github/workflows/new-bugs-announce-notifier.yml b/.github/workflows/new-bugs-announce-notifier.yml index a18946306f839..ad434917491c0 100644 --- a/.github/workflows/new-bugs-announce-notifier.yml +++ b/.github/workflows/new-bugs-announce-notifier.yml @@ -9,7 +9,7 @@ jobs: notify-new-bugs-announce: runs-on: ubuntu-latest steps: - - uses: actions/setup-node at v2 + - uses: actions/setup-node at v3 with: node-version: 14 - run: npm install mailgun.js form-data From webhook-mailer at python.org Sun May 1 16:52:53 2022 From: webhook-mailer at python.org (JelleZijlstra) Date: Sun, 01 May 2022 20:52:53 -0000 Subject: [Python-checkins] build(deps): bump actions/github-script from 5 to 6 (#92109) Message-ID: https://github.com/python/cpython/commit/51f69461a50908b05e29333c7917189b1dc6c96c commit: 51f69461a50908b05e29333c7917189b1dc6c96c branch: main author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> committer: JelleZijlstra date: 2022-05-01T14:52:21-06:00 summary: build(deps): bump actions/github-script from 5 to 6 (#92109) Bumps [actions/github-script](https://github.com/actions/github-script) from 5 to 6. - [Release notes](https://github.com/actions/github-script/releases) - [Commits](https://github.com/actions/github-script/compare/v5...v6) --- updated-dependencies: - dependency-name: actions/github-script dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> files: M .github/workflows/new-bugs-announce-notifier.yml diff --git a/.github/workflows/new-bugs-announce-notifier.yml b/.github/workflows/new-bugs-announce-notifier.yml index ad434917491c0..8cd834419f00b 100644 --- a/.github/workflows/new-bugs-announce-notifier.yml +++ b/.github/workflows/new-bugs-announce-notifier.yml @@ -14,7 +14,7 @@ jobs: node-version: 14 - run: npm install mailgun.js form-data - name: Send notification - uses: actions/github-script at v5 + uses: actions/github-script at v6 env: MAILGUN_API_KEY: ${{ secrets.PSF_MAILGUN_KEY }} with: From webhook-mailer at python.org Sun May 1 16:53:25 2022 From: webhook-mailer at python.org (JelleZijlstra) Date: Sun, 01 May 2022 20:53:25 -0000 Subject: [Python-checkins] build(deps): bump actions/stale from 4 to 5 (#92108) Message-ID: https://github.com/python/cpython/commit/34129f7c42b31d12d8ed692cd3f82c8d36c6c644 commit: 34129f7c42b31d12d8ed692cd3f82c8d36c6c644 branch: main author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> committer: JelleZijlstra date: 2022-05-01T14:53:15-06:00 summary: build(deps): bump actions/stale from 4 to 5 (#92108) Bumps [actions/stale](https://github.com/actions/stale) from 4 to 5. - [Release notes](https://github.com/actions/stale/releases) - [Changelog](https://github.com/actions/stale/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/stale/compare/v4...v5) --- updated-dependencies: - dependency-name: actions/stale dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> files: M .github/workflows/stale.yml diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 72a7a0ba9c83c..a8fecbf216b95 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -15,7 +15,7 @@ jobs: steps: - name: "Check PRs" - uses: actions/stale at v4 + uses: actions/stale at v5 with: repo-token: ${{ secrets.GITHUB_TOKEN }} stale-pr-message: 'This PR is stale because it has been open for 30 days with no activity.' From webhook-mailer at python.org Sun May 1 19:09:55 2022 From: webhook-mailer at python.org (gpshead) Date: Sun, 01 May 2022 23:09:55 -0000 Subject: [Python-checkins] [3.10] gh-91401: Conservative backport of `subprocess._USE_VFORK` (#91932) Message-ID: https://github.com/python/cpython/commit/ea1eba03e7e8401d5acf8b30b56b41faa209e8c6 commit: ea1eba03e7e8401d5acf8b30b56b41faa209e8c6 branch: 3.10 author: Gregory P. Smith committer: gpshead date: 2022-05-01T16:09:50-07:00 summary: [3.10] gh-91401: Conservative backport of `subprocess._USE_VFORK` (#91932) This does not alter the `_posixsubprocess.fork_exec()` private API to avoid issues for anyone relying on that (bad idea) or for anyone who's `subprocess.py` and `_posixsubprocess.so` upgrades may not become visible to existing Python 3.10 processes at the same time. Backports the concept of cd5726fe674eaff442510eeb6c75628858be9e9f. Provides a fail-safe way to disable vfork for #91401. I didn't backport the documentation as I don't actually expect this to be used and `.. versionadded: 3.10.5` always looks weird in docs. It's being done more to have a fail-safe in place for people just in case. files: A Misc/NEWS.d/next/Library/2022-04-26-00-10-06.gh-issue-91401.mddRC8.rst M Lib/subprocess.py M Lib/test/test_subprocess.py M Modules/_posixsubprocess.c diff --git a/Lib/subprocess.py b/Lib/subprocess.py index ccb46a6337b3d..a414321b9d197 100644 --- a/Lib/subprocess.py +++ b/Lib/subprocess.py @@ -691,7 +691,10 @@ def _use_posix_spawn(): return False +# These are primarily fail-safe knobs for negatives. A True value does not +# guarantee the given libc/syscall API will be used. _USE_POSIX_SPAWN = _use_posix_spawn() +_USE_VFORK = True class Popen: diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py index 7bb049296912b..b91791a02a2e5 100644 --- a/Lib/test/test_subprocess.py +++ b/Lib/test/test_subprocess.py @@ -1702,6 +1702,28 @@ def test_run_with_shell_timeout_and_capture_output(self): msg="TimeoutExpired was delayed! Bad traceback:\n```\n" f"{stacks}```") + @unittest.skipIf(not sysconfig.get_config_var("HAVE_VFORK"), + "vfork() not enabled by configure.") + def test__use_vfork(self): + # Attempts code coverage within _posixsubprocess.c on the code that + # probes the subprocess module for the existence and value of this + # attribute in 3.10.5. + self.assertTrue(subprocess._USE_VFORK) # The default value regardless. + with mock.patch.object(subprocess, "_USE_VFORK", False): + self.assertEqual(self.run_python("pass").returncode, 0, + msg="False _USE_VFORK failed") + + class RaisingBool: + def __bool__(self): + raise RuntimeError("force PyObject_IsTrue to return -1") + + with mock.patch.object(subprocess, "_USE_VFORK", RaisingBool()): + self.assertEqual(self.run_python("pass").returncode, 0, + msg="odd bool()-error _USE_VFORK failed") + del subprocess._USE_VFORK + self.assertEqual(self.run_python("pass").returncode, 0, + msg="lack of a _USE_VFORK attribute failed") + def _get_test_grp_name(): for name_group in ('staff', 'nogroup', 'grp', 'nobody', 'nfsnobody'): diff --git a/Misc/NEWS.d/next/Library/2022-04-26-00-10-06.gh-issue-91401.mddRC8.rst b/Misc/NEWS.d/next/Library/2022-04-26-00-10-06.gh-issue-91401.mddRC8.rst new file mode 100644 index 0000000000000..964a54f8935c2 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2022-04-26-00-10-06.gh-issue-91401.mddRC8.rst @@ -0,0 +1,5 @@ +Provide a fail-safe way to disable :mod:`subprocess` use of ``vfork()`` via +a private ``subprocess._USE_VFORK`` attribute. While there is currently no +known need for this, if you find a need please only set it to ``False``. +File a CPython issue as to why you needed it and link to that from a +comment in your code. This attribute is documented as a footnote in 3.11. diff --git a/Modules/_posixsubprocess.c b/Modules/_posixsubprocess.c index 18a81c6ed8b35..b852ad71d7225 100644 --- a/Modules/_posixsubprocess.c +++ b/Modules/_posixsubprocess.c @@ -936,8 +936,31 @@ subprocess_fork_exec(PyObject *module, PyObject *args) #ifdef VFORK_USABLE /* Use vfork() only if it's safe. See the comment above child_exec(). */ sigset_t old_sigs; - if (preexec_fn == Py_None && - !call_setuid && !call_setgid && !call_setgroups) { + int allow_vfork; + if (preexec_fn == Py_None) { + allow_vfork = 1; /* 3.10.0 behavior */ + PyObject *subprocess_module = PyImport_ImportModule("subprocess"); + if (subprocess_module != NULL) { + PyObject *allow_vfork_obj = PyObject_GetAttrString( + subprocess_module, "_USE_VFORK"); + Py_DECREF(subprocess_module); + if (allow_vfork_obj != NULL) { + allow_vfork = PyObject_IsTrue(allow_vfork_obj); + Py_DECREF(allow_vfork_obj); + if (allow_vfork < 0) { + PyErr_Clear(); /* Bad _USE_VFORK attribute. */ + allow_vfork = 1; /* 3.10.0 behavior */ + } + } else { + PyErr_Clear(); /* No _USE_VFORK attribute. */ + } + } else { + PyErr_Clear(); /* no subprocess module? suspicious; don't care. */ + } + } else { + allow_vfork = 0; + } + if (allow_vfork && !call_setuid && !call_setgid && !call_setgroups) { /* Block all signals to ensure that no signal handlers are run in the * child process while it shares memory with us. Note that signals * used internally by C libraries won't be blocked by From webhook-mailer at python.org Sun May 1 19:46:22 2022 From: webhook-mailer at python.org (JelleZijlstra) Date: Sun, 01 May 2022 23:46:22 -0000 Subject: [Python-checkins] [3.10] build(deps): bump actions/stale from 4 to 5 (GH-92108) (#92127) Message-ID: https://github.com/python/cpython/commit/1fd3ab7c28451f7346c7e911e265ad74f6086d19 commit: 1fd3ab7c28451f7346c7e911e265ad74f6086d19 branch: 3.10 author: Jelle Zijlstra committer: JelleZijlstra date: 2022-05-01T17:46:06-06:00 summary: [3.10] build(deps): bump actions/stale from 4 to 5 (GH-92108) (#92127) Bumps [actions/stale](https://github.com/actions/stale) from 4 to 5. - [Release notes](https://github.com/actions/stale/releases) - [Changelog](https://github.com/actions/stale/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/stale/compare/v4...v5) --- updated-dependencies: - dependency-name: actions/stale dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>. (cherry picked from commit 34129f7c42b31d12d8ed692cd3f82c8d36c6c644) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> files: M .github/workflows/stale.yml diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 26806fad814f1..4a08ef0d8dac5 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -13,7 +13,8 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/stale at v3 + - name: "Check PRs" + uses: actions/stale at v5 with: repo-token: ${{ secrets.GITHUB_TOKEN }} stale-pr-message: 'This PR is stale because it has been open for 30 days with no activity.' From webhook-mailer at python.org Sun May 1 19:46:22 2022 From: webhook-mailer at python.org (JelleZijlstra) Date: Sun, 01 May 2022 23:46:22 -0000 Subject: [Python-checkins] [3.9] build(deps): bump actions/cache from 3.0.1 to 3.0.2 (GH-92111) (#92125) Message-ID: https://github.com/python/cpython/commit/07c1cfd3a75d79358f5ddb130d0738c2b237545e commit: 07c1cfd3a75d79358f5ddb130d0738c2b237545e branch: 3.9 author: Jelle Zijlstra committer: JelleZijlstra date: 2022-05-01T17:46:15-06:00 summary: [3.9] build(deps): bump actions/cache from 3.0.1 to 3.0.2 (GH-92111) (#92125) Bumps [actions/cache](https://github.com/actions/cache) from 3.0.1 to 3.0.2. - [Release notes](https://github.com/actions/cache/releases) - [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md) - [Commits](https://github.com/actions/cache/compare/v3.0.1...v3.0.2) --- updated-dependencies: - dependency-name: actions/cache dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>. (cherry picked from commit eefe6911f4f497e8b73e0690f9b3f47904fdb02a) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> files: M .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7a3f7b35a612c..b2792efc0dae9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -178,7 +178,7 @@ jobs: echo "LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/multissl/openssl/${OPENSSL_VER}/lib" >> $GITHUB_ENV - name: 'Restore OpenSSL build' id: cache-openssl - uses: actions/cache at v3.0.1 + uses: actions/cache at v3.0.2 with: path: ./multissl/openssl/${{ env.OPENSSL_VER }} key: ${{ runner.os }}-multissl-openssl-${{ env.OPENSSL_VER }} @@ -224,7 +224,7 @@ jobs: echo "LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/multissl/openssl/${OPENSSL_VER}/lib" >> $GITHUB_ENV - name: 'Restore OpenSSL build' id: cache-openssl - uses: actions/cache at v3.0.1 + uses: actions/cache at v3.0.2 with: path: ./multissl/openssl/${{ env.OPENSSL_VER }} key: ${{ runner.os }}-multissl-openssl-${{ env.OPENSSL_VER }} From webhook-mailer at python.org Sun May 1 21:25:19 2022 From: webhook-mailer at python.org (rhettinger) Date: Mon, 02 May 2022 01:25:19 -0000 Subject: [Python-checkins] gh-91998: 'WebAssemby' to 'WebAssembly' (#92040) Message-ID: https://github.com/python/cpython/commit/ed711290a0d6f40e16acc569dd86cfc4611dbcd3 commit: ed711290a0d6f40e16acc569dd86cfc4611dbcd3 branch: main author: vainaijr <43755000+vainaijr at users.noreply.github.com> committer: rhettinger date: 2022-05-01T20:24:41-05:00 summary: gh-91998: 'WebAssemby' to 'WebAssembly' (#92040) files: M Doc/using/configure.rst diff --git a/Doc/using/configure.rst b/Doc/using/configure.rst index 2321d24663f68..4bf9b84e6b90f 100644 --- a/Doc/using/configure.rst +++ b/Doc/using/configure.rst @@ -143,8 +143,8 @@ General Options .. versionadded:: 3.11 -WebAssemby Options ------------------- +WebAssembly Options +------------------- .. cmdoption:: --with-emscripten-target=[browser|node] From webhook-mailer at python.org Mon May 2 01:29:58 2022 From: webhook-mailer at python.org (serhiy-storchaka) Date: Mon, 02 May 2022 05:29:58 -0000 Subject: [Python-checkins] gh-92114: Improve error message for types with __class_getitem__ = None (GH-92115) Message-ID: https://github.com/python/cpython/commit/4d10f703d79b72a9c7f88862c0b4a9abbfb04ee2 commit: 4d10f703d79b72a9c7f88862c0b4a9abbfb04ee2 branch: main author: Serhiy Storchaka committer: serhiy-storchaka date: 2022-05-02T08:29:49+03:00 summary: gh-92114: Improve error message for types with __class_getitem__ = None (GH-92115) files: A Misc/NEWS.d/next/Core and Builtins/2022-05-01-16-40-07.gh-issue-92114.5xTlLt.rst M Lib/test/test_genericclass.py M Objects/abstract.c diff --git a/Lib/test/test_genericclass.py b/Lib/test/test_genericclass.py index 27420d4f2bad5..d8bb37f69e18a 100644 --- a/Lib/test/test_genericclass.py +++ b/Lib/test/test_genericclass.py @@ -220,6 +220,7 @@ def __class_getitem__(cls): return None with self.assertRaises(TypeError): C_too_few[int] + class C_too_many: def __class_getitem__(cls, one, two): return None @@ -232,16 +233,23 @@ def __class_getitem__(cls, item): return None with self.assertRaises(TypeError): C()[int] + class E: ... e = E() e.__class_getitem__ = lambda cls, item: 'This will not work' with self.assertRaises(TypeError): e[int] + class C_not_callable: __class_getitem__ = "Surprise!" with self.assertRaises(TypeError): C_not_callable[int] + class C_is_none(tuple): + __class_getitem__ = None + with self.assertRaisesRegex(TypeError, "C_is_none"): + C_is_none[int] + def test_class_getitem_metaclass(self): class Meta(type): def __class_getitem__(cls, item): diff --git a/Misc/NEWS.d/next/Core and Builtins/2022-05-01-16-40-07.gh-issue-92114.5xTlLt.rst b/Misc/NEWS.d/next/Core and Builtins/2022-05-01-16-40-07.gh-issue-92114.5xTlLt.rst new file mode 100644 index 0000000000000..a999245953022 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2022-05-01-16-40-07.gh-issue-92114.5xTlLt.rst @@ -0,0 +1,2 @@ +Improve error message when subscript a type with ``__class_getitem__`` set +to ``None``. diff --git a/Objects/abstract.c b/Objects/abstract.c index cfb0edcab0e5d..9034737235681 100644 --- a/Objects/abstract.c +++ b/Objects/abstract.c @@ -185,11 +185,12 @@ PyObject_GetItem(PyObject *o, PyObject *key) if (_PyObject_LookupAttr(o, &_Py_ID(__class_getitem__), &meth) < 0) { return NULL; } - if (meth) { + if (meth && meth != Py_None) { result = PyObject_CallOneArg(meth, key); Py_DECREF(meth); return result; } + Py_XDECREF(meth); PyErr_Format(PyExc_TypeError, "type '%.200s' is not subscriptable", ((PyTypeObject *)o)->tp_name); return NULL; From webhook-mailer at python.org Mon May 2 04:23:46 2022 From: webhook-mailer at python.org (methane) Date: Mon, 02 May 2022 08:23:46 -0000 Subject: [Python-checkins] gh-90822: Make `PY_SSIZE_T_MAX` and `PY_SSIZE_T_MIN` constant expression (GH-92071) Message-ID: https://github.com/python/cpython/commit/d414f7ece8169097a32cd228bb32da0418833db4 commit: d414f7ece8169097a32cd228bb32da0418833db4 branch: main author: Ganesh Kathiresan committer: methane date: 2022-05-02T17:23:28+09:00 summary: gh-90822: Make `PY_SSIZE_T_MAX` and `PY_SSIZE_T_MIN` constant expression (GH-92071) files: M Include/pyport.h M PC/pyconfig.h diff --git a/Include/pyport.h b/Include/pyport.h index 5102f7487d21c..923897305fc6b 100644 --- a/Include/pyport.h +++ b/Include/pyport.h @@ -114,17 +114,23 @@ typedef intptr_t Py_intptr_t; /* Py_ssize_t is a signed integral type such that sizeof(Py_ssize_t) == * sizeof(size_t). C99 doesn't define such a thing directly (size_t is an * unsigned integral type). See PEP 353 for details. + * PY_SSIZE_T_MAX is the largest positive value of type Py_ssize_t. */ #ifdef HAVE_PY_SSIZE_T #elif HAVE_SSIZE_T typedef ssize_t Py_ssize_t; +# define PY_SSIZE_T_MAX SSIZE_MAX #elif SIZEOF_VOID_P == SIZEOF_SIZE_T typedef Py_intptr_t Py_ssize_t; +# define PY_SSIZE_T_MAX INTPTR_MAX #else # error "Python needs a typedef for Py_ssize_t in pyport.h." #endif +/* Smallest negative value of type Py_ssize_t. */ +#define PY_SSIZE_T_MIN (-PY_SSIZE_T_MAX-1) + /* Py_hash_t is the same size as a pointer. */ #define SIZEOF_PY_HASH_T SIZEOF_SIZE_T typedef Py_ssize_t Py_hash_t; @@ -138,11 +144,6 @@ typedef Py_ssize_t Py_ssize_clean_t; /* Largest possible value of size_t. */ #define PY_SIZE_MAX SIZE_MAX -/* Largest positive value of type Py_ssize_t. */ -#define PY_SSIZE_T_MAX ((Py_ssize_t)(((size_t)-1)>>1)) -/* Smallest negative value of type Py_ssize_t. */ -#define PY_SSIZE_T_MIN (-PY_SSIZE_T_MAX-1) - /* Macro kept for backward compatibility: use "z" in new code. * * PY_FORMAT_SIZE_T is a platform-specific modifier for use in a printf diff --git a/PC/pyconfig.h b/PC/pyconfig.h index e8649be568420..5a96a4ebe51ee 100644 --- a/PC/pyconfig.h +++ b/PC/pyconfig.h @@ -162,8 +162,10 @@ WIN32 is still required for the locale module. /* Define like size_t, omitting the "unsigned" */ #ifdef MS_WIN64 typedef __int64 Py_ssize_t; +# define PY_SSIZE_T_MAX LLONG_MAX #else typedef _W64 int Py_ssize_t; +# define PY_SSIZE_T_MAX INT_MAX #endif #define HAVE_PY_SSIZE_T 1 From webhook-mailer at python.org Mon May 2 04:25:10 2022 From: webhook-mailer at python.org (methane) Date: Mon, 02 May 2022 08:25:10 -0000 Subject: [Python-checkins] gh-85679: Recommend `encoding="utf-8"` in tutorial (GH-91778) Message-ID: https://github.com/python/cpython/commit/614420df9796c8a4f01e24052fc0128b4c20c5bf commit: 614420df9796c8a4f01e24052fc0128b4c20c5bf branch: main author: Inada Naoki committer: methane date: 2022-05-02T17:25:05+09:00 summary: gh-85679: Recommend `encoding="utf-8"` in tutorial (GH-91778) files: M Doc/tutorial/inputoutput.rst diff --git a/Doc/tutorial/inputoutput.rst b/Doc/tutorial/inputoutput.rst index 7f83c4d4612eb..b50063654e262 100644 --- a/Doc/tutorial/inputoutput.rst +++ b/Doc/tutorial/inputoutput.rst @@ -279,11 +279,12 @@ Reading and Writing Files object: file :func:`open` returns a :term:`file object`, and is most commonly used with -two arguments: ``open(filename, mode)``. +two positional arguments and one keyword argument: +``open(filename, mode, encoding=None)`` :: - >>> f = open('workfile', 'w') + >>> f = open('workfile', 'w', encoding="utf-8") .. XXX str(f) is @@ -300,11 +301,14 @@ writing. The *mode* argument is optional; ``'r'`` will be assumed if it's omitted. Normally, files are opened in :dfn:`text mode`, that means, you read and write -strings from and to the file, which are encoded in a specific encoding. If -encoding is not specified, the default is platform dependent (see -:func:`open`). ``'b'`` appended to the mode opens the file in -:dfn:`binary mode`: now the data is read and written in the form of bytes -objects. This mode should be used for all files that don't contain text. +strings from and to the file, which are encoded in a specific *encoding*. +If *encoding* is not specified, the default is platform dependent +(see :func:`open`). +Because UTF-8 is the modern de-facto standard, ``encoding="utf-8"`` is +recommended unless you know that you need to use a different encoding. +Appending a ``'b'`` to the mode opens the file in :dfn:`binary mode`. +Binary mode data is read and written as :class:`bytes` objects. +You can not specify *encoding* when opening file in binary mode. In text mode, the default when reading is to convert platform-specific line endings (``\n`` on Unix, ``\r\n`` on Windows) to just ``\n``. When writing in @@ -320,7 +324,7 @@ after its suite finishes, even if an exception is raised at some point. Using :keyword:`!with` is also much shorter than writing equivalent :keyword:`try`\ -\ :keyword:`finally` blocks:: - >>> with open('workfile') as f: + >>> with open('workfile', encoding="utf-8") as f: ... read_data = f.read() >>> # We can check that the file has been automatically closed. @@ -490,11 +494,15 @@ simply serializes the object to a :term:`text file`. So if ``f`` is a json.dump(x, f) -To decode the object again, if ``f`` is a :term:`text file` object which has -been opened for reading:: +To decode the object again, if ``f`` is a :term:`binary file` or +:term:`text file` object which has been opened for reading:: x = json.load(f) +.. note:: + JSON files must be encoded in UTF-8. Use ``encoding="utf-8"`` when opening + JSON file as a :term:`text file` for both of reading and writing. + This simple serialization technique can handle lists and dictionaries, but serializing arbitrary class instances in JSON requires a bit of extra effort. The reference for the :mod:`json` module contains an explanation of this. From webhook-mailer at python.org Mon May 2 04:45:19 2022 From: webhook-mailer at python.org (miss-islington) Date: Mon, 02 May 2022 08:45:19 -0000 Subject: [Python-checkins] gh-85679: Recommend `encoding="utf-8"` in tutorial (GH-91778) Message-ID: https://github.com/python/cpython/commit/a7d3de7fe650d393d63039cb0ed7c1320d050345 commit: a7d3de7fe650d393d63039cb0ed7c1320d050345 branch: 3.10 author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com> committer: miss-islington <31488909+miss-islington at users.noreply.github.com> date: 2022-05-02T01:45:10-07:00 summary: gh-85679: Recommend `encoding="utf-8"` in tutorial (GH-91778) (cherry picked from commit 614420df9796c8a4f01e24052fc0128b4c20c5bf) Co-authored-by: Inada Naoki files: M Doc/tutorial/inputoutput.rst diff --git a/Doc/tutorial/inputoutput.rst b/Doc/tutorial/inputoutput.rst index 7f83c4d4612eb..b50063654e262 100644 --- a/Doc/tutorial/inputoutput.rst +++ b/Doc/tutorial/inputoutput.rst @@ -279,11 +279,12 @@ Reading and Writing Files object: file :func:`open` returns a :term:`file object`, and is most commonly used with -two arguments: ``open(filename, mode)``. +two positional arguments and one keyword argument: +``open(filename, mode, encoding=None)`` :: - >>> f = open('workfile', 'w') + >>> f = open('workfile', 'w', encoding="utf-8") .. XXX str(f) is @@ -300,11 +301,14 @@ writing. The *mode* argument is optional; ``'r'`` will be assumed if it's omitted. Normally, files are opened in :dfn:`text mode`, that means, you read and write -strings from and to the file, which are encoded in a specific encoding. If -encoding is not specified, the default is platform dependent (see -:func:`open`). ``'b'`` appended to the mode opens the file in -:dfn:`binary mode`: now the data is read and written in the form of bytes -objects. This mode should be used for all files that don't contain text. +strings from and to the file, which are encoded in a specific *encoding*. +If *encoding* is not specified, the default is platform dependent +(see :func:`open`). +Because UTF-8 is the modern de-facto standard, ``encoding="utf-8"`` is +recommended unless you know that you need to use a different encoding. +Appending a ``'b'`` to the mode opens the file in :dfn:`binary mode`. +Binary mode data is read and written as :class:`bytes` objects. +You can not specify *encoding* when opening file in binary mode. In text mode, the default when reading is to convert platform-specific line endings (``\n`` on Unix, ``\r\n`` on Windows) to just ``\n``. When writing in @@ -320,7 +324,7 @@ after its suite finishes, even if an exception is raised at some point. Using :keyword:`!with` is also much shorter than writing equivalent :keyword:`try`\ -\ :keyword:`finally` blocks:: - >>> with open('workfile') as f: + >>> with open('workfile', encoding="utf-8") as f: ... read_data = f.read() >>> # We can check that the file has been automatically closed. @@ -490,11 +494,15 @@ simply serializes the object to a :term:`text file`. So if ``f`` is a json.dump(x, f) -To decode the object again, if ``f`` is a :term:`text file` object which has -been opened for reading:: +To decode the object again, if ``f`` is a :term:`binary file` or +:term:`text file` object which has been opened for reading:: x = json.load(f) +.. note:: + JSON files must be encoded in UTF-8. Use ``encoding="utf-8"`` when opening + JSON file as a :term:`text file` for both of reading and writing. + This simple serialization technique can handle lists and dictionaries, but serializing arbitrary class instances in JSON requires a bit of extra effort. The reference for the :mod:`json` module contains an explanation of this. From webhook-mailer at python.org Mon May 2 04:45:50 2022 From: webhook-mailer at python.org (miss-islington) Date: Mon, 02 May 2022 08:45:50 -0000 Subject: [Python-checkins] gh-85679: Recommend `encoding="utf-8"` in tutorial (GH-91778) Message-ID: https://github.com/python/cpython/commit/d05ee916c142d9c9172cc20292285d02d4aaef3c commit: d05ee916c142d9c9172cc20292285d02d4aaef3c branch: 3.9 author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com> committer: miss-islington <31488909+miss-islington at users.noreply.github.com> date: 2022-05-02T01:45:45-07:00 summary: gh-85679: Recommend `encoding="utf-8"` in tutorial (GH-91778) (cherry picked from commit 614420df9796c8a4f01e24052fc0128b4c20c5bf) Co-authored-by: Inada Naoki files: M Doc/tutorial/inputoutput.rst diff --git a/Doc/tutorial/inputoutput.rst b/Doc/tutorial/inputoutput.rst index 7f83c4d4612eb..b50063654e262 100644 --- a/Doc/tutorial/inputoutput.rst +++ b/Doc/tutorial/inputoutput.rst @@ -279,11 +279,12 @@ Reading and Writing Files object: file :func:`open` returns a :term:`file object`, and is most commonly used with -two arguments: ``open(filename, mode)``. +two positional arguments and one keyword argument: +``open(filename, mode, encoding=None)`` :: - >>> f = open('workfile', 'w') + >>> f = open('workfile', 'w', encoding="utf-8") .. XXX str(f) is @@ -300,11 +301,14 @@ writing. The *mode* argument is optional; ``'r'`` will be assumed if it's omitted. Normally, files are opened in :dfn:`text mode`, that means, you read and write -strings from and to the file, which are encoded in a specific encoding. If -encoding is not specified, the default is platform dependent (see -:func:`open`). ``'b'`` appended to the mode opens the file in -:dfn:`binary mode`: now the data is read and written in the form of bytes -objects. This mode should be used for all files that don't contain text. +strings from and to the file, which are encoded in a specific *encoding*. +If *encoding* is not specified, the default is platform dependent +(see :func:`open`). +Because UTF-8 is the modern de-facto standard, ``encoding="utf-8"`` is +recommended unless you know that you need to use a different encoding. +Appending a ``'b'`` to the mode opens the file in :dfn:`binary mode`. +Binary mode data is read and written as :class:`bytes` objects. +You can not specify *encoding* when opening file in binary mode. In text mode, the default when reading is to convert platform-specific line endings (``\n`` on Unix, ``\r\n`` on Windows) to just ``\n``. When writing in @@ -320,7 +324,7 @@ after its suite finishes, even if an exception is raised at some point. Using :keyword:`!with` is also much shorter than writing equivalent :keyword:`try`\ -\ :keyword:`finally` blocks:: - >>> with open('workfile') as f: + >>> with open('workfile', encoding="utf-8") as f: ... read_data = f.read() >>> # We can check that the file has been automatically closed. @@ -490,11 +494,15 @@ simply serializes the object to a :term:`text file`. So if ``f`` is a json.dump(x, f) -To decode the object again, if ``f`` is a :term:`text file` object which has -been opened for reading:: +To decode the object again, if ``f`` is a :term:`binary file` or +:term:`text file` object which has been opened for reading:: x = json.load(f) +.. note:: + JSON files must be encoded in UTF-8. Use ``encoding="utf-8"`` when opening + JSON file as a :term:`text file` for both of reading and writing. + This simple serialization technique can handle lists and dictionaries, but serializing arbitrary class instances in JSON requires a bit of extra effort. The reference for the :mod:`json` module contains an explanation of this. From webhook-mailer at python.org Mon May 2 05:37:57 2022 From: webhook-mailer at python.org (serhiy-storchaka) Date: Mon, 02 May 2022 09:37:57 -0000 Subject: [Python-checkins] bpo-36819: Fix crashes in built-in encoders with weird error handlers (GH-28593) Message-ID: https://github.com/python/cpython/commit/18b07d773e09a2719e69aeaa925d5abb7ba0c068 commit: 18b07d773e09a2719e69aeaa925d5abb7ba0c068 branch: main author: Serhiy Storchaka committer: serhiy-storchaka date: 2022-05-02T12:37:48+03:00 summary: bpo-36819: Fix crashes in built-in encoders with weird error handlers (GH-28593) If the error handler returns position less or equal than the starting position of non-encodable characters, most of built-in encoders didn't properly re-size the output buffer. This led to out-of-bounds writes, and segfaults. files: A Misc/NEWS.d/next/Core and Builtins/2021-09-28-10-58-30.bpo-36819.cyV50C.rst M Lib/test/test_codeccallbacks.py M Objects/stringlib/codecs.h M Objects/unicodeobject.c diff --git a/Lib/test/test_codeccallbacks.py b/Lib/test/test_codeccallbacks.py index 243f002c4ecad..4991330489d13 100644 --- a/Lib/test/test_codeccallbacks.py +++ b/Lib/test/test_codeccallbacks.py @@ -1,5 +1,6 @@ import codecs import html.entities +import itertools import sys import unicodedata import unittest @@ -22,6 +23,18 @@ def handle(self, exc): self.pos = len(exc.object) return ("", oldpos) +class RepeatedPosReturn: + def __init__(self, repl=""): + self.repl = repl + self.pos = 0 + self.count = 0 + + def handle(self, exc): + if self.count > 0: + self.count -= 1 + return (self.repl, self.pos) + return (self.repl, exc.end) + # A UnicodeEncodeError object with a bad start attribute class BadStartUnicodeEncodeError(UnicodeEncodeError): def __init__(self): @@ -783,20 +796,104 @@ def test_lookup(self): codecs.lookup_error("namereplace") ) - def test_unencodablereplacement(self): + def test_encode_nonascii_replacement(self): + def handle(exc): + if isinstance(exc, UnicodeEncodeError): + return (repl, exc.end) + raise TypeError("don't know how to handle %r" % exc) + codecs.register_error("test.replacing", handle) + + for enc, input, repl in ( + ("ascii", "[?]", "abc"), + ("iso-8859-1", "[?]", "??"), + ("iso-8859-15", "[?]", "??"), + ): + res = input.encode(enc, "test.replacing") + self.assertEqual(res, ("[" + repl + "]").encode(enc)) + + for enc, input, repl in ( + ("utf-8", "[\udc80]", "\U0001f40d"), + ("utf-16", "[\udc80]", "\U0001f40d"), + ("utf-32", "[\udc80]", "\U0001f40d"), + ): + with self.subTest(encoding=enc): + with self.assertRaises(UnicodeEncodeError) as cm: + input.encode(enc, "test.replacing") + exc = cm.exception + self.assertEqual(exc.start, 1) + self.assertEqual(exc.end, 2) + self.assertEqual(exc.object, input) + + def test_encode_unencodable_replacement(self): def unencrepl(exc): if isinstance(exc, UnicodeEncodeError): - return ("\u4242", exc.end) + return (repl, exc.end) else: raise TypeError("don't know how to handle %r" % exc) codecs.register_error("test.unencreplhandler", unencrepl) - for enc in ("ascii", "iso-8859-1", "iso-8859-15"): - self.assertRaises( - UnicodeEncodeError, - "\u4242".encode, - enc, - "test.unencreplhandler" - ) + + for enc, input, repl in ( + ("ascii", "[?]", "?"), + ("iso-8859-1", "[?]", "?"), + ("iso-8859-15", "[?]", "?"), + ("utf-8", "[\udc80]", "\udcff"), + ("utf-16", "[\udc80]", "\udcff"), + ("utf-32", "[\udc80]", "\udcff"), + ): + with self.subTest(encoding=enc): + with self.assertRaises(UnicodeEncodeError) as cm: + input.encode(enc, "test.unencreplhandler") + exc = cm.exception + self.assertEqual(exc.start, 1) + self.assertEqual(exc.end, 2) + self.assertEqual(exc.object, input) + + def test_encode_bytes_replacement(self): + def handle(exc): + if isinstance(exc, UnicodeEncodeError): + return (repl, exc.end) + raise TypeError("don't know how to handle %r" % exc) + codecs.register_error("test.replacing", handle) + + # It works even if the bytes sequence is not decodable. + for enc, input, repl in ( + ("ascii", "[?]", b"\xbd\xbe"), + ("iso-8859-1", "[?]", b"\xbd\xbe"), + ("iso-8859-15", "[?]", b"\xbd\xbe"), + ("utf-8", "[\udc80]", b"\xbd\xbe"), + ("utf-16le", "[\udc80]", b"\xbd\xbe"), + ("utf-16be", "[\udc80]", b"\xbd\xbe"), + ("utf-32le", "[\udc80]", b"\xbc\xbd\xbe\xbf"), + ("utf-32be", "[\udc80]", b"\xbc\xbd\xbe\xbf"), + ): + with self.subTest(encoding=enc): + res = input.encode(enc, "test.replacing") + self.assertEqual(res, "[".encode(enc) + repl + "]".encode(enc)) + + def test_encode_odd_bytes_replacement(self): + def handle(exc): + if isinstance(exc, UnicodeEncodeError): + return (repl, exc.end) + raise TypeError("don't know how to handle %r" % exc) + codecs.register_error("test.replacing", handle) + + input = "[\udc80]" + # Tests in which the replacement bytestring contains not whole number + # of code units. + for enc, repl in ( + *itertools.product(("utf-16le", "utf-16be"), + [b"a", b"abc"]), + *itertools.product(("utf-32le", "utf-32be"), + [b"a", b"ab", b"abc", b"abcde"]), + ): + with self.subTest(encoding=enc, repl=repl): + with self.assertRaises(UnicodeEncodeError) as cm: + input.encode(enc, "test.replacing") + exc = cm.exception + self.assertEqual(exc.start, 1) + self.assertEqual(exc.end, 2) + self.assertEqual(exc.object, input) + self.assertEqual(exc.reason, "surrogates not allowed") def test_badregistercall(self): # enhance coverage of: @@ -940,6 +1037,68 @@ def __getitem__(self, key): self.assertRaises(ValueError, codecs.charmap_encode, "\xff", err, D()) self.assertRaises(TypeError, codecs.charmap_encode, "\xff", err, {0xff: 300}) + def test_decodehelper_bug36819(self): + handler = RepeatedPosReturn("x") + codecs.register_error("test.bug36819", handler.handle) + + testcases = [ + ("ascii", b"\xff"), + ("utf-8", b"\xff"), + ("utf-16be", b'\xdc\x80'), + ("utf-32be", b'\x00\x00\xdc\x80'), + ("iso-8859-6", b"\xff"), + ] + for enc, bad in testcases: + input = "abcd".encode(enc) + bad + with self.subTest(encoding=enc): + handler.count = 50 + decoded = input.decode(enc, "test.bug36819") + self.assertEqual(decoded, 'abcdx' * 51) + + def test_encodehelper_bug36819(self): + handler = RepeatedPosReturn() + codecs.register_error("test.bug36819", handler.handle) + + input = "abcd\udc80" + encodings = ["ascii", "latin1", "utf-8", "utf-16", "utf-32"] # built-in + encodings += ["iso-8859-15"] # charmap codec + if sys.platform == 'win32': + encodings = ["mbcs", "oem"] # code page codecs + + handler.repl = "\udcff" + for enc in encodings: + with self.subTest(encoding=enc): + handler.count = 50 + with self.assertRaises(UnicodeEncodeError) as cm: + input.encode(enc, "test.bug36819") + exc = cm.exception + self.assertEqual(exc.start, 4) + self.assertEqual(exc.end, 5) + self.assertEqual(exc.object, input) + if sys.platform == "win32": + handler.count = 50 + with self.assertRaises(UnicodeEncodeError) as cm: + codecs.code_page_encode(437, input, "test.bug36819") + exc = cm.exception + self.assertEqual(exc.start, 4) + self.assertEqual(exc.end, 5) + self.assertEqual(exc.object, input) + + handler.repl = "x" + for enc in encodings: + with self.subTest(encoding=enc): + # The interpreter should segfault after a handful of attempts. + # 50 was chosen to try to ensure a segfault without a fix, + # but not OOM a machine with one. + handler.count = 50 + encoded = input.encode(enc, "test.bug36819") + self.assertEqual(encoded.decode(enc), "abcdx" * 51) + if sys.platform == "win32": + handler.count = 50 + encoded = codecs.code_page_encode(437, input, "test.bug36819") + self.assertEqual(encoded[0].decode(), "abcdx" * 51) + self.assertEqual(encoded[1], len(input)) + def test_translatehelper(self): # enhance coverage of: # Objects/unicodeobject.c::unicode_encode_call_errorhandler() diff --git a/Misc/NEWS.d/next/Core and Builtins/2021-09-28-10-58-30.bpo-36819.cyV50C.rst b/Misc/NEWS.d/next/Core and Builtins/2021-09-28-10-58-30.bpo-36819.cyV50C.rst new file mode 100644 index 0000000000000..32bb55a90e6c4 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2021-09-28-10-58-30.bpo-36819.cyV50C.rst @@ -0,0 +1,2 @@ +Fix crashes in built-in encoders with error handlers that return position +less or equal than the starting position of non-encodable characters. diff --git a/Objects/stringlib/codecs.h b/Objects/stringlib/codecs.h index b17cda18f54b3..958cc86147815 100644 --- a/Objects/stringlib/codecs.h +++ b/Objects/stringlib/codecs.h @@ -387,8 +387,19 @@ STRINGLIB(utf8_encoder)(_PyBytesWriter *writer, if (!rep) goto error; - /* subtract preallocated bytes */ - writer->min_size -= max_char_size * (newpos - startpos); + if (newpos < startpos) { + writer->overallocate = 1; + p = _PyBytesWriter_Prepare(writer, p, + max_char_size * (startpos - newpos)); + if (p == NULL) + goto error; + } + else { + /* subtract preallocated bytes */ + writer->min_size -= max_char_size * (newpos - startpos); + /* Only overallocate the buffer if it's not the last write */ + writer->overallocate = (newpos < size); + } if (PyBytes_Check(rep)) { p = _PyBytesWriter_WriteBytes(writer, p, diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 493307556529b..36a52966c6820 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -5868,7 +5868,7 @@ _PyUnicode_EncodeUTF32(PyObject *str, pos = 0; while (pos < len) { - Py_ssize_t repsize, moreunits; + Py_ssize_t newpos, repsize, moreunits; if (kind == PyUnicode_2BYTE_KIND) { pos += ucs2lib_utf32_encode((const Py_UCS2 *)data + pos, len - pos, @@ -5885,7 +5885,7 @@ _PyUnicode_EncodeUTF32(PyObject *str, rep = unicode_encode_call_errorhandler( errors, &errorHandler, encoding, "surrogates not allowed", - str, &exc, pos, pos + 1, &pos); + str, &exc, pos, pos + 1, &newpos); if (!rep) goto error; @@ -5893,7 +5893,7 @@ _PyUnicode_EncodeUTF32(PyObject *str, repsize = PyBytes_GET_SIZE(rep); if (repsize & 3) { raise_encode_exception(&exc, encoding, - str, pos - 1, pos, + str, pos, pos + 1, "surrogates not allowed"); goto error; } @@ -5906,28 +5906,30 @@ _PyUnicode_EncodeUTF32(PyObject *str, moreunits = repsize = PyUnicode_GET_LENGTH(rep); if (!PyUnicode_IS_ASCII(rep)) { raise_encode_exception(&exc, encoding, - str, pos - 1, pos, + str, pos, pos + 1, "surrogates not allowed"); goto error; } } + moreunits += pos - newpos; + pos = newpos; /* four bytes are reserved for each surrogate */ - if (moreunits > 1) { + if (moreunits > 0) { Py_ssize_t outpos = out - (uint32_t*) PyBytes_AS_STRING(v); if (moreunits >= (PY_SSIZE_T_MAX - PyBytes_GET_SIZE(v)) / 4) { /* integer overflow */ PyErr_NoMemory(); goto error; } - if (_PyBytes_Resize(&v, PyBytes_GET_SIZE(v) + 4 * (moreunits - 1)) < 0) + if (_PyBytes_Resize(&v, PyBytes_GET_SIZE(v) + 4 * moreunits) < 0) goto error; out = (uint32_t*) PyBytes_AS_STRING(v) + outpos; } if (PyBytes_Check(rep)) { memcpy(out, PyBytes_AS_STRING(rep), repsize); - out += moreunits; + out += repsize / 4; } else /* rep is unicode */ { assert(PyUnicode_KIND(rep) == PyUnicode_1BYTE_KIND); ucs1lib_utf32_encode(PyUnicode_1BYTE_DATA(rep), repsize, @@ -6205,7 +6207,7 @@ _PyUnicode_EncodeUTF16(PyObject *str, pos = 0; while (pos < len) { - Py_ssize_t repsize, moreunits; + Py_ssize_t newpos, repsize, moreunits; if (kind == PyUnicode_2BYTE_KIND) { pos += ucs2lib_utf16_encode((const Py_UCS2 *)data + pos, len - pos, @@ -6222,7 +6224,7 @@ _PyUnicode_EncodeUTF16(PyObject *str, rep = unicode_encode_call_errorhandler( errors, &errorHandler, encoding, "surrogates not allowed", - str, &exc, pos, pos + 1, &pos); + str, &exc, pos, pos + 1, &newpos); if (!rep) goto error; @@ -6230,7 +6232,7 @@ _PyUnicode_EncodeUTF16(PyObject *str, repsize = PyBytes_GET_SIZE(rep); if (repsize & 1) { raise_encode_exception(&exc, encoding, - str, pos - 1, pos, + str, pos, pos + 1, "surrogates not allowed"); goto error; } @@ -6243,28 +6245,30 @@ _PyUnicode_EncodeUTF16(PyObject *str, moreunits = repsize = PyUnicode_GET_LENGTH(rep); if (!PyUnicode_IS_ASCII(rep)) { raise_encode_exception(&exc, encoding, - str, pos - 1, pos, + str, pos, pos + 1, "surrogates not allowed"); goto error; } } + moreunits += pos - newpos; + pos = newpos; /* two bytes are reserved for each surrogate */ - if (moreunits > 1) { + if (moreunits > 0) { Py_ssize_t outpos = out - (unsigned short*) PyBytes_AS_STRING(v); if (moreunits >= (PY_SSIZE_T_MAX - PyBytes_GET_SIZE(v)) / 2) { /* integer overflow */ PyErr_NoMemory(); goto error; } - if (_PyBytes_Resize(&v, PyBytes_GET_SIZE(v) + 2 * (moreunits - 1)) < 0) + if (_PyBytes_Resize(&v, PyBytes_GET_SIZE(v) + 2 * moreunits) < 0) goto error; out = (unsigned short*) PyBytes_AS_STRING(v) + outpos; } if (PyBytes_Check(rep)) { memcpy(out, PyBytes_AS_STRING(rep), repsize); - out += moreunits; + out += repsize / 2; } else /* rep is unicode */ { assert(PyUnicode_KIND(rep) == PyUnicode_1BYTE_KIND); ucs1lib_utf16_encode(PyUnicode_1BYTE_DATA(rep), repsize, @@ -7167,8 +7171,19 @@ unicode_encode_ucs1(PyObject *unicode, if (rep == NULL) goto onError; - /* subtract preallocated bytes */ - writer.min_size -= newpos - collstart; + if (newpos < collstart) { + writer.overallocate = 1; + str = _PyBytesWriter_Prepare(&writer, str, + collstart - newpos); + if (str == NULL) + goto onError; + } + else { + /* subtract preallocated bytes */ + writer.min_size -= newpos - collstart; + /* Only overallocate the buffer if it's not the last write */ + writer.overallocate = (newpos < size); + } if (PyBytes_Check(rep)) { /* Directly copy bytes result to output. */ @@ -7944,13 +7959,14 @@ encode_code_page_errors(UINT code_page, PyObject **outbytes, pos, pos + 1, &newpos); if (rep == NULL) goto error; - pos = newpos; + Py_ssize_t morebytes = pos - newpos; if (PyBytes_Check(rep)) { outsize = PyBytes_GET_SIZE(rep); - if (outsize != 1) { + morebytes += outsize; + if (morebytes > 0) { Py_ssize_t offset = out - PyBytes_AS_STRING(*outbytes); - newoutsize = PyBytes_GET_SIZE(*outbytes) + (outsize - 1); + newoutsize = PyBytes_GET_SIZE(*outbytes) + morebytes; if (_PyBytes_Resize(outbytes, newoutsize) < 0) { Py_DECREF(rep); goto error; @@ -7971,9 +7987,10 @@ encode_code_page_errors(UINT code_page, PyObject **outbytes, } outsize = PyUnicode_GET_LENGTH(rep); - if (outsize != 1) { + morebytes += outsize; + if (morebytes > 0) { Py_ssize_t offset = out - PyBytes_AS_STRING(*outbytes); - newoutsize = PyBytes_GET_SIZE(*outbytes) + (outsize - 1); + newoutsize = PyBytes_GET_SIZE(*outbytes) + morebytes; if (_PyBytes_Resize(outbytes, newoutsize) < 0) { Py_DECREF(rep); goto error; @@ -7996,6 +8013,7 @@ encode_code_page_errors(UINT code_page, PyObject **outbytes, out++; } } + pos = newpos; Py_DECREF(rep); } /* write a NUL byte */ From webhook-mailer at python.org Mon May 2 05:59:03 2022 From: webhook-mailer at python.org (miss-islington) Date: Mon, 02 May 2022 09:59:03 -0000 Subject: [Python-checkins] bpo-36819: Fix crashes in built-in encoders with weird error handlers (GH-28593) Message-ID: https://github.com/python/cpython/commit/d985c8e2e0d38e6905cc27124008eb926254247b commit: d985c8e2e0d38e6905cc27124008eb926254247b branch: 3.10 author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com> committer: miss-islington <31488909+miss-islington at users.noreply.github.com> date: 2022-05-02T02:58:41-07:00 summary: bpo-36819: Fix crashes in built-in encoders with weird error handlers (GH-28593) If the error handler returns position less or equal than the starting position of non-encodable characters, most of built-in encoders didn't properly re-size the output buffer. This led to out-of-bounds writes, and segfaults. (cherry picked from commit 18b07d773e09a2719e69aeaa925d5abb7ba0c068) Co-authored-by: Serhiy Storchaka files: A Misc/NEWS.d/next/Core and Builtins/2021-09-28-10-58-30.bpo-36819.cyV50C.rst M Lib/test/test_codeccallbacks.py M Objects/stringlib/codecs.h M Objects/unicodeobject.c diff --git a/Lib/test/test_codeccallbacks.py b/Lib/test/test_codeccallbacks.py index 243f002c4ecad..4991330489d13 100644 --- a/Lib/test/test_codeccallbacks.py +++ b/Lib/test/test_codeccallbacks.py @@ -1,5 +1,6 @@ import codecs import html.entities +import itertools import sys import unicodedata import unittest @@ -22,6 +23,18 @@ def handle(self, exc): self.pos = len(exc.object) return ("", oldpos) +class RepeatedPosReturn: + def __init__(self, repl=""): + self.repl = repl + self.pos = 0 + self.count = 0 + + def handle(self, exc): + if self.count > 0: + self.count -= 1 + return (self.repl, self.pos) + return (self.repl, exc.end) + # A UnicodeEncodeError object with a bad start attribute class BadStartUnicodeEncodeError(UnicodeEncodeError): def __init__(self): @@ -783,20 +796,104 @@ def test_lookup(self): codecs.lookup_error("namereplace") ) - def test_unencodablereplacement(self): + def test_encode_nonascii_replacement(self): + def handle(exc): + if isinstance(exc, UnicodeEncodeError): + return (repl, exc.end) + raise TypeError("don't know how to handle %r" % exc) + codecs.register_error("test.replacing", handle) + + for enc, input, repl in ( + ("ascii", "[?]", "abc"), + ("iso-8859-1", "[?]", "??"), + ("iso-8859-15", "[?]", "??"), + ): + res = input.encode(enc, "test.replacing") + self.assertEqual(res, ("[" + repl + "]").encode(enc)) + + for enc, input, repl in ( + ("utf-8", "[\udc80]", "\U0001f40d"), + ("utf-16", "[\udc80]", "\U0001f40d"), + ("utf-32", "[\udc80]", "\U0001f40d"), + ): + with self.subTest(encoding=enc): + with self.assertRaises(UnicodeEncodeError) as cm: + input.encode(enc, "test.replacing") + exc = cm.exception + self.assertEqual(exc.start, 1) + self.assertEqual(exc.end, 2) + self.assertEqual(exc.object, input) + + def test_encode_unencodable_replacement(self): def unencrepl(exc): if isinstance(exc, UnicodeEncodeError): - return ("\u4242", exc.end) + return (repl, exc.end) else: raise TypeError("don't know how to handle %r" % exc) codecs.register_error("test.unencreplhandler", unencrepl) - for enc in ("ascii", "iso-8859-1", "iso-8859-15"): - self.assertRaises( - UnicodeEncodeError, - "\u4242".encode, - enc, - "test.unencreplhandler" - ) + + for enc, input, repl in ( + ("ascii", "[?]", "?"), + ("iso-8859-1", "[?]", "?"), + ("iso-8859-15", "[?]", "?"), + ("utf-8", "[\udc80]", "\udcff"), + ("utf-16", "[\udc80]", "\udcff"), + ("utf-32", "[\udc80]", "\udcff"), + ): + with self.subTest(encoding=enc): + with self.assertRaises(UnicodeEncodeError) as cm: + input.encode(enc, "test.unencreplhandler") + exc = cm.exception + self.assertEqual(exc.start, 1) + self.assertEqual(exc.end, 2) + self.assertEqual(exc.object, input) + + def test_encode_bytes_replacement(self): + def handle(exc): + if isinstance(exc, UnicodeEncodeError): + return (repl, exc.end) + raise TypeError("don't know how to handle %r" % exc) + codecs.register_error("test.replacing", handle) + + # It works even if the bytes sequence is not decodable. + for enc, input, repl in ( + ("ascii", "[?]", b"\xbd\xbe"), + ("iso-8859-1", "[?]", b"\xbd\xbe"), + ("iso-8859-15", "[?]", b"\xbd\xbe"), + ("utf-8", "[\udc80]", b"\xbd\xbe"), + ("utf-16le", "[\udc80]", b"\xbd\xbe"), + ("utf-16be", "[\udc80]", b"\xbd\xbe"), + ("utf-32le", "[\udc80]", b"\xbc\xbd\xbe\xbf"), + ("utf-32be", "[\udc80]", b"\xbc\xbd\xbe\xbf"), + ): + with self.subTest(encoding=enc): + res = input.encode(enc, "test.replacing") + self.assertEqual(res, "[".encode(enc) + repl + "]".encode(enc)) + + def test_encode_odd_bytes_replacement(self): + def handle(exc): + if isinstance(exc, UnicodeEncodeError): + return (repl, exc.end) + raise TypeError("don't know how to handle %r" % exc) + codecs.register_error("test.replacing", handle) + + input = "[\udc80]" + # Tests in which the replacement bytestring contains not whole number + # of code units. + for enc, repl in ( + *itertools.product(("utf-16le", "utf-16be"), + [b"a", b"abc"]), + *itertools.product(("utf-32le", "utf-32be"), + [b"a", b"ab", b"abc", b"abcde"]), + ): + with self.subTest(encoding=enc, repl=repl): + with self.assertRaises(UnicodeEncodeError) as cm: + input.encode(enc, "test.replacing") + exc = cm.exception + self.assertEqual(exc.start, 1) + self.assertEqual(exc.end, 2) + self.assertEqual(exc.object, input) + self.assertEqual(exc.reason, "surrogates not allowed") def test_badregistercall(self): # enhance coverage of: @@ -940,6 +1037,68 @@ def __getitem__(self, key): self.assertRaises(ValueError, codecs.charmap_encode, "\xff", err, D()) self.assertRaises(TypeError, codecs.charmap_encode, "\xff", err, {0xff: 300}) + def test_decodehelper_bug36819(self): + handler = RepeatedPosReturn("x") + codecs.register_error("test.bug36819", handler.handle) + + testcases = [ + ("ascii", b"\xff"), + ("utf-8", b"\xff"), + ("utf-16be", b'\xdc\x80'), + ("utf-32be", b'\x00\x00\xdc\x80'), + ("iso-8859-6", b"\xff"), + ] + for enc, bad in testcases: + input = "abcd".encode(enc) + bad + with self.subTest(encoding=enc): + handler.count = 50 + decoded = input.decode(enc, "test.bug36819") + self.assertEqual(decoded, 'abcdx' * 51) + + def test_encodehelper_bug36819(self): + handler = RepeatedPosReturn() + codecs.register_error("test.bug36819", handler.handle) + + input = "abcd\udc80" + encodings = ["ascii", "latin1", "utf-8", "utf-16", "utf-32"] # built-in + encodings += ["iso-8859-15"] # charmap codec + if sys.platform == 'win32': + encodings = ["mbcs", "oem"] # code page codecs + + handler.repl = "\udcff" + for enc in encodings: + with self.subTest(encoding=enc): + handler.count = 50 + with self.assertRaises(UnicodeEncodeError) as cm: + input.encode(enc, "test.bug36819") + exc = cm.exception + self.assertEqual(exc.start, 4) + self.assertEqual(exc.end, 5) + self.assertEqual(exc.object, input) + if sys.platform == "win32": + handler.count = 50 + with self.assertRaises(UnicodeEncodeError) as cm: + codecs.code_page_encode(437, input, "test.bug36819") + exc = cm.exception + self.assertEqual(exc.start, 4) + self.assertEqual(exc.end, 5) + self.assertEqual(exc.object, input) + + handler.repl = "x" + for enc in encodings: + with self.subTest(encoding=enc): + # The interpreter should segfault after a handful of attempts. + # 50 was chosen to try to ensure a segfault without a fix, + # but not OOM a machine with one. + handler.count = 50 + encoded = input.encode(enc, "test.bug36819") + self.assertEqual(encoded.decode(enc), "abcdx" * 51) + if sys.platform == "win32": + handler.count = 50 + encoded = codecs.code_page_encode(437, input, "test.bug36819") + self.assertEqual(encoded[0].decode(), "abcdx" * 51) + self.assertEqual(encoded[1], len(input)) + def test_translatehelper(self): # enhance coverage of: # Objects/unicodeobject.c::unicode_encode_call_errorhandler() diff --git a/Misc/NEWS.d/next/Core and Builtins/2021-09-28-10-58-30.bpo-36819.cyV50C.rst b/Misc/NEWS.d/next/Core and Builtins/2021-09-28-10-58-30.bpo-36819.cyV50C.rst new file mode 100644 index 0000000000000..32bb55a90e6c4 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2021-09-28-10-58-30.bpo-36819.cyV50C.rst @@ -0,0 +1,2 @@ +Fix crashes in built-in encoders with error handlers that return position +less or equal than the starting position of non-encodable characters. diff --git a/Objects/stringlib/codecs.h b/Objects/stringlib/codecs.h index b17cda18f54b3..958cc86147815 100644 --- a/Objects/stringlib/codecs.h +++ b/Objects/stringlib/codecs.h @@ -387,8 +387,19 @@ STRINGLIB(utf8_encoder)(_PyBytesWriter *writer, if (!rep) goto error; - /* subtract preallocated bytes */ - writer->min_size -= max_char_size * (newpos - startpos); + if (newpos < startpos) { + writer->overallocate = 1; + p = _PyBytesWriter_Prepare(writer, p, + max_char_size * (startpos - newpos)); + if (p == NULL) + goto error; + } + else { + /* subtract preallocated bytes */ + writer->min_size -= max_char_size * (newpos - startpos); + /* Only overallocate the buffer if it's not the last write */ + writer->overallocate = (newpos < size); + } if (PyBytes_Check(rep)) { p = _PyBytesWriter_WriteBytes(writer, p, diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 5ddde5054428a..b7ec1f28d7e86 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -5959,7 +5959,7 @@ _PyUnicode_EncodeUTF32(PyObject *str, pos = 0; while (pos < len) { - Py_ssize_t repsize, moreunits; + Py_ssize_t newpos, repsize, moreunits; if (kind == PyUnicode_2BYTE_KIND) { pos += ucs2lib_utf32_encode((const Py_UCS2 *)data + pos, len - pos, @@ -5976,7 +5976,7 @@ _PyUnicode_EncodeUTF32(PyObject *str, rep = unicode_encode_call_errorhandler( errors, &errorHandler, encoding, "surrogates not allowed", - str, &exc, pos, pos + 1, &pos); + str, &exc, pos, pos + 1, &newpos); if (!rep) goto error; @@ -5984,7 +5984,7 @@ _PyUnicode_EncodeUTF32(PyObject *str, repsize = PyBytes_GET_SIZE(rep); if (repsize & 3) { raise_encode_exception(&exc, encoding, - str, pos - 1, pos, + str, pos, pos + 1, "surrogates not allowed"); goto error; } @@ -5997,28 +5997,30 @@ _PyUnicode_EncodeUTF32(PyObject *str, moreunits = repsize = PyUnicode_GET_LENGTH(rep); if (!PyUnicode_IS_ASCII(rep)) { raise_encode_exception(&exc, encoding, - str, pos - 1, pos, + str, pos, pos + 1, "surrogates not allowed"); goto error; } } + moreunits += pos - newpos; + pos = newpos; /* four bytes are reserved for each surrogate */ - if (moreunits > 1) { + if (moreunits > 0) { Py_ssize_t outpos = out - (uint32_t*) PyBytes_AS_STRING(v); if (moreunits >= (PY_SSIZE_T_MAX - PyBytes_GET_SIZE(v)) / 4) { /* integer overflow */ PyErr_NoMemory(); goto error; } - if (_PyBytes_Resize(&v, PyBytes_GET_SIZE(v) + 4 * (moreunits - 1)) < 0) + if (_PyBytes_Resize(&v, PyBytes_GET_SIZE(v) + 4 * moreunits) < 0) goto error; out = (uint32_t*) PyBytes_AS_STRING(v) + outpos; } if (PyBytes_Check(rep)) { memcpy(out, PyBytes_AS_STRING(rep), repsize); - out += moreunits; + out += repsize / 4; } else /* rep is unicode */ { assert(PyUnicode_KIND(rep) == PyUnicode_1BYTE_KIND); ucs1lib_utf32_encode(PyUnicode_1BYTE_DATA(rep), repsize, @@ -6311,7 +6313,7 @@ _PyUnicode_EncodeUTF16(PyObject *str, pos = 0; while (pos < len) { - Py_ssize_t repsize, moreunits; + Py_ssize_t newpos, repsize, moreunits; if (kind == PyUnicode_2BYTE_KIND) { pos += ucs2lib_utf16_encode((const Py_UCS2 *)data + pos, len - pos, @@ -6328,7 +6330,7 @@ _PyUnicode_EncodeUTF16(PyObject *str, rep = unicode_encode_call_errorhandler( errors, &errorHandler, encoding, "surrogates not allowed", - str, &exc, pos, pos + 1, &pos); + str, &exc, pos, pos + 1, &newpos); if (!rep) goto error; @@ -6336,7 +6338,7 @@ _PyUnicode_EncodeUTF16(PyObject *str, repsize = PyBytes_GET_SIZE(rep); if (repsize & 1) { raise_encode_exception(&exc, encoding, - str, pos - 1, pos, + str, pos, pos + 1, "surrogates not allowed"); goto error; } @@ -6349,28 +6351,30 @@ _PyUnicode_EncodeUTF16(PyObject *str, moreunits = repsize = PyUnicode_GET_LENGTH(rep); if (!PyUnicode_IS_ASCII(rep)) { raise_encode_exception(&exc, encoding, - str, pos - 1, pos, + str, pos, pos + 1, "surrogates not allowed"); goto error; } } + moreunits += pos - newpos; + pos = newpos; /* two bytes are reserved for each surrogate */ - if (moreunits > 1) { + if (moreunits > 0) { Py_ssize_t outpos = out - (unsigned short*) PyBytes_AS_STRING(v); if (moreunits >= (PY_SSIZE_T_MAX - PyBytes_GET_SIZE(v)) / 2) { /* integer overflow */ PyErr_NoMemory(); goto error; } - if (_PyBytes_Resize(&v, PyBytes_GET_SIZE(v) + 2 * (moreunits - 1)) < 0) + if (_PyBytes_Resize(&v, PyBytes_GET_SIZE(v) + 2 * moreunits) < 0) goto error; out = (unsigned short*) PyBytes_AS_STRING(v) + outpos; } if (PyBytes_Check(rep)) { memcpy(out, PyBytes_AS_STRING(rep), repsize); - out += moreunits; + out += repsize / 2; } else /* rep is unicode */ { assert(PyUnicode_KIND(rep) == PyUnicode_1BYTE_KIND); ucs1lib_utf16_encode(PyUnicode_1BYTE_DATA(rep), repsize, @@ -7297,8 +7301,19 @@ unicode_encode_ucs1(PyObject *unicode, if (rep == NULL) goto onError; - /* subtract preallocated bytes */ - writer.min_size -= newpos - collstart; + if (newpos < collstart) { + writer.overallocate = 1; + str = _PyBytesWriter_Prepare(&writer, str, + collstart - newpos); + if (str == NULL) + goto onError; + } + else { + /* subtract preallocated bytes */ + writer.min_size -= newpos - collstart; + /* Only overallocate the buffer if it's not the last write */ + writer.overallocate = (newpos < size); + } if (PyBytes_Check(rep)) { /* Directly copy bytes result to output. */ @@ -8104,13 +8119,14 @@ encode_code_page_errors(UINT code_page, PyObject **outbytes, pos, pos + 1, &newpos); if (rep == NULL) goto error; - pos = newpos; + Py_ssize_t morebytes = pos - newpos; if (PyBytes_Check(rep)) { outsize = PyBytes_GET_SIZE(rep); - if (outsize != 1) { + morebytes += outsize; + if (morebytes > 0) { Py_ssize_t offset = out - PyBytes_AS_STRING(*outbytes); - newoutsize = PyBytes_GET_SIZE(*outbytes) + (outsize - 1); + newoutsize = PyBytes_GET_SIZE(*outbytes) + morebytes; if (_PyBytes_Resize(outbytes, newoutsize) < 0) { Py_DECREF(rep); goto error; @@ -8131,9 +8147,10 @@ encode_code_page_errors(UINT code_page, PyObject **outbytes, } outsize = PyUnicode_GET_LENGTH(rep); - if (outsize != 1) { + morebytes += outsize; + if (morebytes > 0) { Py_ssize_t offset = out - PyBytes_AS_STRING(*outbytes); - newoutsize = PyBytes_GET_SIZE(*outbytes) + (outsize - 1); + newoutsize = PyBytes_GET_SIZE(*outbytes) + morebytes; if (_PyBytes_Resize(outbytes, newoutsize) < 0) { Py_DECREF(rep); goto error; @@ -8156,6 +8173,7 @@ encode_code_page_errors(UINT code_page, PyObject **outbytes, out++; } } + pos = newpos; Py_DECREF(rep); } /* write a NUL byte */ From webhook-mailer at python.org Mon May 2 05:59:44 2022 From: webhook-mailer at python.org (miss-islington) Date: Mon, 02 May 2022 09:59:44 -0000 Subject: [Python-checkins] bpo-36819: Fix crashes in built-in encoders with weird error handlers (GH-28593) Message-ID: https://github.com/python/cpython/commit/206f416bd07ca3bc9c8bafd124c943d4d0293039 commit: 206f416bd07ca3bc9c8bafd124c943d4d0293039 branch: 3.9 author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com> committer: miss-islington <31488909+miss-islington at users.noreply.github.com> date: 2022-05-02T02:59:40-07:00 summary: bpo-36819: Fix crashes in built-in encoders with weird error handlers (GH-28593) If the error handler returns position less or equal than the starting position of non-encodable characters, most of built-in encoders didn't properly re-size the output buffer. This led to out-of-bounds writes, and segfaults. (cherry picked from commit 18b07d773e09a2719e69aeaa925d5abb7ba0c068) Co-authored-by: Serhiy Storchaka files: A Misc/NEWS.d/next/Core and Builtins/2021-09-28-10-58-30.bpo-36819.cyV50C.rst M Lib/test/test_codeccallbacks.py M Objects/stringlib/codecs.h M Objects/unicodeobject.c diff --git a/Lib/test/test_codeccallbacks.py b/Lib/test/test_codeccallbacks.py index 243f002c4ecad..4991330489d13 100644 --- a/Lib/test/test_codeccallbacks.py +++ b/Lib/test/test_codeccallbacks.py @@ -1,5 +1,6 @@ import codecs import html.entities +import itertools import sys import unicodedata import unittest @@ -22,6 +23,18 @@ def handle(self, exc): self.pos = len(exc.object) return ("", oldpos) +class RepeatedPosReturn: + def __init__(self, repl=""): + self.repl = repl + self.pos = 0 + self.count = 0 + + def handle(self, exc): + if self.count > 0: + self.count -= 1 + return (self.repl, self.pos) + return (self.repl, exc.end) + # A UnicodeEncodeError object with a bad start attribute class BadStartUnicodeEncodeError(UnicodeEncodeError): def __init__(self): @@ -783,20 +796,104 @@ def test_lookup(self): codecs.lookup_error("namereplace") ) - def test_unencodablereplacement(self): + def test_encode_nonascii_replacement(self): + def handle(exc): + if isinstance(exc, UnicodeEncodeError): + return (repl, exc.end) + raise TypeError("don't know how to handle %r" % exc) + codecs.register_error("test.replacing", handle) + + for enc, input, repl in ( + ("ascii", "[?]", "abc"), + ("iso-8859-1", "[?]", "??"), + ("iso-8859-15", "[?]", "??"), + ): + res = input.encode(enc, "test.replacing") + self.assertEqual(res, ("[" + repl + "]").encode(enc)) + + for enc, input, repl in ( + ("utf-8", "[\udc80]", "\U0001f40d"), + ("utf-16", "[\udc80]", "\U0001f40d"), + ("utf-32", "[\udc80]", "\U0001f40d"), + ): + with self.subTest(encoding=enc): + with self.assertRaises(UnicodeEncodeError) as cm: + input.encode(enc, "test.replacing") + exc = cm.exception + self.assertEqual(exc.start, 1) + self.assertEqual(exc.end, 2) + self.assertEqual(exc.object, input) + + def test_encode_unencodable_replacement(self): def unencrepl(exc): if isinstance(exc, UnicodeEncodeError): - return ("\u4242", exc.end) + return (repl, exc.end) else: raise TypeError("don't know how to handle %r" % exc) codecs.register_error("test.unencreplhandler", unencrepl) - for enc in ("ascii", "iso-8859-1", "iso-8859-15"): - self.assertRaises( - UnicodeEncodeError, - "\u4242".encode, - enc, - "test.unencreplhandler" - ) + + for enc, input, repl in ( + ("ascii", "[?]", "?"), + ("iso-8859-1", "[?]", "?"), + ("iso-8859-15", "[?]", "?"), + ("utf-8", "[\udc80]", "\udcff"), + ("utf-16", "[\udc80]", "\udcff"), + ("utf-32", "[\udc80]", "\udcff"), + ): + with self.subTest(encoding=enc): + with self.assertRaises(UnicodeEncodeError) as cm: + input.encode(enc, "test.unencreplhandler") + exc = cm.exception + self.assertEqual(exc.start, 1) + self.assertEqual(exc.end, 2) + self.assertEqual(exc.object, input) + + def test_encode_bytes_replacement(self): + def handle(exc): + if isinstance(exc, UnicodeEncodeError): + return (repl, exc.end) + raise TypeError("don't know how to handle %r" % exc) + codecs.register_error("test.replacing", handle) + + # It works even if the bytes sequence is not decodable. + for enc, input, repl in ( + ("ascii", "[?]", b"\xbd\xbe"), + ("iso-8859-1", "[?]", b"\xbd\xbe"), + ("iso-8859-15", "[?]", b"\xbd\xbe"), + ("utf-8", "[\udc80]", b"\xbd\xbe"), + ("utf-16le", "[\udc80]", b"\xbd\xbe"), + ("utf-16be", "[\udc80]", b"\xbd\xbe"), + ("utf-32le", "[\udc80]", b"\xbc\xbd\xbe\xbf"), + ("utf-32be", "[\udc80]", b"\xbc\xbd\xbe\xbf"), + ): + with self.subTest(encoding=enc): + res = input.encode(enc, "test.replacing") + self.assertEqual(res, "[".encode(enc) + repl + "]".encode(enc)) + + def test_encode_odd_bytes_replacement(self): + def handle(exc): + if isinstance(exc, UnicodeEncodeError): + return (repl, exc.end) + raise TypeError("don't know how to handle %r" % exc) + codecs.register_error("test.replacing", handle) + + input = "[\udc80]" + # Tests in which the replacement bytestring contains not whole number + # of code units. + for enc, repl in ( + *itertools.product(("utf-16le", "utf-16be"), + [b"a", b"abc"]), + *itertools.product(("utf-32le", "utf-32be"), + [b"a", b"ab", b"abc", b"abcde"]), + ): + with self.subTest(encoding=enc, repl=repl): + with self.assertRaises(UnicodeEncodeError) as cm: + input.encode(enc, "test.replacing") + exc = cm.exception + self.assertEqual(exc.start, 1) + self.assertEqual(exc.end, 2) + self.assertEqual(exc.object, input) + self.assertEqual(exc.reason, "surrogates not allowed") def test_badregistercall(self): # enhance coverage of: @@ -940,6 +1037,68 @@ def __getitem__(self, key): self.assertRaises(ValueError, codecs.charmap_encode, "\xff", err, D()) self.assertRaises(TypeError, codecs.charmap_encode, "\xff", err, {0xff: 300}) + def test_decodehelper_bug36819(self): + handler = RepeatedPosReturn("x") + codecs.register_error("test.bug36819", handler.handle) + + testcases = [ + ("ascii", b"\xff"), + ("utf-8", b"\xff"), + ("utf-16be", b'\xdc\x80'), + ("utf-32be", b'\x00\x00\xdc\x80'), + ("iso-8859-6", b"\xff"), + ] + for enc, bad in testcases: + input = "abcd".encode(enc) + bad + with self.subTest(encoding=enc): + handler.count = 50 + decoded = input.decode(enc, "test.bug36819") + self.assertEqual(decoded, 'abcdx' * 51) + + def test_encodehelper_bug36819(self): + handler = RepeatedPosReturn() + codecs.register_error("test.bug36819", handler.handle) + + input = "abcd\udc80" + encodings = ["ascii", "latin1", "utf-8", "utf-16", "utf-32"] # built-in + encodings += ["iso-8859-15"] # charmap codec + if sys.platform == 'win32': + encodings = ["mbcs", "oem"] # code page codecs + + handler.repl = "\udcff" + for enc in encodings: + with self.subTest(encoding=enc): + handler.count = 50 + with self.assertRaises(UnicodeEncodeError) as cm: + input.encode(enc, "test.bug36819") + exc = cm.exception + self.assertEqual(exc.start, 4) + self.assertEqual(exc.end, 5) + self.assertEqual(exc.object, input) + if sys.platform == "win32": + handler.count = 50 + with self.assertRaises(UnicodeEncodeError) as cm: + codecs.code_page_encode(437, input, "test.bug36819") + exc = cm.exception + self.assertEqual(exc.start, 4) + self.assertEqual(exc.end, 5) + self.assertEqual(exc.object, input) + + handler.repl = "x" + for enc in encodings: + with self.subTest(encoding=enc): + # The interpreter should segfault after a handful of attempts. + # 50 was chosen to try to ensure a segfault without a fix, + # but not OOM a machine with one. + handler.count = 50 + encoded = input.encode(enc, "test.bug36819") + self.assertEqual(encoded.decode(enc), "abcdx" * 51) + if sys.platform == "win32": + handler.count = 50 + encoded = codecs.code_page_encode(437, input, "test.bug36819") + self.assertEqual(encoded[0].decode(), "abcdx" * 51) + self.assertEqual(encoded[1], len(input)) + def test_translatehelper(self): # enhance coverage of: # Objects/unicodeobject.c::unicode_encode_call_errorhandler() diff --git a/Misc/NEWS.d/next/Core and Builtins/2021-09-28-10-58-30.bpo-36819.cyV50C.rst b/Misc/NEWS.d/next/Core and Builtins/2021-09-28-10-58-30.bpo-36819.cyV50C.rst new file mode 100644 index 0000000000000..32bb55a90e6c4 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2021-09-28-10-58-30.bpo-36819.cyV50C.rst @@ -0,0 +1,2 @@ +Fix crashes in built-in encoders with error handlers that return position +less or equal than the starting position of non-encodable characters. diff --git a/Objects/stringlib/codecs.h b/Objects/stringlib/codecs.h index 9b2a29ba3b8c2..c8da7d57cdcc1 100644 --- a/Objects/stringlib/codecs.h +++ b/Objects/stringlib/codecs.h @@ -388,8 +388,19 @@ STRINGLIB(utf8_encoder)(_PyBytesWriter *writer, if (!rep) goto error; - /* subtract preallocated bytes */ - writer->min_size -= max_char_size * (newpos - startpos); + if (newpos < startpos) { + writer->overallocate = 1; + p = _PyBytesWriter_Prepare(writer, p, + max_char_size * (startpos - newpos)); + if (p == NULL) + goto error; + } + else { + /* subtract preallocated bytes */ + writer->min_size -= max_char_size * (newpos - startpos); + /* Only overallocate the buffer if it's not the last write */ + writer->overallocate = (newpos < size); + } if (PyBytes_Check(rep)) { p = _PyBytesWriter_WriteBytes(writer, p, diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 369f91342e3ac..e5e9ba20301c0 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -5805,7 +5805,7 @@ _PyUnicode_EncodeUTF32(PyObject *str, pos = 0; while (pos < len) { - Py_ssize_t repsize, moreunits; + Py_ssize_t newpos, repsize, moreunits; if (kind == PyUnicode_2BYTE_KIND) { pos += ucs2lib_utf32_encode((const Py_UCS2 *)data + pos, len - pos, @@ -5822,7 +5822,7 @@ _PyUnicode_EncodeUTF32(PyObject *str, rep = unicode_encode_call_errorhandler( errors, &errorHandler, encoding, "surrogates not allowed", - str, &exc, pos, pos + 1, &pos); + str, &exc, pos, pos + 1, &newpos); if (!rep) goto error; @@ -5830,7 +5830,7 @@ _PyUnicode_EncodeUTF32(PyObject *str, repsize = PyBytes_GET_SIZE(rep); if (repsize & 3) { raise_encode_exception(&exc, encoding, - str, pos - 1, pos, + str, pos, pos + 1, "surrogates not allowed"); goto error; } @@ -5843,28 +5843,30 @@ _PyUnicode_EncodeUTF32(PyObject *str, moreunits = repsize = PyUnicode_GET_LENGTH(rep); if (!PyUnicode_IS_ASCII(rep)) { raise_encode_exception(&exc, encoding, - str, pos - 1, pos, + str, pos, pos + 1, "surrogates not allowed"); goto error; } } + moreunits += pos - newpos; + pos = newpos; /* four bytes are reserved for each surrogate */ - if (moreunits > 1) { + if (moreunits > 0) { Py_ssize_t outpos = out - (uint32_t*) PyBytes_AS_STRING(v); if (moreunits >= (PY_SSIZE_T_MAX - PyBytes_GET_SIZE(v)) / 4) { /* integer overflow */ PyErr_NoMemory(); goto error; } - if (_PyBytes_Resize(&v, PyBytes_GET_SIZE(v) + 4 * (moreunits - 1)) < 0) + if (_PyBytes_Resize(&v, PyBytes_GET_SIZE(v) + 4 * moreunits) < 0) goto error; out = (uint32_t*) PyBytes_AS_STRING(v) + outpos; } if (PyBytes_Check(rep)) { memcpy(out, PyBytes_AS_STRING(rep), repsize); - out += moreunits; + out += repsize / 4; } else /* rep is unicode */ { assert(PyUnicode_KIND(rep) == PyUnicode_1BYTE_KIND); ucs1lib_utf32_encode(PyUnicode_1BYTE_DATA(rep), repsize, @@ -6157,7 +6159,7 @@ _PyUnicode_EncodeUTF16(PyObject *str, pos = 0; while (pos < len) { - Py_ssize_t repsize, moreunits; + Py_ssize_t newpos, repsize, moreunits; if (kind == PyUnicode_2BYTE_KIND) { pos += ucs2lib_utf16_encode((const Py_UCS2 *)data + pos, len - pos, @@ -6174,7 +6176,7 @@ _PyUnicode_EncodeUTF16(PyObject *str, rep = unicode_encode_call_errorhandler( errors, &errorHandler, encoding, "surrogates not allowed", - str, &exc, pos, pos + 1, &pos); + str, &exc, pos, pos + 1, &newpos); if (!rep) goto error; @@ -6182,7 +6184,7 @@ _PyUnicode_EncodeUTF16(PyObject *str, repsize = PyBytes_GET_SIZE(rep); if (repsize & 1) { raise_encode_exception(&exc, encoding, - str, pos - 1, pos, + str, pos, pos + 1, "surrogates not allowed"); goto error; } @@ -6195,28 +6197,30 @@ _PyUnicode_EncodeUTF16(PyObject *str, moreunits = repsize = PyUnicode_GET_LENGTH(rep); if (!PyUnicode_IS_ASCII(rep)) { raise_encode_exception(&exc, encoding, - str, pos - 1, pos, + str, pos, pos + 1, "surrogates not allowed"); goto error; } } + moreunits += pos - newpos; + pos = newpos; /* two bytes are reserved for each surrogate */ - if (moreunits > 1) { + if (moreunits > 0) { Py_ssize_t outpos = out - (unsigned short*) PyBytes_AS_STRING(v); if (moreunits >= (PY_SSIZE_T_MAX - PyBytes_GET_SIZE(v)) / 2) { /* integer overflow */ PyErr_NoMemory(); goto error; } - if (_PyBytes_Resize(&v, PyBytes_GET_SIZE(v) + 2 * (moreunits - 1)) < 0) + if (_PyBytes_Resize(&v, PyBytes_GET_SIZE(v) + 2 * moreunits) < 0) goto error; out = (unsigned short*) PyBytes_AS_STRING(v) + outpos; } if (PyBytes_Check(rep)) { memcpy(out, PyBytes_AS_STRING(rep), repsize); - out += moreunits; + out += repsize / 2; } else /* rep is unicode */ { assert(PyUnicode_KIND(rep) == PyUnicode_1BYTE_KIND); ucs1lib_utf16_encode(PyUnicode_1BYTE_DATA(rep), repsize, @@ -7143,8 +7147,19 @@ unicode_encode_ucs1(PyObject *unicode, if (rep == NULL) goto onError; - /* subtract preallocated bytes */ - writer.min_size -= newpos - collstart; + if (newpos < collstart) { + writer.overallocate = 1; + str = _PyBytesWriter_Prepare(&writer, str, + collstart - newpos); + if (str == NULL) + goto onError; + } + else { + /* subtract preallocated bytes */ + writer.min_size -= newpos - collstart; + /* Only overallocate the buffer if it's not the last write */ + writer.overallocate = (newpos < size); + } if (PyBytes_Check(rep)) { /* Directly copy bytes result to output. */ @@ -7933,13 +7948,14 @@ encode_code_page_errors(UINT code_page, PyObject **outbytes, pos, pos + 1, &newpos); if (rep == NULL) goto error; - pos = newpos; + Py_ssize_t morebytes = pos - newpos; if (PyBytes_Check(rep)) { outsize = PyBytes_GET_SIZE(rep); - if (outsize != 1) { + morebytes += outsize; + if (morebytes > 0) { Py_ssize_t offset = out - PyBytes_AS_STRING(*outbytes); - newoutsize = PyBytes_GET_SIZE(*outbytes) + (outsize - 1); + newoutsize = PyBytes_GET_SIZE(*outbytes) + morebytes; if (_PyBytes_Resize(outbytes, newoutsize) < 0) { Py_DECREF(rep); goto error; @@ -7960,9 +7976,10 @@ encode_code_page_errors(UINT code_page, PyObject **outbytes, } outsize = PyUnicode_GET_LENGTH(rep); - if (outsize != 1) { + morebytes += outsize; + if (morebytes > 0) { Py_ssize_t offset = out - PyBytes_AS_STRING(*outbytes); - newoutsize = PyBytes_GET_SIZE(*outbytes) + (outsize - 1); + newoutsize = PyBytes_GET_SIZE(*outbytes) + morebytes; if (_PyBytes_Resize(outbytes, newoutsize) < 0) { Py_DECREF(rep); goto error; @@ -7985,6 +8002,7 @@ encode_code_page_errors(UINT code_page, PyObject **outbytes, out++; } } + pos = newpos; Py_DECREF(rep); } /* write a NUL byte */ From webhook-mailer at python.org Mon May 2 08:09:26 2022 From: webhook-mailer at python.org (vstinner) Date: Mon, 02 May 2022 12:09:26 -0000 Subject: [Python-checkins] gh-91321: Add _testcppext C++ extension (#32175) Message-ID: https://github.com/python/cpython/commit/79886e7b62f4879a4cb17526a9a809bd0f5ed5e3 commit: 79886e7b62f4879a4cb17526a9a809bd0f5ed5e3 branch: main author: Victor Stinner committer: vstinner date: 2022-05-02T14:09:22+02:00 summary: gh-91321: Add _testcppext C++ extension (#32175) Build a basic C++ test extension to check that the Python C API is compatible with C++ and does not emit C++ compiler warnings. * Add Modules/_testcppext.cpp: C++ extension * Add Lib/test/test_cppext.py: test building the C++ extension. files: A Lib/test/_testcppext.cpp A Lib/test/test_cppext.py diff --git a/Lib/test/_testcppext.cpp b/Lib/test/_testcppext.cpp new file mode 100644 index 00000000000000..14cd1ddad17572 --- /dev/null +++ b/Lib/test/_testcppext.cpp @@ -0,0 +1,62 @@ +// gh-91321: Very basic C++ test extension to check that the Python C API is +// compatible with C++ and does not emit C++ compiler warnings. + +#include "Python.h" + +PyDoc_STRVAR(_testcppext_add_doc, +"add(x, y)\n" +"\n" +"Return the sum of two integers: x + y."); + +static PyObject * +_testcppext_add(PyObject *Py_UNUSED(module), PyObject *args) +{ + long i, j; + if (!PyArg_ParseTuple(args, "ll:foo", &i, &j)) { + return nullptr; + } + long res = i + j; + return PyLong_FromLong(res); +} + + +static PyMethodDef _testcppext_methods[] = { + {"add", _testcppext_add, METH_VARARGS, _testcppext_add_doc}, + {nullptr, nullptr, 0, nullptr} /* sentinel */ +}; + + +static int +_testcppext_exec(PyObject *module) +{ + if (PyModule_AddIntMacro(module, __cplusplus) < 0) { + return -1; + } + return 0; +} + +static PyModuleDef_Slot _testcppext_slots[] = { + {Py_mod_exec, reinterpret_cast(_testcppext_exec)}, + {0, NULL} +}; + + +PyDoc_STRVAR(_testcppext_doc, "C++ test extension."); + +static struct PyModuleDef _testcppext_module = { + PyModuleDef_HEAD_INIT, // m_base + "_testcppext", // m_name + _testcppext_doc, // m_doc + 0, // m_size + _testcppext_methods, // m_methods + _testcppext_slots, // m_slots + NULL, // m_traverse + NULL, // m_clear + nullptr, // m_free +}; + +PyMODINIT_FUNC +PyInit__testcppext(void) +{ + return PyModuleDef_Init(&_testcppext_module); +} diff --git a/Lib/test/test_cppext.py b/Lib/test/test_cppext.py new file mode 100644 index 00000000000000..c1d02bc54b3890 --- /dev/null +++ b/Lib/test/test_cppext.py @@ -0,0 +1,79 @@ +# gh-91321: Build a basic C++ test extension to check that the Python C API is +# compatible with C++ and does not emit C++ compiler warnings. +import os +import sys +import unittest +import warnings +from test import support +from test.support import os_helper + +with warnings.catch_warnings(): + warnings.simplefilter('ignore', DeprecationWarning) + from distutils.core import setup, Extension + import distutils.sysconfig + + +MS_WINDOWS = (sys.platform == 'win32') + + +SOURCE = support.findfile('_testcppext.cpp') +if not MS_WINDOWS: + # C++ compiler flags for GCC and clang + CPPFLAGS = [ + # Python currently targets C++11 + '-std=c++11', + # gh-91321: The purpose of _testcppext extension is to check that building + # a C++ extension using the Python C API does not emit C++ compiler + # warnings + '-Werror', + ] +else: + # Don't pass any compiler flag to MSVC + CPPFLAGS = [] + + +class TestCPPExt(unittest.TestCase): + def build(self): + cpp_ext = Extension( + '_testcppext', + sources=[SOURCE], + language='c++', + extra_compile_args=CPPFLAGS) + + try: + try: + with (support.captured_stdout() as stdout, + support.swap_attr(sys, 'argv', ['setup.py', 'build_ext'])): + setup(name="_testcppext", ext_modules=[cpp_ext]) + return + except: + # Show output on error + print() + print(stdout.getvalue()) + raise + except SystemExit: + self.fail("Build failed") + + # With MSVC, the linker fails with: cannot open file 'python311.lib' + # https://github.com/python/cpython/pull/32175#issuecomment-1111175897 + @unittest.skipIf(MS_WINDOWS, 'test fails on Windows') + def test_build(self): + # save/restore os.environ + def restore_env(old_env): + os.environ.clear() + os.environ.update(old_env) + self.addCleanup(restore_env, dict(os.environ)) + + def restore_sysconfig_vars(old_config_vars): + distutils.sysconfig._config_vars.clear() + distutils.sysconfig._config_vars.update(old_config_vars) + self.addCleanup(restore_sysconfig_vars, + dict(distutils.sysconfig._config_vars)) + + # Build in a temporary directory + with os_helper.temp_cwd(): + self.build() + + +if __name__ == "__main__": + unittest.main() From webhook-mailer at python.org Mon May 2 09:29:34 2022 From: webhook-mailer at python.org (vstinner) Date: Mon, 02 May 2022 13:29:34 -0000 Subject: [Python-checkins] gh-88097: doc: fix link to Py_Version (#92141) Message-ID: https://github.com/python/cpython/commit/6811bdef63d4f3af6ff901d324556cf8954575a7 commit: 6811bdef63d4f3af6ff901d324556cf8954575a7 branch: main author: Victor Stinner committer: vstinner date: 2022-05-02T15:29:22+02:00 summary: gh-88097: doc: fix link to Py_Version (#92141) files: M Doc/c-api/init.rst diff --git a/Doc/c-api/init.rst b/Doc/c-api/init.rst index 9d38fb47d10d6..d9a7d8e44e196 100644 --- a/Doc/c-api/init.rst +++ b/Doc/c-api/init.rst @@ -553,7 +553,7 @@ Process-wide parameters period. The returned string points into static storage; the caller should not modify its value. The value is available to Python code as :data:`sys.version`. - See also the :data:`Py_Version` constant. + See also the :c:var:`Py_Version` constant. .. c:function:: const char* Py_GetPlatform() From webhook-mailer at python.org Mon May 2 10:14:51 2022 From: webhook-mailer at python.org (JelleZijlstra) Date: Mon, 02 May 2022 14:14:51 -0000 Subject: [Python-checkins] gh-89301: Fix regression with bound values in traced SQLite statements (#92053) Message-ID: https://github.com/python/cpython/commit/721aa96540bb96700f8c4bab0b4095b43491dca1 commit: 721aa96540bb96700f8c4bab0b4095b43491dca1 branch: main author: Erlend Egeberg Aasland committer: JelleZijlstra date: 2022-05-02T08:14:35-06:00 summary: gh-89301: Fix regression with bound values in traced SQLite statements (#92053) files: A Misc/NEWS.d/next/Library/2021-09-08-16-21-03.bpo-45138.yghUrK.rst M Lib/test/test_sqlite3/test_hooks.py M Modules/_sqlite/connection.c diff --git a/Lib/test/test_sqlite3/test_hooks.py b/Lib/test/test_sqlite3/test_hooks.py index d4790cfe77b7b..21042b9bf106f 100644 --- a/Lib/test/test_sqlite3/test_hooks.py +++ b/Lib/test/test_sqlite3/test_hooks.py @@ -20,12 +20,16 @@ # misrepresented as being the original software. # 3. This notice may not be removed or altered from any source distribution. -import unittest +import contextlib import sqlite3 as sqlite +import unittest from test.support.os_helper import TESTFN, unlink + +from test.test_sqlite3.test_dbapi import memory_database, cx_limit from test.test_sqlite3.test_userfunctions import with_tracebacks + class CollationTests(unittest.TestCase): def test_create_collation_not_string(self): con = sqlite.connect(":memory:") @@ -224,6 +228,16 @@ def bad_progress(): class TraceCallbackTests(unittest.TestCase): + @contextlib.contextmanager + def check_stmt_trace(self, cx, expected): + try: + traced = [] + cx.set_trace_callback(lambda stmt: traced.append(stmt)) + yield + finally: + self.assertEqual(traced, expected) + cx.set_trace_callback(None) + def test_trace_callback_used(self): """ Test that the trace callback is invoked once it is set. @@ -289,6 +303,52 @@ def trace(statement): con2.close() self.assertEqual(traced_statements, queries) + def test_trace_expanded_sql(self): + expected = [ + "create table t(t)", + "BEGIN ", + "insert into t values(0)", + "insert into t values(1)", + "insert into t values(2)", + "COMMIT", + ] + with memory_database() as cx, self.check_stmt_trace(cx, expected): + with cx: + cx.execute("create table t(t)") + cx.executemany("insert into t values(?)", ((v,) for v in range(3))) + + @with_tracebacks( + sqlite.DataError, + regex="Expanded SQL string exceeds the maximum string length" + ) + def test_trace_too_much_expanded_sql(self): + # If the expanded string is too large, we'll fall back to the + # unexpanded SQL statement (for SQLite 3.14.0 and newer). + # The resulting string length is limited by the runtime limit + # SQLITE_LIMIT_LENGTH. + template = "select 1 as a where a=" + category = sqlite.SQLITE_LIMIT_LENGTH + with memory_database() as cx, cx_limit(cx, category=category) as lim: + ok_param = "a" + bad_param = "a" * lim + + unexpanded_query = template + "?" + expected = [unexpanded_query] + if sqlite.sqlite_version_info < (3, 14, 0): + expected = [] + with self.check_stmt_trace(cx, expected): + cx.execute(unexpanded_query, (bad_param,)) + + expanded_query = f"{template}'{ok_param}'" + with self.check_stmt_trace(cx, [expanded_query]): + cx.execute(unexpanded_query, (ok_param,)) + + @with_tracebacks(ZeroDivisionError, regex="division by zero") + def test_trace_bad_handler(self): + with memory_database() as cx: + cx.set_trace_callback(lambda stmt: 5/0) + cx.execute("select 1") + if __name__ == "__main__": unittest.main() diff --git a/Misc/NEWS.d/next/Library/2021-09-08-16-21-03.bpo-45138.yghUrK.rst b/Misc/NEWS.d/next/Library/2021-09-08-16-21-03.bpo-45138.yghUrK.rst new file mode 100644 index 0000000000000..906ed4c4db43c --- /dev/null +++ b/Misc/NEWS.d/next/Library/2021-09-08-16-21-03.bpo-45138.yghUrK.rst @@ -0,0 +1,3 @@ +Fix a regression in the :mod:`sqlite3` trace callback where bound parameters +were not expanded in the passed statement string. The regression was introduced +in Python 3.10 by :issue:`40318`. Patch by Erlend E. Aasland. diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c index 0028cf72f997a..fe244c8b22771 100644 --- a/Modules/_sqlite/connection.c +++ b/Modules/_sqlite/connection.c @@ -1332,11 +1332,10 @@ progress_callback(void *ctx) * to ensure future compatibility. */ static int -trace_callback(unsigned int type, void *ctx, void *prepared_statement, - void *statement_string) +trace_callback(unsigned int type, void *ctx, void *stmt, void *sql) #else static void -trace_callback(void *ctx, const char *statement_string) +trace_callback(void *ctx, const char *sql) #endif { #ifdef HAVE_TRACE_V2 @@ -1347,24 +1346,51 @@ trace_callback(void *ctx, const char *statement_string) PyGILState_STATE gilstate = PyGILState_Ensure(); - PyObject *py_statement = NULL; - PyObject *ret = NULL; - py_statement = PyUnicode_DecodeUTF8(statement_string, - strlen(statement_string), "replace"); assert(ctx != NULL); + pysqlite_state *state = ((callback_context *)ctx)->state; + assert(state != NULL); + + PyObject *py_statement = NULL; +#ifdef HAVE_TRACE_V2 + const char *expanded_sql = sqlite3_expanded_sql((sqlite3_stmt *)stmt); + if (expanded_sql == NULL) { + sqlite3 *db = sqlite3_db_handle((sqlite3_stmt *)stmt); + if (sqlite3_errcode(db) == SQLITE_NOMEM) { + (void)PyErr_NoMemory(); + goto exit; + } + + PyErr_SetString(state->DataError, + "Expanded SQL string exceeds the maximum string length"); + print_or_clear_traceback((callback_context *)ctx); + + // Fall back to unexpanded sql + py_statement = PyUnicode_FromString((const char *)sql); + } + else { + py_statement = PyUnicode_FromString(expanded_sql); + sqlite3_free((void *)expanded_sql); + } +#else + if (sql == NULL) { + PyErr_SetString(state->DataError, + "Expanded SQL string exceeds the maximum string length"); + print_or_clear_traceback((callback_context *)ctx); + goto exit; + } + py_statement = PyUnicode_FromString(sql); +#endif if (py_statement) { PyObject *callable = ((callback_context *)ctx)->callable; - ret = PyObject_CallOneArg(callable, py_statement); + PyObject *ret = PyObject_CallOneArg(callable, py_statement); Py_DECREF(py_statement); + Py_XDECREF(ret); } - - if (ret) { - Py_DECREF(ret); - } - else { - print_or_clear_traceback(ctx); + if (PyErr_Occurred()) { + print_or_clear_traceback((callback_context *)ctx); } +exit: PyGILState_Release(gilstate); #ifdef HAVE_TRACE_V2 return 0; From webhook-mailer at python.org Mon May 2 10:31:59 2022 From: webhook-mailer at python.org (JelleZijlstra) Date: Mon, 02 May 2022 14:31:59 -0000 Subject: [Python-checkins] gh-84714: Add behavior if dst file exists (#91867) Message-ID: https://github.com/python/cpython/commit/9166ace805d915c8a918cd89fff0e58b65e3327c commit: 9166ace805d915c8a918cd89fff0e58b65e3327c branch: main author: slateny <46876382+slateny at users.noreply.github.com> committer: JelleZijlstra date: 2022-05-02T08:31:55-06:00 summary: gh-84714: Add behavior if dst file exists (#91867) files: M Doc/library/shutil.rst diff --git a/Doc/library/shutil.rst b/Doc/library/shutil.rst index 75ffb79d535c8..cb72ff6f3914b 100644 --- a/Doc/library/shutil.rst +++ b/Doc/library/shutil.rst @@ -160,7 +160,8 @@ Directory and files operations Copies the file *src* to the file or directory *dst*. *src* and *dst* should be :term:`path-like objects ` or strings. If *dst* specifies a directory, the file will be copied into *dst* using the - base filename from *src*. Returns the path to the newly created file. + base filename from *src*. If *dst* specifies a file that already exists, + it will be replaced. Returns the path to the newly created file. If *follow_symlinks* is false, and *src* is a symbolic link, *dst* will be created as a symbolic link. If *follow_symlinks* From webhook-mailer at python.org Mon May 2 10:36:50 2022 From: webhook-mailer at python.org (JelleZijlstra) Date: Mon, 02 May 2022 14:36:50 -0000 Subject: [Python-checkins] [3.9] gh-81488: Add recursive wording for issubclass docs (GH-92087) (#92131) Message-ID: https://github.com/python/cpython/commit/28cd98f352dcb9728c272d842070602edc69c0a7 commit: 28cd98f352dcb9728c272d842070602edc69c0a7 branch: 3.9 author: slateny <46876382+slateny at users.noreply.github.com> committer: JelleZijlstra date: 2022-05-02T08:36:19-06:00 summary: [3.9] gh-81488: Add recursive wording for issubclass docs (GH-92087) (#92131) (cherry picked from commit 1066ecb97042b8e89de554e6f9dc2e3d634208c0) Co-authored-by: slateny <46876382+slateny at users.noreply.github.com> files: M Doc/library/functions.rst diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst index 937e00bf994e6..13d7d6e5b0aa3 100644 --- a/Doc/library/functions.rst +++ b/Doc/library/functions.rst @@ -862,7 +862,8 @@ are always available. They are listed here in alphabetical order. Return ``True`` if *class* is a subclass (direct, indirect or :term:`virtual `) of *classinfo*. A class is considered a subclass of itself. *classinfo* may be a tuple of class - objects, in which case return ``True`` if *class* is a subclass of any entry + objects (or recursively, other such tuples), + in which case return ``True`` if *class* is a subclass of any entry in *classinfo*. In any other case, a :exc:`TypeError` exception is raised. From webhook-mailer at python.org Mon May 2 10:43:51 2022 From: webhook-mailer at python.org (JelleZijlstra) Date: Mon, 02 May 2022 14:43:51 -0000 Subject: [Python-checkins] gh-85133: os docs: Add that getenv uses os.environ (#91874) Message-ID: https://github.com/python/cpython/commit/b25352a5c039d95e019dd8ca111f6f77c43ca1f7 commit: b25352a5c039d95e019dd8ca111f6f77c43ca1f7 branch: main author: slateny <46876382+slateny at users.noreply.github.com> committer: JelleZijlstra date: 2022-05-02T08:43:32-06:00 summary: gh-85133: os docs: Add that getenv uses os.environ (#91874) Co-authored-by: Jelle Zijlstra files: M Doc/library/os.rst diff --git a/Doc/library/os.rst b/Doc/library/os.rst index d42259b2548f6..aa50673445884 100644 --- a/Doc/library/os.rst +++ b/Doc/library/os.rst @@ -177,8 +177,8 @@ process and user. This mapping is captured the first time the :mod:`os` module is imported, typically during Python startup as part of processing :file:`site.py`. Changes - to the environment made after this time are not reflected in ``os.environ``, - except for changes made by modifying ``os.environ`` directly. + to the environment made after this time are not reflected in :data:`os.environ`, + except for changes made by modifying :data:`os.environ` directly. This mapping may be used to modify the environment as well as query the environment. :func:`putenv` will be called automatically when the mapping @@ -190,8 +190,8 @@ process and user. .. note:: - Calling :func:`putenv` directly does not change ``os.environ``, so it's better - to modify ``os.environ``. + Calling :func:`putenv` directly does not change :data:`os.environ`, so it's better + to modify :data:`os.environ`. .. note:: @@ -201,7 +201,7 @@ process and user. You can delete items in this mapping to unset environment variables. :func:`unsetenv` will be called automatically when an item is deleted from - ``os.environ``, and when one of the :meth:`pop` or :meth:`clear` methods is + :data:`os.environ`, and when one of the :meth:`pop` or :meth:`clear` methods is called. .. versionchanged:: 3.9 @@ -292,7 +292,10 @@ process and user. .. function:: getenv(key, default=None) Return the value of the environment variable *key* if it exists, or - *default* if it doesn't. *key*, *default* and the result are str. + *default* if it doesn't. *key*, *default* and the result are str. Note that + since :func:`getenv` uses :data:`os.environ`, the mapping of :func:`getenv` is + similarly also captured on import, and the function may not reflect + future environment changes. On Unix, keys and values are decoded with :func:`sys.getfilesystemencoding` and ``'surrogateescape'`` error handler. Use :func:`os.getenvb` if you @@ -304,7 +307,11 @@ process and user. .. function:: getenvb(key, default=None) Return the value of the environment variable *key* if it exists, or - *default* if it doesn't. *key*, *default* and the result are bytes. + *default* if it doesn't. *key*, *default* and the result are bytes. Note that + since :func:`getenvb` uses :data:`os.environb`, the mapping of :func:`getenvb` is + similarly also captured on import, and the function may not reflect + future environment changes. + :func:`getenvb` is only available if :data:`supports_bytes_environ` is ``True``. @@ -511,10 +518,11 @@ process and user. changes to the environment affect subprocesses started with :func:`os.system`, :func:`popen` or :func:`fork` and :func:`execv`. - Assignments to items in ``os.environ`` are automatically translated into + Assignments to items in :data:`os.environ` are automatically translated into corresponding calls to :func:`putenv`; however, calls to :func:`putenv` - don't update ``os.environ``, so it is actually preferable to assign to items - of ``os.environ``. + don't update :data:`os.environ`, so it is actually preferable to assign to items + of :data:`os.environ`. This also applies to :func:`getenv` and :func:`getenvb`, which + respectively use :data:`os.environ` and :data:`os.environb` in their implementations. .. note:: @@ -713,10 +721,10 @@ process and user. environment affect subprocesses started with :func:`os.system`, :func:`popen` or :func:`fork` and :func:`execv`. - Deletion of items in ``os.environ`` is automatically translated into a + Deletion of items in :data:`os.environ` is automatically translated into a corresponding call to :func:`unsetenv`; however, calls to :func:`unsetenv` - don't update ``os.environ``, so it is actually preferable to delete items of - ``os.environ``. + don't update :data:`os.environ`, so it is actually preferable to delete items of + :data:`os.environ`. .. audit-event:: os.unsetenv key os.unsetenv From webhook-mailer at python.org Mon May 2 10:51:16 2022 From: webhook-mailer at python.org (miss-islington) Date: Mon, 02 May 2022 14:51:16 -0000 Subject: [Python-checkins] gh-84714: Add behavior if dst file exists (GH-91867) Message-ID: https://github.com/python/cpython/commit/bba721d0fa7832fd9dbdde44ba39f19755513303 commit: bba721d0fa7832fd9dbdde44ba39f19755513303 branch: 3.10 author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com> committer: miss-islington <31488909+miss-islington at users.noreply.github.com> date: 2022-05-02T07:51:07-07:00 summary: gh-84714: Add behavior if dst file exists (GH-91867) (cherry picked from commit 9166ace805d915c8a918cd89fff0e58b65e3327c) Co-authored-by: slateny <46876382+slateny at users.noreply.github.com> files: M Doc/library/shutil.rst diff --git a/Doc/library/shutil.rst b/Doc/library/shutil.rst index 8ce0e80ec8120..403df45b3966a 100644 --- a/Doc/library/shutil.rst +++ b/Doc/library/shutil.rst @@ -160,7 +160,8 @@ Directory and files operations Copies the file *src* to the file or directory *dst*. *src* and *dst* should be :term:`path-like objects ` or strings. If *dst* specifies a directory, the file will be copied into *dst* using the - base filename from *src*. Returns the path to the newly created file. + base filename from *src*. If *dst* specifies a file that already exists, + it will be replaced. Returns the path to the newly created file. If *follow_symlinks* is false, and *src* is a symbolic link, *dst* will be created as a symbolic link. If *follow_symlinks* From webhook-mailer at python.org Mon May 2 10:54:16 2022 From: webhook-mailer at python.org (miss-islington) Date: Mon, 02 May 2022 14:54:16 -0000 Subject: [Python-checkins] gh-84714: Add behavior if dst file exists (GH-91867) Message-ID: https://github.com/python/cpython/commit/cafcb2cdcadc54a358905449549347f6e8c84f21 commit: cafcb2cdcadc54a358905449549347f6e8c84f21 branch: 3.9 author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com> committer: miss-islington <31488909+miss-islington at users.noreply.github.com> date: 2022-05-02T07:54:12-07:00 summary: gh-84714: Add behavior if dst file exists (GH-91867) (cherry picked from commit 9166ace805d915c8a918cd89fff0e58b65e3327c) Co-authored-by: slateny <46876382+slateny at users.noreply.github.com> files: M Doc/library/shutil.rst diff --git a/Doc/library/shutil.rst b/Doc/library/shutil.rst index 8ce0e80ec8120..403df45b3966a 100644 --- a/Doc/library/shutil.rst +++ b/Doc/library/shutil.rst @@ -160,7 +160,8 @@ Directory and files operations Copies the file *src* to the file or directory *dst*. *src* and *dst* should be :term:`path-like objects ` or strings. If *dst* specifies a directory, the file will be copied into *dst* using the - base filename from *src*. Returns the path to the newly created file. + base filename from *src*. If *dst* specifies a file that already exists, + it will be replaced. Returns the path to the newly created file. If *follow_symlinks* is false, and *src* is a symbolic link, *dst* will be created as a symbolic link. If *follow_symlinks* From webhook-mailer at python.org Mon May 2 10:58:13 2022 From: webhook-mailer at python.org (miss-islington) Date: Mon, 02 May 2022 14:58:13 -0000 Subject: [Python-checkins] gh-85133: os docs: Add that getenv uses os.environ (GH-91874) Message-ID: https://github.com/python/cpython/commit/9ce39cc9f218da782949f6957b900fb8a8aa7a75 commit: 9ce39cc9f218da782949f6957b900fb8a8aa7a75 branch: 3.10 author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com> committer: miss-islington <31488909+miss-islington at users.noreply.github.com> date: 2022-05-02T07:58:09-07:00 summary: gh-85133: os docs: Add that getenv uses os.environ (GH-91874) Co-authored-by: Jelle Zijlstra (cherry picked from commit b25352a5c039d95e019dd8ca111f6f77c43ca1f7) Co-authored-by: slateny <46876382+slateny at users.noreply.github.com> files: M Doc/library/os.rst diff --git a/Doc/library/os.rst b/Doc/library/os.rst index b81574b7eaa46..1eaf369ff659a 100644 --- a/Doc/library/os.rst +++ b/Doc/library/os.rst @@ -177,8 +177,8 @@ process and user. This mapping is captured the first time the :mod:`os` module is imported, typically during Python startup as part of processing :file:`site.py`. Changes - to the environment made after this time are not reflected in ``os.environ``, - except for changes made by modifying ``os.environ`` directly. + to the environment made after this time are not reflected in :data:`os.environ`, + except for changes made by modifying :data:`os.environ` directly. This mapping may be used to modify the environment as well as query the environment. :func:`putenv` will be called automatically when the mapping @@ -190,8 +190,8 @@ process and user. .. note:: - Calling :func:`putenv` directly does not change ``os.environ``, so it's better - to modify ``os.environ``. + Calling :func:`putenv` directly does not change :data:`os.environ`, so it's better + to modify :data:`os.environ`. .. note:: @@ -201,7 +201,7 @@ process and user. You can delete items in this mapping to unset environment variables. :func:`unsetenv` will be called automatically when an item is deleted from - ``os.environ``, and when one of the :meth:`pop` or :meth:`clear` methods is + :data:`os.environ`, and when one of the :meth:`pop` or :meth:`clear` methods is called. .. versionchanged:: 3.9 @@ -292,7 +292,10 @@ process and user. .. function:: getenv(key, default=None) Return the value of the environment variable *key* if it exists, or - *default* if it doesn't. *key*, *default* and the result are str. + *default* if it doesn't. *key*, *default* and the result are str. Note that + since :func:`getenv` uses :data:`os.environ`, the mapping of :func:`getenv` is + similarly also captured on import, and the function may not reflect + future environment changes. On Unix, keys and values are decoded with :func:`sys.getfilesystemencoding` and ``'surrogateescape'`` error handler. Use :func:`os.getenvb` if you @@ -304,7 +307,11 @@ process and user. .. function:: getenvb(key, default=None) Return the value of the environment variable *key* if it exists, or - *default* if it doesn't. *key*, *default* and the result are bytes. + *default* if it doesn't. *key*, *default* and the result are bytes. Note that + since :func:`getenvb` uses :data:`os.environb`, the mapping of :func:`getenvb` is + similarly also captured on import, and the function may not reflect + future environment changes. + :func:`getenvb` is only available if :data:`supports_bytes_environ` is ``True``. @@ -510,10 +517,11 @@ process and user. changes to the environment affect subprocesses started with :func:`os.system`, :func:`popen` or :func:`fork` and :func:`execv`. - Assignments to items in ``os.environ`` are automatically translated into + Assignments to items in :data:`os.environ` are automatically translated into corresponding calls to :func:`putenv`; however, calls to :func:`putenv` - don't update ``os.environ``, so it is actually preferable to assign to items - of ``os.environ``. + don't update :data:`os.environ`, so it is actually preferable to assign to items + of :data:`os.environ`. This also applies to :func:`getenv` and :func:`getenvb`, which + respectively use :data:`os.environ` and :data:`os.environb` in their implementations. .. note:: @@ -712,10 +720,10 @@ process and user. environment affect subprocesses started with :func:`os.system`, :func:`popen` or :func:`fork` and :func:`execv`. - Deletion of items in ``os.environ`` is automatically translated into a + Deletion of items in :data:`os.environ` is automatically translated into a corresponding call to :func:`unsetenv`; however, calls to :func:`unsetenv` - don't update ``os.environ``, so it is actually preferable to delete items of - ``os.environ``. + don't update :data:`os.environ`, so it is actually preferable to delete items of + :data:`os.environ`. .. audit-event:: os.unsetenv key os.unsetenv From webhook-mailer at python.org Mon May 2 11:01:12 2022 From: webhook-mailer at python.org (JelleZijlstra) Date: Mon, 02 May 2022 15:01:12 -0000 Subject: [Python-checkins] Fix typo in Programming FAQ (#92083) Message-ID: https://github.com/python/cpython/commit/2a7efa324274a54fe0e5480cae1438d8294b9ec3 commit: 2a7efa324274a54fe0e5480cae1438d8294b9ec3 branch: main author: Matt Harding committer: JelleZijlstra date: 2022-05-02T09:01:03-06:00 summary: Fix typo in Programming FAQ (#92083) I believe the word "with" was missing here. files: M Doc/faq/programming.rst diff --git a/Doc/faq/programming.rst b/Doc/faq/programming.rst index da011ccb29edb..f87eaff9531fc 100644 --- a/Doc/faq/programming.rst +++ b/Doc/faq/programming.rst @@ -78,7 +78,7 @@ set of modules required by a program and bind these modules together with a Python binary to produce a single executable. One is to use the freeze tool, which is included in the Python source tree as -``Tools/freeze``. It converts Python byte code to C arrays; a C compiler you can +``Tools/freeze``. It converts Python byte code to C arrays; with a C compiler you can embed all your modules into a new program, which is then linked with the standard Python modules. From webhook-mailer at python.org Mon May 2 11:01:56 2022 From: webhook-mailer at python.org (JelleZijlstra) Date: Mon, 02 May 2022 15:01:56 -0000 Subject: [Python-checkins] asyncio.subprocess: Fix a typo in doc (#92030) Message-ID: https://github.com/python/cpython/commit/bb857a96ef368ba9de1da2db12b1a1f1870606ac commit: bb857a96ef368ba9de1da2db12b1a1f1870606ac branch: main author: Harsh <65716674+Harsh-br0 at users.noreply.github.com> committer: JelleZijlstra date: 2022-05-02T09:01:52-06:00 summary: asyncio.subprocess: Fix a typo in doc (#92030) Remove a confusion for read method in asyncio-subprocess doc for stderr StreamReader instance files: M Doc/library/asyncio-subprocess.rst diff --git a/Doc/library/asyncio-subprocess.rst b/Doc/library/asyncio-subprocess.rst index 748b704032554..e5000532a895d 100644 --- a/Doc/library/asyncio-subprocess.rst +++ b/Doc/library/asyncio-subprocess.rst @@ -275,7 +275,7 @@ their completion. Use the :meth:`communicate` method rather than :attr:`process.stdin.write() `, :attr:`await process.stdout.read() ` or - :attr:`await process.stderr.read `. + :attr:`await process.stderr.read() `. This avoids deadlocks due to streams pausing reading or writing and blocking the child process. From webhook-mailer at python.org Mon May 2 11:02:58 2022 From: webhook-mailer at python.org (zooba) Date: Mon, 02 May 2022 15:02:58 -0000 Subject: [Python-checkins] bpo-46907: Update Windows installer to SQLite 3.38.3. (GH-91995) Message-ID: https://github.com/python/cpython/commit/e6040604b3e12a2897274ed6c715c45eea524cb5 commit: e6040604b3e12a2897274ed6c715c45eea524cb5 branch: main author: Mariusz Felisiak committer: zooba date: 2022-05-02T16:02:54+01:00 summary: bpo-46907: Update Windows installer to SQLite 3.38.3. (GH-91995) files: A Misc/NEWS.d/next/Windows/2022-04-27-19-36-56.bpo-46907.lfurlP.rst M PCbuild/get_externals.bat M PCbuild/python.props M PCbuild/readme.txt M PCbuild/sqlite3.vcxproj diff --git a/Misc/NEWS.d/next/Windows/2022-04-27-19-36-56.bpo-46907.lfurlP.rst b/Misc/NEWS.d/next/Windows/2022-04-27-19-36-56.bpo-46907.lfurlP.rst new file mode 100644 index 0000000000000..88ea9f931188e --- /dev/null +++ b/Misc/NEWS.d/next/Windows/2022-04-27-19-36-56.bpo-46907.lfurlP.rst @@ -0,0 +1 @@ +Update Windows installer to use SQLite 3.38.3. diff --git a/PCbuild/get_externals.bat b/PCbuild/get_externals.bat index 35646edb2e9e8..4241baadec4bd 100644 --- a/PCbuild/get_externals.bat +++ b/PCbuild/get_externals.bat @@ -54,7 +54,7 @@ set libraries= set libraries=%libraries% bzip2-1.0.8 if NOT "%IncludeLibffiSrc%"=="false" set libraries=%libraries% libffi-3.4.2 if NOT "%IncludeSSLSrc%"=="false" set libraries=%libraries% openssl-1.1.1n -set libraries=%libraries% sqlite-3.38.2.0 +set libraries=%libraries% sqlite-3.38.3.0 if NOT "%IncludeTkinterSrc%"=="false" set libraries=%libraries% tcl-core-8.6.12.1 if NOT "%IncludeTkinterSrc%"=="false" set libraries=%libraries% tk-8.6.12.1 if NOT "%IncludeTkinterSrc%"=="false" set libraries=%libraries% tix-8.4.3.6 diff --git a/PCbuild/python.props b/PCbuild/python.props index baa6526378a75..e50fdc0aa61f3 100644 --- a/PCbuild/python.props +++ b/PCbuild/python.props @@ -61,7 +61,7 @@ $(EXTERNALS_DIR) $([System.IO.Path]::GetFullPath(`$(PySourcePath)externals`)) $(ExternalsDir)\ - $(ExternalsDir)sqlite-3.38.2.0\ + $(ExternalsDir)sqlite-3.38.3.0\ $(ExternalsDir)bzip2-1.0.8\ $(ExternalsDir)xz-5.2.5\ $(ExternalsDir)libffi-3.4.2\ diff --git a/PCbuild/readme.txt b/PCbuild/readme.txt index 4c99b867c52bd..da8947c938b51 100644 --- a/PCbuild/readme.txt +++ b/PCbuild/readme.txt @@ -189,7 +189,7 @@ _ssl again when building. _sqlite3 - Wraps SQLite 3.38.2, which is itself built by sqlite3.vcxproj + Wraps SQLite 3.38.3, which is itself built by sqlite3.vcxproj Homepage: http://www.sqlite.org/ _tkinter diff --git a/PCbuild/sqlite3.vcxproj b/PCbuild/sqlite3.vcxproj index 310795c4e4d20..c502d51833b91 100644 --- a/PCbuild/sqlite3.vcxproj +++ b/PCbuild/sqlite3.vcxproj @@ -98,7 +98,7 @@ $(sqlite3Dir);%(AdditionalIncludeDirectories) - SQLITE_ENABLE_MATH_FUNCTIONS;SQLITE_ENABLE_JSON1;SQLITE_ENABLE_FTS4;SQLITE_ENABLE_FTS5;SQLITE_ENABLE_RTREE;SQLITE_OMIT_AUTOINIT;SQLITE_API=__declspec(dllexport);%(PreprocessorDefinitions) + SQLITE_ENABLE_MATH_FUNCTIONS;SQLITE_ENABLE_FTS4;SQLITE_ENABLE_FTS5;SQLITE_ENABLE_RTREE;SQLITE_OMIT_AUTOINIT;SQLITE_API=__declspec(dllexport);%(PreprocessorDefinitions) Level1 From webhook-mailer at python.org Mon May 2 11:05:34 2022 From: webhook-mailer at python.org (JelleZijlstra) Date: Mon, 02 May 2022 15:05:34 -0000 Subject: [Python-checkins] concurrent.futures: Fix typo in docstring (#92121) Message-ID: https://github.com/python/cpython/commit/b11243e85e020ed2f524bdd83c339faf11ef03d4 commit: b11243e85e020ed2f524bdd83c339faf11ef03d4 branch: main author: Yiannis Hadjicharalambous committer: JelleZijlstra date: 2022-05-02T09:05:26-06:00 summary: concurrent.futures: Fix typo in docstring (#92121) files: M Lib/concurrent/futures/_base.py diff --git a/Lib/concurrent/futures/_base.py b/Lib/concurrent/futures/_base.py index 706a4f2c09d1f..d7e7e41967cc2 100644 --- a/Lib/concurrent/futures/_base.py +++ b/Lib/concurrent/futures/_base.py @@ -379,7 +379,7 @@ def running(self): return self._state == RUNNING def done(self): - """Return True of the future was cancelled or finished executing.""" + """Return True if the future was cancelled or finished executing.""" with self._condition: return self._state in [CANCELLED, CANCELLED_AND_NOTIFIED, FINISHED] From webhook-mailer at python.org Mon May 2 11:07:06 2022 From: webhook-mailer at python.org (vstinner) Date: Mon, 02 May 2022 15:07:06 -0000 Subject: [Python-checkins] gh-92135: Fix _Py_reinterpret_cast() for const (#92138) Message-ID: https://github.com/python/cpython/commit/031397063e9c22711abfbf90f2617c8785cfc42c commit: 031397063e9c22711abfbf90f2617c8785cfc42c branch: main author: Victor Stinner committer: vstinner date: 2022-05-02T17:07:00+02:00 summary: gh-92135: Fix _Py_reinterpret_cast() for const (#92138) Fix C++ compiler warnings on cast macros, like _PyObject_CAST(), when casting a constant expression to a non constant type: use const_cast<> in C++. * In C++, Py_SAFE_DOWNCAST() now uses static_cast<> rather than reinterpret_cast<>. * Add tests to the _testcppext C++ extension. * test_cppext no longer captures stdout in verbose mode. files: M Include/methodobject.h M Include/objimpl.h M Include/pyport.h M Lib/test/_testcppext.cpp M Lib/test/test_cppext.py diff --git a/Include/methodobject.h b/Include/methodobject.h index 2046ab948de05..f4be3858f2f8a 100644 --- a/Include/methodobject.h +++ b/Include/methodobject.h @@ -43,8 +43,7 @@ typedef PyObject *(*PyCMethod)(PyObject *, PyTypeObject *, PyObject *const *, // it triggers an undefined behavior when Python calls it with 2 parameters // (bpo-33012). #define _PyCFunction_CAST(func) \ - _Py_reinterpret_cast(PyCFunction, \ - _Py_reinterpret_cast(void(*)(void), (func))) + _Py_reinterpret_cast(PyCFunction, _Py_reinterpret_cast(void(*)(void), (func))) PyAPI_FUNC(PyCFunction) PyCFunction_GetFunction(PyObject *); PyAPI_FUNC(PyObject *) PyCFunction_GetSelf(PyObject *); diff --git a/Include/objimpl.h b/Include/objimpl.h index 94e03045f882a..c8e57c9755749 100644 --- a/Include/objimpl.h +++ b/Include/objimpl.h @@ -182,9 +182,9 @@ PyAPI_FUNC(void) PyObject_GC_UnTrack(void *); PyAPI_FUNC(void) PyObject_GC_Del(void *); #define PyObject_GC_New(type, typeobj) \ - _Py_reinterpret_cast(type*, _PyObject_GC_New(typeobj)) + _Py_reinterpret_cast(type*, _PyObject_GC_New(typeobj)) #define PyObject_GC_NewVar(type, typeobj, n) \ - _Py_reinterpret_cast(type*, _PyObject_GC_NewVar((typeobj), (n))) + _Py_reinterpret_cast(type*, _PyObject_GC_NewVar((typeobj), (n))) PyAPI_FUNC(int) PyObject_GC_IsTracked(PyObject *); PyAPI_FUNC(int) PyObject_GC_IsFinalized(PyObject *); diff --git a/Include/pyport.h b/Include/pyport.h index 923897305fc6b..3f5ce672bdafe 100644 --- a/Include/pyport.h +++ b/Include/pyport.h @@ -14,10 +14,20 @@ #endif -// Macro to use C++ static_cast<> and reinterpret_cast<> in the Python C API +// Macro to use C++ static_cast<>, reinterpret_cast<> and const_cast<> +// in the Python C API. +// +// In C++, _Py_reinterpret_cast(type, expr) converts a constant expression to a +// non constant type using const_cast. For example, +// _Py_reinterpret_cast(PyObject*, op) can convert a "const PyObject*" to +// "PyObject*". +// +// The type argument must not be constant. For example, in C++, +// _Py_reinterpret_cast(const PyObject*, expr) fails with a compiler error. #ifdef __cplusplus # define _Py_static_cast(type, expr) static_cast(expr) -# define _Py_reinterpret_cast(type, expr) reinterpret_cast(expr) +# define _Py_reinterpret_cast(type, expr) \ + const_cast(reinterpret_cast(expr)) #else # define _Py_static_cast(type, expr) ((type)(expr)) # define _Py_reinterpret_cast(type, expr) ((type)(expr)) @@ -307,10 +317,10 @@ extern "C" { */ #ifdef Py_DEBUG # define Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW) \ - (assert((WIDE)(NARROW)(VALUE) == (VALUE)), (NARROW)(VALUE)) + (assert(_Py_static_cast(WIDE, _Py_static_cast(NARROW, (VALUE))) == (VALUE)), \ + _Py_static_cast(NARROW, (VALUE))) #else -# define Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW) \ - _Py_reinterpret_cast(NARROW, (VALUE)) +# define Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW) _Py_static_cast(NARROW, (VALUE)) #endif diff --git a/Lib/test/_testcppext.cpp b/Lib/test/_testcppext.cpp index 14cd1ddad1757..257843bfc7726 100644 --- a/Lib/test/_testcppext.cpp +++ b/Lib/test/_testcppext.cpp @@ -1,6 +1,9 @@ // gh-91321: Very basic C++ test extension to check that the Python C API is // compatible with C++ and does not emit C++ compiler warnings. +// Always enable assertions +#undef NDEBUG + #include "Python.h" PyDoc_STRVAR(_testcppext_add_doc, @@ -20,8 +23,36 @@ _testcppext_add(PyObject *Py_UNUSED(module), PyObject *args) } +static PyObject * +test_api_casts(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args)) +{ + PyObject *obj = Py_BuildValue("(ii)", 1, 2); + if (obj == nullptr) { + return nullptr; + } + + // gh-92138: For backward compatibility, functions of Python C API accepts + // "const PyObject*". Check that using it does not emit C++ compiler + // warnings. + const PyObject *const_obj = obj; + Py_INCREF(const_obj); + Py_DECREF(const_obj); + PyTypeObject *type = Py_TYPE(const_obj); + assert(Py_REFCNT(const_obj) >= 1); + + assert(type == &PyTuple_Type); + assert(PyTuple_GET_SIZE(const_obj) == 2); + PyObject *one = PyTuple_GET_ITEM(const_obj, 0); + assert(PyLong_AsLong(one) == 1); + + Py_DECREF(obj); + Py_RETURN_NONE; +} + + static PyMethodDef _testcppext_methods[] = { {"add", _testcppext_add, METH_VARARGS, _testcppext_add_doc}, + {"test_api_casts", test_api_casts, METH_NOARGS, NULL}, {nullptr, nullptr, 0, nullptr} /* sentinel */ }; diff --git a/Lib/test/test_cppext.py b/Lib/test/test_cppext.py index c1d02bc54b389..99f6062d79d47 100644 --- a/Lib/test/test_cppext.py +++ b/Lib/test/test_cppext.py @@ -1,5 +1,6 @@ # gh-91321: Build a basic C++ test extension to check that the Python C API is # compatible with C++ and does not emit C++ compiler warnings. +import contextlib import os import sys import unittest @@ -39,17 +40,24 @@ def build(self): sources=[SOURCE], language='c++', extra_compile_args=CPPFLAGS) + capture_stdout = (not support.verbose) try: try: - with (support.captured_stdout() as stdout, - support.swap_attr(sys, 'argv', ['setup.py', 'build_ext'])): + if capture_stdout: + stdout = support.captured_stdout() + else: + print() + stdout = contextlib.nullcontext() + with (stdout, + support.swap_attr(sys, 'argv', ['setup.py', 'build_ext', '--verbose'])): setup(name="_testcppext", ext_modules=[cpp_ext]) return except: - # Show output on error - print() - print(stdout.getvalue()) + if capture_stdout: + # Show output on error + print() + print(stdout.getvalue()) raise except SystemExit: self.fail("Build failed") From webhook-mailer at python.org Mon May 2 11:08:48 2022 From: webhook-mailer at python.org (miss-islington) Date: Mon, 02 May 2022 15:08:48 -0000 Subject: [Python-checkins] gh-85133: os docs: Add that getenv uses os.environ (GH-91874) Message-ID: https://github.com/python/cpython/commit/5a0f3ae22f8e56fe2e149a73329bd4bcc8987eda commit: 5a0f3ae22f8e56fe2e149a73329bd4bcc8987eda branch: 3.9 author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com> committer: miss-islington <31488909+miss-islington at users.noreply.github.com> date: 2022-05-02T08:08:40-07:00 summary: gh-85133: os docs: Add that getenv uses os.environ (GH-91874) Co-authored-by: Jelle Zijlstra (cherry picked from commit b25352a5c039d95e019dd8ca111f6f77c43ca1f7) Co-authored-by: slateny <46876382+slateny at users.noreply.github.com> files: M Doc/library/os.rst diff --git a/Doc/library/os.rst b/Doc/library/os.rst index f8985a1f3ab9d..35a7e1e96d346 100644 --- a/Doc/library/os.rst +++ b/Doc/library/os.rst @@ -109,8 +109,8 @@ process and user. This mapping is captured the first time the :mod:`os` module is imported, typically during Python startup as part of processing :file:`site.py`. Changes - to the environment made after this time are not reflected in ``os.environ``, - except for changes made by modifying ``os.environ`` directly. + to the environment made after this time are not reflected in :data:`os.environ`, + except for changes made by modifying :data:`os.environ` directly. This mapping may be used to modify the environment as well as query the environment. :func:`putenv` will be called automatically when the mapping @@ -122,8 +122,8 @@ process and user. .. note:: - Calling :func:`putenv` directly does not change ``os.environ``, so it's better - to modify ``os.environ``. + Calling :func:`putenv` directly does not change :data:`os.environ`, so it's better + to modify :data:`os.environ`. .. note:: @@ -133,7 +133,7 @@ process and user. You can delete items in this mapping to unset environment variables. :func:`unsetenv` will be called automatically when an item is deleted from - ``os.environ``, and when one of the :meth:`pop` or :meth:`clear` methods is + :data:`os.environ`, and when one of the :meth:`pop` or :meth:`clear` methods is called. .. versionchanged:: 3.9 @@ -224,7 +224,10 @@ process and user. .. function:: getenv(key, default=None) Return the value of the environment variable *key* if it exists, or - *default* if it doesn't. *key*, *default* and the result are str. + *default* if it doesn't. *key*, *default* and the result are str. Note that + since :func:`getenv` uses :data:`os.environ`, the mapping of :func:`getenv` is + similarly also captured on import, and the function may not reflect + future environment changes. On Unix, keys and values are decoded with :func:`sys.getfilesystemencoding` and ``'surrogateescape'`` error handler. Use :func:`os.getenvb` if you @@ -236,7 +239,11 @@ process and user. .. function:: getenvb(key, default=None) Return the value of the environment variable *key* if it exists, or - *default* if it doesn't. *key*, *default* and the result are bytes. + *default* if it doesn't. *key*, *default* and the result are bytes. Note that + since :func:`getenvb` uses :data:`os.environb`, the mapping of :func:`getenvb` is + similarly also captured on import, and the function may not reflect + future environment changes. + :func:`getenvb` is only available if :data:`supports_bytes_environ` is ``True``. @@ -443,10 +450,11 @@ process and user. changes to the environment affect subprocesses started with :func:`os.system`, :func:`popen` or :func:`fork` and :func:`execv`. - Assignments to items in ``os.environ`` are automatically translated into + Assignments to items in :data:`os.environ` are automatically translated into corresponding calls to :func:`putenv`; however, calls to :func:`putenv` - don't update ``os.environ``, so it is actually preferable to assign to items - of ``os.environ``. + don't update :data:`os.environ`, so it is actually preferable to assign to items + of :data:`os.environ`. This also applies to :func:`getenv` and :func:`getenvb`, which + respectively use :data:`os.environ` and :data:`os.environb` in their implementations. .. note:: @@ -645,10 +653,10 @@ process and user. environment affect subprocesses started with :func:`os.system`, :func:`popen` or :func:`fork` and :func:`execv`. - Deletion of items in ``os.environ`` is automatically translated into a + Deletion of items in :data:`os.environ` is automatically translated into a corresponding call to :func:`unsetenv`; however, calls to :func:`unsetenv` - don't update ``os.environ``, so it is actually preferable to delete items of - ``os.environ``. + don't update :data:`os.environ`, so it is actually preferable to delete items of + :data:`os.environ`. .. audit-event:: os.unsetenv key os.unsetenv From webhook-mailer at python.org Mon May 2 11:10:08 2022 From: webhook-mailer at python.org (JelleZijlstra) Date: Mon, 02 May 2022 15:10:08 -0000 Subject: [Python-checkins] gh-92128: Add `__class_getitem__` to `logging.LoggerAdapter` and `logging.StreamHandler` (#92129) Message-ID: https://github.com/python/cpython/commit/ab616d323dbc473f8d5563b596e882ed3ccdf77b commit: ab616d323dbc473f8d5563b596e882ed3ccdf77b branch: main author: Alex Waygood committer: JelleZijlstra date: 2022-05-02T09:10:02-06:00 summary: gh-92128: Add `__class_getitem__` to `logging.LoggerAdapter` and `logging.StreamHandler` (#92129) Closes #92128 files: A Misc/NEWS.d/next/Library/2022-05-01-21-45-41.gh-issue-92128.Di7VbE.rst M Lib/logging/__init__.py M Lib/test/test_genericalias.py diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py index d6315b047334e..432fefcb5b314 100644 --- a/Lib/logging/__init__.py +++ b/Lib/logging/__init__.py @@ -25,6 +25,7 @@ import sys, os, time, io, re, traceback, warnings, weakref, collections.abc +from types import GenericAlias from string import Template from string import Formatter as StrFormatter @@ -1145,6 +1146,8 @@ def __repr__(self): name += ' ' return '<%s %s(%s)>' % (self.__class__.__name__, name, level) + __class_getitem__ = classmethod(GenericAlias) + class FileHandler(StreamHandler): """ @@ -1939,6 +1942,8 @@ def __repr__(self): level = getLevelName(logger.getEffectiveLevel()) return '<%s %s (%s)>' % (self.__class__.__name__, logger.name, level) + __class_getitem__ = classmethod(GenericAlias) + root = RootLogger(WARNING) Logger.root = root Logger.manager = Manager(Logger.root) diff --git a/Lib/test/test_genericalias.py b/Lib/test/test_genericalias.py index bf96ba065fbb0..635ac0f7a85d7 100644 --- a/Lib/test/test_genericalias.py +++ b/Lib/test/test_genericalias.py @@ -14,6 +14,7 @@ from dataclasses import Field from functools import partial, partialmethod, cached_property from graphlib import TopologicalSorter +from logging import LoggerAdapter, StreamHandler from mailbox import Mailbox, _PartialFile try: import ctypes @@ -113,6 +114,7 @@ class BaseTest(unittest.TestCase): MappingProxyType, AsyncGeneratorType, DirEntry, chain, + LoggerAdapter, StreamHandler, TemporaryDirectory, SpooledTemporaryFile, Queue, SimpleQueue, _AssertRaisesContext, diff --git a/Misc/NEWS.d/next/Library/2022-05-01-21-45-41.gh-issue-92128.Di7VbE.rst b/Misc/NEWS.d/next/Library/2022-05-01-21-45-41.gh-issue-92128.Di7VbE.rst new file mode 100644 index 0000000000000..e4d62d221d8a0 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2022-05-01-21-45-41.gh-issue-92128.Di7VbE.rst @@ -0,0 +1,3 @@ +Add :meth:`~object.__class_getitem__` to :class:`logging.LoggerAdapter` and +:class:`logging.StreamHandler`, allowing them to be parameterized at runtime. +Patch by Alex Waygood. From webhook-mailer at python.org Mon May 2 11:11:14 2022 From: webhook-mailer at python.org (JelleZijlstra) Date: Mon, 02 May 2022 15:11:14 -0000 Subject: [Python-checkins] gh-88546: glob.glob docs: Make new paragraph for emphasis and reordered sentence (#91614) Message-ID: https://github.com/python/cpython/commit/b9ab6cea0819bd498063f0934cb5bb0bb5a6a2d4 commit: b9ab6cea0819bd498063f0934cb5bb0bb5a6a2d4 branch: main author: slateny <46876382+slateny at users.noreply.github.com> committer: JelleZijlstra date: 2022-05-02T09:11:05-06:00 summary: gh-88546: glob.glob docs: Make new paragraph for emphasis and reordered sentence (#91614) files: M Doc/library/glob.rst diff --git a/Doc/library/glob.rst b/Doc/library/glob.rst index 54621d1d12bb5..01ad67732cf2e 100644 --- a/Doc/library/glob.rst +++ b/Doc/library/glob.rst @@ -23,8 +23,11 @@ according to the rules used by the Unix shell, although results are returned in arbitrary order. No tilde expansion is done, but ``*``, ``?``, and character ranges expressed with ``[]`` will be correctly matched. This is done by using the :func:`os.scandir` and :func:`fnmatch.fnmatch` functions in concert, and -not by actually invoking a subshell. Note that unlike :func:`fnmatch.fnmatch`, -:mod:`glob` treats filenames beginning with a dot (``.``) as special cases. +not by actually invoking a subshell. + +Note that files beginning with a dot (``.``) can only be matched by +patterns that also start with a dot, +unlike :func:`fnmatch.fnmatch` or :func:`pathlib.Path.glob`. (For tilde and shell variable expansion, use :func:`os.path.expanduser` and :func:`os.path.expandvars`.) From webhook-mailer at python.org Mon May 2 11:18:10 2022 From: webhook-mailer at python.org (miss-islington) Date: Mon, 02 May 2022 15:18:10 -0000 Subject: [Python-checkins] asyncio.subprocess: Fix a typo in doc (GH-92030) Message-ID: https://github.com/python/cpython/commit/9941640041ef528dc6565ae7b2d1d26efdf8d19e commit: 9941640041ef528dc6565ae7b2d1d26efdf8d19e branch: 3.10 author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com> committer: miss-islington <31488909+miss-islington at users.noreply.github.com> date: 2022-05-02T08:18:01-07:00 summary: asyncio.subprocess: Fix a typo in doc (GH-92030) Remove a confusion for read method in asyncio-subprocess doc for stderr StreamReader instance (cherry picked from commit bb857a96ef368ba9de1da2db12b1a1f1870606ac) Co-authored-by: Harsh <65716674+Harsh-br0 at users.noreply.github.com> files: M Doc/library/asyncio-subprocess.rst diff --git a/Doc/library/asyncio-subprocess.rst b/Doc/library/asyncio-subprocess.rst index 748b704032554..e5000532a895d 100644 --- a/Doc/library/asyncio-subprocess.rst +++ b/Doc/library/asyncio-subprocess.rst @@ -275,7 +275,7 @@ their completion. Use the :meth:`communicate` method rather than :attr:`process.stdin.write() `, :attr:`await process.stdout.read() ` or - :attr:`await process.stderr.read `. + :attr:`await process.stderr.read() `. This avoids deadlocks due to streams pausing reading or writing and blocking the child process. From webhook-mailer at python.org Mon May 2 11:20:17 2022 From: webhook-mailer at python.org (miss-islington) Date: Mon, 02 May 2022 15:20:17 -0000 Subject: [Python-checkins] Fix typo in Programming FAQ (GH-92083) Message-ID: https://github.com/python/cpython/commit/090a0f6ffbde8f9e4d7bb57b29da140c6d4c8db3 commit: 090a0f6ffbde8f9e4d7bb57b29da140c6d4c8db3 branch: 3.9 author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com> committer: miss-islington <31488909+miss-islington at users.noreply.github.com> date: 2022-05-02T08:20:09-07:00 summary: Fix typo in Programming FAQ (GH-92083) I believe the word "with" was missing here. (cherry picked from commit 2a7efa324274a54fe0e5480cae1438d8294b9ec3) Co-authored-by: Matt Harding files: M Doc/faq/programming.rst diff --git a/Doc/faq/programming.rst b/Doc/faq/programming.rst index 3cf041e1a4230..c2656382aad78 100644 --- a/Doc/faq/programming.rst +++ b/Doc/faq/programming.rst @@ -78,7 +78,7 @@ set of modules required by a program and bind these modules together with a Python binary to produce a single executable. One is to use the freeze tool, which is included in the Python source tree as -``Tools/freeze``. It converts Python byte code to C arrays; a C compiler you can +``Tools/freeze``. It converts Python byte code to C arrays; with a C compiler you can embed all your modules into a new program, which is then linked with the standard Python modules. From webhook-mailer at python.org Mon May 2 11:20:29 2022 From: webhook-mailer at python.org (miss-islington) Date: Mon, 02 May 2022 15:20:29 -0000 Subject: [Python-checkins] asyncio.subprocess: Fix a typo in doc (GH-92030) Message-ID: https://github.com/python/cpython/commit/0c011cc6c2a7629b8120ec26d7776713c096e69c commit: 0c011cc6c2a7629b8120ec26d7776713c096e69c branch: 3.9 author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com> committer: miss-islington <31488909+miss-islington at users.noreply.github.com> date: 2022-05-02T08:20:25-07:00 summary: asyncio.subprocess: Fix a typo in doc (GH-92030) Remove a confusion for read method in asyncio-subprocess doc for stderr StreamReader instance (cherry picked from commit bb857a96ef368ba9de1da2db12b1a1f1870606ac) Co-authored-by: Harsh <65716674+Harsh-br0 at users.noreply.github.com> files: M Doc/library/asyncio-subprocess.rst diff --git a/Doc/library/asyncio-subprocess.rst b/Doc/library/asyncio-subprocess.rst index 6ba24249f28d8..fbe68f78a2f9b 100644 --- a/Doc/library/asyncio-subprocess.rst +++ b/Doc/library/asyncio-subprocess.rst @@ -278,7 +278,7 @@ their completion. Use the :meth:`communicate` method rather than :attr:`process.stdin.write() `, :attr:`await process.stdout.read() ` or - :attr:`await process.stderr.read `. + :attr:`await process.stderr.read() `. This avoids deadlocks due to streams pausing reading or writing and blocking the child process. From webhook-mailer at python.org Mon May 2 11:34:01 2022 From: webhook-mailer at python.org (miss-islington) Date: Mon, 02 May 2022 15:34:01 -0000 Subject: [Python-checkins] gh-88546: glob.glob docs: Make new paragraph for emphasis and reordered sentence (GH-91614) Message-ID: https://github.com/python/cpython/commit/9b7cdfdf357fa819fd47f0ebe1c0e2010a5d4e31 commit: 9b7cdfdf357fa819fd47f0ebe1c0e2010a5d4e31 branch: 3.9 author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com> committer: miss-islington <31488909+miss-islington at users.noreply.github.com> date: 2022-05-02T08:33:39-07:00 summary: gh-88546: glob.glob docs: Make new paragraph for emphasis and reordered sentence (GH-91614) (cherry picked from commit b9ab6cea0819bd498063f0934cb5bb0bb5a6a2d4) Co-authored-by: slateny <46876382+slateny at users.noreply.github.com> files: M Doc/library/glob.rst diff --git a/Doc/library/glob.rst b/Doc/library/glob.rst index 3c468ebf73769..ced84c7fd8d11 100644 --- a/Doc/library/glob.rst +++ b/Doc/library/glob.rst @@ -23,8 +23,11 @@ according to the rules used by the Unix shell, although results are returned in arbitrary order. No tilde expansion is done, but ``*``, ``?``, and character ranges expressed with ``[]`` will be correctly matched. This is done by using the :func:`os.scandir` and :func:`fnmatch.fnmatch` functions in concert, and -not by actually invoking a subshell. Note that unlike :func:`fnmatch.fnmatch`, -:mod:`glob` treats filenames beginning with a dot (``.``) as special cases. +not by actually invoking a subshell. + +Note that files beginning with a dot (``.``) can only be matched by +patterns that also start with a dot, +unlike :func:`fnmatch.fnmatch` or :func:`pathlib.Path.glob`. (For tilde and shell variable expansion, use :func:`os.path.expanduser` and :func:`os.path.expandvars`.) From webhook-mailer at python.org Mon May 2 11:35:49 2022 From: webhook-mailer at python.org (miss-islington) Date: Mon, 02 May 2022 15:35:49 -0000 Subject: [Python-checkins] gh-88546: glob.glob docs: Make new paragraph for emphasis and reordered sentence (GH-91614) Message-ID: https://github.com/python/cpython/commit/446cc037304e55e94c2e7492533f7b396c9c0e35 commit: 446cc037304e55e94c2e7492533f7b396c9c0e35 branch: 3.10 author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com> committer: miss-islington <31488909+miss-islington at users.noreply.github.com> date: 2022-05-02T08:35:37-07:00 summary: gh-88546: glob.glob docs: Make new paragraph for emphasis and reordered sentence (GH-91614) (cherry picked from commit b9ab6cea0819bd498063f0934cb5bb0bb5a6a2d4) Co-authored-by: slateny <46876382+slateny at users.noreply.github.com> files: M Doc/library/glob.rst diff --git a/Doc/library/glob.rst b/Doc/library/glob.rst index 215f60d328c76..4a290473d8924 100644 --- a/Doc/library/glob.rst +++ b/Doc/library/glob.rst @@ -23,8 +23,11 @@ according to the rules used by the Unix shell, although results are returned in arbitrary order. No tilde expansion is done, but ``*``, ``?``, and character ranges expressed with ``[]`` will be correctly matched. This is done by using the :func:`os.scandir` and :func:`fnmatch.fnmatch` functions in concert, and -not by actually invoking a subshell. Note that unlike :func:`fnmatch.fnmatch`, -:mod:`glob` treats filenames beginning with a dot (``.``) as special cases. +not by actually invoking a subshell. + +Note that files beginning with a dot (``.``) can only be matched by +patterns that also start with a dot, +unlike :func:`fnmatch.fnmatch` or :func:`pathlib.Path.glob`. (For tilde and shell variable expansion, use :func:`os.path.expanduser` and :func:`os.path.expandvars`.) From webhook-mailer at python.org Mon May 2 11:51:26 2022 From: webhook-mailer at python.org (iritkatriel) Date: Mon, 02 May 2022 15:51:26 -0000 Subject: [Python-checkins] gh-91276: revert the increase of dis output width (GH-92126) Message-ID: https://github.com/python/cpython/commit/84b986ba10d704394aa36955b00e6106ca25e8ba commit: 84b986ba10d704394aa36955b00e6106ca25e8ba branch: main author: Irit Katriel <1055913+iritkatriel at users.noreply.github.com> committer: iritkatriel <1055913+iritkatriel at users.noreply.github.com> date: 2022-05-02T16:51:17+01:00 summary: gh-91276: revert the increase of dis output width (GH-92126) files: M Lib/dis.py M Lib/test/test_dis.py diff --git a/Lib/dis.py b/Lib/dis.py index 205e9d8d193f3..c0e5367afb55a 100644 --- a/Lib/dis.py +++ b/Lib/dis.py @@ -264,7 +264,7 @@ def show_code(co, *, file=None): _ExceptionTableEntry = collections.namedtuple("_ExceptionTableEntry", "start end target depth lasti") -_OPNAME_WIDTH = max(map(len, opmap)) +_OPNAME_WIDTH = 20 _OPARG_WIDTH = 5 class Instruction(_Instruction): diff --git a/Lib/test/test_dis.py b/Lib/test/test_dis.py index 0bd589d5cfb6f..b8d1c542bae90 100644 --- a/Lib/test/test_dis.py +++ b/Lib/test/test_dis.py @@ -41,48 +41,48 @@ def cm(cls, x): cls.x = x == 1 dis_c_instance_method = """\ -%3d RESUME 0 - -%3d LOAD_FAST 1 (x) - LOAD_CONST 1 (1) - COMPARE_OP 2 (==) - LOAD_FAST 0 (self) - STORE_ATTR 0 (x) - LOAD_CONST 0 (None) +%3d RESUME 0 + +%3d LOAD_FAST 1 (x) + LOAD_CONST 1 (1) + COMPARE_OP 2 (==) + LOAD_FAST 0 (self) + STORE_ATTR 0 (x) + LOAD_CONST 0 (None) RETURN_VALUE """ % (_C.__init__.__code__.co_firstlineno, _C.__init__.__code__.co_firstlineno + 1,) dis_c_instance_method_bytes = """\ - RESUME 0 - LOAD_FAST 1 - LOAD_CONST 1 - COMPARE_OP 2 (==) - LOAD_FAST 0 - STORE_ATTR 0 - LOAD_CONST 0 + RESUME 0 + LOAD_FAST 1 + LOAD_CONST 1 + COMPARE_OP 2 (==) + LOAD_FAST 0 + STORE_ATTR 0 + LOAD_CONST 0 RETURN_VALUE """ dis_c_class_method = """\ -%3d RESUME 0 - -%3d LOAD_FAST 1 (x) - LOAD_CONST 1 (1) - COMPARE_OP 2 (==) - LOAD_FAST 0 (cls) - STORE_ATTR 0 (x) - LOAD_CONST 0 (None) +%3d RESUME 0 + +%3d LOAD_FAST 1 (x) + LOAD_CONST 1 (1) + COMPARE_OP 2 (==) + LOAD_FAST 0 (cls) + STORE_ATTR 0 (x) + LOAD_CONST 0 (None) RETURN_VALUE """ % (_C.cm.__code__.co_firstlineno, _C.cm.__code__.co_firstlineno + 2,) dis_c_static_method = """\ -%3d RESUME 0 +%3d RESUME 0 -%3d LOAD_FAST 0 (x) - LOAD_CONST 1 (1) - COMPARE_OP 2 (==) - STORE_FAST 0 (x) - LOAD_CONST 0 (None) +%3d LOAD_FAST 0 (x) + LOAD_CONST 1 (1) + COMPARE_OP 2 (==) + STORE_FAST 0 (x) + LOAD_CONST 0 (None) RETURN_VALUE """ % (_C.sm.__code__.co_firstlineno, _C.sm.__code__.co_firstlineno + 2,) @@ -103,15 +103,15 @@ def _f(a): return 1 dis_f = """\ -%3d RESUME 0 +%3d RESUME 0 -%3d LOAD_GLOBAL 1 (NULL + print) - LOAD_FAST 0 (a) - PRECALL 1 - CALL 1 +%3d LOAD_GLOBAL 1 (NULL + print) + LOAD_FAST 0 (a) + PRECALL 1 + CALL 1 POP_TOP -%3d LOAD_CONST 1 (1) +%3d LOAD_CONST 1 (1) RETURN_VALUE """ % (_f.__code__.co_firstlineno, _f.__code__.co_firstlineno + 1, @@ -119,13 +119,13 @@ def _f(a): dis_f_co_code = """\ - RESUME 0 - LOAD_GLOBAL 1 - LOAD_FAST 0 - PRECALL 1 - CALL 1 + RESUME 0 + LOAD_GLOBAL 1 + LOAD_FAST 0 + PRECALL 1 + CALL 1 POP_TOP - LOAD_CONST 1 + LOAD_CONST 1 RETURN_VALUE """ @@ -136,22 +136,22 @@ def bug708901(): pass dis_bug708901 = """\ -%3d RESUME 0 +%3d RESUME 0 -%3d LOAD_GLOBAL 1 (NULL + range) - LOAD_CONST 1 (1) +%3d LOAD_GLOBAL 1 (NULL + range) + LOAD_CONST 1 (1) -%3d LOAD_CONST 2 (10) +%3d LOAD_CONST 2 (10) -%3d PRECALL 2 - CALL 2 +%3d PRECALL 2 + CALL 2 GET_ITER - >> FOR_ITER 2 (to 40) - STORE_FAST 0 (res) + >> FOR_ITER 2 (to 40) + STORE_FAST 0 (res) -%3d JUMP_BACKWARD 3 (to 34) +%3d JUMP_BACKWARD 3 (to 34) -%3d >> LOAD_CONST 0 (None) +%3d >> LOAD_CONST 0 (None) RETURN_VALUE """ % (bug708901.__code__.co_firstlineno, bug708901.__code__.co_firstlineno + 1, @@ -167,22 +167,22 @@ def bug1333982(x=[]): pass dis_bug1333982 = """\ -%3d RESUME 0 +%3d RESUME 0 %3d LOAD_ASSERTION_ERROR - LOAD_CONST 2 ( at 0x..., file "%s", line %d>) - MAKE_FUNCTION 0 - LOAD_FAST 0 (x) + LOAD_CONST 2 ( at 0x..., file "%s", line %d>) + MAKE_FUNCTION 0 + LOAD_FAST 0 (x) GET_ITER - PRECALL 0 - CALL 0 + PRECALL 0 + CALL 0 -%3d LOAD_CONST 3 (1) +%3d LOAD_CONST 3 (1) -%3d BINARY_OP 0 (+) - PRECALL 0 - CALL 0 - RAISE_VARARGS 1 +%3d BINARY_OP 0 (+) + PRECALL 0 + CALL 0 + RAISE_VARARGS 1 """ % (bug1333982.__code__.co_firstlineno, bug1333982.__code__.co_firstlineno + 1, __file__, @@ -200,8 +200,8 @@ def bug42562(): dis_bug42562 = """\ - RESUME 0 - LOAD_CONST 0 (None) + RESUME 0 + LOAD_CONST 0 (None) RETURN_VALUE """ @@ -215,10 +215,10 @@ def bug42562(): ]) dis_bug_45757 = """\ - EXTENDED_ARG 1 + EXTENDED_ARG 1 NOP - EXTENDED_ARG 1 - LOAD_CONST 297 + EXTENDED_ARG 1 + LOAD_CONST 297 RETURN_VALUE """ @@ -232,39 +232,39 @@ def bug42562(): dis_bug46724 = """\ - >> EXTENDED_ARG 255 - EXTENDED_ARG 65535 - EXTENDED_ARG 16777215 - JUMP_FORWARD -4 (to 0) + >> EXTENDED_ARG 255 + EXTENDED_ARG 65535 + EXTENDED_ARG 16777215 + JUMP_FORWARD -4 (to 0) """ _BIG_LINENO_FORMAT = """\ - 1 RESUME 0 + 1 RESUME 0 -%3d LOAD_GLOBAL 0 (spam) +%3d LOAD_GLOBAL 0 (spam) POP_TOP - LOAD_CONST 0 (None) + LOAD_CONST 0 (None) RETURN_VALUE """ _BIG_LINENO_FORMAT2 = """\ - 1 RESUME 0 + 1 RESUME 0 -%4d LOAD_GLOBAL 0 (spam) +%4d LOAD_GLOBAL 0 (spam) POP_TOP - LOAD_CONST 0 (None) + LOAD_CONST 0 (None) RETURN_VALUE """ dis_module_expected_results = """\ Disassembly of f: - 4 RESUME 0 - LOAD_CONST 0 (None) + 4 RESUME 0 + LOAD_CONST 0 (None) RETURN_VALUE Disassembly of g: - 5 RESUME 0 - LOAD_CONST 0 (None) + 5 RESUME 0 + LOAD_CONST 0 (None) RETURN_VALUE """ @@ -272,24 +272,24 @@ def bug42562(): expr_str = "x + 1" dis_expr_str = """\ - RESUME 0 + RESUME 0 - 1 LOAD_NAME 0 (x) - LOAD_CONST 0 (1) - BINARY_OP 0 (+) + 1 LOAD_NAME 0 (x) + LOAD_CONST 0 (1) + BINARY_OP 0 (+) RETURN_VALUE """ simple_stmt_str = "x = x + 1" dis_simple_stmt_str = """\ - RESUME 0 + RESUME 0 - 1 LOAD_NAME 0 (x) - LOAD_CONST 0 (1) - BINARY_OP 0 (+) - STORE_NAME 0 (x) - LOAD_CONST 1 (None) + 1 LOAD_NAME 0 (x) + LOAD_CONST 0 (1) + BINARY_OP 0 (+) + STORE_NAME 0 (x) + LOAD_CONST 1 (None) RETURN_VALUE """ @@ -302,36 +302,36 @@ def bug42562(): # leading newline is for a reason (tests lineno) dis_annot_stmt_str = """\ - RESUME 0 + RESUME 0 2 SETUP_ANNOTATIONS - LOAD_CONST 0 (1) - STORE_NAME 0 (x) - LOAD_NAME 1 (int) - LOAD_NAME 2 (__annotations__) - LOAD_CONST 1 ('x') + LOAD_CONST 0 (1) + STORE_NAME 0 (x) + LOAD_NAME 1 (int) + LOAD_NAME 2 (__annotations__) + LOAD_CONST 1 ('x') STORE_SUBSCR 3 PUSH_NULL - LOAD_NAME 3 (fun) - LOAD_CONST 0 (1) - PRECALL 1 - CALL 1 - LOAD_NAME 2 (__annotations__) - LOAD_CONST 2 ('y') + LOAD_NAME 3 (fun) + LOAD_CONST 0 (1) + PRECALL 1 + CALL 1 + LOAD_NAME 2 (__annotations__) + LOAD_CONST 2 ('y') STORE_SUBSCR - 4 LOAD_CONST 0 (1) - LOAD_NAME 4 (lst) + 4 LOAD_CONST 0 (1) + LOAD_NAME 4 (lst) PUSH_NULL - LOAD_NAME 3 (fun) - LOAD_CONST 3 (0) - PRECALL 1 - CALL 1 + LOAD_NAME 3 (fun) + LOAD_CONST 3 (0) + PRECALL 1 + CALL 1 STORE_SUBSCR - LOAD_NAME 1 (int) + LOAD_NAME 1 (int) POP_TOP - LOAD_CONST 4 (None) + LOAD_CONST 4 (None) RETURN_VALUE """ @@ -342,59 +342,59 @@ def bug42562(): # Trailing newline has been deliberately omitted dis_compound_stmt_str = """\ - RESUME 0 + RESUME 0 - 1 LOAD_CONST 0 (0) - STORE_NAME 0 (x) + 1 LOAD_CONST 0 (0) + STORE_NAME 0 (x) 2 NOP - 3 >> LOAD_NAME 0 (x) - LOAD_CONST 1 (1) - BINARY_OP 13 (+=) - STORE_NAME 0 (x) + 3 >> LOAD_NAME 0 (x) + LOAD_CONST 1 (1) + BINARY_OP 13 (+=) + STORE_NAME 0 (x) - 2 JUMP_BACKWARD 6 (to 8) + 2 JUMP_BACKWARD 6 (to 8) """ dis_traceback = """\ -%3d RESUME 0 +%3d RESUME 0 %3d NOP -%3d LOAD_CONST 1 (1) - LOAD_CONST 2 (0) - --> BINARY_OP 11 (/) +%3d LOAD_CONST 1 (1) + LOAD_CONST 2 (0) + --> BINARY_OP 11 (/) POP_TOP -%3d LOAD_FAST 1 (tb) +%3d LOAD_FAST 1 (tb) RETURN_VALUE >> PUSH_EXC_INFO -%3d LOAD_GLOBAL 0 (Exception) +%3d LOAD_GLOBAL 0 (Exception) CHECK_EXC_MATCH - POP_JUMP_FORWARD_IF_FALSE 18 (to 72) - STORE_FAST 0 (e) + POP_JUMP_FORWARD_IF_FALSE 18 (to 72) + STORE_FAST 0 (e) -%3d LOAD_FAST 0 (e) - LOAD_ATTR 1 (__traceback__) - STORE_FAST 1 (tb) +%3d LOAD_FAST 0 (e) + LOAD_ATTR 1 (__traceback__) + STORE_FAST 1 (tb) POP_EXCEPT - LOAD_CONST 0 (None) - STORE_FAST 0 (e) - DELETE_FAST 0 (e) + LOAD_CONST 0 (None) + STORE_FAST 0 (e) + DELETE_FAST 0 (e) -%3d LOAD_FAST 1 (tb) +%3d LOAD_FAST 1 (tb) RETURN_VALUE - >> LOAD_CONST 0 (None) - STORE_FAST 0 (e) - DELETE_FAST 0 (e) - RERAISE 1 + >> LOAD_CONST 0 (None) + STORE_FAST 0 (e) + DELETE_FAST 0 (e) + RERAISE 1 -%3d >> RERAISE 0 - >> COPY 3 +%3d >> RERAISE 0 + >> COPY 3 POP_EXCEPT - RERAISE 1 + RERAISE 1 ExceptionTable: """ % (TRACEBACK_CODE.co_firstlineno, TRACEBACK_CODE.co_firstlineno + 1, @@ -409,22 +409,22 @@ def _fstring(a, b, c, d): return f'{a} {b:4} {c!r} {d!r:4}' dis_fstring = """\ -%3d RESUME 0 - -%3d LOAD_FAST 0 (a) - FORMAT_VALUE 0 - LOAD_CONST 1 (' ') - LOAD_FAST 1 (b) - LOAD_CONST 2 ('4') - FORMAT_VALUE 4 (with format) - LOAD_CONST 1 (' ') - LOAD_FAST 2 (c) - FORMAT_VALUE 2 (repr) - LOAD_CONST 1 (' ') - LOAD_FAST 3 (d) - LOAD_CONST 2 ('4') - FORMAT_VALUE 6 (repr, with format) - BUILD_STRING 7 +%3d RESUME 0 + +%3d LOAD_FAST 0 (a) + FORMAT_VALUE 0 + LOAD_CONST 1 (' ') + LOAD_FAST 1 (b) + LOAD_CONST 2 ('4') + FORMAT_VALUE 4 (with format) + LOAD_CONST 1 (' ') + LOAD_FAST 2 (c) + FORMAT_VALUE 2 (repr) + LOAD_CONST 1 (' ') + LOAD_FAST 3 (d) + LOAD_CONST 2 ('4') + FORMAT_VALUE 6 (repr, with format) + BUILD_STRING 7 RETURN_VALUE """ % (_fstring.__code__.co_firstlineno, _fstring.__code__.co_firstlineno + 1) @@ -441,28 +441,28 @@ def _tryfinallyconst(b): b() dis_tryfinally = """\ -%3d RESUME 0 +%3d RESUME 0 %3d NOP -%3d LOAD_FAST 0 (a) +%3d LOAD_FAST 0 (a) %3d PUSH_NULL - LOAD_FAST 1 (b) - PRECALL 0 - CALL 0 + LOAD_FAST 1 (b) + PRECALL 0 + CALL 0 POP_TOP RETURN_VALUE >> PUSH_EXC_INFO PUSH_NULL - LOAD_FAST 1 (b) - PRECALL 0 - CALL 0 + LOAD_FAST 1 (b) + PRECALL 0 + CALL 0 POP_TOP - RERAISE 0 - >> COPY 3 + RERAISE 0 + >> COPY 3 POP_EXCEPT - RERAISE 1 + RERAISE 1 ExceptionTable: """ % (_tryfinally.__code__.co_firstlineno, _tryfinally.__code__.co_firstlineno + 1, @@ -471,29 +471,29 @@ def _tryfinallyconst(b): ) dis_tryfinallyconst = """\ -%3d RESUME 0 +%3d RESUME 0 %3d NOP %3d NOP %3d PUSH_NULL - LOAD_FAST 0 (b) - PRECALL 0 - CALL 0 + LOAD_FAST 0 (b) + PRECALL 0 + CALL 0 POP_TOP - LOAD_CONST 1 (1) + LOAD_CONST 1 (1) RETURN_VALUE PUSH_EXC_INFO PUSH_NULL - LOAD_FAST 0 (b) - PRECALL 0 - CALL 0 + LOAD_FAST 0 (b) + PRECALL 0 + CALL 0 POP_TOP - RERAISE 0 - >> COPY 3 + RERAISE 0 + >> COPY 3 POP_EXCEPT - RERAISE 1 + RERAISE 1 ExceptionTable: """ % (_tryfinallyconst.__code__.co_firstlineno, _tryfinallyconst.__code__.co_firstlineno + 1, @@ -518,17 +518,17 @@ def foo(x): return foo dis_nested_0 = """\ - MAKE_CELL 0 (y) + MAKE_CELL 0 (y) -%3d RESUME 0 +%3d RESUME 0 -%3d LOAD_CLOSURE 0 (y) - BUILD_TUPLE 1 - LOAD_CONST 1 () - MAKE_FUNCTION 8 (closure) - STORE_FAST 1 (foo) +%3d LOAD_CLOSURE 0 (y) + BUILD_TUPLE 1 + LOAD_CONST 1 () + MAKE_FUNCTION 8 (closure) + STORE_FAST 1 (foo) -%3d LOAD_FAST 1 (foo) +%3d LOAD_FAST 1 (foo) RETURN_VALUE """ % (_h.__code__.co_firstlineno, _h.__code__.co_firstlineno + 1, @@ -539,19 +539,19 @@ def foo(x): dis_nested_1 = """%s Disassembly of : - COPY_FREE_VARS 1 - MAKE_CELL 0 (x) + COPY_FREE_VARS 1 + MAKE_CELL 0 (x) -%3d RESUME 0 +%3d RESUME 0 -%3d LOAD_CLOSURE 0 (x) - BUILD_TUPLE 1 - LOAD_CONST 1 ( at 0x..., file "%s", line %d>) - MAKE_FUNCTION 8 (closure) - LOAD_DEREF 1 (y) +%3d LOAD_CLOSURE 0 (x) + BUILD_TUPLE 1 + LOAD_CONST 1 ( at 0x..., file "%s", line %d>) + MAKE_FUNCTION 8 (closure) + LOAD_DEREF 1 (y) GET_ITER - PRECALL 0 - CALL 0 + PRECALL 0 + CALL 0 RETURN_VALUE """ % (dis_nested_0, __file__, @@ -564,18 +564,18 @@ def foo(x): dis_nested_2 = """%s Disassembly of at 0x..., file "%s", line %d>: - COPY_FREE_VARS 1 - -%3d RESUME 0 - BUILD_LIST 0 - LOAD_FAST 0 (.0) - >> FOR_ITER 7 (to 24) - STORE_FAST 1 (z) - LOAD_DEREF 2 (x) - LOAD_FAST 1 (z) - BINARY_OP 0 (+) - LIST_APPEND 2 - JUMP_BACKWARD 8 (to 8) + COPY_FREE_VARS 1 + +%3d RESUME 0 + BUILD_LIST 0 + LOAD_FAST 0 (.0) + >> FOR_ITER 7 (to 24) + STORE_FAST 1 (z) + LOAD_DEREF 2 (x) + LOAD_FAST 1 (z) + BINARY_OP 0 (+) + LIST_APPEND 2 + JUMP_BACKWARD 8 (to 8) >> RETURN_VALUE """ % (dis_nested_1, __file__, @@ -588,16 +588,16 @@ def load_test(x, y=0): return a, b dis_load_test_quickened_code = """\ -%3d 0 RESUME_QUICK 0 +%3d 0 RESUME_QUICK 0 -%3d 2 LOAD_FAST__LOAD_FAST 0 (x) - 4 LOAD_FAST 1 (y) - 6 STORE_FAST__STORE_FAST 3 (b) - 8 STORE_FAST__LOAD_FAST 2 (a) +%3d 2 LOAD_FAST__LOAD_FAST 0 (x) + 4 LOAD_FAST 1 (y) + 6 STORE_FAST__STORE_FAST 3 (b) + 8 STORE_FAST__LOAD_FAST 2 (a) -%3d 10 LOAD_FAST__LOAD_FAST 2 (a) - 12 LOAD_FAST 3 (b) - 14 BUILD_TUPLE 2 +%3d 10 LOAD_FAST__LOAD_FAST 2 (a) + 12 LOAD_FAST 3 (b) + 14 BUILD_TUPLE 2 16 RETURN_VALUE """ % (load_test.__code__.co_firstlineno, load_test.__code__.co_firstlineno + 1, @@ -608,25 +608,25 @@ def loop_test(): load_test(i) dis_loop_test_quickened_code = """\ -%3d 0 RESUME_QUICK 0 +%3d 0 RESUME_QUICK 0 -%3d 2 BUILD_LIST 0 - 4 LOAD_CONST 1 ((1, 2, 3)) - 6 LIST_EXTEND 1 - 8 LOAD_CONST 2 (3) - 10 BINARY_OP_ADAPTIVE 5 (*) +%3d 2 BUILD_LIST 0 + 4 LOAD_CONST 1 ((1, 2, 3)) + 6 LIST_EXTEND 1 + 8 LOAD_CONST 2 (3) + 10 BINARY_OP_ADAPTIVE 5 (*) 14 GET_ITER - 16 FOR_ITER 17 (to 52) - 18 STORE_FAST 0 (i) + 16 FOR_ITER 17 (to 52) + 18 STORE_FAST 0 (i) -%3d 20 LOAD_GLOBAL_MODULE 1 (NULL + load_test) - 32 LOAD_FAST 0 (i) - 34 PRECALL_PYFUNC 1 - 38 CALL_PY_WITH_DEFAULTS 1 +%3d 20 LOAD_GLOBAL_MODULE 1 (NULL + load_test) + 32 LOAD_FAST 0 (i) + 34 PRECALL_PYFUNC 1 + 38 CALL_PY_WITH_DEFAULTS 1 48 POP_TOP - 50 JUMP_BACKWARD_QUICK 18 (to 16) + 50 JUMP_BACKWARD_QUICK 18 (to 16) -%3d >> 52 LOAD_CONST 0 (None) +%3d >> 52 LOAD_CONST 0 (None) 54 RETURN_VALUE """ % (loop_test.__code__.co_firstlineno, loop_test.__code__.co_firstlineno + 1, @@ -734,7 +734,19 @@ def test_boundaries(self): self.assertEqual(dis.opmap["STORE_NAME"], dis.HAVE_ARGUMENT) def test_widths(self): + long_opcodes = set(['POP_JUMP_FORWARD_IF_FALSE', + 'POP_JUMP_FORWARD_IF_TRUE', + 'POP_JUMP_FORWARD_IF_NOT_NONE', + 'POP_JUMP_FORWARD_IF_NONE', + 'POP_JUMP_BACKWARD_IF_FALSE', + 'POP_JUMP_BACKWARD_IF_TRUE', + 'POP_JUMP_BACKWARD_IF_NOT_NONE', + 'POP_JUMP_BACKWARD_IF_NONE', + 'JUMP_BACKWARD_NO_INTERRUPT', + ]) for opcode, opname in enumerate(dis.opname): + if opname in long_opcodes: + continue with self.subTest(opname=opname): width = dis._OPNAME_WIDTH if opcode < dis.HAVE_ARGUMENT: @@ -800,19 +812,19 @@ def func(count): def expected(count, w): s = ['''\ - 1 %*d RESUME 0 + 1 %*d RESUME 0 ''' % (w, 0)] s += ['''\ - %*d LOAD_FAST 0 (x) - %*d LOAD_CONST 1 (1) - %*d BINARY_OP 0 (+) - %*d STORE_FAST 0 (x) + %*d LOAD_FAST 0 (x) + %*d LOAD_CONST 1 (1) + %*d BINARY_OP 0 (+) + %*d STORE_FAST 0 (x) ''' % (w, 10*i + 2, w, 10*i + 4, w, 10*i + 6, w, 10*i + 10) for i in range(count)] s += ['''\ - 3 %*d LOAD_FAST 0 (x) + 3 %*d LOAD_FAST 0 (x) %*d RETURN_VALUE ''' % (w, 10*count + 2, w, 10*count + 4)] s[1] = ' 2' + s[1][3:] @@ -926,28 +938,28 @@ def test_super_instructions(self): @cpython_only def test_binary_specialize(self): binary_op_quicken = """\ - 0 RESUME_QUICK 0 + 0 RESUME_QUICK 0 - 1 2 LOAD_NAME 0 (a) - 4 LOAD_NAME 1 (b) + 1 2 LOAD_NAME 0 (a) + 4 LOAD_NAME 1 (b) 6 %s 10 RETURN_VALUE """ co_int = compile('a + b', "", "eval") self.code_quicken(lambda: exec(co_int, {}, {'a': 1, 'b': 2})) got = self.get_disassembly(co_int, adaptive=True) - self.do_disassembly_compare(got, binary_op_quicken % "BINARY_OP_ADD_INT 0 (+)", True) + self.do_disassembly_compare(got, binary_op_quicken % "BINARY_OP_ADD_INT 0 (+)", True) co_unicode = compile('a + b', "", "eval") self.code_quicken(lambda: exec(co_unicode, {}, {'a': 'a', 'b': 'b'})) got = self.get_disassembly(co_unicode, adaptive=True) - self.do_disassembly_compare(got, binary_op_quicken % "BINARY_OP_ADD_UNICODE 0 (+)", True) + self.do_disassembly_compare(got, binary_op_quicken % "BINARY_OP_ADD_UNICODE 0 (+)", True) binary_subscr_quicken = """\ - 0 RESUME_QUICK 0 + 0 RESUME_QUICK 0 - 1 2 LOAD_NAME 0 (a) - 4 LOAD_CONST 0 (0) + 1 2 LOAD_NAME 0 (a) + 4 LOAD_CONST 0 (0) 6 %s 16 RETURN_VALUE """ @@ -964,10 +976,10 @@ def test_binary_specialize(self): @cpython_only def test_load_attr_specialize(self): load_attr_quicken = """\ - 0 RESUME_QUICK 0 + 0 RESUME_QUICK 0 - 1 2 LOAD_CONST 0 ('a') - 4 LOAD_ATTR_SLOT 0 (__class__) + 1 2 LOAD_CONST 0 ('a') + 4 LOAD_ATTR_SLOT 0 (__class__) 14 RETURN_VALUE """ co = compile("'a'.__class__", "", "eval") @@ -978,13 +990,13 @@ def test_load_attr_specialize(self): @cpython_only def test_call_specialize(self): call_quicken = """\ - 0 RESUME_QUICK 0 + 0 RESUME_QUICK 0 1 2 PUSH_NULL - 4 LOAD_NAME 0 (str) - 6 LOAD_CONST 0 (1) - 8 PRECALL_NO_KW_STR_1 1 - 12 CALL_ADAPTIVE 1 + 4 LOAD_NAME 0 (str) + 6 LOAD_CONST 0 (1) + 8 PRECALL_NO_KW_STR_1 1 + 12 CALL_ADAPTIVE 1 22 RETURN_VALUE """ co = compile("str(1)", "", "eval") From webhook-mailer at python.org Mon May 2 12:06:47 2022 From: webhook-mailer at python.org (miss-islington) Date: Mon, 02 May 2022 16:06:47 -0000 Subject: [Python-checkins] concurrent.futures: Fix typo in docstring (GH-92121) Message-ID: https://github.com/python/cpython/commit/ac508276dc8c9e1ac0731ec7fce3aae3a378ffd1 commit: ac508276dc8c9e1ac0731ec7fce3aae3a378ffd1 branch: 3.10 author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com> committer: miss-islington <31488909+miss-islington at users.noreply.github.com> date: 2022-05-02T09:06:43-07:00 summary: concurrent.futures: Fix typo in docstring (GH-92121) (cherry picked from commit b11243e85e020ed2f524bdd83c339faf11ef03d4) Co-authored-by: Yiannis Hadjicharalambous files: M Lib/concurrent/futures/_base.py diff --git a/Lib/concurrent/futures/_base.py b/Lib/concurrent/futures/_base.py index 5c00f2edbe548..cf119ac6437aa 100644 --- a/Lib/concurrent/futures/_base.py +++ b/Lib/concurrent/futures/_base.py @@ -381,7 +381,7 @@ def running(self): return self._state == RUNNING def done(self): - """Return True of the future was cancelled or finished executing.""" + """Return True if the future was cancelled or finished executing.""" with self._condition: return self._state in [CANCELLED, CANCELLED_AND_NOTIFIED, FINISHED] From webhook-mailer at python.org Mon May 2 12:07:08 2022 From: webhook-mailer at python.org (JelleZijlstra) Date: Mon, 02 May 2022 16:07:08 -0000 Subject: [Python-checkins] [3.10] build(deps): bump actions/cache from 3.0.1 to 3.0.2 (GH-92111) (#92124) Message-ID: https://github.com/python/cpython/commit/67120224473f12e62a16a6985b9864b5cc3d0aa4 commit: 67120224473f12e62a16a6985b9864b5cc3d0aa4 branch: 3.10 author: Jelle Zijlstra committer: JelleZijlstra date: 2022-05-02T10:07:03-06:00 summary: [3.10] build(deps): bump actions/cache from 3.0.1 to 3.0.2 (GH-92111) (#92124) Bumps [actions/cache](https://github.com/actions/cache) from 3.0.1 to 3.0.2. - [Release notes](https://github.com/actions/cache/releases) - [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md) - [Commits](https://github.com/actions/cache/compare/v3.0.1...v3.0.2) --- updated-dependencies: - dependency-name: actions/cache dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>. (cherry picked from commit eefe6911f4f497e8b73e0690f9b3f47904fdb02a) files: M .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index adbe2fe1d248c..61cbef982a9ef 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -196,7 +196,7 @@ jobs: echo "LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/multissl/openssl/${OPENSSL_VER}/lib" >> $GITHUB_ENV - name: 'Restore OpenSSL build' id: cache-openssl - uses: actions/cache at v3.0.1 + uses: actions/cache at v3.0.2 with: path: ./multissl/openssl/${{ env.OPENSSL_VER }} key: ${{ runner.os }}-multissl-openssl-${{ env.OPENSSL_VER }} @@ -244,7 +244,7 @@ jobs: echo "LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/multissl/openssl/${OPENSSL_VER}/lib" >> $GITHUB_ENV - name: 'Restore OpenSSL build' id: cache-openssl - uses: actions/cache at v3.0.1 + uses: actions/cache at v3.0.2 with: path: ./multissl/openssl/${{ env.OPENSSL_VER }} key: ${{ runner.os }}-multissl-openssl-${{ env.OPENSSL_VER }} From webhook-mailer at python.org Mon May 2 12:20:44 2022 From: webhook-mailer at python.org (JelleZijlstra) Date: Mon, 02 May 2022 16:20:44 -0000 Subject: [Python-checkins] gh-92082: contextlib docs: Change aclosing from a class to a function for consistency (#92155) Message-ID: https://github.com/python/cpython/commit/958f21c5cdb3bbbd16fec87164785cff3dacce96 commit: 958f21c5cdb3bbbd16fec87164785cff3dacce96 branch: main author: Thaddeus1499 <104600742+Thaddeus1499 at users.noreply.github.com> committer: JelleZijlstra date: 2022-05-02T10:20:30-06:00 summary: gh-92082: contextlib docs: Change aclosing from a class to a function for consistency (#92155) Signed-off-by: prwatson files: M Doc/library/contextlib.rst diff --git a/Doc/library/contextlib.rst b/Doc/library/contextlib.rst index 38134c1f14319..84c4ca098c601 100644 --- a/Doc/library/contextlib.rst +++ b/Doc/library/contextlib.rst @@ -181,7 +181,7 @@ Functions and classes provided: ``page.close()`` will be called when the :keyword:`with` block is exited. -.. class:: aclosing(thing) +.. function:: aclosing(thing) Return an async context manager that calls the ``aclose()`` method of *thing* upon completion of the block. This is basically equivalent to:: From webhook-mailer at python.org Mon May 2 12:21:18 2022 From: webhook-mailer at python.org (JelleZijlstra) Date: Mon, 02 May 2022 16:21:18 -0000 Subject: [Python-checkins] [3.10] gh-89301: Fix regression with bound values in traced SQLite statements (#92147) Message-ID: https://github.com/python/cpython/commit/178d79ae67848e129958172e8a9ca4838f8503b9 commit: 178d79ae67848e129958172e8a9ca4838f8503b9 branch: 3.10 author: Erlend Egeberg Aasland committer: JelleZijlstra date: 2022-05-02T10:21:13-06:00 summary: [3.10] gh-89301: Fix regression with bound values in traced SQLite statements (#92147) (cherry picked from commit 721aa96540bb96700f8c4bab0b4095b43491dca1) files: A Misc/NEWS.d/next/Library/2021-09-08-16-21-03.bpo-45138.yghUrK.rst M Lib/sqlite3/test/hooks.py M Modules/_sqlite/connection.c diff --git a/Lib/sqlite3/test/hooks.py b/Lib/sqlite3/test/hooks.py index 8c60bdcf5d70a..97121eea1be5f 100644 --- a/Lib/sqlite3/test/hooks.py +++ b/Lib/sqlite3/test/hooks.py @@ -20,6 +20,7 @@ # misrepresented as being the original software. # 3. This notice may not be removed or altered from any source distribution. +import contextlib import unittest import sqlite3 as sqlite @@ -200,6 +201,16 @@ def progress(): self.assertEqual(action, 0, "progress handler was not cleared") class TraceCallbackTests(unittest.TestCase): + @contextlib.contextmanager + def check_stmt_trace(self, cx, expected): + try: + traced = [] + cx.set_trace_callback(lambda stmt: traced.append(stmt)) + yield + finally: + self.assertEqual(traced, expected) + cx.set_trace_callback(None) + def test_trace_callback_used(self): """ Test that the trace callback is invoked once it is set. @@ -261,6 +272,21 @@ def trace(statement): cur.execute(queries[1]) self.assertEqual(traced_statements, queries) + def test_trace_expanded_sql(self): + expected = [ + "create table t(t)", + "BEGIN ", + "insert into t values(0)", + "insert into t values(1)", + "insert into t values(2)", + "COMMIT", + ] + cx = sqlite.connect(":memory:") + with self.check_stmt_trace(cx, expected): + with cx: + cx.execute("create table t(t)") + cx.executemany("insert into t values(?)", ((v,) for v in range(3))) + def suite(): tests = [ diff --git a/Misc/NEWS.d/next/Library/2021-09-08-16-21-03.bpo-45138.yghUrK.rst b/Misc/NEWS.d/next/Library/2021-09-08-16-21-03.bpo-45138.yghUrK.rst new file mode 100644 index 0000000000000..906ed4c4db43c --- /dev/null +++ b/Misc/NEWS.d/next/Library/2021-09-08-16-21-03.bpo-45138.yghUrK.rst @@ -0,0 +1,3 @@ +Fix a regression in the :mod:`sqlite3` trace callback where bound parameters +were not expanded in the passed statement string. The regression was introduced +in Python 3.10 by :issue:`40318`. Patch by Erlend E. Aasland. diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c index c9c10b41398e2..68c5aee79ab15 100644 --- a/Modules/_sqlite/connection.c +++ b/Modules/_sqlite/connection.c @@ -1050,33 +1050,65 @@ static int _progress_handler(void* user_arg) * may change in future releases. Callback implementations should return zero * to ensure future compatibility. */ -static int _trace_callback(unsigned int type, void* user_arg, void* prepared_statement, void* statement_string) +static int +_trace_callback(unsigned int type, void *callable, void *stmt, void *sql) #else -static void _trace_callback(void* user_arg, const char* statement_string) +static void +_trace_callback(void *callable, const char *sql) #endif { - PyObject *py_statement = NULL; - PyObject *ret = NULL; - - PyGILState_STATE gilstate; - #ifdef HAVE_TRACE_V2 if (type != SQLITE_TRACE_STMT) { return 0; } #endif - gilstate = PyGILState_Ensure(); - py_statement = PyUnicode_DecodeUTF8(statement_string, - strlen(statement_string), "replace"); + PyGILState_STATE gilstate = PyGILState_Ensure(); + + PyObject *py_statement = NULL; +#ifdef HAVE_TRACE_V2 + const char *expanded_sql = sqlite3_expanded_sql((sqlite3_stmt *)stmt); + if (expanded_sql == NULL) { + sqlite3 *db = sqlite3_db_handle((sqlite3_stmt *)stmt); + if (sqlite3_errcode(db) == SQLITE_NOMEM) { + (void)PyErr_NoMemory(); + goto exit; + } + + PyErr_SetString(pysqlite_DataError, + "Expanded SQL string exceeds the maximum string length"); + if (_pysqlite_enable_callback_tracebacks) { + PyErr_Print(); + } else { + PyErr_Clear(); + } + + // Fall back to unexpanded sql + py_statement = PyUnicode_FromString((const char *)sql); + } + else { + py_statement = PyUnicode_FromString(expanded_sql); + sqlite3_free((void *)expanded_sql); + } +#else + if (sql == NULL) { + PyErr_SetString(pysqlite_DataError, + "Expanded SQL string exceeds the maximum string length"); + if (_pysqlite_enable_callback_tracebacks) { + PyErr_Print(); + } else { + PyErr_Clear(); + } + goto exit; + } + py_statement = PyUnicode_FromString(sql); +#endif if (py_statement) { - ret = PyObject_CallOneArg((PyObject*)user_arg, py_statement); + PyObject *ret = PyObject_CallOneArg((PyObject *)callable, py_statement); Py_DECREF(py_statement); + Py_XDECREF(ret); } - - if (ret) { - Py_DECREF(ret); - } else { + if (PyErr_Occurred()) { if (_pysqlite_enable_callback_tracebacks) { PyErr_Print(); } else { @@ -1084,6 +1116,7 @@ static void _trace_callback(void* user_arg, const char* statement_string) } } +exit: PyGILState_Release(gilstate); #ifdef HAVE_TRACE_V2 return 0; From webhook-mailer at python.org Mon May 2 12:26:02 2022 From: webhook-mailer at python.org (miss-islington) Date: Mon, 02 May 2022 16:26:02 -0000 Subject: [Python-checkins] concurrent.futures: Fix typo in docstring (GH-92121) Message-ID: https://github.com/python/cpython/commit/1a7867fc0c3913828157e23623381baa7625b626 commit: 1a7867fc0c3913828157e23623381baa7625b626 branch: 3.9 author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com> committer: miss-islington <31488909+miss-islington at users.noreply.github.com> date: 2022-05-02T09:25:45-07:00 summary: concurrent.futures: Fix typo in docstring (GH-92121) (cherry picked from commit b11243e85e020ed2f524bdd83c339faf11ef03d4) Co-authored-by: Yiannis Hadjicharalambous files: M Lib/concurrent/futures/_base.py diff --git a/Lib/concurrent/futures/_base.py b/Lib/concurrent/futures/_base.py index 5c00f2edbe548..cf119ac6437aa 100644 --- a/Lib/concurrent/futures/_base.py +++ b/Lib/concurrent/futures/_base.py @@ -381,7 +381,7 @@ def running(self): return self._state == RUNNING def done(self): - """Return True of the future was cancelled or finished executing.""" + """Return True if the future was cancelled or finished executing.""" with self._condition: return self._state in [CANCELLED, CANCELLED_AND_NOTIFIED, FINISHED] From webhook-mailer at python.org Mon May 2 12:36:49 2022 From: webhook-mailer at python.org (ericvsmith) Date: Mon, 02 May 2022 16:36:49 -0000 Subject: [Python-checkins] Add weakref_slot to dataclass decorator, to allow instances with slots to be weakref-able. (#92160) Message-ID: https://github.com/python/cpython/commit/5f9c0f5ddf441dedeb085b0d9f9c9488ca6bd44d commit: 5f9c0f5ddf441dedeb085b0d9f9c9488ca6bd44d branch: main author: Eric V. Smith committer: ericvsmith date: 2022-05-02T10:36:39-06:00 summary: Add weakref_slot to dataclass decorator, to allow instances with slots to be weakref-able. (#92160) files: A Misc/NEWS.d/next/Library/2022-05-02-09-09-47.gh-issue-91215.l1p7CJ.rst M Doc/library/dataclasses.rst M Lib/dataclasses.py M Lib/test/test_dataclasses.py diff --git a/Doc/library/dataclasses.rst b/Doc/library/dataclasses.rst index 08568da19d71a..ec50696ea89d4 100644 --- a/Doc/library/dataclasses.rst +++ b/Doc/library/dataclasses.rst @@ -46,7 +46,7 @@ directly specified in the ``InventoryItem`` definition shown above. Module contents --------------- -.. decorator:: dataclass(*, init=True, repr=True, eq=True, order=False, unsafe_hash=False, frozen=False, match_args=True, kw_only=False, slots=False) +.. decorator:: dataclass(*, init=True, repr=True, eq=True, order=False, unsafe_hash=False, frozen=False, match_args=True, kw_only=False, slots=False, weakref_slot=False) This function is a :term:`decorator` that is used to add generated :term:`special method`\s to classes, as described below. @@ -79,7 +79,7 @@ Module contents class C: ... - @dataclass(init=True, repr=True, eq=True, order=False, unsafe_hash=False, frozen=False, match_args=True, kw_only=False, slots=False) + @dataclass(init=True, repr=True, eq=True, order=False, unsafe_hash=False, frozen=False, match_args=True, kw_only=False, slots=False, weakref_slot=False) class C: ... @@ -198,6 +198,13 @@ Module contents base class ``__slots__`` may be any iterable, but *not* an iterator. + - ``weakref_slot``: If true (the default is ``False``), add a slot + named "__weakref__", which is required to make an instance + weakref-able. It is an error to specify ``weakref_slot=True`` + without also specifying ``slots=True``. + + .. versionadded:: 3.11 + ``field``\s may optionally specify a default value, using normal Python syntax:: @@ -381,7 +388,7 @@ Module contents :func:`astuple` raises :exc:`TypeError` if ``obj`` is not a dataclass instance. -.. function:: make_dataclass(cls_name, fields, *, bases=(), namespace=None, init=True, repr=True, eq=True, order=False, unsafe_hash=False, frozen=False, match_args=True, kw_only=False, slots=False) +.. function:: make_dataclass(cls_name, fields, *, bases=(), namespace=None, init=True, repr=True, eq=True, order=False, unsafe_hash=False, frozen=False, match_args=True, kw_only=False, slots=False, weakref_slot=False) Creates a new dataclass with name ``cls_name``, fields as defined in ``fields``, base classes as given in ``bases``, and initialized @@ -390,8 +397,8 @@ Module contents or ``(name, type, Field)``. If just ``name`` is supplied, ``typing.Any`` is used for ``type``. The values of ``init``, ``repr``, ``eq``, ``order``, ``unsafe_hash``, ``frozen``, - ``match_args``, ``kw_only``, and ``slots`` have the same meaning as - they do in :func:`dataclass`. + ``match_args``, ``kw_only``, ``slots``, and ``weakref_slot`` have + the same meaning as they do in :func:`dataclass`. This function is not strictly required, because any Python mechanism for creating a new class with ``__annotations__`` can diff --git a/Lib/dataclasses.py b/Lib/dataclasses.py index 1acb7128f1a0c..4645ebfa71e71 100644 --- a/Lib/dataclasses.py +++ b/Lib/dataclasses.py @@ -883,7 +883,7 @@ def _hash_exception(cls, fields, globals): def _process_class(cls, init, repr, eq, order, unsafe_hash, frozen, - match_args, kw_only, slots): + match_args, kw_only, slots, weakref_slot): # Now that dicts retain insertion order, there's no reason to use # an ordered dict. I am leveraging that ordering here, because # derived class fields overwrite base class fields, but the order @@ -1101,8 +1101,11 @@ def _process_class(cls, init, repr, eq, order, unsafe_hash, frozen, _set_new_attribute(cls, '__match_args__', tuple(f.name for f in std_init_fields)) + # It's an error to specify weakref_slot if slots is False. + if weakref_slot and not slots: + raise TypeError('weakref_slot is True but slots is False') if slots: - cls = _add_slots(cls, frozen) + cls = _add_slots(cls, frozen, weakref_slot) abc.update_abstractmethods(cls) @@ -1137,7 +1140,7 @@ def _get_slots(cls): raise TypeError(f"Slots of '{cls.__name__}' cannot be determined") -def _add_slots(cls, is_frozen): +def _add_slots(cls, is_frozen, weakref_slot): # Need to create a new class, since we can't set __slots__ # after a class has been created. @@ -1152,9 +1155,14 @@ def _add_slots(cls, is_frozen): inherited_slots = set( itertools.chain.from_iterable(map(_get_slots, cls.__mro__[1:-1])) ) + # The slots for our class. Remove slots from our base classes. Add + # '__weakref__' if weakref_slot was given. cls_dict["__slots__"] = tuple( - itertools.filterfalse(inherited_slots.__contains__, field_names) + itertools.chain( + itertools.filterfalse(inherited_slots.__contains__, field_names), + ("__weakref__",) if weakref_slot else ()) ) + for field_name in field_names: # Remove our attributes, if present. They'll still be # available in _MARKER. @@ -1179,7 +1187,7 @@ def _add_slots(cls, is_frozen): def dataclass(cls=None, /, *, init=True, repr=True, eq=True, order=False, unsafe_hash=False, frozen=False, match_args=True, - kw_only=False, slots=False): + kw_only=False, slots=False, weakref_slot=False): """Returns the same class as was passed in, with dunder methods added based on the fields defined in the class. @@ -1197,7 +1205,8 @@ def dataclass(cls=None, /, *, init=True, repr=True, eq=True, order=False, def wrap(cls): return _process_class(cls, init, repr, eq, order, unsafe_hash, - frozen, match_args, kw_only, slots) + frozen, match_args, kw_only, slots, + weakref_slot) # See if we're being called as @dataclass or @dataclass(). if cls is None: @@ -1356,7 +1365,8 @@ def _astuple_inner(obj, tuple_factory): def make_dataclass(cls_name, fields, *, bases=(), namespace=None, init=True, repr=True, eq=True, order=False, unsafe_hash=False, - frozen=False, match_args=True, kw_only=False, slots=False): + frozen=False, match_args=True, kw_only=False, slots=False, + weakref_slot=False): """Return a new dynamically created dataclass. The dataclass name will be 'cls_name'. 'fields' is an iterable @@ -1423,7 +1433,8 @@ def exec_body_callback(ns): # Apply the normal decorator. return dataclass(cls, init=init, repr=repr, eq=eq, order=order, unsafe_hash=unsafe_hash, frozen=frozen, - match_args=match_args, kw_only=kw_only, slots=slots) + match_args=match_args, kw_only=kw_only, slots=slots, + weakref_slot=weakref_slot) def replace(obj, /, **changes): diff --git a/Lib/test/test_dataclasses.py b/Lib/test/test_dataclasses.py index 847bcd46a6926..6a36da104ac89 100644 --- a/Lib/test/test_dataclasses.py +++ b/Lib/test/test_dataclasses.py @@ -9,6 +9,7 @@ import inspect import builtins import types +import weakref import unittest from unittest.mock import Mock from typing import ClassVar, Any, List, Union, Tuple, Dict, Generic, TypeVar, Optional, Protocol @@ -3038,6 +3039,77 @@ class A: self.assertEqual(obj.a, 'a') self.assertEqual(obj.b, 'b') + def test_slots_no_weakref(self): + @dataclass(slots=True) + class A: + # No weakref. + pass + + self.assertNotIn("__weakref__", A.__slots__) + a = A() + with self.assertRaisesRegex(TypeError, + "cannot create weak reference"): + weakref.ref(a) + + def test_slots_weakref(self): + @dataclass(slots=True, weakref_slot=True) + class A: + a: int + + self.assertIn("__weakref__", A.__slots__) + a = A(1) + weakref.ref(a) + + def test_slots_weakref_base_str(self): + class Base: + __slots__ = '__weakref__' + + @dataclass(slots=True) + class A(Base): + a: int + + # __weakref__ is in the base class, not A. But an A is still weakref-able. + self.assertIn("__weakref__", Base.__slots__) + self.assertNotIn("__weakref__", A.__slots__) + a = A(1) + weakref.ref(a) + + def test_slots_weakref_base_tuple(self): + # Same as test_slots_weakref_base, but use a tuple instead of a string + # in the base class. + class Base: + __slots__ = ('__weakref__',) + + @dataclass(slots=True) + class A(Base): + a: int + + # __weakref__ is in the base class, not A. But an A is still + # weakref-able. + self.assertIn("__weakref__", Base.__slots__) + self.assertNotIn("__weakref__", A.__slots__) + a = A(1) + weakref.ref(a) + + def test_weakref_slot_without_slot(self): + with self.assertRaisesRegex(TypeError, + "weakref_slot is True but slots is False"): + @dataclass(weakref_slot=True) + class A: + a: int + + def test_weakref_slot_make_dataclass(self): + A = make_dataclass('A', [('a', int),], slots=True, weakref_slot=True) + self.assertIn("__weakref__", A.__slots__) + a = A(1) + weakref.ref(a) + + # And make sure if raises if slots=True is not given. + with self.assertRaisesRegex(TypeError, + "weakref_slot is True but slots is False"): + B = make_dataclass('B', [('a', int),], weakref_slot=True) + + class TestDescriptors(unittest.TestCase): def test_set_name(self): # See bpo-33141. diff --git a/Misc/NEWS.d/next/Library/2022-05-02-09-09-47.gh-issue-91215.l1p7CJ.rst b/Misc/NEWS.d/next/Library/2022-05-02-09-09-47.gh-issue-91215.l1p7CJ.rst new file mode 100644 index 0000000000000..3a9897cb79642 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2022-05-02-09-09-47.gh-issue-91215.l1p7CJ.rst @@ -0,0 +1,3 @@ +For @dataclass, add weakref_slot. Default is False. If True, and if +slots=True, add a slot named "__weakref__", which will allow instances to be +weakref'd. Contributed by Eric V. Smith From webhook-mailer at python.org Mon May 2 12:37:20 2022 From: webhook-mailer at python.org (miss-islington) Date: Mon, 02 May 2022 16:37:20 -0000 Subject: [Python-checkins] gh-92082: contextlib docs: Change aclosing from a class to a function for consistency (GH-92155) Message-ID: https://github.com/python/cpython/commit/0e9927b6b008ff7537600cec4f91169a006d0c9d commit: 0e9927b6b008ff7537600cec4f91169a006d0c9d branch: 3.10 author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com> committer: miss-islington <31488909+miss-islington at users.noreply.github.com> date: 2022-05-02T09:37:10-07:00 summary: gh-92082: contextlib docs: Change aclosing from a class to a function for consistency (GH-92155) Signed-off-by: prwatson (cherry picked from commit 958f21c5cdb3bbbd16fec87164785cff3dacce96) Co-authored-by: Thaddeus1499 <104600742+Thaddeus1499 at users.noreply.github.com> files: M Doc/library/contextlib.rst diff --git a/Doc/library/contextlib.rst b/Doc/library/contextlib.rst index 0fe3206540e80..7c0b831407968 100644 --- a/Doc/library/contextlib.rst +++ b/Doc/library/contextlib.rst @@ -181,7 +181,7 @@ Functions and classes provided: ``page.close()`` will be called when the :keyword:`with` block is exited. -.. class:: aclosing(thing) +.. function:: aclosing(thing) Return an async context manager that calls the ``aclose()`` method of *thing* upon completion of the block. This is basically equivalent to:: From webhook-mailer at python.org Mon May 2 12:57:40 2022 From: webhook-mailer at python.org (JelleZijlstra) Date: Mon, 02 May 2022 16:57:40 -0000 Subject: [Python-checkins] Fix typo in turtle deprecation warning and use warnings._deprecated (#91862) Message-ID: https://github.com/python/cpython/commit/341689cb85c4ee4f58dc9f0f96ecc94ded8fd9d4 commit: 341689cb85c4ee4f58dc9f0f96ecc94ded8fd9d4 branch: main author: Hugo van Kemenade committer: JelleZijlstra date: 2022-05-02T10:57:00-06:00 summary: Fix typo in turtle deprecation warning and use warnings._deprecated (#91862) files: M Lib/turtle.py diff --git a/Lib/turtle.py b/Lib/turtle.py index d5e715efec96a..a8876e76bce40 100644 --- a/Lib/turtle.py +++ b/Lib/turtle.py @@ -2863,10 +2863,10 @@ def settiltangle(self, angle): >>> turtle.stamp() >>> turtle.fd(50) """ - warnings.warn("turtle.RawTurtle.settiltangle() is deprecated since " - "Python 3.1 and scheduled for removal in Python 3.13." - "Use tiltangle() instead.", - DeprecationWarning) + warnings._deprecated("turtle.RawTurtle.settiltangle()", + "{name!r} is deprecated since Python 3.1 and scheduled " + "for removal in Python {remove}. Use tiltangle() instead.", + remove=(3, 13)) self.tiltangle(angle) def tiltangle(self, angle=None): From webhook-mailer at python.org Mon May 2 13:09:46 2022 From: webhook-mailer at python.org (JelleZijlstra) Date: Mon, 02 May 2022 17:09:46 -0000 Subject: [Python-checkins] suggestions.c: Improve efficiency of levenshtein_distance method (#91835) Message-ID: https://github.com/python/cpython/commit/feb45d0ae98f3030b2b07089bc0eb066b69f5625 commit: feb45d0ae98f3030b2b07089bc0eb066b69f5625 branch: main author: Pieter Eendebak committer: JelleZijlstra date: 2022-05-02T11:09:35-06:00 summary: suggestions.c: Improve efficiency of levenshtein_distance method (#91835) files: M Python/suggestions.c diff --git a/Python/suggestions.c b/Python/suggestions.c index d9e69fa7e0db2..b84acaaed6b1f 100644 --- a/Python/suggestions.c +++ b/Python/suggestions.c @@ -78,9 +78,11 @@ levenshtein_distance(const char *a, size_t a_size, // Instead of producing the whole traditional len(a)-by-len(b) // matrix, we can update just one row in place. // Initialize the buffer row + size_t tmp = MOVE_COST; for (size_t i = 0; i < a_size; i++) { // cost from b[:0] to a[:i+1] - buffer[i] = (i + 1) * MOVE_COST; + buffer[i] = tmp; + tmp += MOVE_COST; } size_t result = 0; From webhook-mailer at python.org Mon May 2 13:15:13 2022 From: webhook-mailer at python.org (JelleZijlstra) Date: Mon, 02 May 2022 17:15:13 -0000 Subject: [Python-checkins] gh-91783: Document security considerations for shutil.unpack_archive (#91844) Message-ID: https://github.com/python/cpython/commit/4b297a9ffd4a1d420c1a8016f4ed2c7f1d298469 commit: 4b297a9ffd4a1d420c1a8016f4ed2c7f1d298469 branch: main author: Sam Ezeh committer: JelleZijlstra date: 2022-05-02T11:15:04-06:00 summary: gh-91783: Document security considerations for shutil.unpack_archive (#91844) files: A Misc/NEWS.d/next/Documentation/2022-04-23-00-22-54.gh-issue-91783.N09dRR.rst M Doc/library/shutil.rst diff --git a/Doc/library/shutil.rst b/Doc/library/shutil.rst index cb72ff6f3914b..9a25b0d008bf5 100644 --- a/Doc/library/shutil.rst +++ b/Doc/library/shutil.rst @@ -636,10 +636,16 @@ provided. They rely on the :mod:`zipfile` and :mod:`tarfile` modules. .. audit-event:: shutil.unpack_archive filename,extract_dir,format shutil.unpack_archive + .. warning:: + + Never extract archives from untrusted sources without prior inspection. + It is possible that files are created outside of the path specified in + the *extract_dir* argument, e.g. members that have absolute filenames + starting with "/" or filenames with two dots "..". + .. versionchanged:: 3.7 Accepts a :term:`path-like object` for *filename* and *extract_dir*. - .. function:: register_unpack_format(name, extensions, function[, extra_args[, description]]) Registers an unpack format. *name* is the name of the format and diff --git a/Misc/NEWS.d/next/Documentation/2022-04-23-00-22-54.gh-issue-91783.N09dRR.rst b/Misc/NEWS.d/next/Documentation/2022-04-23-00-22-54.gh-issue-91783.N09dRR.rst new file mode 100644 index 0000000000000..4d6be37402079 --- /dev/null +++ b/Misc/NEWS.d/next/Documentation/2022-04-23-00-22-54.gh-issue-91783.N09dRR.rst @@ -0,0 +1,2 @@ +Document security issues concerning the use of the function +:meth:`shutil.unpack_archive` From webhook-mailer at python.org Mon May 2 13:19:16 2022 From: webhook-mailer at python.org (markshannon) Date: Mon, 02 May 2022 17:19:16 -0000 Subject: [Python-checkins] gh-90213: Speed up right shifts of negative integers (GH-30277) Message-ID: https://github.com/python/cpython/commit/0ed91a26fed8cd78b04b814ef2b402f000b0538c commit: 0ed91a26fed8cd78b04b814ef2b402f000b0538c branch: main author: Mark Dickinson committer: markshannon date: 2022-05-02T11:19:03-06:00 summary: gh-90213: Speed up right shifts of negative integers (GH-30277) files: A Misc/NEWS.d/next/Core and Builtins/2022-04-12-09-40-57.gh-issue-46055.IPb1HA.rst M Lib/test/test_long.py M Objects/longobject.c diff --git a/Lib/test/test_long.py b/Lib/test/test_long.py index 2de4526ff33fd..d092e0176c261 100644 --- a/Lib/test/test_long.py +++ b/Lib/test/test_long.py @@ -985,6 +985,10 @@ def test_medium_rshift(self): self.assertEqual((-1122) >> 9, -3) self.assertEqual(2**128 >> 9, 2**119) self.assertEqual(-2**128 >> 9, -2**119) + # Exercise corner case of the current algorithm, where the result of + # shifting a two-limb int by the limb size still has two limbs. + self.assertEqual((1 - BASE*BASE) >> SHIFT, -BASE) + self.assertEqual((BASE - 1 - BASE*BASE) >> SHIFT, -BASE) def test_big_rshift(self): self.assertEqual(42 >> 32, 0) diff --git a/Misc/NEWS.d/next/Core and Builtins/2022-04-12-09-40-57.gh-issue-46055.IPb1HA.rst b/Misc/NEWS.d/next/Core and Builtins/2022-04-12-09-40-57.gh-issue-46055.IPb1HA.rst new file mode 100644 index 0000000000000..ed7e4113fd2e6 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2022-04-12-09-40-57.gh-issue-46055.IPb1HA.rst @@ -0,0 +1,2 @@ +Speed up right shift of negative integers, by removing unnecessary creation +of temporaries. Original patch by Xinhang Xu, reworked by Mark Dickinson. diff --git a/Objects/longobject.c b/Objects/longobject.c index e805dac1209e7..78360a58facc6 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -4688,13 +4688,23 @@ divmod_shift(PyObject *shiftby, Py_ssize_t *wordshift, digit *remshift) return 0; } +/* Inner function for both long_rshift and _PyLong_Rshift, shifting an + integer right by PyLong_SHIFT*wordshift + remshift bits. + wordshift should be nonnegative. */ + static PyObject * long_rshift1(PyLongObject *a, Py_ssize_t wordshift, digit remshift) { PyLongObject *z = NULL; - Py_ssize_t newsize, hishift, i, j; + Py_ssize_t newsize, hishift, size_a; twodigits accum; + int a_negative; + + /* Total number of bits shifted must be nonnegative. */ + assert(wordshift >= 0); + assert(remshift < PyLong_SHIFT); + /* Fast path for small a. */ if (IS_MEDIUM_VALUE(a)) { stwodigits m, x; digit shift; @@ -4704,37 +4714,67 @@ long_rshift1(PyLongObject *a, Py_ssize_t wordshift, digit remshift) return _PyLong_FromSTwoDigits(x); } - if (Py_SIZE(a) < 0) { - /* Right shifting negative numbers is harder */ - PyLongObject *a1, *a2; - a1 = (PyLongObject *) long_invert(a); - if (a1 == NULL) - return NULL; - a2 = (PyLongObject *) long_rshift1(a1, wordshift, remshift); - Py_DECREF(a1); - if (a2 == NULL) - return NULL; - z = (PyLongObject *) long_invert(a2); - Py_DECREF(a2); + a_negative = Py_SIZE(a) < 0; + size_a = Py_ABS(Py_SIZE(a)); + + if (a_negative) { + /* For negative 'a', adjust so that 0 < remshift <= PyLong_SHIFT, + while keeping PyLong_SHIFT*wordshift + remshift the same. This + ensures that 'newsize' is computed correctly below. */ + if (remshift == 0) { + if (wordshift == 0) { + /* Can only happen if the original shift was 0. */ + return long_long((PyObject *)a); + } + remshift = PyLong_SHIFT; + --wordshift; + } } - else { - newsize = Py_SIZE(a) - wordshift; - if (newsize <= 0) - return PyLong_FromLong(0); - hishift = PyLong_SHIFT - remshift; - z = _PyLong_New(newsize); - if (z == NULL) - return NULL; - j = wordshift; - accum = a->ob_digit[j++] >> remshift; - for (i = 0; j < Py_SIZE(a); i++, j++) { - accum |= (twodigits)a->ob_digit[j] << hishift; - z->ob_digit[i] = (digit)(accum & PyLong_MASK); - accum >>= PyLong_SHIFT; + + assert(wordshift >= 0); + newsize = size_a - wordshift; + if (newsize <= 0) { + /* Shifting all the bits of 'a' out gives either -1 or 0. */ + return PyLong_FromLong(-a_negative); + } + z = _PyLong_New(newsize); + if (z == NULL) { + return NULL; + } + hishift = PyLong_SHIFT - remshift; + + accum = a->ob_digit[wordshift]; + if (a_negative) { + /* + For a positive integer a and nonnegative shift, we have: + + (-a) >> shift == -((a + 2**shift - 1) >> shift). + + In the addition `a + (2**shift - 1)`, the low `wordshift` digits of + `2**shift - 1` all have value `PyLong_MASK`, so we get a carry out + from the bottom `wordshift` digits when at least one of the least + significant `wordshift` digits of `a` is nonzero. Digit `wordshift` + of `2**shift - 1` has value `PyLong_MASK >> hishift`. + */ + Py_SET_SIZE(z, -newsize); + + digit sticky = 0; + for (Py_ssize_t j = 0; j < wordshift; j++) { + sticky |= a->ob_digit[j]; } - z->ob_digit[i] = (digit)accum; - z = maybe_small_long(long_normalize(z)); + accum += (PyLong_MASK >> hishift) + (digit)(sticky != 0); } + + accum >>= remshift; + for (Py_ssize_t i = 0, j = wordshift + 1; j < size_a; i++, j++) { + accum += (twodigits)a->ob_digit[j] << hishift; + z->ob_digit[i] = (digit)(accum & PyLong_MASK); + accum >>= PyLong_SHIFT; + } + assert(accum <= PyLong_MASK); + z->ob_digit[newsize - 1] = (digit)accum; + + z = maybe_small_long(long_normalize(z)); return (PyObject *)z; } From webhook-mailer at python.org Mon May 2 13:22:44 2022 From: webhook-mailer at python.org (JelleZijlstra) Date: Mon, 02 May 2022 17:22:44 -0000 Subject: [Python-checkins] gh-90765: configparser test: Catch deprecation warning (#91480) Message-ID: https://github.com/python/cpython/commit/56f98440148e4257aa5b27150ce2269c98cea0ea commit: 56f98440148e4257aa5b27150ce2269c98cea0ea branch: main author: Hugo van Kemenade committer: JelleZijlstra date: 2022-05-02T11:22:26-06:00 summary: gh-90765: configparser test: Catch deprecation warning (#91480) files: M Lib/test/test_configparser.py diff --git a/Lib/test/test_configparser.py b/Lib/test/test_configparser.py index efd98ffb67a54..59c4b275cb46d 100644 --- a/Lib/test/test_configparser.py +++ b/Lib/test/test_configparser.py @@ -1028,7 +1028,9 @@ class CustomConfigParser(configparser.ConfigParser): class ConfigParserTestCaseLegacyInterpolation(ConfigParserTestCase): config_class = configparser.ConfigParser - interpolation = configparser.LegacyInterpolation() + with warnings.catch_warnings(): + warnings.simplefilter("ignore", DeprecationWarning) + interpolation = configparser.LegacyInterpolation() def test_set_malformatted_interpolation(self): cf = self.fromstring("[sect]\n" From webhook-mailer at python.org Mon May 2 13:24:59 2022 From: webhook-mailer at python.org (miss-islington) Date: Mon, 02 May 2022 17:24:59 -0000 Subject: [Python-checkins] [3.10] Fix typo in Programming FAQ (GH-92083) (GH-92148) Message-ID: https://github.com/python/cpython/commit/864058ba86d93eee9b6ed10b93bd8839a6131e44 commit: 864058ba86d93eee9b6ed10b93bd8839a6131e44 branch: 3.10 author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com> committer: miss-islington <31488909+miss-islington at users.noreply.github.com> date: 2022-05-02T10:24:49-07:00 summary: [3.10] Fix typo in Programming FAQ (GH-92083) (GH-92148) I believe the word "with" was missing here. (cherry picked from commit 2a7efa324274a54fe0e5480cae1438d8294b9ec3) Co-authored-by: Matt Harding files: M Doc/faq/programming.rst diff --git a/Doc/faq/programming.rst b/Doc/faq/programming.rst index a1adf851bdded..a1701bd4184bb 100644 --- a/Doc/faq/programming.rst +++ b/Doc/faq/programming.rst @@ -78,7 +78,7 @@ set of modules required by a program and bind these modules together with a Python binary to produce a single executable. One is to use the freeze tool, which is included in the Python source tree as -``Tools/freeze``. It converts Python byte code to C arrays; a C compiler you can +``Tools/freeze``. It converts Python byte code to C arrays; with a C compiler you can embed all your modules into a new program, which is then linked with the standard Python modules. From webhook-mailer at python.org Mon May 2 13:35:07 2022 From: webhook-mailer at python.org (miss-islington) Date: Mon, 02 May 2022 17:35:07 -0000 Subject: [Python-checkins] gh-91783: Document security considerations for shutil.unpack_archive (GH-91844) Message-ID: https://github.com/python/cpython/commit/bab4d0bb1695ec8e4d89efe14c843c5080d46735 commit: bab4d0bb1695ec8e4d89efe14c843c5080d46735 branch: 3.10 author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com> committer: miss-islington <31488909+miss-islington at users.noreply.github.com> date: 2022-05-02T10:34:59-07:00 summary: gh-91783: Document security considerations for shutil.unpack_archive (GH-91844) (cherry picked from commit 4b297a9ffd4a1d420c1a8016f4ed2c7f1d298469) Co-authored-by: Sam Ezeh files: A Misc/NEWS.d/next/Documentation/2022-04-23-00-22-54.gh-issue-91783.N09dRR.rst M Doc/library/shutil.rst diff --git a/Doc/library/shutil.rst b/Doc/library/shutil.rst index 403df45b3966a..193c01006171e 100644 --- a/Doc/library/shutil.rst +++ b/Doc/library/shutil.rst @@ -630,10 +630,16 @@ provided. They rely on the :mod:`zipfile` and :mod:`tarfile` modules. .. audit-event:: shutil.unpack_archive filename,extract_dir,format shutil.unpack_archive + .. warning:: + + Never extract archives from untrusted sources without prior inspection. + It is possible that files are created outside of the path specified in + the *extract_dir* argument, e.g. members that have absolute filenames + starting with "/" or filenames with two dots "..". + .. versionchanged:: 3.7 Accepts a :term:`path-like object` for *filename* and *extract_dir*. - .. function:: register_unpack_format(name, extensions, function[, extra_args[, description]]) Registers an unpack format. *name* is the name of the format and diff --git a/Misc/NEWS.d/next/Documentation/2022-04-23-00-22-54.gh-issue-91783.N09dRR.rst b/Misc/NEWS.d/next/Documentation/2022-04-23-00-22-54.gh-issue-91783.N09dRR.rst new file mode 100644 index 0000000000000..4d6be37402079 --- /dev/null +++ b/Misc/NEWS.d/next/Documentation/2022-04-23-00-22-54.gh-issue-91783.N09dRR.rst @@ -0,0 +1,2 @@ +Document security issues concerning the use of the function +:meth:`shutil.unpack_archive` From webhook-mailer at python.org Mon May 2 13:36:09 2022 From: webhook-mailer at python.org (miss-islington) Date: Mon, 02 May 2022 17:36:09 -0000 Subject: [Python-checkins] gh-91783: Document security considerations for shutil.unpack_archive (GH-91844) Message-ID: https://github.com/python/cpython/commit/d113674b3e20ee35ca8890650f7c0b3912f14fef commit: d113674b3e20ee35ca8890650f7c0b3912f14fef branch: 3.9 author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com> committer: miss-islington <31488909+miss-islington at users.noreply.github.com> date: 2022-05-02T10:36:05-07:00 summary: gh-91783: Document security considerations for shutil.unpack_archive (GH-91844) (cherry picked from commit 4b297a9ffd4a1d420c1a8016f4ed2c7f1d298469) Co-authored-by: Sam Ezeh files: A Misc/NEWS.d/next/Documentation/2022-04-23-00-22-54.gh-issue-91783.N09dRR.rst M Doc/library/shutil.rst diff --git a/Doc/library/shutil.rst b/Doc/library/shutil.rst index 403df45b3966a..193c01006171e 100644 --- a/Doc/library/shutil.rst +++ b/Doc/library/shutil.rst @@ -630,10 +630,16 @@ provided. They rely on the :mod:`zipfile` and :mod:`tarfile` modules. .. audit-event:: shutil.unpack_archive filename,extract_dir,format shutil.unpack_archive + .. warning:: + + Never extract archives from untrusted sources without prior inspection. + It is possible that files are created outside of the path specified in + the *extract_dir* argument, e.g. members that have absolute filenames + starting with "/" or filenames with two dots "..". + .. versionchanged:: 3.7 Accepts a :term:`path-like object` for *filename* and *extract_dir*. - .. function:: register_unpack_format(name, extensions, function[, extra_args[, description]]) Registers an unpack format. *name* is the name of the format and diff --git a/Misc/NEWS.d/next/Documentation/2022-04-23-00-22-54.gh-issue-91783.N09dRR.rst b/Misc/NEWS.d/next/Documentation/2022-04-23-00-22-54.gh-issue-91783.N09dRR.rst new file mode 100644 index 0000000000000..4d6be37402079 --- /dev/null +++ b/Misc/NEWS.d/next/Documentation/2022-04-23-00-22-54.gh-issue-91783.N09dRR.rst @@ -0,0 +1,2 @@ +Document security issues concerning the use of the function +:meth:`shutil.unpack_archive` From webhook-mailer at python.org Mon May 2 14:21:56 2022 From: webhook-mailer at python.org (JelleZijlstra) Date: Mon, 02 May 2022 18:21:56 -0000 Subject: [Python-checkins] [3.10] bpo-43504: Remove effbot urls (GH-26308) (#92161) Message-ID: https://github.com/python/cpython/commit/c8ab1633fce42e84734179d267a1cd01e3fef323 commit: c8ab1633fce42e84734179d267a1cd01e3fef323 branch: 3.10 author: Thaddeus1499 <104600742+Thaddeus1499 at users.noreply.github.com> committer: JelleZijlstra date: 2022-05-02T12:21:51-06:00 summary: [3.10] bpo-43504: Remove effbot urls (GH-26308) (#92161) * [3.10] Remove effbot urls (GH-26308). (cherry picked from commit e9f66aedf44ccc3be27975cfb070a44ce6a6bd13) Co-authored-by: E-Paine <63801254+E-Paine at users.noreply.github.com> files: M Doc/about.rst M Doc/faq/library.rst M Doc/howto/curses.rst M Doc/library/xml.etree.elementtree.rst M Doc/library/xmlrpc.client.rst M Lib/xml/etree/ElementPath.py M Objects/stringlib/fastsearch.h diff --git a/Doc/about.rst b/Doc/about.rst index 3ea311fa629dd..f0b908487b2d0 100644 --- a/Doc/about.rst +++ b/Doc/about.rst @@ -23,9 +23,8 @@ Many thanks go to: and writer of much of the content; * the `Docutils `_ project for creating reStructuredText and the Docutils suite; -* Fredrik Lundh for his `Alternative Python Reference - `_ project from which Sphinx got many good - ideas. +* Fredrik Lundh for his Alternative Python Reference project from which Sphinx + got many good ideas. Contributors to the Python Documentation diff --git a/Doc/faq/library.rst b/Doc/faq/library.rst index faca834e96545..b9e541c150dc4 100644 --- a/Doc/faq/library.rst +++ b/Doc/faq/library.rst @@ -106,9 +106,6 @@ support, pads, and mouse support. This means the module isn't compatible with operating systems that only have BSD curses, but there don't seem to be any currently maintained OSes that fall into this category. -For Windows: use `the consolelib module -`_. - Is there an equivalent to C's onexit() in Python? ------------------------------------------------- diff --git a/Doc/howto/curses.rst b/Doc/howto/curses.rst index cc4b4785b1229..c0149ffff3771 100644 --- a/Doc/howto/curses.rst +++ b/Doc/howto/curses.rst @@ -55,11 +55,7 @@ everything, though. The Windows version of Python doesn't include the :mod:`curses` module. A ported version called `UniCurses -`_ is available. You could -also try `the Console module `_ -written by Fredrik Lundh, which doesn't -use the same API as curses but provides cursor-addressable text output -and full support for mouse and keyboard input. +`_ is available. The Python curses module diff --git a/Doc/library/xml.etree.elementtree.rst b/Doc/library/xml.etree.elementtree.rst index 87f4ee347d604..e3932bc9e659f 100644 --- a/Doc/library/xml.etree.elementtree.rst +++ b/Doc/library/xml.etree.elementtree.rst @@ -363,13 +363,6 @@ These two approaches both output:: |--> Commander Clement -Additional resources -^^^^^^^^^^^^^^^^^^^^ - -See http://effbot.org/zone/element-index.htm for tutorials and links to other -docs. - - .. _elementtree-xpath: XPath support diff --git a/Doc/library/xmlrpc.client.rst b/Doc/library/xmlrpc.client.rst index 51279b35fd71b..8d9db53ef1f0d 100644 --- a/Doc/library/xmlrpc.client.rst +++ b/Doc/library/xmlrpc.client.rst @@ -169,12 +169,6 @@ between conformable Python objects and XML on the wire. `XML-RPC Specification `_ The official specification. - `Unofficial XML-RPC Errata `_ - Fredrik Lundh's "unofficial errata, intended to clarify certain - details in the XML-RPC specification, as well as hint at - 'best practices' to use when designing your own XML-RPC - implementations." - .. _serverproxy-objects: ServerProxy Objects diff --git a/Lib/xml/etree/ElementPath.py b/Lib/xml/etree/ElementPath.py index a1170b572feea..cd3c354d0813e 100644 --- a/Lib/xml/etree/ElementPath.py +++ b/Lib/xml/etree/ElementPath.py @@ -226,7 +226,6 @@ def select(context, result): def prepare_predicate(next, token): # FIXME: replace with real parser!!! refs: - # http://effbot.org/zone/simple-iterator-parser.htm # http://javascript.crockford.com/tdop/tdop.html signature = [] predicate = [] diff --git a/Objects/stringlib/fastsearch.h b/Objects/stringlib/fastsearch.h index 6574720b609f4..7b8be5d649215 100644 --- a/Objects/stringlib/fastsearch.h +++ b/Objects/stringlib/fastsearch.h @@ -4,7 +4,8 @@ /* fast search/count implementation, based on a mix between boyer- moore and horspool, with a few more bells and whistles on the top. - for some more background, see: http://effbot.org/zone/stringlib.htm */ + for some more background, see: + https://web.archive.org/web/20201107074620/http://effbot.org/zone/stringlib.htm */ /* note: fastsearch may access s[n], which isn't a problem when using Python's ordinary string types, but may cause problems if you're From webhook-mailer at python.org Mon May 2 14:22:09 2022 From: webhook-mailer at python.org (JelleZijlstra) Date: Mon, 02 May 2022 18:22:09 -0000 Subject: [Python-checkins] [3.9] Remove effbot urls (GH-26308). (#92162) Message-ID: https://github.com/python/cpython/commit/e48da7264765041d8df71c21e3664b93d2b98f32 commit: e48da7264765041d8df71c21e3664b93d2b98f32 branch: 3.9 author: Thaddeus1499 <104600742+Thaddeus1499 at users.noreply.github.com> committer: JelleZijlstra date: 2022-05-02T12:22:05-06:00 summary: [3.9] Remove effbot urls (GH-26308). (#92162) (cherry picked from commit e9f66aedf44ccc3be27975cfb070a44ce6a6bd13) Co-authored-by: E-Paine <63801254+E-Paine at users.noreply.github.com> files: M Doc/about.rst M Doc/faq/library.rst M Doc/howto/curses.rst M Doc/library/xml.etree.elementtree.rst M Doc/library/xmlrpc.client.rst M Lib/xml/etree/ElementPath.py M Objects/stringlib/fastsearch.h diff --git a/Doc/about.rst b/Doc/about.rst index 3ea311fa629dd..f0b908487b2d0 100644 --- a/Doc/about.rst +++ b/Doc/about.rst @@ -23,9 +23,8 @@ Many thanks go to: and writer of much of the content; * the `Docutils `_ project for creating reStructuredText and the Docutils suite; -* Fredrik Lundh for his `Alternative Python Reference - `_ project from which Sphinx got many good - ideas. +* Fredrik Lundh for his Alternative Python Reference project from which Sphinx + got many good ideas. Contributors to the Python Documentation diff --git a/Doc/faq/library.rst b/Doc/faq/library.rst index 7703d48a2137a..96525ddca32d6 100644 --- a/Doc/faq/library.rst +++ b/Doc/faq/library.rst @@ -106,9 +106,6 @@ support, pads, and mouse support. This means the module isn't compatible with operating systems that only have BSD curses, but there don't seem to be any currently maintained OSes that fall into this category. -For Windows: use `the consolelib module -`_. - Is there an equivalent to C's onexit() in Python? ------------------------------------------------- diff --git a/Doc/howto/curses.rst b/Doc/howto/curses.rst index cc4b4785b1229..c0149ffff3771 100644 --- a/Doc/howto/curses.rst +++ b/Doc/howto/curses.rst @@ -55,11 +55,7 @@ everything, though. The Windows version of Python doesn't include the :mod:`curses` module. A ported version called `UniCurses -`_ is available. You could -also try `the Console module `_ -written by Fredrik Lundh, which doesn't -use the same API as curses but provides cursor-addressable text output -and full support for mouse and keyboard input. +`_ is available. The Python curses module diff --git a/Doc/library/xml.etree.elementtree.rst b/Doc/library/xml.etree.elementtree.rst index f4bccf6609810..92248e751632b 100644 --- a/Doc/library/xml.etree.elementtree.rst +++ b/Doc/library/xml.etree.elementtree.rst @@ -363,13 +363,6 @@ These two approaches both output:: |--> Commander Clement -Additional resources -^^^^^^^^^^^^^^^^^^^^ - -See http://effbot.org/zone/element-index.htm for tutorials and links to other -docs. - - .. _elementtree-xpath: XPath support diff --git a/Doc/library/xmlrpc.client.rst b/Doc/library/xmlrpc.client.rst index 32403819531aa..30c5a710e0ed8 100644 --- a/Doc/library/xmlrpc.client.rst +++ b/Doc/library/xmlrpc.client.rst @@ -169,12 +169,6 @@ between conformable Python objects and XML on the wire. `XML-RPC Specification `_ The official specification. - `Unofficial XML-RPC Errata `_ - Fredrik Lundh's "unofficial errata, intended to clarify certain - details in the XML-RPC specification, as well as hint at - 'best practices' to use when designing your own XML-RPC - implementations." - .. _serverproxy-objects: ServerProxy Objects diff --git a/Lib/xml/etree/ElementPath.py b/Lib/xml/etree/ElementPath.py index 880ea7bd99116..493c026dbabec 100644 --- a/Lib/xml/etree/ElementPath.py +++ b/Lib/xml/etree/ElementPath.py @@ -225,7 +225,6 @@ def select(context, result): def prepare_predicate(next, token): # FIXME: replace with real parser!!! refs: - # http://effbot.org/zone/simple-iterator-parser.htm # http://javascript.crockford.com/tdop/tdop.html signature = [] predicate = [] diff --git a/Objects/stringlib/fastsearch.h b/Objects/stringlib/fastsearch.h index 56a4467d35381..84b415a94906b 100644 --- a/Objects/stringlib/fastsearch.h +++ b/Objects/stringlib/fastsearch.h @@ -4,7 +4,8 @@ /* fast search/count implementation, based on a mix between boyer- moore and horspool, with a few more bells and whistles on the top. - for some more background, see: http://effbot.org/zone/stringlib.htm */ + for some more background, see: + https://web.archive.org/web/20201107074620/http://effbot.org/zone/stringlib.htm */ /* note: fastsearch may access s[n], which isn't a problem when using Python's ordinary string types, but may cause problems if you're From webhook-mailer at python.org Mon May 2 15:22:04 2022 From: webhook-mailer at python.org (JelleZijlstra) Date: Mon, 02 May 2022 19:22:04 -0000 Subject: [Python-checkins] gh-87390: Add __unpacked__ attribute to types.GenericAlias (#92059) Message-ID: https://github.com/python/cpython/commit/ff88f7e007deb7a9f7539938dcf6f4adbfebf442 commit: ff88f7e007deb7a9f7539938dcf6f4adbfebf442 branch: main author: Jelle Zijlstra committer: JelleZijlstra date: 2022-05-02T13:21:59-06:00 summary: gh-87390: Add __unpacked__ attribute to types.GenericAlias (#92059) files: A Misc/NEWS.d/next/Library/2022-04-29-16-41-08.gh-issue-87390.3LNNCv.rst M Doc/library/stdtypes.rst M Lib/test/test_genericalias.py M Objects/genericaliasobject.c diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 764d83a6800d1..44447400c29bc 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -5055,6 +5055,15 @@ All parameterized generics implement special read-only attributes. have correct ``__parameters__`` after substitution because :class:`typing.ParamSpec` is intended primarily for static type checking. + +.. attribute:: genericalias.__unpacked__ + + A boolean that is true if the alias has been unpacked using the + ``*`` operator (see :data:`~typing.TypeVarTuple`). + + .. versionadded:: 3.11 + + .. seealso:: :pep:`484` - Type Hints diff --git a/Lib/test/test_genericalias.py b/Lib/test/test_genericalias.py index 635ac0f7a85d7..2d2adc11e1594 100644 --- a/Lib/test/test_genericalias.py +++ b/Lib/test/test_genericalias.py @@ -418,6 +418,12 @@ def __deepcopy__(self, memo): self.assertEqual(copied.__args__, alias.__args__) self.assertEqual(copied.__parameters__, alias.__parameters__) + def test_unpack(self): + alias = tuple[str, ...] + self.assertIs(alias.__unpacked__, False) + unpacked = (*alias,)[0] + self.assertIs(unpacked.__unpacked__, True) + def test_union(self): a = typing.Union[list[int], list[str]] self.assertEqual(a.__args__, (list[int], list[str])) diff --git a/Misc/NEWS.d/next/Library/2022-04-29-16-41-08.gh-issue-87390.3LNNCv.rst b/Misc/NEWS.d/next/Library/2022-04-29-16-41-08.gh-issue-87390.3LNNCv.rst new file mode 100644 index 0000000000000..c368c1eb3be18 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2022-04-29-16-41-08.gh-issue-87390.3LNNCv.rst @@ -0,0 +1,2 @@ +Add an ``__unpacked__`` attribute to :class:`types.GenericAlias`. Patch by +Jelle Zijlstra. diff --git a/Objects/genericaliasobject.c b/Objects/genericaliasobject.c index 7b689912dffc1..c6ed1611bd29e 100644 --- a/Objects/genericaliasobject.c +++ b/Objects/genericaliasobject.c @@ -516,6 +516,7 @@ ga_vectorcall(PyObject *self, PyObject *const *args, static const char* const attr_exceptions[] = { "__origin__", "__args__", + "__unpacked__", "__parameters__", "__mro_entries__", "__reduce_ex__", // needed so we don't look up object.__reduce_ex__ @@ -657,6 +658,7 @@ static PyMethodDef ga_methods[] = { static PyMemberDef ga_members[] = { {"__origin__", T_OBJECT, offsetof(gaobject, origin), READONLY}, {"__args__", T_OBJECT, offsetof(gaobject, args), READONLY}, + {"__unpacked__", T_BOOL, offsetof(gaobject, starred), READONLY}, {0} }; From webhook-mailer at python.org Mon May 2 15:43:57 2022 From: webhook-mailer at python.org (benjaminp) Date: Mon, 02 May 2022 19:43:57 -0000 Subject: [Python-checkins] Fix duplicate word. (GH-92182) Message-ID: https://github.com/python/cpython/commit/dd57fe1dd7675c53e69af33b511786127ae8d25c commit: dd57fe1dd7675c53e69af33b511786127ae8d25c branch: main author: Benjamin Peterson committer: benjaminp date: 2022-05-02T13:43:52-06:00 summary: Fix duplicate word. (GH-92182) files: M Doc/library/asyncio-runner.rst diff --git a/Doc/library/asyncio-runner.rst b/Doc/library/asyncio-runner.rst index a526b459f7474..d0df1db892f9e 100644 --- a/Doc/library/asyncio-runner.rst +++ b/Doc/library/asyncio-runner.rst @@ -139,7 +139,7 @@ To mitigate this issue, :mod:`asyncio` handles :const:`signal.SIGINT` as follows execution. 3. When :const:`signal.SIGINT` is raised by :kbd:`Ctrl-C`, the custom signal handler cancels the main task by calling :meth:`asyncio.Task.cancel` which raises - :exc:`asyncio.CancelledError` inside the the main task. This causes the Python stack + :exc:`asyncio.CancelledError` inside the main task. This causes the Python stack to unwind, ``try/except`` and ``try/finally`` blocks can be used for resource cleanup. After the main task is cancelled, :meth:`asyncio.Runner.run` raises :exc:`KeyboardInterrupt`. From webhook-mailer at python.org Mon May 2 16:08:31 2022 From: webhook-mailer at python.org (markshannon) Date: Mon, 02 May 2022 20:08:31 -0000 Subject: [Python-checkins] Fix the closure argument to PyEval_EvalCodeEx. (GH-92175) Message-ID: https://github.com/python/cpython/commit/c96da83a8ed020c026c3f080e0b646f553524c85 commit: c96da83a8ed020c026c3f080e0b646f553524c85 branch: main author: larryhastings committer: markshannon date: 2022-05-02T14:08:22-06:00 summary: Fix the closure argument to PyEval_EvalCodeEx. (GH-92175) files: A Misc/NEWS.d/next/C API/2022-05-02-12-39-33.gh-issue-92173.len2Is.rst M Objects/funcobject.c diff --git a/Misc/NEWS.d/next/C API/2022-05-02-12-39-33.gh-issue-92173.len2Is.rst b/Misc/NEWS.d/next/C API/2022-05-02-12-39-33.gh-issue-92173.len2Is.rst new file mode 100644 index 0000000000000..c8f9b58bd6393 --- /dev/null +++ b/Misc/NEWS.d/next/C API/2022-05-02-12-39-33.gh-issue-92173.len2Is.rst @@ -0,0 +1 @@ +Fix the ``closure`` argument to :c:func:`PyEval_EvalCodeEx`. diff --git a/Objects/funcobject.c b/Objects/funcobject.c index 1e0cfb7efb479..32b4155c03e6a 100644 --- a/Objects/funcobject.c +++ b/Objects/funcobject.c @@ -29,7 +29,8 @@ _PyFunction_FromConstructor(PyFrameConstructor *constr) op->func_code = constr->fc_code; op->func_defaults = NULL; op->func_kwdefaults = NULL; - op->func_closure = NULL; + Py_XINCREF(constr->fc_closure); + op->func_closure = constr->fc_closure; Py_INCREF(Py_None); op->func_doc = Py_None; op->func_dict = NULL; From webhook-mailer at python.org Mon May 2 16:24:43 2022 From: webhook-mailer at python.org (JelleZijlstra) Date: Mon, 02 May 2022 20:24:43 -0000 Subject: [Python-checkins] bpo-46787: Fix `ProcessPoolExecutor exception` memory leak (GH-31408) (#31408) Message-ID: https://github.com/python/cpython/commit/9c204b148fad9742ed19b3bce173073cdec79819 commit: 9c204b148fad9742ed19b3bce173073cdec79819 branch: main author: themylogin committer: JelleZijlstra date: 2022-05-02T14:24:39-06:00 summary: bpo-46787: Fix `ProcessPoolExecutor exception` memory leak (GH-31408) (#31408) Do not store `ProcessPoolExecutor` work item exception traceback that prevents exception frame locals from being garbage collected. files: A Misc/NEWS.d/next/Library/2022-02-18-20-09-29.bpo-46787.juwWc0.rst M Lib/concurrent/futures/process.py diff --git a/Lib/concurrent/futures/process.py b/Lib/concurrent/futures/process.py index 695f7733305ed..0d49379c9bf7c 100644 --- a/Lib/concurrent/futures/process.py +++ b/Lib/concurrent/futures/process.py @@ -125,6 +125,9 @@ class _ExceptionWithTraceback: def __init__(self, exc, tb): tb = ''.join(format_exception(type(exc), exc, tb)) self.exc = exc + # Traceback object needs to be garbage-collected as its frames + # contain references to all the objects in the exception scope + self.exc.__traceback__ = None self.tb = '\n"""\n%s"""' % tb def __reduce__(self): return _rebuild_exc, (self.exc, self.tb) diff --git a/Misc/NEWS.d/next/Library/2022-02-18-20-09-29.bpo-46787.juwWc0.rst b/Misc/NEWS.d/next/Library/2022-02-18-20-09-29.bpo-46787.juwWc0.rst new file mode 100644 index 0000000000000..cf167ff48115b --- /dev/null +++ b/Misc/NEWS.d/next/Library/2022-02-18-20-09-29.bpo-46787.juwWc0.rst @@ -0,0 +1 @@ +Fix :class:`concurrent.futures.ProcessPoolExecutor` exception memory leak From webhook-mailer at python.org Mon May 2 16:26:45 2022 From: webhook-mailer at python.org (JelleZijlstra) Date: Mon, 02 May 2022 20:26:45 -0000 Subject: [Python-checkins] importlib docs: Update importlib.abc hierarchy (#31113) Message-ID: https://github.com/python/cpython/commit/5f45a9d3c3de97a4eafedb60ecea224a78bae52c commit: 5f45a9d3c3de97a4eafedb60ecea224a78bae52c branch: main author: David Gilbertson committer: JelleZijlstra date: 2022-05-02T14:26:35-06:00 summary: importlib docs: Update importlib.abc hierarchy (#31113) Fixed some inconsistencies in the text about relationships files: M Doc/library/importlib.rst diff --git a/Doc/library/importlib.rst b/Doc/library/importlib.rst index 783653831b507..0241fb30b6efb 100644 --- a/Doc/library/importlib.rst +++ b/Doc/library/importlib.rst @@ -248,8 +248,8 @@ ABC hierarchy:: object +-- Finder (deprecated) - | +-- MetaPathFinder - | +-- PathEntryFinder + +-- MetaPathFinder + +-- PathEntryFinder +-- Loader +-- ResourceLoader --------+ +-- InspectLoader | @@ -282,8 +282,7 @@ ABC hierarchy:: .. class:: MetaPathFinder - An abstract base class representing a :term:`meta path finder`. For - compatibility, this is a subclass of :class:`Finder`. + An abstract base class representing a :term:`meta path finder`. .. versionadded:: 3.3 From webhook-mailer at python.org Mon May 2 16:49:10 2022 From: webhook-mailer at python.org (miss-islington) Date: Mon, 02 May 2022 20:49:10 -0000 Subject: [Python-checkins] importlib docs: Update importlib.abc hierarchy (GH-31113) Message-ID: https://github.com/python/cpython/commit/d851f37b886a91400642c4c845c56d585ab94ec0 commit: d851f37b886a91400642c4c845c56d585ab94ec0 branch: 3.10 author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com> committer: miss-islington <31488909+miss-islington at users.noreply.github.com> date: 2022-05-02T13:48:59-07:00 summary: importlib docs: Update importlib.abc hierarchy (GH-31113) Fixed some inconsistencies in the text about relationships (cherry picked from commit 5f45a9d3c3de97a4eafedb60ecea224a78bae52c) Co-authored-by: David Gilbertson files: M Doc/library/importlib.rst diff --git a/Doc/library/importlib.rst b/Doc/library/importlib.rst index 3576941efa46d..c9fb63b75a471 100644 --- a/Doc/library/importlib.rst +++ b/Doc/library/importlib.rst @@ -230,8 +230,8 @@ ABC hierarchy:: object +-- Finder (deprecated) - | +-- MetaPathFinder - | +-- PathEntryFinder + +-- MetaPathFinder + +-- PathEntryFinder +-- Loader +-- ResourceLoader --------+ +-- InspectLoader | @@ -264,8 +264,7 @@ ABC hierarchy:: .. class:: MetaPathFinder - An abstract base class representing a :term:`meta path finder`. For - compatibility, this is a subclass of :class:`Finder`. + An abstract base class representing a :term:`meta path finder`. .. versionadded:: 3.3 From webhook-mailer at python.org Mon May 2 18:26:06 2022 From: webhook-mailer at python.org (JelleZijlstra) Date: Mon, 02 May 2022 22:26:06 -0000 Subject: [Python-checkins] bpo-46547: remove leaking vars into `pydoc.Helper` namespace (#30957) Message-ID: https://github.com/python/cpython/commit/cb6c6648bea57046d5ceff9382f19ebae024b918 commit: cb6c6648bea57046d5ceff9382f19ebae024b918 branch: main author: Nikita Sobolev committer: JelleZijlstra date: 2022-05-02T16:25:52-06:00 summary: bpo-46547: remove leaking vars into `pydoc.Helper` namespace (#30957) Fixes #90705 files: A Misc/NEWS.d/next/Library/2022-01-27-14-41-55.bpo-46547.JMyYz9.rst M Lib/pydoc.py diff --git a/Lib/pydoc.py b/Lib/pydoc.py index 12c2bb450e4f5..297ff967a2ce9 100755 --- a/Lib/pydoc.py +++ b/Lib/pydoc.py @@ -1891,6 +1891,7 @@ class Helper: if topic not in topics: topics = topics + ' ' + topic symbols[symbol] = topics + del topic, symbols_, symbol, topics topics = { 'TYPES': ('types', 'STRINGS UNICODE NUMBERS SEQUENCES MAPPINGS ' diff --git a/Misc/NEWS.d/next/Library/2022-01-27-14-41-55.bpo-46547.JMyYz9.rst b/Misc/NEWS.d/next/Library/2022-01-27-14-41-55.bpo-46547.JMyYz9.rst new file mode 100644 index 0000000000000..83065a7a06030 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2022-01-27-14-41-55.bpo-46547.JMyYz9.rst @@ -0,0 +1 @@ +Remove variables leaking into ``pydoc.Helper`` class namespace. From webhook-mailer at python.org Mon May 2 18:26:52 2022 From: webhook-mailer at python.org (JelleZijlstra) Date: Mon, 02 May 2022 22:26:52 -0000 Subject: [Python-checkins] bpo-6686: Replace String with Bytes in xml.sax.handler documentation (#30612) Message-ID: https://github.com/python/cpython/commit/32e4f450af3fbcc5c7e186f83ff74e2efe164136 commit: 32e4f450af3fbcc5c7e186f83ff74e2efe164136 branch: main author: Yassir Karroum committer: JelleZijlstra date: 2022-05-02T16:26:42-06:00 summary: bpo-6686: Replace String with Bytes in xml.sax.handler documentation (#30612) files: M Doc/library/xml.sax.handler.rst diff --git a/Doc/library/xml.sax.handler.rst b/Doc/library/xml.sax.handler.rst index 59d0d1b3b0117..719ce5ab1bcf6 100644 --- a/Doc/library/xml.sax.handler.rst +++ b/Doc/library/xml.sax.handler.rst @@ -147,7 +147,7 @@ for the feature and property names. .. data:: property_xml_string | value: ``"http://xml.org/sax/properties/xml-string"`` - | data type: String + | data type: Bytes | description: The literal string of characters that was the source for the current event. | access: read-only From webhook-mailer at python.org Mon May 2 18:29:05 2022 From: webhook-mailer at python.org (JelleZijlstra) Date: Mon, 02 May 2022 22:29:05 -0000 Subject: [Python-checkins] bpo-46285: Add command-line option -p/--protocol to module http.server (#30999) Message-ID: https://github.com/python/cpython/commit/2d30adee72317e569d24739243cdd6f7631fa68f commit: 2d30adee72317e569d24739243cdd6f7631fa68f branch: main author: G?ry Ogam committer: JelleZijlstra date: 2022-05-02T16:28:45-06:00 summary: bpo-46285: Add command-line option -p/--protocol to module http.server (#30999) Co-authored-by: ?ric Co-authored-by: Jelle Zijlstra files: A Misc/NEWS.d/next/Library/2022-01-29-00-23-00.bpo-46285.pt84qm.rst M Doc/library/http.server.rst M Lib/http/server.py diff --git a/Doc/library/http.server.rst b/Doc/library/http.server.rst index 0de02834401aa..9d5e5e3a75b19 100644 --- a/Doc/library/http.server.rst +++ b/Doc/library/http.server.rst @@ -157,7 +157,9 @@ provides three different variants: .. attribute:: protocol_version - This specifies the HTTP protocol version used in responses. If set to + Specifies the HTTP version to which the server is conformant. It is sent + in responses to let the client know the server's communication + capabilities for future requests. If set to ``'HTTP/1.1'``, the server will permit HTTP persistent connections; however, your server *must* then include an accurate ``Content-Length`` header (using :meth:`send_header`) in all of its responses to clients. @@ -193,7 +195,7 @@ provides three different variants: .. method:: handle_expect_100() - When a HTTP/1.1 compliant server receives an ``Expect: 100-continue`` + When an HTTP/1.1 conformant server receives an ``Expect: 100-continue`` request header it responds back with a ``100 Continue`` followed by ``200 OK`` headers. This method can be overridden to raise an error if the server does not @@ -444,6 +446,15 @@ the following command uses a specific directory:: .. versionadded:: 3.7 ``--directory`` argument was introduced. +By default, the server is conformant to HTTP/1.0. The option ``-p/--protocol`` +specifies the HTTP version to which the server is conformant. For example, the +following command runs an HTTP/1.1 conformant server:: + + python -m http.server --protocol HTTP/1.1 + +.. versionadded:: 3.11 + ``--protocol`` argument was introduced. + .. class:: CGIHTTPRequestHandler(request, client_address, server) This class is used to serve either files or output of CGI scripts from the diff --git a/Lib/http/server.py b/Lib/http/server.py index a6100d4829751..d115dfc162bb1 100644 --- a/Lib/http/server.py +++ b/Lib/http/server.py @@ -1256,15 +1256,19 @@ def test(HandlerClass=BaseHTTPRequestHandler, parser = argparse.ArgumentParser() parser.add_argument('--cgi', action='store_true', help='run as CGI server') - parser.add_argument('--bind', '-b', metavar='ADDRESS', - help='specify alternate bind address ' + parser.add_argument('-b', '--bind', metavar='ADDRESS', + help='bind to this address ' '(default: all interfaces)') - parser.add_argument('--directory', '-d', default=os.getcwd(), - help='specify alternate directory ' + parser.add_argument('-d', '--directory', default=os.getcwd(), + help='serve this directory ' '(default: current directory)') - parser.add_argument('port', action='store', default=8000, type=int, - nargs='?', - help='specify alternate port (default: 8000)') + parser.add_argument('-p', '--protocol', metavar='VERSION', + default='HTTP/1.0', + help='conform to this HTTP version ' + '(default: %(default)s)') + parser.add_argument('port', default=8000, type=int, nargs='?', + help='bind to this port ' + '(default: %(default)s)') args = parser.parse_args() if args.cgi: handler_class = CGIHTTPRequestHandler @@ -1290,4 +1294,5 @@ def finish_request(self, request, client_address): ServerClass=DualStackServer, port=args.port, bind=args.bind, + protocol=args.protocol, ) diff --git a/Misc/NEWS.d/next/Library/2022-01-29-00-23-00.bpo-46285.pt84qm.rst b/Misc/NEWS.d/next/Library/2022-01-29-00-23-00.bpo-46285.pt84qm.rst new file mode 100644 index 0000000000000..83c4990e475d3 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2022-01-29-00-23-00.bpo-46285.pt84qm.rst @@ -0,0 +1,4 @@ +Add command-line option ``-p``/``--protocol`` to module :mod:`http.server` +which specifies the HTTP version to which the server is conformant (HTTP/1.1 +conformant servers can now be run from the command-line interface of module +:mod:`http.server`). Patch by G?ry Ogam. From webhook-mailer at python.org Mon May 2 18:29:13 2022 From: webhook-mailer at python.org (JelleZijlstra) Date: Mon, 02 May 2022 22:29:13 -0000 Subject: [Python-checkins] Delete outdated comment in logging module (#31117) Message-ID: https://github.com/python/cpython/commit/5e9323a54724079796688425dd32f2683f81b56f commit: 5e9323a54724079796688425dd32f2683f81b56f branch: main author: Thomas Miedema committer: JelleZijlstra date: 2022-05-02T16:29:03-06:00 summary: Delete outdated comment in logging module (#31117) The root logger is now accessible via its name, see https://github.com/python/cpython/pull/15077 Co-authored-by: Jelle Zijlstra files: M Lib/logging/__init__.py diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py index 432fefcb5b314..79e4b7d09bfa4 100644 --- a/Lib/logging/__init__.py +++ b/Lib/logging/__init__.py @@ -1777,8 +1777,6 @@ def __repr__(self): return '<%s %s (%s)>' % (self.__class__.__name__, self.name, level) def __reduce__(self): - # In general, only the root logger will not be accessible via its name. - # However, the root logger's class has its own __reduce__ method. if getLogger(self.name) is not self: import pickle raise pickle.PicklingError('logger cannot be pickled') From webhook-mailer at python.org Mon May 2 18:32:54 2022 From: webhook-mailer at python.org (JelleZijlstra) Date: Mon, 02 May 2022 22:32:54 -0000 Subject: [Python-checkins] bpo-46586: Fix more erroneous doc links to builtins (#31429) Message-ID: https://github.com/python/cpython/commit/cc6ae4f4835f9e76a34f24cd1f666c1cc0fecfa3 commit: cc6ae4f4835f9e76a34f24cd1f666c1cc0fecfa3 branch: main author: Meer Suri <46469858+meersuri at users.noreply.github.com> committer: JelleZijlstra date: 2022-05-02T16:32:44-06:00 summary: bpo-46586: Fix more erroneous doc links to builtins (#31429) Co-authored-by: Jelle Zijlstra Co-authored-by: ?ric files: M Doc/library/fileinput.rst M Doc/library/urllib.request.rst M Doc/library/zipfile.rst diff --git a/Doc/library/fileinput.rst b/Doc/library/fileinput.rst index 2a2c1b3c2b921..4bc868759f202 100644 --- a/Doc/library/fileinput.rst +++ b/Doc/library/fileinput.rst @@ -224,5 +224,5 @@ The two following opening hooks are provided by this module: Added the optional *errors* parameter. .. deprecated:: 3.10 - This function is deprecated since :func:`input` and :class:`FileInput` + This function is deprecated since :func:`fileinput.input` and :class:`FileInput` now have *encoding* and *errors* parameters. diff --git a/Doc/library/urllib.request.rst b/Doc/library/urllib.request.rst index 3823981b37c40..491ef022a1fad 100644 --- a/Doc/library/urllib.request.rst +++ b/Doc/library/urllib.request.rst @@ -739,7 +739,7 @@ The following attribute and methods should only be used by classes derived from This method, if implemented, will be called by the parent :class:`OpenerDirector`. It should return a file-like object as described in - the return value of the :meth:`open` of :class:`OpenerDirector`, or ``None``. + the return value of the :meth:`~OpenerDirector.open` method of :class:`OpenerDirector`, or ``None``. It should raise :exc:`~urllib.error.URLError`, unless a truly exceptional thing happens (for example, :exc:`MemoryError` should not be mapped to :exc:`URLError`). diff --git a/Doc/library/zipfile.rst b/Doc/library/zipfile.rst index d6a1fce49c545..19e128ce02f54 100644 --- a/Doc/library/zipfile.rst +++ b/Doc/library/zipfile.rst @@ -311,7 +311,7 @@ ZipFile Objects compressed text files in :term:`universal newlines` mode. .. versionchanged:: 3.6 - :meth:`open` can now be used to write files into the archive with the + :meth:`ZipFile.open` can now be used to write files into the archive with the ``mode='w'`` option. .. versionchanged:: 3.6 From webhook-mailer at python.org Mon May 2 18:36:46 2022 From: webhook-mailer at python.org (JelleZijlstra) Date: Mon, 02 May 2022 22:36:46 -0000 Subject: [Python-checkins] gh-92032: Add soft keywords to rlcompleter (#92029) Message-ID: https://github.com/python/cpython/commit/4bed9c47bd6c581c4c8ab59ab7acf0e57510d1f7 commit: 4bed9c47bd6c581c4c8ab59ab7acf0e57510d1f7 branch: main author: kbeldan committer: JelleZijlstra date: 2022-05-02T16:36:29-06:00 summary: gh-92032: Add soft keywords to rlcompleter (#92029) Let the interpreter autocomplete soft-keywords, ATM the PEP-634 'match' / 'case' / '_' (wildcard pattern). Co-authored-by: Jelle Zijlstra Co-authored-by: Alex Waygood files: A Misc/NEWS.d/next/Core and Builtins/2022-04-28-20-19-49.gh-issue-92032.ef-UfM.rst M Lib/rlcompleter.py M Lib/test/test_rlcompleter.py diff --git a/Lib/rlcompleter.py b/Lib/rlcompleter.py index 98b7930b32fab..4ede6dcce3fea 100644 --- a/Lib/rlcompleter.py +++ b/Lib/rlcompleter.py @@ -117,14 +117,14 @@ def global_matches(self, text): matches = [] seen = {"__builtins__"} n = len(text) - for word in keyword.kwlist: + for word in keyword.kwlist + keyword.softkwlist: if word[:n] == text: seen.add(word) if word in {'finally', 'try'}: word = word + ':' elif word not in {'False', 'None', 'True', 'break', 'continue', 'pass', - 'else'}: + 'else', '_'}: word = word + ' ' matches.append(word) for nspace in [self.namespace, builtins.__dict__]: diff --git a/Lib/test/test_rlcompleter.py b/Lib/test/test_rlcompleter.py index 1f7a6ed3f639e..6b5fc9a0247f4 100644 --- a/Lib/test/test_rlcompleter.py +++ b/Lib/test/test_rlcompleter.py @@ -138,6 +138,9 @@ def test_complete(self): self.assertEqual(completer.complete('el', 0), 'elif ') self.assertEqual(completer.complete('el', 1), 'else') self.assertEqual(completer.complete('tr', 0), 'try:') + self.assertEqual(completer.complete('_', 0), '_') + self.assertEqual(completer.complete('match', 0), 'match ') + self.assertEqual(completer.complete('case', 0), 'case ') def test_duplicate_globals(self): namespace = { diff --git a/Misc/NEWS.d/next/Core and Builtins/2022-04-28-20-19-49.gh-issue-92032.ef-UfM.rst b/Misc/NEWS.d/next/Core and Builtins/2022-04-28-20-19-49.gh-issue-92032.ef-UfM.rst new file mode 100644 index 0000000000000..f6f0db2c50cbc --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2022-04-28-20-19-49.gh-issue-92032.ef-UfM.rst @@ -0,0 +1,2 @@ +The interpreter can now autocomplete soft keywords, as of now +``match``, ``case``, and ``_`` (wildcard pattern) from :pep:`634`. From webhook-mailer at python.org Mon May 2 18:38:49 2022 From: webhook-mailer at python.org (JelleZijlstra) Date: Mon, 02 May 2022 22:38:49 -0000 Subject: [Python-checkins] gh-92106: Add test that subscription works on arbitrary TypedDicts (#92176) Message-ID: https://github.com/python/cpython/commit/81fb3548be5a18bf40a6f4505a02cc7fb72c9c34 commit: 81fb3548be5a18bf40a6f4505a02cc7fb72c9c34 branch: main author: Serhiy Storchaka committer: JelleZijlstra date: 2022-05-02T16:38:39-06:00 summary: gh-92106: Add test that subscription works on arbitrary TypedDicts (#92176) files: M Lib/test/test_typing.py diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index 88be2850acb1c..cb7ca3610b06a 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -6024,6 +6024,19 @@ def test_get_type_hints(self): {'a': typing.Optional[int], 'b': int} ) + def test_non_generic_subscript(self): + # For backward compatibility, subscription works + # on arbitrary TypedDict types. + class TD(TypedDict): + a: T + A = TD[int] + self.assertEqual(A.__origin__, TD) + self.assertEqual(A.__parameters__, ()) + self.assertEqual(A.__args__, (int,)) + a = A(a = 1) + self.assertIs(type(a), dict) + self.assertEqual(a, {'a': 1}) + class RequiredTests(BaseTestCase): From webhook-mailer at python.org Mon May 2 18:41:27 2022 From: webhook-mailer at python.org (JelleZijlstra) Date: Mon, 02 May 2022 22:41:27 -0000 Subject: [Python-checkins] bpo-43923: Add support for generic typing.NamedTuple (#92027) Message-ID: https://github.com/python/cpython/commit/b04e02c57f82d6e1ae52ee6f070eb893d019f4fd commit: b04e02c57f82d6e1ae52ee6f070eb893d019f4fd branch: main author: Serhiy Storchaka committer: JelleZijlstra date: 2022-05-02T16:41:23-06:00 summary: bpo-43923: Add support for generic typing.NamedTuple (#92027) files: A Misc/NEWS.d/next/Library/2022-04-28-18-45-58.gh-issue-88089.hu9kRk.rst M Doc/library/typing.rst M Doc/whatsnew/3.11.rst M Lib/test/test_typing.py M Lib/typing.py diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst index 868ea1b81be42..05ac05767f32e 100644 --- a/Doc/library/typing.rst +++ b/Doc/library/typing.rst @@ -1615,6 +1615,12 @@ These are not used in annotations. They are building blocks for declaring types. def __repr__(self) -> str: return f'' + ``NamedTuple`` subclasses can be generic:: + + class Group(NamedTuple, Generic[T]): + key: T + group: list[T] + Backward-compatible usage:: Employee = NamedTuple('Employee', [('name', str), ('id', int)]) @@ -1633,6 +1639,9 @@ These are not used in annotations. They are building blocks for declaring types. Removed the ``_field_types`` attribute in favor of the more standard ``__annotations__`` attribute which has the same information. + .. versionchanged:: 3.11 + Added support for generic namedtuples. + .. class:: NewType(name, tp) A helper class to indicate a distinct type to a typechecker, diff --git a/Doc/whatsnew/3.11.rst b/Doc/whatsnew/3.11.rst index 0a8ba1e8843e0..80ce46261f159 100644 --- a/Doc/whatsnew/3.11.rst +++ b/Doc/whatsnew/3.11.rst @@ -715,6 +715,10 @@ For major changes, see :ref:`new-feat-related-type-hints-311`. to clear all registered overloads of a function. (Contributed by Jelle Zijlstra in :gh:`89263`.) +* :class:`~typing.NamedTuple` subclasses can be generic. + (Contributed by Serhiy Storchaka in :issue:`43923`.) + + unicodedata ----------- diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index cb7ca3610b06a..c074e7a780020 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -5678,6 +5678,45 @@ class A: with self.assertRaises(TypeError): class X(NamedTuple, A): x: int + with self.assertRaises(TypeError): + class X(NamedTuple, tuple): + x: int + with self.assertRaises(TypeError): + class X(NamedTuple, NamedTuple): + x: int + class A(NamedTuple): + x: int + with self.assertRaises(TypeError): + class X(NamedTuple, A): + y: str + + def test_generic(self): + class X(NamedTuple, Generic[T]): + x: T + self.assertEqual(X.__bases__, (tuple, Generic)) + self.assertEqual(X.__orig_bases__, (NamedTuple, Generic[T])) + self.assertEqual(X.__mro__, (X, tuple, Generic, object)) + + class Y(Generic[T], NamedTuple): + x: T + self.assertEqual(Y.__bases__, (Generic, tuple)) + self.assertEqual(Y.__orig_bases__, (Generic[T], NamedTuple)) + self.assertEqual(Y.__mro__, (Y, Generic, tuple, object)) + + for G in X, Y: + with self.subTest(type=G): + self.assertEqual(G.__parameters__, (T,)) + A = G[int] + self.assertIs(A.__origin__, G) + self.assertEqual(A.__args__, (int,)) + self.assertEqual(A.__parameters__, ()) + + a = A(3) + self.assertIs(type(a), G) + self.assertEqual(a.x, 3) + + with self.assertRaises(TypeError): + G[int, str] def test_namedtuple_keyword_usage(self): LocalEmployee = NamedTuple("LocalEmployee", name=str, age=int) diff --git a/Lib/typing.py b/Lib/typing.py index 35deb32220eb8..29a3f43881b16 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -2764,7 +2764,12 @@ def _make_nmtuple(name, types, module, defaults = ()): class NamedTupleMeta(type): def __new__(cls, typename, bases, ns): - assert bases[0] is _NamedTuple + assert _NamedTuple in bases + for base in bases: + if base is not _NamedTuple and base is not Generic: + raise TypeError( + 'can only inherit from a NamedTuple type and Generic') + bases = tuple(tuple if base is _NamedTuple else base for base in bases) types = ns.get('__annotations__', {}) default_names = [] for field_name in types: @@ -2778,12 +2783,18 @@ def __new__(cls, typename, bases, ns): nm_tpl = _make_nmtuple(typename, types.items(), defaults=[ns[n] for n in default_names], module=ns['__module__']) + nm_tpl.__bases__ = bases + if Generic in bases: + class_getitem = Generic.__class_getitem__.__func__ + nm_tpl.__class_getitem__ = classmethod(class_getitem) # update from user namespace without overriding special namedtuple attributes for key in ns: if key in _prohibited: raise AttributeError("Cannot overwrite NamedTuple attribute " + key) elif key not in _special and key not in nm_tpl._fields: setattr(nm_tpl, key, ns[key]) + if Generic in bases: + nm_tpl.__init_subclass__() return nm_tpl @@ -2821,9 +2832,7 @@ class Employee(NamedTuple): _NamedTuple = type.__new__(NamedTupleMeta, 'NamedTuple', (), {}) def _namedtuple_mro_entries(bases): - if len(bases) > 1: - raise TypeError("Multiple inheritance with NamedTuple is not supported") - assert bases[0] is NamedTuple + assert NamedTuple in bases return (_NamedTuple,) NamedTuple.__mro_entries__ = _namedtuple_mro_entries diff --git a/Misc/NEWS.d/next/Library/2022-04-28-18-45-58.gh-issue-88089.hu9kRk.rst b/Misc/NEWS.d/next/Library/2022-04-28-18-45-58.gh-issue-88089.hu9kRk.rst new file mode 100644 index 0000000000000..2665a472db627 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2022-04-28-18-45-58.gh-issue-88089.hu9kRk.rst @@ -0,0 +1 @@ +Add support for generic :class:`typing.NamedTuple`. From webhook-mailer at python.org Mon May 2 18:44:11 2022 From: webhook-mailer at python.org (miss-islington) Date: Mon, 02 May 2022 22:44:11 -0000 Subject: [Python-checkins] bpo-6686: Replace String with Bytes in xml.sax.handler documentation (GH-30612) Message-ID: https://github.com/python/cpython/commit/f44e629a57dae2b29bf22449c915619503894b3b commit: f44e629a57dae2b29bf22449c915619503894b3b branch: 3.10 author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com> committer: miss-islington <31488909+miss-islington at users.noreply.github.com> date: 2022-05-02T15:44:07-07:00 summary: bpo-6686: Replace String with Bytes in xml.sax.handler documentation (GH-30612) (cherry picked from commit 32e4f450af3fbcc5c7e186f83ff74e2efe164136) Co-authored-by: Yassir Karroum files: M Doc/library/xml.sax.handler.rst diff --git a/Doc/library/xml.sax.handler.rst b/Doc/library/xml.sax.handler.rst index 59d0d1b3b0117..719ce5ab1bcf6 100644 --- a/Doc/library/xml.sax.handler.rst +++ b/Doc/library/xml.sax.handler.rst @@ -147,7 +147,7 @@ for the feature and property names. .. data:: property_xml_string | value: ``"http://xml.org/sax/properties/xml-string"`` - | data type: String + | data type: Bytes | description: The literal string of characters that was the source for the current event. | access: read-only From webhook-mailer at python.org Mon May 2 18:45:27 2022 From: webhook-mailer at python.org (miss-islington) Date: Mon, 02 May 2022 22:45:27 -0000 Subject: [Python-checkins] bpo-46787: Fix `ProcessPoolExecutor exception` memory leak (GH-31408) (GH-31408) Message-ID: https://github.com/python/cpython/commit/c467812bc0174c12546f7bfdd4f6e445b87590c0 commit: c467812bc0174c12546f7bfdd4f6e445b87590c0 branch: 3.10 author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com> committer: miss-islington <31488909+miss-islington at users.noreply.github.com> date: 2022-05-02T15:45:22-07:00 summary: bpo-46787: Fix `ProcessPoolExecutor exception` memory leak (GH-31408) (GH-31408) Do not store `ProcessPoolExecutor` work item exception traceback that prevents exception frame locals from being garbage collected. (cherry picked from commit 9c204b148fad9742ed19b3bce173073cdec79819) Co-authored-by: themylogin files: A Misc/NEWS.d/next/Library/2022-02-18-20-09-29.bpo-46787.juwWc0.rst M Lib/concurrent/futures/process.py diff --git a/Lib/concurrent/futures/process.py b/Lib/concurrent/futures/process.py index 6ee2ce626e456..c03187de85a91 100644 --- a/Lib/concurrent/futures/process.py +++ b/Lib/concurrent/futures/process.py @@ -126,6 +126,9 @@ def __init__(self, exc, tb): tb = traceback.format_exception(type(exc), exc, tb) tb = ''.join(tb) self.exc = exc + # Traceback object needs to be garbage-collected as its frames + # contain references to all the objects in the exception scope + self.exc.__traceback__ = None self.tb = '\n"""\n%s"""' % tb def __reduce__(self): return _rebuild_exc, (self.exc, self.tb) diff --git a/Misc/NEWS.d/next/Library/2022-02-18-20-09-29.bpo-46787.juwWc0.rst b/Misc/NEWS.d/next/Library/2022-02-18-20-09-29.bpo-46787.juwWc0.rst new file mode 100644 index 0000000000000..cf167ff48115b --- /dev/null +++ b/Misc/NEWS.d/next/Library/2022-02-18-20-09-29.bpo-46787.juwWc0.rst @@ -0,0 +1 @@ +Fix :class:`concurrent.futures.ProcessPoolExecutor` exception memory leak From webhook-mailer at python.org Mon May 2 18:45:59 2022 From: webhook-mailer at python.org (miss-islington) Date: Mon, 02 May 2022 22:45:59 -0000 Subject: [Python-checkins] bpo-6686: Replace String with Bytes in xml.sax.handler documentation (GH-30612) Message-ID: https://github.com/python/cpython/commit/3fe4e4602ddc84569ea44384812667c0657c9bdb commit: 3fe4e4602ddc84569ea44384812667c0657c9bdb branch: 3.9 author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com> committer: miss-islington <31488909+miss-islington at users.noreply.github.com> date: 2022-05-02T15:45:55-07:00 summary: bpo-6686: Replace String with Bytes in xml.sax.handler documentation (GH-30612) (cherry picked from commit 32e4f450af3fbcc5c7e186f83ff74e2efe164136) Co-authored-by: Yassir Karroum files: M Doc/library/xml.sax.handler.rst diff --git a/Doc/library/xml.sax.handler.rst b/Doc/library/xml.sax.handler.rst index ae0877ca90db0..c7831ce3d7636 100644 --- a/Doc/library/xml.sax.handler.rst +++ b/Doc/library/xml.sax.handler.rst @@ -141,7 +141,7 @@ for the feature and property names. .. data:: property_xml_string | value: ``"http://xml.org/sax/properties/xml-string"`` - | data type: String + | data type: Bytes | description: The literal string of characters that was the source for the current event. | access: read-only From webhook-mailer at python.org Mon May 2 18:51:31 2022 From: webhook-mailer at python.org (miss-islington) Date: Mon, 02 May 2022 22:51:31 -0000 Subject: [Python-checkins] bpo-46787: Fix `ProcessPoolExecutor exception` memory leak (GH-31408) (GH-31408) Message-ID: https://github.com/python/cpython/commit/51b885a38a6cbf1d11d3c49e0d2c6532944fcd4d commit: 51b885a38a6cbf1d11d3c49e0d2c6532944fcd4d branch: 3.9 author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com> committer: miss-islington <31488909+miss-islington at users.noreply.github.com> date: 2022-05-02T15:51:20-07:00 summary: bpo-46787: Fix `ProcessPoolExecutor exception` memory leak (GH-31408) (GH-31408) Do not store `ProcessPoolExecutor` work item exception traceback that prevents exception frame locals from being garbage collected. (cherry picked from commit 9c204b148fad9742ed19b3bce173073cdec79819) Co-authored-by: themylogin files: A Misc/NEWS.d/next/Library/2022-02-18-20-09-29.bpo-46787.juwWc0.rst M Lib/concurrent/futures/process.py diff --git a/Lib/concurrent/futures/process.py b/Lib/concurrent/futures/process.py index a29e5247ab85c..e574299eb033b 100644 --- a/Lib/concurrent/futures/process.py +++ b/Lib/concurrent/futures/process.py @@ -126,6 +126,9 @@ def __init__(self, exc, tb): tb = traceback.format_exception(type(exc), exc, tb) tb = ''.join(tb) self.exc = exc + # Traceback object needs to be garbage-collected as its frames + # contain references to all the objects in the exception scope + self.exc.__traceback__ = None self.tb = '\n"""\n%s"""' % tb def __reduce__(self): return _rebuild_exc, (self.exc, self.tb) diff --git a/Misc/NEWS.d/next/Library/2022-02-18-20-09-29.bpo-46787.juwWc0.rst b/Misc/NEWS.d/next/Library/2022-02-18-20-09-29.bpo-46787.juwWc0.rst new file mode 100644 index 0000000000000..cf167ff48115b --- /dev/null +++ b/Misc/NEWS.d/next/Library/2022-02-18-20-09-29.bpo-46787.juwWc0.rst @@ -0,0 +1 @@ +Fix :class:`concurrent.futures.ProcessPoolExecutor` exception memory leak From webhook-mailer at python.org Mon May 2 18:51:37 2022 From: webhook-mailer at python.org (miss-islington) Date: Mon, 02 May 2022 22:51:37 -0000 Subject: [Python-checkins] bpo-46586: Fix more erroneous doc links to builtins (GH-31429) Message-ID: https://github.com/python/cpython/commit/5f40cb85c22212365caf599665614473ac077143 commit: 5f40cb85c22212365caf599665614473ac077143 branch: 3.10 author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com> committer: miss-islington <31488909+miss-islington at users.noreply.github.com> date: 2022-05-02T15:51:33-07:00 summary: bpo-46586: Fix more erroneous doc links to builtins (GH-31429) Co-authored-by: Jelle Zijlstra Co-authored-by: ?ric (cherry picked from commit cc6ae4f4835f9e76a34f24cd1f666c1cc0fecfa3) Co-authored-by: Meer Suri <46469858+meersuri at users.noreply.github.com> files: M Doc/library/fileinput.rst M Doc/library/urllib.request.rst M Doc/library/zipfile.rst diff --git a/Doc/library/fileinput.rst b/Doc/library/fileinput.rst index 19cf7c67754f6..2df895a69c43d 100644 --- a/Doc/library/fileinput.rst +++ b/Doc/library/fileinput.rst @@ -227,5 +227,5 @@ The two following opening hooks are provided by this module: Added the optional *errors* parameter. .. deprecated:: 3.10 - This function is deprecated since :func:`input` and :class:`FileInput` + This function is deprecated since :func:`fileinput.input` and :class:`FileInput` now have *encoding* and *errors* parameters. diff --git a/Doc/library/urllib.request.rst b/Doc/library/urllib.request.rst index 39d1a277aa6c7..63248b3d94f21 100644 --- a/Doc/library/urllib.request.rst +++ b/Doc/library/urllib.request.rst @@ -739,7 +739,7 @@ The following attribute and methods should only be used by classes derived from This method, if implemented, will be called by the parent :class:`OpenerDirector`. It should return a file-like object as described in - the return value of the :meth:`open` of :class:`OpenerDirector`, or ``None``. + the return value of the :meth:`~OpenerDirector.open` method of :class:`OpenerDirector`, or ``None``. It should raise :exc:`~urllib.error.URLError`, unless a truly exceptional thing happens (for example, :exc:`MemoryError` should not be mapped to :exc:`URLError`). diff --git a/Doc/library/zipfile.rst b/Doc/library/zipfile.rst index 43520b697c9d2..f6288709fec1a 100644 --- a/Doc/library/zipfile.rst +++ b/Doc/library/zipfile.rst @@ -289,7 +289,7 @@ ZipFile Objects compressed text files in :term:`universal newlines` mode. .. versionchanged:: 3.6 - :meth:`open` can now be used to write files into the archive with the + :meth:`ZipFile.open` can now be used to write files into the archive with the ``mode='w'`` option. .. versionchanged:: 3.6 From webhook-mailer at python.org Mon May 2 18:51:38 2022 From: webhook-mailer at python.org (brettcannon) Date: Mon, 02 May 2022 22:51:38 -0000 Subject: [Python-checkins] gh-84461: Add ability for multiprocessed libregrtest to use a different Python executable (GH-91930) Message-ID: https://github.com/python/cpython/commit/aff8c4f4884fe5ffb2059c2ac9485ded3bba3f3c commit: aff8c4f4884fe5ffb2059c2ac9485ded3bba3f3c branch: main author: Ethan Smith committer: brettcannon date: 2022-05-02T15:51:34-07:00 summary: gh-84461: Add ability for multiprocessed libregrtest to use a different Python executable (GH-91930) files: A Misc/NEWS.d/next/Tests/2022-05-02-20-15-54.gh-issue-84461.DhxllI.rst M Lib/test/libregrtest/cmdline.py M Lib/test/libregrtest/runtest_mp.py diff --git a/Lib/test/libregrtest/cmdline.py b/Lib/test/libregrtest/cmdline.py index 11fa0f940bb71..1ac63af734c41 100644 --- a/Lib/test/libregrtest/cmdline.py +++ b/Lib/test/libregrtest/cmdline.py @@ -206,6 +206,8 @@ def _create_parser(): group.add_argument('-S', '--start', metavar='START', help='the name of the test at which to start.' + more_details) + group.add_argument('-p', '--python', metavar='PYTHON', + help='Command to run Python test subprocesses with.') group = parser.add_argument_group('Verbosity') group.add_argument('-v', '--verbose', action='count', @@ -370,6 +372,8 @@ def _parse_args(args, **kwargs): parser.error("-s and -f don't go together!") if ns.use_mp is not None and ns.trace: parser.error("-T and -j don't go together!") + if ns.python is not None and ns.use_mp is None: + parser.error("-p requires -j!") if ns.failfast and not (ns.verbose or ns.verbose3): parser.error("-G/--failfast needs either -v or -W") if ns.pgo and (ns.verbose or ns.verbose2 or ns.verbose3): diff --git a/Lib/test/libregrtest/runtest_mp.py b/Lib/test/libregrtest/runtest_mp.py index 75444e48080ce..39fab5566a089 100644 --- a/Lib/test/libregrtest/runtest_mp.py +++ b/Lib/test/libregrtest/runtest_mp.py @@ -2,6 +2,7 @@ import json import os import queue +import shlex import signal import subprocess import sys @@ -55,8 +56,12 @@ def run_test_in_subprocess(testname: str, ns: Namespace) -> subprocess.Popen: ns_dict = vars(ns) worker_args = (ns_dict, testname) worker_args = json.dumps(worker_args) - - cmd = [sys.executable, *support.args_from_interpreter_flags(), + if ns.python is not None: + # The "executable" may be two or more parts, e.g. "node python.js" + executable = shlex.split(ns.python) + else: + executable = [sys.executable] + cmd = [*executable, *support.args_from_interpreter_flags(), '-u', # Unbuffered stdout and stderr '-m', 'test.regrtest', '--worker-args', worker_args] diff --git a/Misc/NEWS.d/next/Tests/2022-05-02-20-15-54.gh-issue-84461.DhxllI.rst b/Misc/NEWS.d/next/Tests/2022-05-02-20-15-54.gh-issue-84461.DhxllI.rst new file mode 100644 index 0000000000000..4daae71060346 --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2022-05-02-20-15-54.gh-issue-84461.DhxllI.rst @@ -0,0 +1 @@ +When multiprocessing is enabled, libregrtest can now use a Python executable other than :code:`sys.executable` via the ``--python`` flag. From webhook-mailer at python.org Mon May 2 19:08:33 2022 From: webhook-mailer at python.org (JelleZijlstra) Date: Mon, 02 May 2022 23:08:33 -0000 Subject: [Python-checkins] gh-91621: Fix typing.get_type_hints for collections.abc.Callable (#91656) Message-ID: https://github.com/python/cpython/commit/ebb8b512e959ca1a0a506ac0f0faf461b1b2ff85 commit: ebb8b512e959ca1a0a506ac0f0faf461b1b2ff85 branch: main author: Shantanu <12621235+hauntsaninja at users.noreply.github.com> committer: JelleZijlstra date: 2022-05-02T17:08:28-06:00 summary: gh-91621: Fix typing.get_type_hints for collections.abc.Callable (#91656) This mirrors logic in typing.get_args. The trickiness comes from how we flatten args in collections.abc.Callable, see https://bugs.python.org/issue42195 files: A Misc/NEWS.d/next/Library/2022-04-18-18-55-21.gh-issue-91621.ACNlda.rst M Lib/test/test_typing.py M Lib/typing.py diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index c074e7a780020..08f7d0211eafb 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -4876,6 +4876,17 @@ def test_get_type_hints_typeddict(self): 'a': Annotated[Required[int], "a", "b", "c"] }) + def test_get_type_hints_collections_abc_callable(self): + # https://github.com/python/cpython/issues/91621 + P = ParamSpec('P') + def f(x: collections.abc.Callable[[int], int]): ... + def g(x: collections.abc.Callable[..., int]): ... + def h(x: collections.abc.Callable[P, int]): ... + + self.assertEqual(get_type_hints(f), {'x': collections.abc.Callable[[int], int]}) + self.assertEqual(get_type_hints(g), {'x': collections.abc.Callable[..., int]}) + self.assertEqual(get_type_hints(h), {'x': collections.abc.Callable[P, int]}) + class GetUtilitiesTestCase(TestCase): def test_get_origin(self): diff --git a/Lib/typing.py b/Lib/typing.py index 29a3f43881b16..84f0fd1a8a946 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -203,6 +203,24 @@ def _is_param_expr(arg): (tuple, list, ParamSpec, _ConcatenateGenericAlias)) +def _should_unflatten_callable_args(typ, args): + """Internal helper for munging collections.abc.Callable's __args__. + + The canonical representation for a Callable's __args__ flattens the + argument types, see https://bugs.python.org/issue42195. For example: + + collections.abc.Callable[[int, int], str].__args__ == (int, int, str) + collections.abc.Callable[ParamSpec, str].__args__ == (ParamSpec, str) + + As a result, if we need to reconstruct the Callable from its __args__, + we need to unflatten it. + """ + return ( + typ.__origin__ is collections.abc.Callable + and not (len(args) == 2 and _is_param_expr(args[0])) + ) + + def _type_repr(obj): """Return the repr() of an object, special-casing types (internal helper). @@ -351,7 +369,10 @@ def _eval_type(t, globalns, localns, recursive_guard=frozenset()): ForwardRef(arg) if isinstance(arg, str) else arg for arg in t.__args__ ) - t = t.__origin__[args] + if _should_unflatten_callable_args(t, args): + t = t.__origin__[(args[:-1], args[-1])] + else: + t = t.__origin__[args] ev_args = tuple(_eval_type(a, globalns, localns, recursive_guard) for a in t.__args__) if ev_args == t.__args__: return t @@ -2361,8 +2382,7 @@ def get_args(tp): return (tp.__origin__,) + tp.__metadata__ if isinstance(tp, (_GenericAlias, GenericAlias)): res = tp.__args__ - if (tp.__origin__ is collections.abc.Callable - and not (len(res) == 2 and _is_param_expr(res[0]))): + if _should_unflatten_callable_args(tp, res): res = (list(res[:-1]), res[-1]) return res if isinstance(tp, types.UnionType): diff --git a/Misc/NEWS.d/next/Library/2022-04-18-18-55-21.gh-issue-91621.ACNlda.rst b/Misc/NEWS.d/next/Library/2022-04-18-18-55-21.gh-issue-91621.ACNlda.rst new file mode 100644 index 0000000000000..b9e68d225a25b --- /dev/null +++ b/Misc/NEWS.d/next/Library/2022-04-18-18-55-21.gh-issue-91621.ACNlda.rst @@ -0,0 +1 @@ +Fix :func:`typing.get_type_hints` for :class:`collections.abc.Callable`. Patch by Shantanu Jain. From webhook-mailer at python.org Mon May 2 19:19:18 2022 From: webhook-mailer at python.org (zooba) Date: Mon, 02 May 2022 23:19:18 -0000 Subject: [Python-checkins] bpo-46785: Fix race condition between os.stat() and unlink on Windows (GH-31858) Message-ID: https://github.com/python/cpython/commit/39e6b8ae6a5b49bb23746fdcc354d148ff2d98e3 commit: 39e6b8ae6a5b49bb23746fdcc354d148ff2d98e3 branch: main author: Itai Steinherz committer: zooba date: 2022-05-03T00:19:13+01:00 summary: bpo-46785: Fix race condition between os.stat() and unlink on Windows (GH-31858) files: A Misc/NEWS.d/next/Windows/2022-03-13-20-35-41.bpo-46785.Pnknyl.rst M Lib/test/test_os.py M Misc/ACKS M Modules/posixmodule.c diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py index 5f73af81d4560..36ad587760d70 100644 --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -24,6 +24,7 @@ import sys import sysconfig import tempfile +import textwrap import time import types import unittest @@ -2883,6 +2884,49 @@ def test_getfinalpathname_handles(self): self.assertEqual(0, handle_delta) + @support.requires_subprocess() + def test_stat_unlink_race(self): + # bpo-46785: the implementation of os.stat() falls back to reading + # the parent directory if CreateFileW() fails with a permission + # error. If reading the parent directory fails because the file or + # directory are subsequently unlinked, or because the volume or + # share are no longer available, then the original permission error + # should not be restored. + filename = os_helper.TESTFN + self.addCleanup(os_helper.unlink, filename) + deadline = time.time() + 5 + command = textwrap.dedent("""\ + import os + import sys + import time + + filename = sys.argv[1] + deadline = float(sys.argv[2]) + + while time.time() < deadline: + try: + with open(filename, "w") as f: + pass + except OSError: + pass + try: + os.remove(filename) + except OSError: + pass + """) + + with subprocess.Popen([sys.executable, '-c', command, filename, str(deadline)]) as proc: + while time.time() < deadline: + try: + os.stat(filename) + except FileNotFoundError as e: + assert e.winerror == 2 # ERROR_FILE_NOT_FOUND + try: + proc.wait(1) + except subprocess.TimeoutExpired: + proc.terminate() + + @os_helper.skip_unless_symlink class NonLocalSymlinkTests(unittest.TestCase): diff --git a/Misc/ACKS b/Misc/ACKS index 5e66a2e757adf..30b698f90e83b 100644 --- a/Misc/ACKS +++ b/Misc/ACKS @@ -1705,6 +1705,7 @@ Anthony Starks David Steele Oliver Steele Greg Stein +Itai Steinherz Marek Stepniowski Baruch Sterin Chris Stern diff --git a/Misc/NEWS.d/next/Windows/2022-03-13-20-35-41.bpo-46785.Pnknyl.rst b/Misc/NEWS.d/next/Windows/2022-03-13-20-35-41.bpo-46785.Pnknyl.rst new file mode 100644 index 0000000000000..0a87abd77c8ff --- /dev/null +++ b/Misc/NEWS.d/next/Windows/2022-03-13-20-35-41.bpo-46785.Pnknyl.rst @@ -0,0 +1 @@ +Fix race condition between :func:`os.stat` and unlinking a file on Windows, by using errors codes returned by ``FindFirstFileW()`` when appropriate in ``win32_xstat_impl``. diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index a2ea5079969e9..a7f57804687cd 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -1890,7 +1890,17 @@ win32_xstat_impl(const wchar_t *path, struct _Py_stat_struct *result, /* Try reading the parent directory. */ if (!attributes_from_dir(path, &fileInfo, &tagInfo.ReparseTag)) { /* Cannot read the parent directory. */ - SetLastError(error); + switch (GetLastError()) { + case ERROR_FILE_NOT_FOUND: /* File cannot be found */ + case ERROR_PATH_NOT_FOUND: /* File parent directory cannot be found */ + case ERROR_NOT_READY: /* Drive exists but unavailable */ + case ERROR_BAD_NET_NAME: /* Remote drive unavailable */ + break; + /* Restore the error from CreateFileW(). */ + default: + SetLastError(error); + } + return -1; } if (fileInfo.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) { From webhook-mailer at python.org Mon May 2 20:39:28 2022 From: webhook-mailer at python.org (miss-islington) Date: Tue, 03 May 2022 00:39:28 -0000 Subject: [Python-checkins] gh-92106: Add test that subscription works on arbitrary TypedDicts (GH-92176) Message-ID: https://github.com/python/cpython/commit/adc06cd2d727d580cfeda1fc29b419ecce379687 commit: adc06cd2d727d580cfeda1fc29b419ecce379687 branch: 3.10 author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com> committer: miss-islington <31488909+miss-islington at users.noreply.github.com> date: 2022-05-02T17:39:07-07:00 summary: gh-92106: Add test that subscription works on arbitrary TypedDicts (GH-92176) (cherry picked from commit 81fb3548be5a18bf40a6f4505a02cc7fb72c9c34) Co-authored-by: Serhiy Storchaka files: M Lib/test/test_typing.py diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index 779e1758d51d8..111a207dd10b3 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -4485,6 +4485,19 @@ def test_get_type_hints(self): {'a': typing.Optional[int], 'b': int} ) + def test_non_generic_subscript(self): + # For backward compatibility, subscription works + # on arbitrary TypedDict types. + class TD(TypedDict): + a: T + A = TD[int] + self.assertEqual(A.__origin__, TD) + self.assertEqual(A.__parameters__, ()) + self.assertEqual(A.__args__, (int,)) + a = A(a = 1) + self.assertIs(type(a), dict) + self.assertEqual(a, {'a': 1}) + class IOTests(BaseTestCase): From webhook-mailer at python.org Mon May 2 21:06:13 2022 From: webhook-mailer at python.org (miss-islington) Date: Tue, 03 May 2022 01:06:13 -0000 Subject: [Python-checkins] gh-92106: Add test that subscription works on arbitrary TypedDicts (GH-92176) Message-ID: https://github.com/python/cpython/commit/7e55730e3f0a0c8c1b73037011e4b00dd7bd7f69 commit: 7e55730e3f0a0c8c1b73037011e4b00dd7bd7f69 branch: 3.9 author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com> committer: miss-islington <31488909+miss-islington at users.noreply.github.com> date: 2022-05-02T18:05:49-07:00 summary: gh-92106: Add test that subscription works on arbitrary TypedDicts (GH-92176) (cherry picked from commit 81fb3548be5a18bf40a6f4505a02cc7fb72c9c34) Co-authored-by: Serhiy Storchaka files: M Lib/test/test_typing.py diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index 08eddb095d561..3fec59a879141 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -4076,6 +4076,19 @@ def test_get_type_hints(self): {'a': typing.Optional[int], 'b': int} ) + def test_non_generic_subscript(self): + # For backward compatibility, subscription works + # on arbitrary TypedDict types. + class TD(TypedDict): + a: T + A = TD[int] + self.assertEqual(A.__origin__, TD) + self.assertEqual(A.__parameters__, ()) + self.assertEqual(A.__args__, (int,)) + a = A(a = 1) + self.assertIs(type(a), dict) + self.assertEqual(a, {'a': 1}) + class IOTests(BaseTestCase): From webhook-mailer at python.org Mon May 2 23:45:34 2022 From: webhook-mailer at python.org (JelleZijlstra) Date: Tue, 03 May 2022 03:45:34 -0000 Subject: [Python-checkins] gh-92206: Move pysqlite_step() to Modules/_sqlite/cursor.c (#92207) Message-ID: https://github.com/python/cpython/commit/e846fe3fc189ff54413382611ee36e41c2f0776b commit: e846fe3fc189ff54413382611ee36e41c2f0776b branch: main author: Erlend Egeberg Aasland committer: JelleZijlstra date: 2022-05-02T21:45:04-06:00 summary: gh-92206: Move pysqlite_step() to Modules/_sqlite/cursor.c (#92207) files: M Modules/_sqlite/cursor.c M Modules/_sqlite/util.c M Modules/_sqlite/util.h diff --git a/Modules/_sqlite/cursor.c b/Modules/_sqlite/cursor.c index e48a95867298b..861704f95cc83 100644 --- a/Modules/_sqlite/cursor.c +++ b/Modules/_sqlite/cursor.c @@ -454,6 +454,18 @@ get_statement_from_cache(pysqlite_Cursor *self, PyObject *operation) return PyObject_Vectorcall(cache, args + 1, nargsf, NULL); } +static inline int +stmt_step(sqlite3_stmt *statement) +{ + int rc; + + Py_BEGIN_ALLOW_THREADS + rc = sqlite3_step(statement); + Py_END_ALLOW_THREADS + + return rc; +} + PyObject * _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* operation, PyObject* second_argument) { @@ -570,7 +582,7 @@ _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* operation goto error; } - rc = pysqlite_step(self->statement->st); + rc = stmt_step(self->statement->st); if (rc != SQLITE_DONE && rc != SQLITE_ROW) { if (PyErr_Occurred()) { /* there was an error that occurred in a user-defined callback */ @@ -799,7 +811,7 @@ pysqlite_cursor_iternext(pysqlite_Cursor *self) if (row == NULL) { return NULL; } - int rc = pysqlite_step(stmt); + int rc = stmt_step(stmt); if (rc == SQLITE_DONE) { (void)pysqlite_statement_reset(self->statement); } diff --git a/Modules/_sqlite/util.c b/Modules/_sqlite/util.c index 113b581bfac73..37b2dd6cb29f4 100644 --- a/Modules/_sqlite/util.c +++ b/Modules/_sqlite/util.c @@ -24,18 +24,6 @@ #include "module.h" #include "connection.h" -int -pysqlite_step(sqlite3_stmt *statement) -{ - int rc; - - Py_BEGIN_ALLOW_THREADS - rc = sqlite3_step(statement); - Py_END_ALLOW_THREADS - - return rc; -} - // Returns non-NULL if a new exception should be raised static PyObject * get_exception_class(pysqlite_state *state, int errorcode) diff --git a/Modules/_sqlite/util.h b/Modules/_sqlite/util.h index 5eee3fac6f114..a22bcd82d2a05 100644 --- a/Modules/_sqlite/util.h +++ b/Modules/_sqlite/util.h @@ -29,8 +29,6 @@ #include "sqlite3.h" #include "connection.h" -int pysqlite_step(sqlite3_stmt *statement); - /** * Checks the SQLite error code and sets the appropriate DB-API exception. * Returns the error code (0 means no error occurred). From webhook-mailer at python.org Tue May 3 01:11:10 2022 From: webhook-mailer at python.org (JelleZijlstra) Date: Tue, 03 May 2022 05:11:10 -0000 Subject: [Python-checkins] bpo-46267: Test compresslevel in gzip.compress (#30416) Message-ID: https://github.com/python/cpython/commit/a73fc73ff7586b09d68a330760d06862f5bafb9b commit: a73fc73ff7586b09d68a330760d06862f5bafb9b branch: main author: Ruben Vorderman committer: JelleZijlstra date: 2022-05-02T23:11:06-06:00 summary: bpo-46267: Test compresslevel in gzip.compress (#30416) Fixes #90425 files: M Lib/test/test_gzip.py diff --git a/Lib/test/test_gzip.py b/Lib/test/test_gzip.py index 497e66cd553b7..6de413e5056ef 100644 --- a/Lib/test/test_gzip.py +++ b/Lib/test/test_gzip.py @@ -552,6 +552,15 @@ def test_compress_mtime(self): f.read(1) # to set mtime attribute self.assertEqual(f.mtime, mtime) + def test_compress_correct_level(self): + # gzip.compress calls with mtime == 0 take a different code path. + for mtime in (0, 42): + with self.subTest(mtime=mtime): + nocompress = gzip.compress(data1, compresslevel=0, mtime=mtime) + yescompress = gzip.compress(data1, compresslevel=1, mtime=mtime) + self.assertIn(data1, nocompress) + self.assertNotIn(data1, yescompress) + def test_decompress(self): for data in (data1, data2): buf = io.BytesIO() From webhook-mailer at python.org Tue May 3 02:49:17 2022 From: webhook-mailer at python.org (Fidget-Spinner) Date: Tue, 03 May 2022 06:49:17 -0000 Subject: [Python-checkins] Fix doc warnings in What's New in 3.11 (GH-92215) Message-ID: https://github.com/python/cpython/commit/c1767fce521f5d4f175082d0747cfa48542aea3a commit: c1767fce521f5d4f175082d0747cfa48542aea3a branch: main author: Ken Jin committer: Fidget-Spinner date: 2022-05-03T14:49:06+08:00 summary: Fix doc warnings in What's New in 3.11 (GH-92215) files: M Doc/whatsnew/3.11.rst diff --git a/Doc/whatsnew/3.11.rst b/Doc/whatsnew/3.11.rst index 80ce46261f159..607f2e749bb5a 100644 --- a/Doc/whatsnew/3.11.rst +++ b/Doc/whatsnew/3.11.rst @@ -1396,7 +1396,7 @@ C API Changes fields of the result from the exception instance (the ``value`` field). (Contributed by Irit Katriel in :issue:`45711`.) -* :c:struct:`_frozen` has a new ``is_package`` field to indicate whether +* :c:type:`_frozen` has a new ``is_package`` field to indicate whether or not the frozen module is a package. Previously, a negative value in the ``size`` field was the indicator. Now only non-negative values be used for ``size``. From webhook-mailer at python.org Tue May 3 03:18:06 2022 From: webhook-mailer at python.org (serhiy-storchaka) Date: Tue, 03 May 2022 07:18:06 -0000 Subject: [Python-checkins] gh-92169: Use warnings_helper.import_deprecated() to import deprecated modules uniformly in tests (GH-92170) Message-ID: https://github.com/python/cpython/commit/9b027d4cea57e98c76f5176cc3188dc81603356c commit: 9b027d4cea57e98c76f5176cc3188dc81603356c branch: main author: Hugo van Kemenade committer: serhiy-storchaka date: 2022-05-03T10:17:54+03:00 summary: gh-92169: Use warnings_helper.import_deprecated() to import deprecated modules uniformly in tests (GH-92170) files: A Misc/NEWS.d/next/Tests/2022-05-02-20-57-04.gh-issue-92169.Xi4NGV.rst M Lib/test/test_asynchat.py M Lib/test/test_asyncore.py M Lib/test/test_ftplib.py M Lib/test/test_imp.py M Lib/test/test_logging.py M Lib/test/test_poplib.py M Lib/test/test_smtpd.py M Lib/test/test_smtplib.py M Lib/test/test_ssl.py diff --git a/Lib/test/test_asynchat.py b/Lib/test/test_asynchat.py index d28d67732e788..9d08bd02968fd 100644 --- a/Lib/test/test_asynchat.py +++ b/Lib/test/test_asynchat.py @@ -3,6 +3,7 @@ from test import support from test.support import socket_helper from test.support import threading_helper +from test.support import warnings_helper import errno import socket @@ -12,11 +13,9 @@ import unittest import unittest.mock -import warnings -with warnings.catch_warnings(): - warnings.simplefilter('ignore', DeprecationWarning) - import asynchat - import asyncore + +asynchat = warnings_helper.import_deprecated('asynchat') +asyncore = warnings_helper.import_deprecated('asyncore') support.requires_working_socket(module=True) diff --git a/Lib/test/test_asyncore.py b/Lib/test/test_asyncore.py index e3f31bd06d0c3..98ccd3a9304de 100644 --- a/Lib/test/test_asyncore.py +++ b/Lib/test/test_asyncore.py @@ -20,10 +20,7 @@ support.requires_working_socket(module=True) -import warnings -with warnings.catch_warnings(): - warnings.simplefilter('ignore', DeprecationWarning) - import asyncore +asyncore = warnings_helper.import_deprecated('asyncore') HAS_UNIX_SOCKETS = hasattr(socket, 'AF_UNIX') diff --git a/Lib/test/test_ftplib.py b/Lib/test/test_ftplib.py index 2794fccfe7c72..082a90d46baed 100644 --- a/Lib/test/test_ftplib.py +++ b/Lib/test/test_ftplib.py @@ -23,11 +23,10 @@ from test.support import warnings_helper from test.support.socket_helper import HOST, HOSTv6 -import warnings -with warnings.catch_warnings(): - warnings.simplefilter('ignore', DeprecationWarning) - import asyncore - import asynchat + +asynchat = warnings_helper.import_deprecated('asynchat') +asyncore = warnings_helper.import_deprecated('asyncore') + support.requires_working_socket(module=True) diff --git a/Lib/test/test_imp.py b/Lib/test/test_imp.py index 35e9a2a186552..d44dc6b49f293 100644 --- a/Lib/test/test_imp.py +++ b/Lib/test/test_imp.py @@ -8,11 +8,10 @@ from test.support import import_helper from test.support import os_helper from test.support import script_helper +from test.support import warnings_helper import unittest import warnings -with warnings.catch_warnings(): - warnings.simplefilter('ignore', DeprecationWarning) - import imp +imp = warnings_helper.import_deprecated('imp') import _imp diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py index 7555f05d1d0cf..5d4ddedd059fc 100644 --- a/Lib/test/test_logging.py +++ b/Lib/test/test_logging.py @@ -60,10 +60,10 @@ from socketserver import (ThreadingUDPServer, DatagramRequestHandler, ThreadingTCPServer, StreamRequestHandler) -with warnings.catch_warnings(): - warnings.simplefilter('ignore', DeprecationWarning) - import asyncore - import smtpd + +asyncore = warnings_helper.import_deprecated('asyncore') +smtpd = warnings_helper.import_deprecated('smtpd') + try: import win32evtlog, win32evtlogutil, pywintypes diff --git a/Lib/test/test_poplib.py b/Lib/test/test_poplib.py index 57ccc541b81fe..5ad9202433dcf 100644 --- a/Lib/test/test_poplib.py +++ b/Lib/test/test_poplib.py @@ -15,12 +15,12 @@ from test.support import hashlib_helper from test.support import socket_helper from test.support import threading_helper +from test.support import warnings_helper + + +asynchat = warnings_helper.import_deprecated('asynchat') +asyncore = warnings_helper.import_deprecated('asyncore') -import warnings -with warnings.catch_warnings(): - warnings.simplefilter('ignore', DeprecationWarning) - import asynchat - import asyncore test_support.requires_working_socket(module=True) diff --git a/Lib/test/test_smtpd.py b/Lib/test/test_smtpd.py index d2e150d535ff6..57eb98ebc1d1e 100644 --- a/Lib/test/test_smtpd.py +++ b/Lib/test/test_smtpd.py @@ -6,11 +6,9 @@ import socket import io -import warnings -with warnings.catch_warnings(): - warnings.simplefilter('ignore', DeprecationWarning) - import smtpd - import asyncore + +smtpd = warnings_helper.import_deprecated('smtpd') +asyncore = warnings_helper.import_deprecated('asyncore') class DummyServer(smtpd.SMTPServer): diff --git a/Lib/test/test_smtplib.py b/Lib/test/test_smtplib.py index e798645a5ca66..a4074c02f1926 100644 --- a/Lib/test/test_smtplib.py +++ b/Lib/test/test_smtplib.py @@ -21,13 +21,13 @@ from test.support import hashlib_helper from test.support import socket_helper from test.support import threading_helper +from test.support import warnings_helper from unittest.mock import Mock -import warnings -with warnings.catch_warnings(): - warnings.simplefilter('ignore', DeprecationWarning) - import asyncore - import smtpd + +asyncore = warnings_helper.import_deprecated('asyncore') +smtpd = warnings_helper.import_deprecated('smtpd') + support.requires_working_socket(module=True) diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py index 543d34a546933..0eb8d18b3561e 100644 --- a/Lib/test/test_ssl.py +++ b/Lib/test/test_ssl.py @@ -12,7 +12,6 @@ import socket import select import time -import datetime import enum import gc import os @@ -30,10 +29,9 @@ except ImportError: ctypes = None -import warnings -with warnings.catch_warnings(): - warnings.simplefilter('ignore', DeprecationWarning) - import asyncore + +asyncore = warnings_helper.import_deprecated('asyncore') + ssl = import_helper.import_module("ssl") import _ssl diff --git a/Misc/NEWS.d/next/Tests/2022-05-02-20-57-04.gh-issue-92169.Xi4NGV.rst b/Misc/NEWS.d/next/Tests/2022-05-02-20-57-04.gh-issue-92169.Xi4NGV.rst new file mode 100644 index 0000000000000..3809ed4f5a1a1 --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2022-05-02-20-57-04.gh-issue-92169.Xi4NGV.rst @@ -0,0 +1,2 @@ +Use ``warnings_helper.import_deprecated()`` to import deprecated modules +uniformly in tests. Patch by Hugo van Kemenade. From webhook-mailer at python.org Tue May 3 04:41:56 2022 From: webhook-mailer at python.org (rhettinger) Date: Tue, 03 May 2022 08:41:56 -0000 Subject: [Python-checkins] The stdev calculation is more accurate computing its own mean (#92220) Message-ID: https://github.com/python/cpython/commit/ec8d3adb99f1ad93786fed5c1def5119b6ec73c0 commit: ec8d3adb99f1ad93786fed5c1def5119b6ec73c0 branch: main author: Raymond Hettinger committer: rhettinger date: 2022-05-03T03:41:46-05:00 summary: The stdev calculation is more accurate computing its own mean (#92220) files: M Lib/statistics.py diff --git a/Lib/statistics.py b/Lib/statistics.py index f3bc9a1f34639..6e6d62c4a0e26 100644 --- a/Lib/statistics.py +++ b/Lib/statistics.py @@ -1173,8 +1173,7 @@ def from_samples(cls, data): "Make a normal distribution instance from sample data." if not isinstance(data, (list, tuple)): data = list(data) - xbar = fmean(data) - return cls(xbar, stdev(data, xbar)) + return cls(mean(data), stdev(data)) def samples(self, n, *, seed=None): "Generate *n* samples for a given mean and standard deviation." From webhook-mailer at python.org Tue May 3 04:53:57 2022 From: webhook-mailer at python.org (serhiy-storchaka) Date: Tue, 03 May 2022 08:53:57 -0000 Subject: [Python-checkins] [3.10] gh-91583: AC: Fix regression for functions with defining_class (GH-91739) (GH-92079) Message-ID: https://github.com/python/cpython/commit/62ddbbcfafc98aaa4d0345bba56f7d6cd346c83f commit: 62ddbbcfafc98aaa4d0345bba56f7d6cd346c83f branch: 3.10 author: Serhiy Storchaka committer: serhiy-storchaka date: 2022-05-03T11:53:46+03:00 summary: [3.10] gh-91583: AC: Fix regression for functions with defining_class (GH-91739) (GH-92079) Argument Clinic now generates the same efficient code as before adding the defining_class parameter. (cherry picked from commit a055dac0b45031878a8196a8735522de018491e3) files: A Misc/NEWS.d/next/Tools-Demos/2022-04-20-14-26-14.gh-issue-91583.200qI0.rst M Modules/clinic/_curses_panel.c.h M Modules/clinic/_dbmmodule.c.h M Modules/clinic/_gdbmmodule.c.h M Modules/clinic/_lsprof.c.h M Modules/clinic/_queuemodule.c.h M Modules/clinic/_sre.c.h M Modules/clinic/_testmultiphase.c.h M Modules/clinic/arraymodule.c.h M Modules/clinic/md5module.c.h M Modules/clinic/posixmodule.c.h M Modules/clinic/pyexpat.c.h M Modules/clinic/sha1module.c.h M Modules/clinic/sha256module.c.h M Modules/clinic/sha512module.c.h M Modules/clinic/zlibmodule.c.h M Tools/clinic/clinic.py diff --git a/Misc/NEWS.d/next/Tools-Demos/2022-04-20-14-26-14.gh-issue-91583.200qI0.rst b/Misc/NEWS.d/next/Tools-Demos/2022-04-20-14-26-14.gh-issue-91583.200qI0.rst new file mode 100644 index 0000000000000..bdfa71100f95a --- /dev/null +++ b/Misc/NEWS.d/next/Tools-Demos/2022-04-20-14-26-14.gh-issue-91583.200qI0.rst @@ -0,0 +1,2 @@ +Fix regression in the code generated by Argument Clinic for functions with +the ``defining_class`` parameter. diff --git a/Modules/clinic/_curses_panel.c.h b/Modules/clinic/_curses_panel.c.h index 45898070b1f54..e4642b58332de 100644 --- a/Modules/clinic/_curses_panel.c.h +++ b/Modules/clinic/_curses_panel.c.h @@ -17,18 +17,11 @@ _curses_panel_panel_bottom_impl(PyCursesPanelObject *self, PyTypeObject *cls); static PyObject * _curses_panel_panel_bottom(PyCursesPanelObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { - PyObject *return_value = NULL; - static const char * const _keywords[] = { NULL}; - static _PyArg_Parser _parser = {":bottom", _keywords, 0}; - - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser - )) { - goto exit; + if (nargs) { + PyErr_SetString(PyExc_TypeError, "bottom() takes no arguments"); + return NULL; } - return_value = _curses_panel_panel_bottom_impl(self, cls); - -exit: - return return_value; + return _curses_panel_panel_bottom_impl(self, cls); } PyDoc_STRVAR(_curses_panel_panel_hide__doc__, @@ -48,18 +41,11 @@ _curses_panel_panel_hide_impl(PyCursesPanelObject *self, PyTypeObject *cls); static PyObject * _curses_panel_panel_hide(PyCursesPanelObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { - PyObject *return_value = NULL; - static const char * const _keywords[] = { NULL}; - static _PyArg_Parser _parser = {":hide", _keywords, 0}; - - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser - )) { - goto exit; + if (nargs) { + PyErr_SetString(PyExc_TypeError, "hide() takes no arguments"); + return NULL; } - return_value = _curses_panel_panel_hide_impl(self, cls); - -exit: - return return_value; + return _curses_panel_panel_hide_impl(self, cls); } PyDoc_STRVAR(_curses_panel_panel_show__doc__, @@ -77,18 +63,11 @@ _curses_panel_panel_show_impl(PyCursesPanelObject *self, PyTypeObject *cls); static PyObject * _curses_panel_panel_show(PyCursesPanelObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { - PyObject *return_value = NULL; - static const char * const _keywords[] = { NULL}; - static _PyArg_Parser _parser = {":show", _keywords, 0}; - - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser - )) { - goto exit; + if (nargs) { + PyErr_SetString(PyExc_TypeError, "show() takes no arguments"); + return NULL; } - return_value = _curses_panel_panel_show_impl(self, cls); - -exit: - return return_value; + return _curses_panel_panel_show_impl(self, cls); } PyDoc_STRVAR(_curses_panel_panel_top__doc__, @@ -106,18 +85,11 @@ _curses_panel_panel_top_impl(PyCursesPanelObject *self, PyTypeObject *cls); static PyObject * _curses_panel_panel_top(PyCursesPanelObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { - PyObject *return_value = NULL; - static const char * const _keywords[] = { NULL}; - static _PyArg_Parser _parser = {":top", _keywords, 0}; - - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser - )) { - goto exit; + if (nargs) { + PyErr_SetString(PyExc_TypeError, "top() takes no arguments"); + return NULL; } - return_value = _curses_panel_panel_top_impl(self, cls); - -exit: - return return_value; + return _curses_panel_panel_top_impl(self, cls); } PyDoc_STRVAR(_curses_panel_panel_above__doc__, @@ -192,12 +164,21 @@ _curses_panel_panel_move(PyCursesPanelObject *self, PyTypeObject *cls, PyObject { PyObject *return_value = NULL; static const char * const _keywords[] = {"", "", NULL}; - static _PyArg_Parser _parser = {"ii:move", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "move", 0}; + PyObject *argsbuf[2]; int y; int x; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &y, &x)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); + if (!args) { + goto exit; + } + y = _PyLong_AsInt(args[0]); + if (y == -1 && PyErr_Occurred()) { + goto exit; + } + x = _PyLong_AsInt(args[1]); + if (x == -1 && PyErr_Occurred()) { goto exit; } return_value = _curses_panel_panel_move_impl(self, cls, y, x); @@ -243,13 +224,19 @@ _curses_panel_panel_replace(PyCursesPanelObject *self, PyTypeObject *cls, PyObje { PyObject *return_value = NULL; static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = {"O!:replace", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "replace", 0}; + PyObject *argsbuf[1]; PyCursesWindowObject *win; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &PyCursesWindow_Type, &win)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (!PyObject_TypeCheck(args[0], &PyCursesWindow_Type)) { + _PyArg_BadArgument("replace", "argument 1", (&PyCursesWindow_Type)->tp_name, args[0]); goto exit; } + win = (PyCursesWindowObject *)args[0]; return_value = _curses_panel_panel_replace_impl(self, cls, win); exit: @@ -274,13 +261,15 @@ _curses_panel_panel_set_userptr(PyCursesPanelObject *self, PyTypeObject *cls, Py { PyObject *return_value = NULL; static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = {"O:set_userptr", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "set_userptr", 0}; + PyObject *argsbuf[1]; PyObject *obj; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &obj)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { goto exit; } + obj = args[0]; return_value = _curses_panel_panel_set_userptr_impl(self, cls, obj); exit: @@ -303,18 +292,11 @@ _curses_panel_panel_userptr_impl(PyCursesPanelObject *self, static PyObject * _curses_panel_panel_userptr(PyCursesPanelObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { - PyObject *return_value = NULL; - static const char * const _keywords[] = { NULL}; - static _PyArg_Parser _parser = {":userptr", _keywords, 0}; - - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser - )) { - goto exit; + if (nargs) { + PyErr_SetString(PyExc_TypeError, "userptr() takes no arguments"); + return NULL; } - return_value = _curses_panel_panel_userptr_impl(self, cls); - -exit: - return return_value; + return _curses_panel_panel_userptr_impl(self, cls); } PyDoc_STRVAR(_curses_panel_bottom_panel__doc__, @@ -401,4 +383,4 @@ _curses_panel_update_panels(PyObject *module, PyObject *Py_UNUSED(ignored)) { return _curses_panel_update_panels_impl(module); } -/*[clinic end generated code: output=3081ef24e5560cb0 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=c552457e8067bb0a input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_dbmmodule.c.h b/Modules/clinic/_dbmmodule.c.h index af288c2586a10..beb26f612026b 100644 --- a/Modules/clinic/_dbmmodule.c.h +++ b/Modules/clinic/_dbmmodule.c.h @@ -35,18 +35,11 @@ _dbm_dbm_keys_impl(dbmobject *self, PyTypeObject *cls); static PyObject * _dbm_dbm_keys(dbmobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { - PyObject *return_value = NULL; - static const char * const _keywords[] = { NULL}; - static _PyArg_Parser _parser = {":keys", _keywords, 0}; - - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser - )) { - goto exit; + if (nargs) { + PyErr_SetString(PyExc_TypeError, "keys() takes no arguments"); + return NULL; } - return_value = _dbm_dbm_keys_impl(self, cls); - -exit: - return return_value; + return _dbm_dbm_keys_impl(self, cls); } PyDoc_STRVAR(_dbm_dbm_get__doc__, @@ -187,4 +180,4 @@ dbmopen(PyObject *module, PyObject *const *args, Py_ssize_t nargs) exit: return return_value; } -/*[clinic end generated code: output=6947b1115df66f7c input=a9049054013a1b77]*/ +/*[clinic end generated code: output=a4599b89ce338b08 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_gdbmmodule.c.h b/Modules/clinic/_gdbmmodule.c.h index ea4ee7df001c1..630cb499ae14f 100644 --- a/Modules/clinic/_gdbmmodule.c.h +++ b/Modules/clinic/_gdbmmodule.c.h @@ -104,18 +104,11 @@ _gdbm_gdbm_keys_impl(gdbmobject *self, PyTypeObject *cls); static PyObject * _gdbm_gdbm_keys(gdbmobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { - PyObject *return_value = NULL; - static const char * const _keywords[] = { NULL}; - static _PyArg_Parser _parser = {":keys", _keywords, 0}; - - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser - )) { - goto exit; + if (nargs) { + PyErr_SetString(PyExc_TypeError, "keys() takes no arguments"); + return NULL; } - return_value = _gdbm_gdbm_keys_impl(self, cls); - -exit: - return return_value; + return _gdbm_gdbm_keys_impl(self, cls); } PyDoc_STRVAR(_gdbm_gdbm_firstkey__doc__, @@ -137,18 +130,11 @@ _gdbm_gdbm_firstkey_impl(gdbmobject *self, PyTypeObject *cls); static PyObject * _gdbm_gdbm_firstkey(gdbmobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { - PyObject *return_value = NULL; - static const char * const _keywords[] = { NULL}; - static _PyArg_Parser _parser = {":firstkey", _keywords, 0}; - - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser - )) { - goto exit; + if (nargs) { + PyErr_SetString(PyExc_TypeError, "firstkey() takes no arguments"); + return NULL; } - return_value = _gdbm_gdbm_firstkey_impl(self, cls); - -exit: - return return_value; + return _gdbm_gdbm_firstkey_impl(self, cls); } PyDoc_STRVAR(_gdbm_gdbm_nextkey__doc__, @@ -212,18 +198,11 @@ _gdbm_gdbm_reorganize_impl(gdbmobject *self, PyTypeObject *cls); static PyObject * _gdbm_gdbm_reorganize(gdbmobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { - PyObject *return_value = NULL; - static const char * const _keywords[] = { NULL}; - static _PyArg_Parser _parser = {":reorganize", _keywords, 0}; - - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser - )) { - goto exit; + if (nargs) { + PyErr_SetString(PyExc_TypeError, "reorganize() takes no arguments"); + return NULL; } - return_value = _gdbm_gdbm_reorganize_impl(self, cls); - -exit: - return return_value; + return _gdbm_gdbm_reorganize_impl(self, cls); } PyDoc_STRVAR(_gdbm_gdbm_sync__doc__, @@ -244,18 +223,11 @@ _gdbm_gdbm_sync_impl(gdbmobject *self, PyTypeObject *cls); static PyObject * _gdbm_gdbm_sync(gdbmobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { - PyObject *return_value = NULL; - static const char * const _keywords[] = { NULL}; - static _PyArg_Parser _parser = {":sync", _keywords, 0}; - - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser - )) { - goto exit; + if (nargs) { + PyErr_SetString(PyExc_TypeError, "sync() takes no arguments"); + return NULL; } - return_value = _gdbm_gdbm_sync_impl(self, cls); - -exit: - return return_value; + return _gdbm_gdbm_sync_impl(self, cls); } PyDoc_STRVAR(dbmopen__doc__, @@ -340,4 +312,4 @@ dbmopen(PyObject *module, PyObject *const *args, Py_ssize_t nargs) exit: return return_value; } -/*[clinic end generated code: output=3b88446433e43d96 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=125f5bc685304744 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_lsprof.c.h b/Modules/clinic/_lsprof.c.h index 5d9c209eab856..b0adb746974ab 100644 --- a/Modules/clinic/_lsprof.c.h +++ b/Modules/clinic/_lsprof.c.h @@ -39,17 +39,10 @@ _lsprof_Profiler_getstats_impl(ProfilerObject *self, PyTypeObject *cls); static PyObject * _lsprof_Profiler_getstats(ProfilerObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { - PyObject *return_value = NULL; - static const char * const _keywords[] = { NULL}; - static _PyArg_Parser _parser = {":getstats", _keywords, 0}; - - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser - )) { - goto exit; + if (nargs) { + PyErr_SetString(PyExc_TypeError, "getstats() takes no arguments"); + return NULL; } - return_value = _lsprof_Profiler_getstats_impl(self, cls); - -exit: - return return_value; + return _lsprof_Profiler_getstats_impl(self, cls); } -/*[clinic end generated code: output=b4727cfebecdd22d input=a9049054013a1b77]*/ +/*[clinic end generated code: output=57c7b6b0b8666429 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_queuemodule.c.h b/Modules/clinic/_queuemodule.c.h index 8741f7d9aff88..29e4c60cfa755 100644 --- a/Modules/clinic/_queuemodule.c.h +++ b/Modules/clinic/_queuemodule.c.h @@ -144,14 +144,30 @@ _queue_SimpleQueue_get(simplequeueobject *self, PyTypeObject *cls, PyObject *con { PyObject *return_value = NULL; static const char * const _keywords[] = {"block", "timeout", NULL}; - static _PyArg_Parser _parser = {"|pO:get", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "get", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; int block = 1; PyObject *timeout = Py_None; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &block, &timeout)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 2, 0, argsbuf); + if (!args) { goto exit; } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[0]) { + block = PyObject_IsTrue(args[0]); + if (block < 0) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + timeout = args[1]; +skip_optional_pos: return_value = _queue_SimpleQueue_get_impl(self, cls, block, timeout); exit: @@ -177,18 +193,11 @@ _queue_SimpleQueue_get_nowait_impl(simplequeueobject *self, static PyObject * _queue_SimpleQueue_get_nowait(simplequeueobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { - PyObject *return_value = NULL; - static const char * const _keywords[] = { NULL}; - static _PyArg_Parser _parser = {":get_nowait", _keywords, 0}; - - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser - )) { - goto exit; + if (nargs) { + PyErr_SetString(PyExc_TypeError, "get_nowait() takes no arguments"); + return NULL; } - return_value = _queue_SimpleQueue_get_nowait_impl(self, cls); - -exit: - return return_value; + return _queue_SimpleQueue_get_nowait_impl(self, cls); } PyDoc_STRVAR(_queue_SimpleQueue_empty__doc__, @@ -246,4 +255,4 @@ _queue_SimpleQueue_qsize(simplequeueobject *self, PyObject *Py_UNUSED(ignored)) exit: return return_value; } -/*[clinic end generated code: output=ce56b46fac150909 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=a9d567e8a64e6170 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_sre.c.h b/Modules/clinic/_sre.c.h index 72d772c289ae8..d60827db24b06 100644 --- a/Modules/clinic/_sre.c.h +++ b/Modules/clinic/_sre.c.h @@ -176,15 +176,51 @@ _sre_SRE_Pattern_match(PatternObject *self, PyTypeObject *cls, PyObject *const * { PyObject *return_value = NULL; static const char * const _keywords[] = {"string", "pos", "endpos", NULL}; - static _PyArg_Parser _parser = {"O|nn:match", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "match", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *string; Py_ssize_t pos = 0; Py_ssize_t endpos = PY_SSIZE_T_MAX; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &string, &pos, &endpos)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf); + if (!args) { goto exit; } + string = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1]) { + { + Py_ssize_t ival = -1; + PyObject *iobj = _PyNumber_Index(args[1]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + pos = ival; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + { + Py_ssize_t ival = -1; + PyObject *iobj = _PyNumber_Index(args[2]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + endpos = ival; + } +skip_optional_pos: return_value = _sre_SRE_Pattern_match_impl(self, cls, string, pos, endpos); exit: @@ -210,15 +246,51 @@ _sre_SRE_Pattern_fullmatch(PatternObject *self, PyTypeObject *cls, PyObject *con { PyObject *return_value = NULL; static const char * const _keywords[] = {"string", "pos", "endpos", NULL}; - static _PyArg_Parser _parser = {"O|nn:fullmatch", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "fullmatch", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *string; Py_ssize_t pos = 0; Py_ssize_t endpos = PY_SSIZE_T_MAX; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &string, &pos, &endpos)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf); + if (!args) { goto exit; } + string = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1]) { + { + Py_ssize_t ival = -1; + PyObject *iobj = _PyNumber_Index(args[1]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + pos = ival; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + { + Py_ssize_t ival = -1; + PyObject *iobj = _PyNumber_Index(args[2]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + endpos = ival; + } +skip_optional_pos: return_value = _sre_SRE_Pattern_fullmatch_impl(self, cls, string, pos, endpos); exit: @@ -246,15 +318,51 @@ _sre_SRE_Pattern_search(PatternObject *self, PyTypeObject *cls, PyObject *const { PyObject *return_value = NULL; static const char * const _keywords[] = {"string", "pos", "endpos", NULL}; - static _PyArg_Parser _parser = {"O|nn:search", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "search", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *string; Py_ssize_t pos = 0; Py_ssize_t endpos = PY_SSIZE_T_MAX; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &string, &pos, &endpos)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf); + if (!args) { goto exit; } + string = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1]) { + { + Py_ssize_t ival = -1; + PyObject *iobj = _PyNumber_Index(args[1]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + pos = ival; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + { + Py_ssize_t ival = -1; + PyObject *iobj = _PyNumber_Index(args[2]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + endpos = ival; + } +skip_optional_pos: return_value = _sre_SRE_Pattern_search_impl(self, cls, string, pos, endpos); exit: @@ -351,15 +459,51 @@ _sre_SRE_Pattern_finditer(PatternObject *self, PyTypeObject *cls, PyObject *cons { PyObject *return_value = NULL; static const char * const _keywords[] = {"string", "pos", "endpos", NULL}; - static _PyArg_Parser _parser = {"O|nn:finditer", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "finditer", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *string; Py_ssize_t pos = 0; Py_ssize_t endpos = PY_SSIZE_T_MAX; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &string, &pos, &endpos)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf); + if (!args) { goto exit; } + string = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1]) { + { + Py_ssize_t ival = -1; + PyObject *iobj = _PyNumber_Index(args[1]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + pos = ival; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + { + Py_ssize_t ival = -1; + PyObject *iobj = _PyNumber_Index(args[2]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + endpos = ival; + } +skip_optional_pos: return_value = _sre_SRE_Pattern_finditer_impl(self, cls, string, pos, endpos); exit: @@ -384,15 +528,51 @@ _sre_SRE_Pattern_scanner(PatternObject *self, PyTypeObject *cls, PyObject *const { PyObject *return_value = NULL; static const char * const _keywords[] = {"string", "pos", "endpos", NULL}; - static _PyArg_Parser _parser = {"O|nn:scanner", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "scanner", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *string; Py_ssize_t pos = 0; Py_ssize_t endpos = PY_SSIZE_T_MAX; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &string, &pos, &endpos)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf); + if (!args) { goto exit; } + string = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1]) { + { + Py_ssize_t ival = -1; + PyObject *iobj = _PyNumber_Index(args[1]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + pos = ival; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + { + Py_ssize_t ival = -1; + PyObject *iobj = _PyNumber_Index(args[2]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + endpos = ival; + } +skip_optional_pos: return_value = _sre_SRE_Pattern_scanner_impl(self, cls, string, pos, endpos); exit: @@ -468,15 +648,35 @@ _sre_SRE_Pattern_sub(PatternObject *self, PyTypeObject *cls, PyObject *const *ar { PyObject *return_value = NULL; static const char * const _keywords[] = {"repl", "string", "count", NULL}; - static _PyArg_Parser _parser = {"OO|n:sub", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "sub", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; PyObject *repl; PyObject *string; Py_ssize_t count = 0; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &repl, &string, &count)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 3, 0, argsbuf); + if (!args) { goto exit; } + repl = args[0]; + string = args[1]; + if (!noptargs) { + goto skip_optional_pos; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = _PyNumber_Index(args[2]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + count = ival; + } +skip_optional_pos: return_value = _sre_SRE_Pattern_sub_impl(self, cls, repl, string, count); exit: @@ -502,15 +702,35 @@ _sre_SRE_Pattern_subn(PatternObject *self, PyTypeObject *cls, PyObject *const *a { PyObject *return_value = NULL; static const char * const _keywords[] = {"repl", "string", "count", NULL}; - static _PyArg_Parser _parser = {"OO|n:subn", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "subn", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; PyObject *repl; PyObject *string; Py_ssize_t count = 0; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &repl, &string, &count)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 3, 0, argsbuf); + if (!args) { goto exit; } + repl = args[0]; + string = args[1]; + if (!noptargs) { + goto skip_optional_pos; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = _PyNumber_Index(args[2]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + count = ival; + } +skip_optional_pos: return_value = _sre_SRE_Pattern_subn_impl(self, cls, repl, string, count); exit: @@ -869,18 +1089,11 @@ _sre_SRE_Scanner_match_impl(ScannerObject *self, PyTypeObject *cls); static PyObject * _sre_SRE_Scanner_match(ScannerObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { - PyObject *return_value = NULL; - static const char * const _keywords[] = { NULL}; - static _PyArg_Parser _parser = {":match", _keywords, 0}; - - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser - )) { - goto exit; + if (nargs) { + PyErr_SetString(PyExc_TypeError, "match() takes no arguments"); + return NULL; } - return_value = _sre_SRE_Scanner_match_impl(self, cls); - -exit: - return return_value; + return _sre_SRE_Scanner_match_impl(self, cls); } PyDoc_STRVAR(_sre_SRE_Scanner_search__doc__, @@ -897,17 +1110,10 @@ _sre_SRE_Scanner_search_impl(ScannerObject *self, PyTypeObject *cls); static PyObject * _sre_SRE_Scanner_search(ScannerObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { - PyObject *return_value = NULL; - static const char * const _keywords[] = { NULL}; - static _PyArg_Parser _parser = {":search", _keywords, 0}; - - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser - )) { - goto exit; + if (nargs) { + PyErr_SetString(PyExc_TypeError, "search() takes no arguments"); + return NULL; } - return_value = _sre_SRE_Scanner_search_impl(self, cls); - -exit: - return return_value; + return _sre_SRE_Scanner_search_impl(self, cls); } -/*[clinic end generated code: output=518f7bb775c1184f input=a9049054013a1b77]*/ +/*[clinic end generated code: output=ead5eb818b7771f8 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_testmultiphase.c.h b/Modules/clinic/_testmultiphase.c.h index 17c28d54ce575..26212d86dd0f8 100644 --- a/Modules/clinic/_testmultiphase.c.h +++ b/Modules/clinic/_testmultiphase.c.h @@ -21,18 +21,11 @@ _testmultiphase_StateAccessType_get_defining_module_impl(StateAccessTypeObject * static PyObject * _testmultiphase_StateAccessType_get_defining_module(StateAccessTypeObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { - PyObject *return_value = NULL; - static const char * const _keywords[] = { NULL}; - static _PyArg_Parser _parser = {":get_defining_module", _keywords, 0}; - - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser - )) { - goto exit; + if (nargs) { + PyErr_SetString(PyExc_TypeError, "get_defining_module() takes no arguments"); + return NULL; } - return_value = _testmultiphase_StateAccessType_get_defining_module_impl(self, cls); - -exit: - return return_value; + return _testmultiphase_StateAccessType_get_defining_module_impl(self, cls); } PyDoc_STRVAR(_testmultiphase_StateAccessType_getmodulebydef_bad_def__doc__, @@ -51,18 +44,11 @@ _testmultiphase_StateAccessType_getmodulebydef_bad_def_impl(StateAccessTypeObjec static PyObject * _testmultiphase_StateAccessType_getmodulebydef_bad_def(StateAccessTypeObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { - PyObject *return_value = NULL; - static const char * const _keywords[] = { NULL}; - static _PyArg_Parser _parser = {":getmodulebydef_bad_def", _keywords, 0}; - - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser - )) { - goto exit; + if (nargs) { + PyErr_SetString(PyExc_TypeError, "getmodulebydef_bad_def() takes no arguments"); + return NULL; } - return_value = _testmultiphase_StateAccessType_getmodulebydef_bad_def_impl(self, cls); - -exit: - return return_value; + return _testmultiphase_StateAccessType_getmodulebydef_bad_def_impl(self, cls); } PyDoc_STRVAR(_testmultiphase_StateAccessType_increment_count_clinic__doc__, @@ -88,14 +74,37 @@ _testmultiphase_StateAccessType_increment_count_clinic(StateAccessTypeObject *se { PyObject *return_value = NULL; static const char * const _keywords[] = {"n", "twice", NULL}; - static _PyArg_Parser _parser = {"|i$p:increment_count_clinic", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "increment_count_clinic", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; int n = 1; int twice = 0; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &n, &twice)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { goto exit; } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[0]) { + n = _PyLong_AsInt(args[0]); + if (n == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } +skip_optional_pos: + if (!noptargs) { + goto skip_optional_kwonly; + } + twice = PyObject_IsTrue(args[1]); + if (twice < 0) { + goto exit; + } +skip_optional_kwonly: return_value = _testmultiphase_StateAccessType_increment_count_clinic_impl(self, cls, n, twice); exit: @@ -118,17 +127,10 @@ _testmultiphase_StateAccessType_get_count_impl(StateAccessTypeObject *self, static PyObject * _testmultiphase_StateAccessType_get_count(StateAccessTypeObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { - PyObject *return_value = NULL; - static const char * const _keywords[] = { NULL}; - static _PyArg_Parser _parser = {":get_count", _keywords, 0}; - - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser - )) { - goto exit; + if (nargs) { + PyErr_SetString(PyExc_TypeError, "get_count() takes no arguments"); + return NULL; } - return_value = _testmultiphase_StateAccessType_get_count_impl(self, cls); - -exit: - return return_value; + return _testmultiphase_StateAccessType_get_count_impl(self, cls); } -/*[clinic end generated code: output=eb1b8c2ee6290be3 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=ec5029d1275cbf94 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/arraymodule.c.h b/Modules/clinic/arraymodule.c.h index c46cc738de91b..ce98e411f0fe4 100644 --- a/Modules/clinic/arraymodule.c.h +++ b/Modules/clinic/arraymodule.c.h @@ -155,13 +155,15 @@ array_array_extend(arrayobject *self, PyTypeObject *cls, PyObject *const *args, { PyObject *return_value = NULL; static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = {"O:extend", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "extend", 0}; + PyObject *argsbuf[1]; PyObject *bb; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &bb)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { goto exit; } + bb = args[0]; return_value = array_array_extend_impl(self, cls, bb); exit: @@ -572,4 +574,4 @@ PyDoc_STRVAR(array_arrayiterator___setstate____doc__, #define ARRAY_ARRAYITERATOR___SETSTATE___METHODDEF \ {"__setstate__", (PyCFunction)array_arrayiterator___setstate__, METH_O, array_arrayiterator___setstate____doc__}, -/*[clinic end generated code: output=f130a994f98f1227 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=eb727e087d64f017 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/md5module.c.h b/Modules/clinic/md5module.c.h index 4762f2800d4b8..0ff09b0050a56 100644 --- a/Modules/clinic/md5module.c.h +++ b/Modules/clinic/md5module.c.h @@ -17,18 +17,11 @@ MD5Type_copy_impl(MD5object *self, PyTypeObject *cls); static PyObject * MD5Type_copy(MD5object *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { - PyObject *return_value = NULL; - static const char * const _keywords[] = { NULL}; - static _PyArg_Parser _parser = {":copy", _keywords, 0}; - - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser - )) { - goto exit; + if (nargs) { + PyErr_SetString(PyExc_TypeError, "copy() takes no arguments"); + return NULL; } - return_value = MD5Type_copy_impl(self, cls); - -exit: - return return_value; + return MD5Type_copy_impl(self, cls); } PyDoc_STRVAR(MD5Type_digest__doc__, @@ -126,4 +119,4 @@ _md5_md5(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kw exit: return return_value; } -/*[clinic end generated code: output=53ff7f22dbaaea36 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=3061297a669c645c input=a9049054013a1b77]*/ diff --git a/Modules/clinic/posixmodule.c.h b/Modules/clinic/posixmodule.c.h index 7921c222b9009..742acb8e6c07e 100644 --- a/Modules/clinic/posixmodule.c.h +++ b/Modules/clinic/posixmodule.c.h @@ -8254,12 +8254,10 @@ static PyObject * os_DirEntry_is_symlink(DirEntry *self, PyTypeObject *defining_class, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - static const char * const _keywords[] = { NULL}; - static _PyArg_Parser _parser = {":is_symlink", _keywords, 0}; int _return_value; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser - )) { + if (nargs) { + PyErr_SetString(PyExc_TypeError, "is_symlink() takes no arguments"); goto exit; } _return_value = os_DirEntry_is_symlink_impl(self, defining_class); @@ -8290,13 +8288,23 @@ os_DirEntry_stat(DirEntry *self, PyTypeObject *defining_class, PyObject *const * { PyObject *return_value = NULL; static const char * const _keywords[] = {"follow_symlinks", NULL}; - static _PyArg_Parser _parser = {"|$p:stat", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "stat", 0}; + PyObject *argsbuf[1]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; int follow_symlinks = 1; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &follow_symlinks)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 0, 0, argsbuf); + if (!args) { goto exit; } + if (!noptargs) { + goto skip_optional_kwonly; + } + follow_symlinks = PyObject_IsTrue(args[0]); + if (follow_symlinks < 0) { + goto exit; + } +skip_optional_kwonly: return_value = os_DirEntry_stat_impl(self, defining_class, follow_symlinks); exit: @@ -8321,14 +8329,24 @@ os_DirEntry_is_dir(DirEntry *self, PyTypeObject *defining_class, PyObject *const { PyObject *return_value = NULL; static const char * const _keywords[] = {"follow_symlinks", NULL}; - static _PyArg_Parser _parser = {"|$p:is_dir", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "is_dir", 0}; + PyObject *argsbuf[1]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; int follow_symlinks = 1; int _return_value; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &follow_symlinks)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 0, 0, argsbuf); + if (!args) { goto exit; } + if (!noptargs) { + goto skip_optional_kwonly; + } + follow_symlinks = PyObject_IsTrue(args[0]); + if (follow_symlinks < 0) { + goto exit; + } +skip_optional_kwonly: _return_value = os_DirEntry_is_dir_impl(self, defining_class, follow_symlinks); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -8357,14 +8375,24 @@ os_DirEntry_is_file(DirEntry *self, PyTypeObject *defining_class, PyObject *cons { PyObject *return_value = NULL; static const char * const _keywords[] = {"follow_symlinks", NULL}; - static _PyArg_Parser _parser = {"|$p:is_file", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "is_file", 0}; + PyObject *argsbuf[1]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; int follow_symlinks = 1; int _return_value; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &follow_symlinks)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 0, 0, argsbuf); + if (!args) { goto exit; } + if (!noptargs) { + goto skip_optional_kwonly; + } + follow_symlinks = PyObject_IsTrue(args[0]); + if (follow_symlinks < 0) { + goto exit; + } +skip_optional_kwonly: _return_value = os_DirEntry_is_file_impl(self, defining_class, follow_symlinks); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -9263,4 +9291,4 @@ os_waitstatus_to_exitcode(PyObject *module, PyObject *const *args, Py_ssize_t na #ifndef OS_WAITSTATUS_TO_EXITCODE_METHODDEF #define OS_WAITSTATUS_TO_EXITCODE_METHODDEF #endif /* !defined(OS_WAITSTATUS_TO_EXITCODE_METHODDEF) */ -/*[clinic end generated code: output=65a85d7d3f2c487e input=a9049054013a1b77]*/ +/*[clinic end generated code: output=debefcf43738ec66 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/pyexpat.c.h b/Modules/clinic/pyexpat.c.h index 7c56d6a8b2591..bee2ee66950a5 100644 --- a/Modules/clinic/pyexpat.c.h +++ b/Modules/clinic/pyexpat.c.h @@ -22,14 +22,24 @@ pyexpat_xmlparser_Parse(xmlparseobject *self, PyTypeObject *cls, PyObject *const { PyObject *return_value = NULL; static const char * const _keywords[] = {"", "", NULL}; - static _PyArg_Parser _parser = {"O|i:Parse", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "Parse", 0}; + PyObject *argsbuf[2]; PyObject *data; int isfinal = 0; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &data, &isfinal)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); + if (!args) { + goto exit; + } + data = args[0]; + if (nargs < 2) { + goto skip_optional_posonly; + } + isfinal = _PyLong_AsInt(args[1]); + if (isfinal == -1 && PyErr_Occurred()) { goto exit; } +skip_optional_posonly: return_value = pyexpat_xmlparser_Parse_impl(self, cls, data, isfinal); exit: @@ -54,13 +64,15 @@ pyexpat_xmlparser_ParseFile(xmlparseobject *self, PyTypeObject *cls, PyObject *c { PyObject *return_value = NULL; static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = {"O:ParseFile", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "ParseFile", 0}; + PyObject *argsbuf[1]; PyObject *file; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &file)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { goto exit; } + file = args[0]; return_value = pyexpat_xmlparser_ParseFile_impl(self, cls, file); exit: @@ -164,14 +176,50 @@ pyexpat_xmlparser_ExternalEntityParserCreate(xmlparseobject *self, PyTypeObject { PyObject *return_value = NULL; static const char * const _keywords[] = {"", "", NULL}; - static _PyArg_Parser _parser = {"z|s:ExternalEntityParserCreate", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "ExternalEntityParserCreate", 0}; + PyObject *argsbuf[2]; const char *context; const char *encoding = NULL; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &context, &encoding)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); + if (!args) { + goto exit; + } + if (args[0] == Py_None) { + context = NULL; + } + else if (PyUnicode_Check(args[0])) { + Py_ssize_t context_length; + context = PyUnicode_AsUTF8AndSize(args[0], &context_length); + if (context == NULL) { + goto exit; + } + if (strlen(context) != (size_t)context_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("ExternalEntityParserCreate", "argument 1", "str or None", args[0]); + goto exit; + } + if (nargs < 2) { + goto skip_optional_posonly; + } + if (!PyUnicode_Check(args[1])) { + _PyArg_BadArgument("ExternalEntityParserCreate", "argument 2", "str", args[1]); goto exit; } + Py_ssize_t encoding_length; + encoding = PyUnicode_AsUTF8AndSize(args[1], &encoding_length); + if (encoding == NULL) { + goto exit; + } + if (strlen(encoding) != (size_t)encoding_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } +skip_optional_posonly: return_value = pyexpat_xmlparser_ExternalEntityParserCreate_impl(self, cls, context, encoding); exit: @@ -235,13 +283,22 @@ pyexpat_xmlparser_UseForeignDTD(xmlparseobject *self, PyTypeObject *cls, PyObjec { PyObject *return_value = NULL; static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = {"|p:UseForeignDTD", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "UseForeignDTD", 0}; + PyObject *argsbuf[1]; int flag = 1; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &flag)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (nargs < 1) { + goto skip_optional_posonly; + } + flag = PyObject_IsTrue(args[0]); + if (flag < 0) { goto exit; } +skip_optional_posonly: return_value = pyexpat_xmlparser_UseForeignDTD_impl(self, cls, flag); exit: @@ -368,4 +425,4 @@ pyexpat_ErrorString(PyObject *module, PyObject *arg) #ifndef PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF #define PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF #endif /* !defined(PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF) */ -/*[clinic end generated code: output=612b9d6a17a679a7 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=5d60049d385d5d56 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/sha1module.c.h b/Modules/clinic/sha1module.c.h index 3a3ab58c1233c..d9a2e150f6d41 100644 --- a/Modules/clinic/sha1module.c.h +++ b/Modules/clinic/sha1module.c.h @@ -17,18 +17,11 @@ SHA1Type_copy_impl(SHA1object *self, PyTypeObject *cls); static PyObject * SHA1Type_copy(SHA1object *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { - PyObject *return_value = NULL; - static const char * const _keywords[] = { NULL}; - static _PyArg_Parser _parser = {":copy", _keywords, 0}; - - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser - )) { - goto exit; + if (nargs) { + PyErr_SetString(PyExc_TypeError, "copy() takes no arguments"); + return NULL; } - return_value = SHA1Type_copy_impl(self, cls); - -exit: - return return_value; + return SHA1Type_copy_impl(self, cls); } PyDoc_STRVAR(SHA1Type_digest__doc__, @@ -126,4 +119,4 @@ _sha1_sha1(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject * exit: return return_value; } -/*[clinic end generated code: output=abf1ab2545cea5a2 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=93ced3c8f8fa4f21 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/sha256module.c.h b/Modules/clinic/sha256module.c.h index 89205c4f14f4e..619fab1a6fe2f 100644 --- a/Modules/clinic/sha256module.c.h +++ b/Modules/clinic/sha256module.c.h @@ -17,18 +17,11 @@ SHA256Type_copy_impl(SHAobject *self, PyTypeObject *cls); static PyObject * SHA256Type_copy(SHAobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { - PyObject *return_value = NULL; - static const char * const _keywords[] = { NULL}; - static _PyArg_Parser _parser = {":copy", _keywords, 0}; - - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser - )) { - goto exit; + if (nargs) { + PyErr_SetString(PyExc_TypeError, "copy() takes no arguments"); + return NULL; } - return_value = SHA256Type_copy_impl(self, cls); - -exit: - return return_value; + return SHA256Type_copy_impl(self, cls); } PyDoc_STRVAR(SHA256Type_digest__doc__, @@ -177,4 +170,4 @@ _sha256_sha224(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObje exit: return return_value; } -/*[clinic end generated code: output=b7283f75c9d08f30 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=4f9fe3ca546b0c58 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/sha512module.c.h b/Modules/clinic/sha512module.c.h index f1192d74f9a1a..fada35eff2261 100644 --- a/Modules/clinic/sha512module.c.h +++ b/Modules/clinic/sha512module.c.h @@ -17,18 +17,11 @@ SHA512Type_copy_impl(SHAobject *self, PyTypeObject *cls); static PyObject * SHA512Type_copy(SHAobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { - PyObject *return_value = NULL; - static const char * const _keywords[] = { NULL}; - static _PyArg_Parser _parser = {":copy", _keywords, 0}; - - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser - )) { - goto exit; + if (nargs) { + PyErr_SetString(PyExc_TypeError, "copy() takes no arguments"); + return NULL; } - return_value = SHA512Type_copy_impl(self, cls); - -exit: - return return_value; + return SHA512Type_copy_impl(self, cls); } PyDoc_STRVAR(SHA512Type_digest__doc__, @@ -177,4 +170,4 @@ _sha512_sha384(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObje exit: return return_value; } -/*[clinic end generated code: output=9ff9f11937fabf35 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=26d2fe27b9673ac2 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/zlibmodule.c.h b/Modules/clinic/zlibmodule.c.h index 14e955db64e72..4394839859063 100644 --- a/Modules/clinic/zlibmodule.c.h +++ b/Modules/clinic/zlibmodule.c.h @@ -340,11 +340,19 @@ zlib_Compress_compress(compobject *self, PyTypeObject *cls, PyObject *const *arg { PyObject *return_value = NULL; static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = {"y*:compress", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "compress", 0}; + PyObject *argsbuf[1]; Py_buffer data = {NULL, NULL}; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &data)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&data, 'C')) { + _PyArg_BadArgument("compress", "argument 1", "contiguous buffer", args[0]); goto exit; } return_value = zlib_Compress_compress_impl(self, cls, &data); @@ -387,14 +395,39 @@ zlib_Decompress_decompress(compobject *self, PyTypeObject *cls, PyObject *const { PyObject *return_value = NULL; static const char * const _keywords[] = {"", "max_length", NULL}; - static _PyArg_Parser _parser = {"y*|n:decompress", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "decompress", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; Py_buffer data = {NULL, NULL}; Py_ssize_t max_length = 0; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &data, &max_length)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); + if (!args) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { goto exit; } + if (!PyBuffer_IsContiguous(&data, 'C')) { + _PyArg_BadArgument("decompress", "argument 1", "contiguous buffer", args[0]); + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = _PyNumber_Index(args[1]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + max_length = ival; + } +skip_optional_pos: return_value = zlib_Decompress_decompress_impl(self, cls, &data, max_length); exit: @@ -429,13 +462,22 @@ zlib_Compress_flush(compobject *self, PyTypeObject *cls, PyObject *const *args, { PyObject *return_value = NULL; static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = {"|i:flush", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "flush", 0}; + PyObject *argsbuf[1]; int mode = Z_FINISH; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &mode)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (nargs < 1) { + goto skip_optional_posonly; + } + mode = _PyLong_AsInt(args[0]); + if (mode == -1 && PyErr_Occurred()) { goto exit; } +skip_optional_posonly: return_value = zlib_Compress_flush_impl(self, cls, mode); exit: @@ -459,18 +501,11 @@ zlib_Compress_copy_impl(compobject *self, PyTypeObject *cls); static PyObject * zlib_Compress_copy(compobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { - PyObject *return_value = NULL; - static const char * const _keywords[] = { NULL}; - static _PyArg_Parser _parser = {":copy", _keywords, 0}; - - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser - )) { - goto exit; + if (nargs) { + PyErr_SetString(PyExc_TypeError, "copy() takes no arguments"); + return NULL; } - return_value = zlib_Compress_copy_impl(self, cls); - -exit: - return return_value; + return zlib_Compress_copy_impl(self, cls); } #endif /* defined(HAVE_ZLIB_COPY) */ @@ -491,18 +526,11 @@ zlib_Compress___copy___impl(compobject *self, PyTypeObject *cls); static PyObject * zlib_Compress___copy__(compobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { - PyObject *return_value = NULL; - static const char * const _keywords[] = { NULL}; - static _PyArg_Parser _parser = {":__copy__", _keywords, 0}; - - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser - )) { - goto exit; + if (nargs) { + PyErr_SetString(PyExc_TypeError, "__copy__() takes no arguments"); + return NULL; } - return_value = zlib_Compress___copy___impl(self, cls); - -exit: - return return_value; + return zlib_Compress___copy___impl(self, cls); } #endif /* defined(HAVE_ZLIB_COPY) */ @@ -526,13 +554,15 @@ zlib_Compress___deepcopy__(compobject *self, PyTypeObject *cls, PyObject *const { PyObject *return_value = NULL; static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = {"O:__deepcopy__", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "__deepcopy__", 0}; + PyObject *argsbuf[1]; PyObject *memo; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &memo)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { goto exit; } + memo = args[0]; return_value = zlib_Compress___deepcopy___impl(self, cls, memo); exit: @@ -558,18 +588,11 @@ zlib_Decompress_copy_impl(compobject *self, PyTypeObject *cls); static PyObject * zlib_Decompress_copy(compobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { - PyObject *return_value = NULL; - static const char * const _keywords[] = { NULL}; - static _PyArg_Parser _parser = {":copy", _keywords, 0}; - - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser - )) { - goto exit; + if (nargs) { + PyErr_SetString(PyExc_TypeError, "copy() takes no arguments"); + return NULL; } - return_value = zlib_Decompress_copy_impl(self, cls); - -exit: - return return_value; + return zlib_Decompress_copy_impl(self, cls); } #endif /* defined(HAVE_ZLIB_COPY) */ @@ -590,18 +613,11 @@ zlib_Decompress___copy___impl(compobject *self, PyTypeObject *cls); static PyObject * zlib_Decompress___copy__(compobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { - PyObject *return_value = NULL; - static const char * const _keywords[] = { NULL}; - static _PyArg_Parser _parser = {":__copy__", _keywords, 0}; - - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser - )) { - goto exit; + if (nargs) { + PyErr_SetString(PyExc_TypeError, "__copy__() takes no arguments"); + return NULL; } - return_value = zlib_Decompress___copy___impl(self, cls); - -exit: - return return_value; + return zlib_Decompress___copy___impl(self, cls); } #endif /* defined(HAVE_ZLIB_COPY) */ @@ -625,13 +641,15 @@ zlib_Decompress___deepcopy__(compobject *self, PyTypeObject *cls, PyObject *cons { PyObject *return_value = NULL; static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = {"O:__deepcopy__", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "__deepcopy__", 0}; + PyObject *argsbuf[1]; PyObject *memo; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &memo)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { goto exit; } + memo = args[0]; return_value = zlib_Decompress___deepcopy___impl(self, cls, memo); exit: @@ -661,13 +679,30 @@ zlib_Decompress_flush(compobject *self, PyTypeObject *cls, PyObject *const *args { PyObject *return_value = NULL; static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = {"|n:flush", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "flush", 0}; + PyObject *argsbuf[1]; Py_ssize_t length = DEF_BUF_SIZE; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &length)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { goto exit; } + if (nargs < 1) { + goto skip_optional_posonly; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = _PyNumber_Index(args[0]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + length = ival; + } +skip_optional_posonly: return_value = zlib_Decompress_flush_impl(self, cls, length); exit: @@ -803,4 +838,4 @@ zlib_crc32(PyObject *module, PyObject *const *args, Py_ssize_t nargs) #ifndef ZLIB_DECOMPRESS___DEEPCOPY___METHODDEF #define ZLIB_DECOMPRESS___DEEPCOPY___METHODDEF #endif /* !defined(ZLIB_DECOMPRESS___DEEPCOPY___METHODDEF) */ -/*[clinic end generated code: output=6736bae59fab268b input=a9049054013a1b77]*/ +/*[clinic end generated code: output=1bda0d996fb51269 input=a9049054013a1b77]*/ diff --git a/Tools/clinic/clinic.py b/Tools/clinic/clinic.py index 969008ade9790..b442c494d31d4 100755 --- a/Tools/clinic/clinic.py +++ b/Tools/clinic/clinic.py @@ -636,6 +636,10 @@ def output_templates(self, f): assert parameters assert isinstance(parameters[0].converter, self_converter) del parameters[0] + requires_defining_class = False + if parameters and isinstance(parameters[0].converter, defining_class_converter): + requires_defining_class = True + del parameters[0] converters = [p.converter for p in parameters] has_option_groups = parameters and (parameters[0].group or parameters[-1].group) @@ -657,10 +661,6 @@ def output_templates(self, f): if not p.is_optional(): min_pos = i - requires_defining_class = any( - isinstance(p.converter, defining_class_converter) - for p in parameters) - meth_o = (len(parameters) == 1 and parameters[0].is_positional_only() and not converters[0].is_optional() and @@ -763,24 +763,40 @@ def parser_body(prototype, *fields, declarations=''): return linear_format(output(), parser_declarations=declarations) if not parameters: - # no parameters, METH_NOARGS + if not requires_defining_class: + # no parameters, METH_NOARGS + flags = "METH_NOARGS" - flags = "METH_NOARGS" + parser_prototype = normalize_snippet(""" + static PyObject * + {c_basename}({self_type}{self_name}, PyObject *Py_UNUSED(ignored)) + """) + parser_code = [] - parser_prototype = normalize_snippet(""" - static PyObject * - {c_basename}({self_type}{self_name}, PyObject *Py_UNUSED(ignored)) - """) - parser_definition = parser_prototype + else: + assert not new_or_init - if default_return_converter: - parser_definition = parser_prototype + '\n' + normalize_snippet(""" - {{ - return {c_basename}_impl({impl_arguments}); + flags = "METH_METHOD|METH_FASTCALL|METH_KEYWORDS" + + parser_prototype = parser_prototype_def_class + return_error = ('return NULL;' if default_return_converter + else 'goto exit;') + parser_code = [normalize_snippet(""" + if (nargs) {{ + PyErr_SetString(PyExc_TypeError, "{name}() takes no arguments"); + %s }} - """) + """ % return_error, indent=4)] + + if default_return_converter: + parser_definition = '\n'.join([ + parser_prototype, + '{{', + *parser_code, + ' return {c_basename}_impl({impl_arguments});', + '}}']) else: - parser_definition = parser_body(parser_prototype) + parser_definition = parser_body(parser_prototype, *parser_code) elif meth_o: flags = "METH_O" @@ -939,6 +955,9 @@ def parser_body(prototype, *fields, declarations=''): add_label = None for i, p in enumerate(parameters): + if isinstance(p.converter, defining_class_converter): + raise ValueError("defining_class should be the first " + "parameter (after self)") displayname = p.get_displayname(i+1) parsearg = p.converter.parse_arg(argname_fmt % i, displayname) if parsearg is None: From webhook-mailer at python.org Tue May 3 04:54:18 2022 From: webhook-mailer at python.org (serhiy-storchaka) Date: Tue, 03 May 2022 08:54:18 -0000 Subject: [Python-checkins] [3.9] gh-91583: AC: Fix regression for functions with defining_class (GH-91739) (GH-92080) Message-ID: https://github.com/python/cpython/commit/1b1c79c566b8aa527f551cb4d41d3fab09b781a5 commit: 1b1c79c566b8aa527f551cb4d41d3fab09b781a5 branch: 3.9 author: Serhiy Storchaka committer: serhiy-storchaka date: 2022-05-03T11:54:06+03:00 summary: [3.9] gh-91583: AC: Fix regression for functions with defining_class (GH-91739) (GH-92080) Argument Clinic now generates the same efficient code as before adding the defining_class parameter. (cherry picked from commit a055dac0b45031878a8196a8735522de018491e3) files: A Misc/NEWS.d/next/Tools-Demos/2022-04-20-14-26-14.gh-issue-91583.200qI0.rst M Modules/clinic/_testmultiphase.c.h M Modules/clinic/posixmodule.c.h M Tools/clinic/clinic.py diff --git a/Misc/NEWS.d/next/Tools-Demos/2022-04-20-14-26-14.gh-issue-91583.200qI0.rst b/Misc/NEWS.d/next/Tools-Demos/2022-04-20-14-26-14.gh-issue-91583.200qI0.rst new file mode 100644 index 0000000000000..bdfa71100f95a --- /dev/null +++ b/Misc/NEWS.d/next/Tools-Demos/2022-04-20-14-26-14.gh-issue-91583.200qI0.rst @@ -0,0 +1,2 @@ +Fix regression in the code generated by Argument Clinic for functions with +the ``defining_class`` parameter. diff --git a/Modules/clinic/_testmultiphase.c.h b/Modules/clinic/_testmultiphase.c.h index 0d38c230f7186..23180d0aa1373 100644 --- a/Modules/clinic/_testmultiphase.c.h +++ b/Modules/clinic/_testmultiphase.c.h @@ -18,18 +18,11 @@ _testmultiphase_StateAccessType_get_defining_module_impl(StateAccessTypeObject * static PyObject * _testmultiphase_StateAccessType_get_defining_module(StateAccessTypeObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { - PyObject *return_value = NULL; - static const char * const _keywords[] = { NULL}; - static _PyArg_Parser _parser = {":get_defining_module", _keywords, 0}; - - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser - )) { - goto exit; + if (nargs) { + PyErr_SetString(PyExc_TypeError, "get_defining_module() takes no arguments"); + return NULL; } - return_value = _testmultiphase_StateAccessType_get_defining_module_impl(self, cls); - -exit: - return return_value; + return _testmultiphase_StateAccessType_get_defining_module_impl(self, cls); } PyDoc_STRVAR(_testmultiphase_StateAccessType_increment_count_clinic__doc__, @@ -55,14 +48,42 @@ _testmultiphase_StateAccessType_increment_count_clinic(StateAccessTypeObject *se { PyObject *return_value = NULL; static const char * const _keywords[] = {"n", "twice", NULL}; - static _PyArg_Parser _parser = {"|i$p:increment_count_clinic", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "increment_count_clinic", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; int n = 1; int twice = 0; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &n, &twice)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { goto exit; } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[0]) { + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + n = _PyLong_AsInt(args[0]); + if (n == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } +skip_optional_pos: + if (!noptargs) { + goto skip_optional_kwonly; + } + twice = PyObject_IsTrue(args[1]); + if (twice < 0) { + goto exit; + } +skip_optional_kwonly: return_value = _testmultiphase_StateAccessType_increment_count_clinic_impl(self, cls, n, twice); exit: @@ -85,17 +106,10 @@ _testmultiphase_StateAccessType_get_count_impl(StateAccessTypeObject *self, static PyObject * _testmultiphase_StateAccessType_get_count(StateAccessTypeObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { - PyObject *return_value = NULL; - static const char * const _keywords[] = { NULL}; - static _PyArg_Parser _parser = {":get_count", _keywords, 0}; - - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser - )) { - goto exit; + if (nargs) { + PyErr_SetString(PyExc_TypeError, "get_count() takes no arguments"); + return NULL; } - return_value = _testmultiphase_StateAccessType_get_count_impl(self, cls); - -exit: - return return_value; + return _testmultiphase_StateAccessType_get_count_impl(self, cls); } -/*[clinic end generated code: output=39eea487e94e7f5d input=a9049054013a1b77]*/ +/*[clinic end generated code: output=60d68e2336064f96 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/posixmodule.c.h b/Modules/clinic/posixmodule.c.h index 28798ab99c1a0..f5df5c3b907ba 100644 --- a/Modules/clinic/posixmodule.c.h +++ b/Modules/clinic/posixmodule.c.h @@ -8438,12 +8438,10 @@ static PyObject * os_DirEntry_is_symlink(DirEntry *self, PyTypeObject *defining_class, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - static const char * const _keywords[] = { NULL}; - static _PyArg_Parser _parser = {":is_symlink", _keywords, 0}; int _return_value; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser - )) { + if (nargs) { + PyErr_SetString(PyExc_TypeError, "is_symlink() takes no arguments"); goto exit; } _return_value = os_DirEntry_is_symlink_impl(self, defining_class); @@ -8474,13 +8472,23 @@ os_DirEntry_stat(DirEntry *self, PyTypeObject *defining_class, PyObject *const * { PyObject *return_value = NULL; static const char * const _keywords[] = {"follow_symlinks", NULL}; - static _PyArg_Parser _parser = {"|$p:stat", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "stat", 0}; + PyObject *argsbuf[1]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; int follow_symlinks = 1; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &follow_symlinks)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 0, 0, argsbuf); + if (!args) { goto exit; } + if (!noptargs) { + goto skip_optional_kwonly; + } + follow_symlinks = PyObject_IsTrue(args[0]); + if (follow_symlinks < 0) { + goto exit; + } +skip_optional_kwonly: return_value = os_DirEntry_stat_impl(self, defining_class, follow_symlinks); exit: @@ -8505,14 +8513,24 @@ os_DirEntry_is_dir(DirEntry *self, PyTypeObject *defining_class, PyObject *const { PyObject *return_value = NULL; static const char * const _keywords[] = {"follow_symlinks", NULL}; - static _PyArg_Parser _parser = {"|$p:is_dir", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "is_dir", 0}; + PyObject *argsbuf[1]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; int follow_symlinks = 1; int _return_value; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &follow_symlinks)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 0, 0, argsbuf); + if (!args) { goto exit; } + if (!noptargs) { + goto skip_optional_kwonly; + } + follow_symlinks = PyObject_IsTrue(args[0]); + if (follow_symlinks < 0) { + goto exit; + } +skip_optional_kwonly: _return_value = os_DirEntry_is_dir_impl(self, defining_class, follow_symlinks); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -8541,14 +8559,24 @@ os_DirEntry_is_file(DirEntry *self, PyTypeObject *defining_class, PyObject *cons { PyObject *return_value = NULL; static const char * const _keywords[] = {"follow_symlinks", NULL}; - static _PyArg_Parser _parser = {"|$p:is_file", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "is_file", 0}; + PyObject *argsbuf[1]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; int follow_symlinks = 1; int _return_value; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &follow_symlinks)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 0, 0, argsbuf); + if (!args) { goto exit; } + if (!noptargs) { + goto skip_optional_kwonly; + } + follow_symlinks = PyObject_IsTrue(args[0]); + if (follow_symlinks < 0) { + goto exit; + } +skip_optional_kwonly: _return_value = os_DirEntry_is_file_impl(self, defining_class, follow_symlinks); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -9441,4 +9469,4 @@ os_waitstatus_to_exitcode(PyObject *module, PyObject *const *args, Py_ssize_t na #ifndef OS_WAITSTATUS_TO_EXITCODE_METHODDEF #define OS_WAITSTATUS_TO_EXITCODE_METHODDEF #endif /* !defined(OS_WAITSTATUS_TO_EXITCODE_METHODDEF) */ -/*[clinic end generated code: output=c7c8796918b09139 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=08879489d9e259a1 input=a9049054013a1b77]*/ diff --git a/Tools/clinic/clinic.py b/Tools/clinic/clinic.py index 61d30b01c0998..655e386512a58 100755 --- a/Tools/clinic/clinic.py +++ b/Tools/clinic/clinic.py @@ -636,6 +636,10 @@ def output_templates(self, f): assert parameters assert isinstance(parameters[0].converter, self_converter) del parameters[0] + requires_defining_class = False + if parameters and isinstance(parameters[0].converter, defining_class_converter): + requires_defining_class = True + del parameters[0] converters = [p.converter for p in parameters] has_option_groups = parameters and (parameters[0].group or parameters[-1].group) @@ -657,10 +661,6 @@ def output_templates(self, f): if not p.is_optional(): min_pos = i - requires_defining_class = any( - isinstance(p.converter, defining_class_converter) - for p in parameters) - meth_o = (len(parameters) == 1 and parameters[0].is_positional_only() and not converters[0].is_optional() and @@ -763,24 +763,40 @@ def parser_body(prototype, *fields, declarations=''): return linear_format(output(), parser_declarations=declarations) if not parameters: - # no parameters, METH_NOARGS + if not requires_defining_class: + # no parameters, METH_NOARGS + flags = "METH_NOARGS" - flags = "METH_NOARGS" + parser_prototype = normalize_snippet(""" + static PyObject * + {c_basename}({self_type}{self_name}, PyObject *Py_UNUSED(ignored)) + """) + parser_code = [] - parser_prototype = normalize_snippet(""" - static PyObject * - {c_basename}({self_type}{self_name}, PyObject *Py_UNUSED(ignored)) - """) - parser_definition = parser_prototype + else: + assert not new_or_init - if default_return_converter: - parser_definition = parser_prototype + '\n' + normalize_snippet(""" - {{ - return {c_basename}_impl({impl_arguments}); + flags = "METH_METHOD|METH_FASTCALL|METH_KEYWORDS" + + parser_prototype = parser_prototype_def_class + return_error = ('return NULL;' if default_return_converter + else 'goto exit;') + parser_code = [normalize_snippet(""" + if (nargs) {{ + PyErr_SetString(PyExc_TypeError, "{name}() takes no arguments"); + %s }} - """) + """ % return_error, indent=4)] + + if default_return_converter: + parser_definition = '\n'.join([ + parser_prototype, + '{{', + *parser_code, + ' return {c_basename}_impl({impl_arguments});', + '}}']) else: - parser_definition = parser_body(parser_prototype) + parser_definition = parser_body(parser_prototype, *parser_code) elif meth_o: flags = "METH_O" @@ -939,6 +955,9 @@ def parser_body(prototype, *fields, declarations=''): add_label = None for i, p in enumerate(parameters): + if isinstance(p.converter, defining_class_converter): + raise ValueError("defining_class should be the first " + "parameter (after self)") displayname = p.get_displayname(i+1) parsearg = p.converter.parse_arg(argname_fmt % i, displayname) if parsearg is None: From webhook-mailer at python.org Tue May 3 08:09:08 2022 From: webhook-mailer at python.org (JelleZijlstra) Date: Tue, 03 May 2022 12:09:08 -0000 Subject: [Python-checkins] [3.9] bpo-46586: Fix more erroneous doc links to builtins (GH-31429) (#92199) Message-ID: https://github.com/python/cpython/commit/92d2615d00ce8035cc9e64c1fb87dabf1d7071de commit: 92d2615d00ce8035cc9e64c1fb87dabf1d7071de branch: 3.9 author: Jelle Zijlstra committer: JelleZijlstra date: 2022-05-03T06:08:55-06:00 summary: [3.9] bpo-46586: Fix more erroneous doc links to builtins (GH-31429) (#92199) Co-authored-by: Jelle Zijlstra Co-authored-by: ?ric . (cherry picked from commit cc6ae4f4835f9e76a34f24cd1f666c1cc0fecfa3) Co-authored-by: Meer Suri <46469858+meersuri at users.noreply.github.com> files: M Doc/library/urllib.request.rst M Doc/library/zipfile.rst diff --git a/Doc/library/urllib.request.rst b/Doc/library/urllib.request.rst index 6f6523d8afe9fa..ae9abe7d48ac85 100644 --- a/Doc/library/urllib.request.rst +++ b/Doc/library/urllib.request.rst @@ -734,7 +734,7 @@ The following attribute and methods should only be used by classes derived from This method, if implemented, will be called by the parent :class:`OpenerDirector`. It should return a file-like object as described in - the return value of the :meth:`open` of :class:`OpenerDirector`, or ``None``. + the return value of the :meth:`~OpenerDirector.open` method of :class:`OpenerDirector`, or ``None``. It should raise :exc:`~urllib.error.URLError`, unless a truly exceptional thing happens (for example, :exc:`MemoryError` should not be mapped to :exc:`URLError`). diff --git a/Doc/library/zipfile.rst b/Doc/library/zipfile.rst index 3d1e8d8c468dcf..de508cadccc6fe 100644 --- a/Doc/library/zipfile.rst +++ b/Doc/library/zipfile.rst @@ -289,7 +289,7 @@ ZipFile Objects compressed text files in :term:`universal newlines` mode. .. versionchanged:: 3.6 - :meth:`open` can now be used to write files into the archive with the + :meth:`ZipFile.open` can now be used to write files into the archive with the ``mode='w'`` option. .. versionchanged:: 3.6 From webhook-mailer at python.org Tue May 3 08:13:06 2022 From: webhook-mailer at python.org (JelleZijlstra) Date: Tue, 03 May 2022 12:13:06 -0000 Subject: [Python-checkins] bpo-46415: Use f-string for ValueError in ipaddress.ip_{address, network, interface} helper functions (#30642) Message-ID: https://github.com/python/cpython/commit/52dc9c3066bcdc67a7a45d41cf158ecb1434d5f3 commit: 52dc9c3066bcdc67a7a45d41cf158ecb1434d5f3 branch: main author: Thomas Cellerier committer: JelleZijlstra date: 2022-05-03T06:12:58-06:00 summary: bpo-46415: Use f-string for ValueError in ipaddress.ip_{address,network,interface} helper functions (#30642) `IPv*Network` and `IPv*Interface` constructors accept a 2-tuple of (address description, netmask) as the address parameter. When the tuple-based address is used errors are not propagated correctly through the `ipaddress.ip_*` helper because of the %-formatting now expecting several arguments: In [7]: ipaddress.ip_network(("192.168.100.0", "fooo")) ... TypeError: not all arguments converted during string formatting Compared to: In [8]: ipaddress.IPv4Network(("192.168.100.0", "foo")) ... NetmaskValueError: 'foo' is not a valid netmask Use an f-string to make sure the error is always properly formatted. Co-authored-by: Jelle Zijlstra files: A Misc/NEWS.d/next/Library/2022-01-17-16-53-30.bpo-46415.6wSYg-.rst M Lib/ipaddress.py M Lib/test/test_ipaddress.py diff --git a/Lib/ipaddress.py b/Lib/ipaddress.py index e601f6f476e4d..3f15601e700d6 100644 --- a/Lib/ipaddress.py +++ b/Lib/ipaddress.py @@ -51,8 +51,7 @@ def ip_address(address): except (AddressValueError, NetmaskValueError): pass - raise ValueError('%r does not appear to be an IPv4 or IPv6 address' % - address) + raise ValueError(f'{address!r} does not appear to be an IPv4 or IPv6 address') def ip_network(address, strict=True): @@ -81,8 +80,7 @@ def ip_network(address, strict=True): except (AddressValueError, NetmaskValueError): pass - raise ValueError('%r does not appear to be an IPv4 or IPv6 network' % - address) + raise ValueError(f'{address!r} does not appear to be an IPv4 or IPv6 network') def ip_interface(address): @@ -116,8 +114,7 @@ def ip_interface(address): except (AddressValueError, NetmaskValueError): pass - raise ValueError('%r does not appear to be an IPv4 or IPv6 interface' % - address) + raise ValueError(f'{address!r} does not appear to be an IPv4 or IPv6 interface') def v4_int_to_packed(address): @@ -160,7 +157,7 @@ def _split_optional_netmask(address): """Helper to split the netmask and raise AddressValueError if needed""" addr = str(address).split('/') if len(addr) > 2: - raise AddressValueError("Only one '/' permitted in %r" % address) + raise AddressValueError(f"Only one '/' permitted in {address!r}") return addr @@ -1304,7 +1301,7 @@ def __init__(self, address): # which converts into a formatted IP string. addr_str = str(address) if '/' in addr_str: - raise AddressValueError("Unexpected '/' in %r" % address) + raise AddressValueError(f"Unexpected '/' in {address!r}") self._ip = self._ip_int_from_string(addr_str) @property @@ -1913,7 +1910,7 @@ def __init__(self, address): # which converts into a formatted IP string. addr_str = str(address) if '/' in addr_str: - raise AddressValueError("Unexpected '/' in %r" % address) + raise AddressValueError(f"Unexpected '/' in {address!r}") addr_str, self._scope_id = self._split_scope_id(addr_str) self._ip = self._ip_int_from_string(addr_str) diff --git a/Lib/test/test_ipaddress.py b/Lib/test/test_ipaddress.py index b0605f0be04bb..e5162e86cb5dc 100644 --- a/Lib/test/test_ipaddress.py +++ b/Lib/test/test_ipaddress.py @@ -1132,6 +1132,14 @@ def testIPv4Tuple(self): self.assertEqual(ipaddress.IPv4Interface((3221225985, 24)), ipaddress.IPv4Interface('192.0.2.1/24')) + # Invalid netmask + with self.assertRaises(ValueError): + ipaddress.IPv4Network(('192.0.2.1', '255.255.255.255.0')) + + # Invalid netmask using factory + with self.assertRaises(ValueError): + ipaddress.ip_network(('192.0.2.1', '255.255.255.255.0')) + # issue #16531: constructing IPv6Network from an (address, mask) tuple def testIPv6Tuple(self): # /128 @@ -1191,6 +1199,14 @@ def testIPv6Tuple(self): ipaddress.IPv6Network((ip_scoped, 96)) # strict=False and host bits set + # Invalid netmask + with self.assertRaises(ValueError): + ipaddress.IPv6Network(('2001:db8::1', '255.255.255.0')) + + # Invalid netmask using factory + with self.assertRaises(ValueError): + ipaddress.ip_network(('2001:db8::1', '255.255.255.0')) + # issue57 def testAddressIntMath(self): self.assertEqual(ipaddress.IPv4Address('1.1.1.1') + 255, diff --git a/Misc/NEWS.d/next/Library/2022-01-17-16-53-30.bpo-46415.6wSYg-.rst b/Misc/NEWS.d/next/Library/2022-01-17-16-53-30.bpo-46415.6wSYg-.rst new file mode 100644 index 0000000000000..016d6656041f9 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2022-01-17-16-53-30.bpo-46415.6wSYg-.rst @@ -0,0 +1,2 @@ +Fix ipaddress.ip_{address,interface,network} raising TypeError instead of +ValueError if given invalid tuple as address parameter. From webhook-mailer at python.org Tue May 3 08:18:31 2022 From: webhook-mailer at python.org (methane) Date: Tue, 03 May 2022 12:18:31 -0000 Subject: [Python-checkins] gh-70363: Implement `io.IOBase` interface for `SpooledTemporaryFile` (GH-29560) Message-ID: https://github.com/python/cpython/commit/78e70be3318bc2ca57dac188061ed35017a0867c commit: 78e70be3318bc2ca57dac188061ed35017a0867c branch: main author: Carey Metcalfe committer: methane date: 2022-05-03T21:18:18+09:00 summary: gh-70363: Implement `io.IOBase` interface for `SpooledTemporaryFile` (GH-29560) Since the underlying file-like objects (either `io.BytesIO`, or a true file object) all implement the `io.IOBase` interface, the `SpooledTemporaryFile` should as well. Additionally, since the underlying file object will either be an instance of an `io.BufferedIOBase` (for binary mode) or an `io.TextIOBase` (for text mode), methods for these classes were also implemented. In every case, the required methods and properties are simply delegated to the underlying file object. Co-authored-by: Gary Fernie Co-authored-by: Inada Naoki files: A Misc/NEWS.d/next/Library/2021-11-14-01-35-04.bpo-26175.LNlOfI.rst M Doc/library/tempfile.rst M Lib/tempfile.py M Lib/test/test_tempfile.py M Misc/ACKS diff --git a/Doc/library/tempfile.rst b/Doc/library/tempfile.rst index c97d119fb8b5e..8fe38b5e81c08 100644 --- a/Doc/library/tempfile.rst +++ b/Doc/library/tempfile.rst @@ -123,6 +123,11 @@ The module defines the following user-callable items: .. versionchanged:: 3.8 Added *errors* parameter. + .. versionchanged:: 3.11 + Fully implements the :class:`io.BufferedIOBase` and + :class:`io.TextIOBase` abstract base classes (depending on whether binary + or text *mode* was specified). + .. class:: TemporaryDirectory(suffix=None, prefix=None, dir=None, ignore_cleanup_errors=False) diff --git a/Lib/tempfile.py b/Lib/tempfile.py index 531cbf32f1283..eb870c998c251 100644 --- a/Lib/tempfile.py +++ b/Lib/tempfile.py @@ -639,7 +639,7 @@ def TemporaryFile(mode='w+b', buffering=-1, encoding=None, _os.close(fd) raise -class SpooledTemporaryFile: +class SpooledTemporaryFile(_io.IOBase): """Temporary file wrapper, specialized to switch from BytesIO or StringIO to a real file when it exceeds a certain size or when a fileno is needed. @@ -704,6 +704,16 @@ def __exit__(self, exc, value, tb): def __iter__(self): return self._file.__iter__() + def __del__(self): + if not self.closed: + _warnings.warn( + "Unclosed file {!r}".format(self), + ResourceWarning, + stacklevel=2, + source=self + ) + self.close() + def close(self): self._file.close() @@ -747,15 +757,30 @@ def name(self): def newlines(self): return self._file.newlines + def readable(self): + return self._file.readable() + def read(self, *args): return self._file.read(*args) + def read1(self, *args): + return self._file.read1(*args) + + def readinto(self, b): + return self._file.readinto(b) + + def readinto1(self, b): + return self._file.readinto1(b) + def readline(self, *args): return self._file.readline(*args) def readlines(self, *args): return self._file.readlines(*args) + def seekable(self): + return self._file.seekable() + def seek(self, *args): return self._file.seek(*args) @@ -764,11 +789,14 @@ def tell(self): def truncate(self, size=None): if size is None: - self._file.truncate() + return self._file.truncate() else: if size > self._max_size: self.rollover() - self._file.truncate(size) + return self._file.truncate(size) + + def writable(self): + return self._file.writable() def write(self, s): file = self._file @@ -782,6 +810,9 @@ def writelines(self, iterable): self._check(file) return rv + def detach(self): + return self._file.detach() + class TemporaryDirectory: """Create and return a temporary directory. This has the same diff --git a/Lib/test/test_tempfile.py b/Lib/test/test_tempfile.py index a6847189dca46..07a54028ec697 100644 --- a/Lib/test/test_tempfile.py +++ b/Lib/test/test_tempfile.py @@ -1061,6 +1061,30 @@ def test_basic(self): f = self.do_create(max_size=100, pre="a", suf=".txt") self.assertFalse(f._rolled) + def test_is_iobase(self): + # SpooledTemporaryFile should implement io.IOBase + self.assertIsInstance(self.do_create(), io.IOBase) + + def test_iobase_interface(self): + # SpooledTemporaryFile should implement the io.IOBase interface. + # Ensure it has all the required methods and properties. + iobase_attrs = { + # From IOBase + 'fileno', 'seek', 'truncate', 'close', 'closed', '__enter__', + '__exit__', 'flush', 'isatty', '__iter__', '__next__', 'readable', + 'readline', 'readlines', 'seekable', 'tell', 'writable', + 'writelines', + # From BufferedIOBase (binary mode) and TextIOBase (text mode) + 'detach', 'read', 'read1', 'write', 'readinto', 'readinto1', + 'encoding', 'errors', 'newlines', + } + spooledtempfile_attrs = set(dir(tempfile.SpooledTemporaryFile)) + missing_attrs = iobase_attrs - spooledtempfile_attrs + self.assertFalse( + missing_attrs, + 'SpooledTemporaryFile missing attributes from IOBase/BufferedIOBase/TextIOBase' + ) + def test_del_on_close(self): # A SpooledTemporaryFile is deleted when closed dir = tempfile.mkdtemp() @@ -1076,6 +1100,30 @@ def test_del_on_close(self): finally: os.rmdir(dir) + def test_del_unrolled_file(self): + # The unrolled SpooledTemporaryFile should raise a ResourceWarning + # when deleted since the file was not explicitly closed. + f = self.do_create(max_size=10) + f.write(b'foo') + self.assertEqual(f.name, None) # Unrolled so no filename/fd + with self.assertWarns(ResourceWarning): + f.__del__() + + def test_del_rolled_file(self): + # The rolled file should be deleted when the SpooledTemporaryFile + # object is deleted. This should raise a ResourceWarning since the file + # was not explicitly closed. + f = self.do_create(max_size=2) + f.write(b'foo') + name = f.name # This is a fd on posix+cygwin, a filename everywhere else + self.assertTrue(os.path.exists(name)) + with self.assertWarns(ResourceWarning): + f.__del__() + self.assertFalse( + os.path.exists(name), + "Rolled SpooledTemporaryFile (name=%s) exists after delete" % name + ) + def test_rewrite_small(self): # A SpooledTemporaryFile can be written to multiple within the max_size f = self.do_create(max_size=30) diff --git a/Misc/ACKS b/Misc/ACKS index 30b698f90e83b..1efc6a07c6cad 100644 --- a/Misc/ACKS +++ b/Misc/ACKS @@ -1172,6 +1172,7 @@ Dimitri Merejkowsky Brian Merrell Bruce Merry Alexis M?taireau +Carey Metcalfe Luke Mewburn Carl Meyer Kyle Meyer diff --git a/Misc/NEWS.d/next/Library/2021-11-14-01-35-04.bpo-26175.LNlOfI.rst b/Misc/NEWS.d/next/Library/2021-11-14-01-35-04.bpo-26175.LNlOfI.rst new file mode 100644 index 0000000000000..89072b3c04f39 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2021-11-14-01-35-04.bpo-26175.LNlOfI.rst @@ -0,0 +1,4 @@ +Fully implement the :class:`io.BufferedIOBase` or :class:`io.TextIOBase` +interface for :class:`tempfile.SpooledTemporaryFile` objects. This lets them +work correctly with higher-level layers (like compression modules). Patch by +Carey Metcalfe. From webhook-mailer at python.org Tue May 3 08:33:27 2022 From: webhook-mailer at python.org (JelleZijlstra) Date: Tue, 03 May 2022 12:33:27 -0000 Subject: [Python-checkins] Dependabot: only bump actions for major versions (#92186) Message-ID: https://github.com/python/cpython/commit/628d6e8270339062c591825ea467ab00bb560f6f commit: 628d6e8270339062c591825ea467ab00bb560f6f branch: main author: Hugo van Kemenade committer: JelleZijlstra date: 2022-05-03T06:33:03-06:00 summary: Dependabot: only bump actions for major versions (#92186) files: M .github/dependabot.yml M .github/workflows/build.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml index e90677b9f775a..555e246e402bf 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -7,3 +7,8 @@ updates: labels: - "skip issue" - "skip news" + ignore: + - dependency-name: "*" + update-types: + - "version-update:semver-minor" + - "version-update:semver-patch" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1f48d6257e760..b489335903772 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -185,7 +185,7 @@ jobs: echo "LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/multissl/openssl/${OPENSSL_VER}/lib" >> $GITHUB_ENV - name: 'Restore OpenSSL build' id: cache-openssl - uses: actions/cache at v3.0.2 + uses: actions/cache at v3 with: path: ./multissl/openssl/${{ env.OPENSSL_VER }} key: ${{ runner.os }}-multissl-openssl-${{ env.OPENSSL_VER }} @@ -248,7 +248,7 @@ jobs: echo "LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/multissl/openssl/${OPENSSL_VER}/lib" >> $GITHUB_ENV - name: 'Restore OpenSSL build' id: cache-openssl - uses: actions/cache at v3.0.2 + uses: actions/cache at v3 with: path: ./multissl/openssl/${{ env.OPENSSL_VER }} key: ${{ runner.os }}-multissl-openssl-${{ env.OPENSSL_VER }} @@ -292,7 +292,7 @@ jobs: echo "LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/multissl/openssl/${OPENSSL_VER}/lib" >> $GITHUB_ENV - name: 'Restore OpenSSL build' id: cache-openssl - uses: actions/cache at v3.0.2 + uses: actions/cache at v3 with: path: ./multissl/openssl/${{ env.OPENSSL_VER }} key: ${{ runner.os }}-multissl-openssl-${{ env.OPENSSL_VER }} From webhook-mailer at python.org Tue May 3 08:33:28 2022 From: webhook-mailer at python.org (JelleZijlstra) Date: Tue, 03 May 2022 12:33:28 -0000 Subject: [Python-checkins] gh-92206: Improve scoping of sqlite3 register cursor helper (#92212) Message-ID: https://github.com/python/cpython/commit/1d4a9a45b7ac8c1c5fecc363c988be59500f1ed7 commit: 1d4a9a45b7ac8c1c5fecc363c988be59500f1ed7 branch: main author: Erlend Egeberg Aasland committer: JelleZijlstra date: 2022-05-03T06:33:24-06:00 summary: gh-92206: Improve scoping of sqlite3 register cursor helper (#92212) files: M Modules/_sqlite/connection.c M Modules/_sqlite/connection.h M Modules/_sqlite/cursor.c diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c index fe244c8b22771..75d29704695c6 100644 --- a/Modules/_sqlite/connection.c +++ b/Modules/_sqlite/connection.c @@ -371,32 +371,6 @@ connection_dealloc(pysqlite_Connection *self) Py_DECREF(tp); } -/* - * Registers a cursor with the connection. - * - * 0 => error; 1 => ok - */ -int pysqlite_connection_register_cursor(pysqlite_Connection* connection, PyObject* cursor) -{ - PyObject* weakref; - - weakref = PyWeakref_NewRef((PyObject*)cursor, NULL); - if (!weakref) { - goto error; - } - - if (PyList_Append(connection->cursors, weakref) != 0) { - Py_CLEAR(weakref); - goto error; - } - - Py_DECREF(weakref); - - return 1; -error: - return 0; -} - /*[clinic input] _sqlite3.Connection.cursor as pysqlite_connection_cursor diff --git a/Modules/_sqlite/connection.h b/Modules/_sqlite/connection.h index 2b946ff3c7369..629fe3d3a95a1 100644 --- a/Modules/_sqlite/connection.h +++ b/Modules/_sqlite/connection.h @@ -99,7 +99,6 @@ typedef struct PyObject* NotSupportedError; } pysqlite_Connection; -int pysqlite_connection_register_cursor(pysqlite_Connection* connection, PyObject* cursor); int pysqlite_check_thread(pysqlite_Connection* self); int pysqlite_check_connection(pysqlite_Connection* con); diff --git a/Modules/_sqlite/cursor.c b/Modules/_sqlite/cursor.c index 861704f95cc83..84f481792ddd3 100644 --- a/Modules/_sqlite/cursor.c +++ b/Modules/_sqlite/cursor.c @@ -35,6 +35,28 @@ class _sqlite3.Cursor "pysqlite_Cursor *" "clinic_state()->CursorType" [clinic start generated code]*/ /*[clinic end generated code: output=da39a3ee5e6b4b0d input=3c5b8115c5cf30f1]*/ +/* + * Registers a cursor with the connection. + * + * 0 => error; 1 => ok + */ +static int +register_cursor(pysqlite_Connection *connection, PyObject *cursor) +{ + PyObject *weakref = PyWeakref_NewRef((PyObject *)cursor, NULL); + if (weakref == NULL) { + return 0; + } + + if (PyList_Append(connection->cursors, weakref) < 0) { + Py_CLEAR(weakref); + return 0; + } + + Py_DECREF(weakref); + return 1; +} + /*[clinic input] _sqlite3.Cursor.__init__ as pysqlite_cursor_init @@ -70,7 +92,7 @@ pysqlite_cursor_init_impl(pysqlite_Cursor *self, return -1; } - if (!pysqlite_connection_register_cursor(connection, (PyObject*)self)) { + if (!register_cursor(connection, (PyObject *)self)) { return -1; } From webhook-mailer at python.org Tue May 3 08:34:55 2022 From: webhook-mailer at python.org (miss-islington) Date: Tue, 03 May 2022 12:34:55 -0000 Subject: [Python-checkins] bpo-46415: Use f-string for ValueError in ipaddress.ip_{address, network, interface} helper functions (GH-30642) Message-ID: https://github.com/python/cpython/commit/020f5c47d8137802d0f058ab2ed2dcb939a2eb8f commit: 020f5c47d8137802d0f058ab2ed2dcb939a2eb8f branch: 3.9 author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com> committer: miss-islington <31488909+miss-islington at users.noreply.github.com> date: 2022-05-03T05:34:50-07:00 summary: bpo-46415: Use f-string for ValueError in ipaddress.ip_{address,network,interface} helper functions (GH-30642) `IPv*Network` and `IPv*Interface` constructors accept a 2-tuple of (address description, netmask) as the address parameter. When the tuple-based address is used errors are not propagated correctly through the `ipaddress.ip_*` helper because of the %-formatting now expecting several arguments: In [7]: ipaddress.ip_network(("192.168.100.0", "fooo")) ... TypeError: not all arguments converted during string formatting Compared to: In [8]: ipaddress.IPv4Network(("192.168.100.0", "foo")) ... NetmaskValueError: 'foo' is not a valid netmask Use an f-string to make sure the error is always properly formatted. Co-authored-by: Jelle Zijlstra (cherry picked from commit 52dc9c3066bcdc67a7a45d41cf158ecb1434d5f3) Co-authored-by: Thomas Cellerier files: A Misc/NEWS.d/next/Library/2022-01-17-16-53-30.bpo-46415.6wSYg-.rst M Lib/ipaddress.py M Lib/test/test_ipaddress.py diff --git a/Lib/ipaddress.py b/Lib/ipaddress.py index 6cb92ed552006..25f373a06a2b6 100644 --- a/Lib/ipaddress.py +++ b/Lib/ipaddress.py @@ -50,8 +50,7 @@ def ip_address(address): except (AddressValueError, NetmaskValueError): pass - raise ValueError('%r does not appear to be an IPv4 or IPv6 address' % - address) + raise ValueError(f'{address!r} does not appear to be an IPv4 or IPv6 address') def ip_network(address, strict=True): @@ -80,8 +79,7 @@ def ip_network(address, strict=True): except (AddressValueError, NetmaskValueError): pass - raise ValueError('%r does not appear to be an IPv4 or IPv6 network' % - address) + raise ValueError(f'{address!r} does not appear to be an IPv4 or IPv6 network') def ip_interface(address): @@ -115,8 +113,7 @@ def ip_interface(address): except (AddressValueError, NetmaskValueError): pass - raise ValueError('%r does not appear to be an IPv4 or IPv6 interface' % - address) + raise ValueError(f'{address!r} does not appear to be an IPv4 or IPv6 interface') def v4_int_to_packed(address): @@ -159,7 +156,7 @@ def _split_optional_netmask(address): """Helper to split the netmask and raise AddressValueError if needed""" addr = str(address).split('/') if len(addr) > 2: - raise AddressValueError("Only one '/' permitted in %r" % address) + raise AddressValueError(f"Only one '/' permitted in {address!r}") return addr @@ -1303,7 +1300,7 @@ def __init__(self, address): # which converts into a formatted IP string. addr_str = str(address) if '/' in addr_str: - raise AddressValueError("Unexpected '/' in %r" % address) + raise AddressValueError(f"Unexpected '/' in {address!r}") self._ip = self._ip_int_from_string(addr_str) @property @@ -1912,7 +1909,7 @@ def __init__(self, address): # which converts into a formatted IP string. addr_str = str(address) if '/' in addr_str: - raise AddressValueError("Unexpected '/' in %r" % address) + raise AddressValueError(f"Unexpected '/' in {address!r}") addr_str, self._scope_id = self._split_scope_id(addr_str) self._ip = self._ip_int_from_string(addr_str) diff --git a/Lib/test/test_ipaddress.py b/Lib/test/test_ipaddress.py index cdd9880c3c17f..224412749340f 100644 --- a/Lib/test/test_ipaddress.py +++ b/Lib/test/test_ipaddress.py @@ -1133,6 +1133,14 @@ def testIPv4Tuple(self): self.assertEqual(ipaddress.IPv4Interface((3221225985, 24)), ipaddress.IPv4Interface('192.0.2.1/24')) + # Invalid netmask + with self.assertRaises(ValueError): + ipaddress.IPv4Network(('192.0.2.1', '255.255.255.255.0')) + + # Invalid netmask using factory + with self.assertRaises(ValueError): + ipaddress.ip_network(('192.0.2.1', '255.255.255.255.0')) + # issue #16531: constructing IPv6Network from an (address, mask) tuple def testIPv6Tuple(self): # /128 @@ -1192,6 +1200,14 @@ def testIPv6Tuple(self): ipaddress.IPv6Network((ip_scoped, 96)) # strict=False and host bits set + # Invalid netmask + with self.assertRaises(ValueError): + ipaddress.IPv6Network(('2001:db8::1', '255.255.255.0')) + + # Invalid netmask using factory + with self.assertRaises(ValueError): + ipaddress.ip_network(('2001:db8::1', '255.255.255.0')) + # issue57 def testAddressIntMath(self): self.assertEqual(ipaddress.IPv4Address('1.1.1.1') + 255, diff --git a/Misc/NEWS.d/next/Library/2022-01-17-16-53-30.bpo-46415.6wSYg-.rst b/Misc/NEWS.d/next/Library/2022-01-17-16-53-30.bpo-46415.6wSYg-.rst new file mode 100644 index 0000000000000..016d6656041f9 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2022-01-17-16-53-30.bpo-46415.6wSYg-.rst @@ -0,0 +1,2 @@ +Fix ipaddress.ip_{address,interface,network} raising TypeError instead of +ValueError if given invalid tuple as address parameter. From webhook-mailer at python.org Tue May 3 08:37:21 2022 From: webhook-mailer at python.org (miss-islington) Date: Tue, 03 May 2022 12:37:21 -0000 Subject: [Python-checkins] bpo-46415: Use f-string for ValueError in ipaddress.ip_{address, network, interface} helper functions (GH-30642) Message-ID: https://github.com/python/cpython/commit/5f709bdb86261fdba3ea8e5fd529f8af9fca4f42 commit: 5f709bdb86261fdba3ea8e5fd529f8af9fca4f42 branch: 3.10 author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com> committer: miss-islington <31488909+miss-islington at users.noreply.github.com> date: 2022-05-03T05:37:17-07:00 summary: bpo-46415: Use f-string for ValueError in ipaddress.ip_{address,network,interface} helper functions (GH-30642) `IPv*Network` and `IPv*Interface` constructors accept a 2-tuple of (address description, netmask) as the address parameter. When the tuple-based address is used errors are not propagated correctly through the `ipaddress.ip_*` helper because of the %-formatting now expecting several arguments: In [7]: ipaddress.ip_network(("192.168.100.0", "fooo")) ... TypeError: not all arguments converted during string formatting Compared to: In [8]: ipaddress.IPv4Network(("192.168.100.0", "foo")) ... NetmaskValueError: 'foo' is not a valid netmask Use an f-string to make sure the error is always properly formatted. Co-authored-by: Jelle Zijlstra (cherry picked from commit 52dc9c3066bcdc67a7a45d41cf158ecb1434d5f3) Co-authored-by: Thomas Cellerier files: A Misc/NEWS.d/next/Library/2022-01-17-16-53-30.bpo-46415.6wSYg-.rst M Lib/ipaddress.py M Lib/test/test_ipaddress.py diff --git a/Lib/ipaddress.py b/Lib/ipaddress.py index 4a6496a5da3ef..756f1bc38c97f 100644 --- a/Lib/ipaddress.py +++ b/Lib/ipaddress.py @@ -51,8 +51,7 @@ def ip_address(address): except (AddressValueError, NetmaskValueError): pass - raise ValueError('%r does not appear to be an IPv4 or IPv6 address' % - address) + raise ValueError(f'{address!r} does not appear to be an IPv4 or IPv6 address') def ip_network(address, strict=True): @@ -81,8 +80,7 @@ def ip_network(address, strict=True): except (AddressValueError, NetmaskValueError): pass - raise ValueError('%r does not appear to be an IPv4 or IPv6 network' % - address) + raise ValueError(f'{address!r} does not appear to be an IPv4 or IPv6 network') def ip_interface(address): @@ -116,8 +114,7 @@ def ip_interface(address): except (AddressValueError, NetmaskValueError): pass - raise ValueError('%r does not appear to be an IPv4 or IPv6 interface' % - address) + raise ValueError(f'{address!r} does not appear to be an IPv4 or IPv6 interface') def v4_int_to_packed(address): @@ -160,7 +157,7 @@ def _split_optional_netmask(address): """Helper to split the netmask and raise AddressValueError if needed""" addr = str(address).split('/') if len(addr) > 2: - raise AddressValueError("Only one '/' permitted in %r" % address) + raise AddressValueError(f"Only one '/' permitted in {address!r}") return addr @@ -1304,7 +1301,7 @@ def __init__(self, address): # which converts into a formatted IP string. addr_str = str(address) if '/' in addr_str: - raise AddressValueError("Unexpected '/' in %r" % address) + raise AddressValueError(f"Unexpected '/' in {address!r}") self._ip = self._ip_int_from_string(addr_str) @property @@ -1913,7 +1910,7 @@ def __init__(self, address): # which converts into a formatted IP string. addr_str = str(address) if '/' in addr_str: - raise AddressValueError("Unexpected '/' in %r" % address) + raise AddressValueError(f"Unexpected '/' in {address!r}") addr_str, self._scope_id = self._split_scope_id(addr_str) self._ip = self._ip_int_from_string(addr_str) diff --git a/Lib/test/test_ipaddress.py b/Lib/test/test_ipaddress.py index ff77bdb1bbc58..b2bb609ea8b4b 100644 --- a/Lib/test/test_ipaddress.py +++ b/Lib/test/test_ipaddress.py @@ -1133,6 +1133,14 @@ def testIPv4Tuple(self): self.assertEqual(ipaddress.IPv4Interface((3221225985, 24)), ipaddress.IPv4Interface('192.0.2.1/24')) + # Invalid netmask + with self.assertRaises(ValueError): + ipaddress.IPv4Network(('192.0.2.1', '255.255.255.255.0')) + + # Invalid netmask using factory + with self.assertRaises(ValueError): + ipaddress.ip_network(('192.0.2.1', '255.255.255.255.0')) + # issue #16531: constructing IPv6Network from an (address, mask) tuple def testIPv6Tuple(self): # /128 @@ -1192,6 +1200,14 @@ def testIPv6Tuple(self): ipaddress.IPv6Network((ip_scoped, 96)) # strict=False and host bits set + # Invalid netmask + with self.assertRaises(ValueError): + ipaddress.IPv6Network(('2001:db8::1', '255.255.255.0')) + + # Invalid netmask using factory + with self.assertRaises(ValueError): + ipaddress.ip_network(('2001:db8::1', '255.255.255.0')) + # issue57 def testAddressIntMath(self): self.assertEqual(ipaddress.IPv4Address('1.1.1.1') + 255, diff --git a/Misc/NEWS.d/next/Library/2022-01-17-16-53-30.bpo-46415.6wSYg-.rst b/Misc/NEWS.d/next/Library/2022-01-17-16-53-30.bpo-46415.6wSYg-.rst new file mode 100644 index 0000000000000..016d6656041f9 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2022-01-17-16-53-30.bpo-46415.6wSYg-.rst @@ -0,0 +1,2 @@ +Fix ipaddress.ip_{address,interface,network} raising TypeError instead of +ValueError if given invalid tuple as address parameter. From webhook-mailer at python.org Tue May 3 09:13:48 2022 From: webhook-mailer at python.org (Fidget-Spinner) Date: Tue, 03 May 2022 13:13:48 -0000 Subject: [Python-checkins] gh-92154: Expose PyCode_GetCode in the C API (GH-92168) Message-ID: https://github.com/python/cpython/commit/6c7249f2655749a06b4674a17537f844bd54d217 commit: 6c7249f2655749a06b4674a17537f844bd54d217 branch: main author: Ken Jin committer: Fidget-Spinner date: 2022-05-03T21:13:13+08:00 summary: gh-92154: Expose PyCode_GetCode in the C API (GH-92168) files: A Misc/NEWS.d/next/C API/2022-05-03-20-08-35.gh-issue-92154.IqMcAJ.rst M Doc/c-api/code.rst M Doc/whatsnew/3.11.rst M Include/cpython/code.h M Modules/_testcapimodule.c M Objects/codeobject.c diff --git a/Doc/c-api/code.rst b/Doc/c-api/code.rst index 407d8b481be4a..7915b81b46377 100644 --- a/Doc/c-api/code.rst +++ b/Doc/c-api/code.rst @@ -76,3 +76,17 @@ bound into a function. information is not available for any particular element. Returns ``1`` if the function succeeds and 0 otherwise. + +.. c:function:: PyObject* PyCode_GetCode(PyCodeObject *co) + + Equivalent to the Python code ``getattr(co, 'co_code')``. + Returns a strong reference to a :c:type:`PyBytesObject` representing the + bytecode in a code object. On error, ``NULL`` is returned and an exception + is raised. + + This ``PyBytesObject`` may be created on-demand by the interpreter and does + not necessarily represent the bytecode actually executed by CPython. The + primary use case for this function is debuggers and profilers. + + .. versionadded:: 3.11 + diff --git a/Doc/whatsnew/3.11.rst b/Doc/whatsnew/3.11.rst index 607f2e749bb5a..c19f158f57a31 100644 --- a/Doc/whatsnew/3.11.rst +++ b/Doc/whatsnew/3.11.rst @@ -1412,6 +1412,11 @@ C API Changes To get a custom code object: create a code object using the compiler, then get a modified version with the ``replace`` method. +* :c:type:`PyCodeObject` no longer has a ``co_code`` field. Instead, + use ``PyObject_GetAttrString(code_object, "co_code")`` or + :c:func:`PyCode_GetCode` to get the underlying bytes object. + (Contributed by Brandt Bucher in :issue:`46841` and Ken Jin in :gh:`92154`.) + New Features ------------ diff --git a/Include/cpython/code.h b/Include/cpython/code.h index be3b10bba724b..ba7324b48d867 100644 --- a/Include/cpython/code.h +++ b/Include/cpython/code.h @@ -202,6 +202,9 @@ PyAPI_FUNC(int) _PyCode_GetExtra(PyObject *code, Py_ssize_t index, PyAPI_FUNC(int) _PyCode_SetExtra(PyObject *code, Py_ssize_t index, void *extra); +/* Equivalent to getattr(code, 'co_code') in Python. + Returns a strong reference to a bytes object. */ +PyAPI_FUNC(PyObject *) PyCode_GetCode(PyCodeObject *code); typedef enum _PyCodeLocationInfoKind { /* short forms are 0 to 9 */ diff --git a/Misc/NEWS.d/next/C API/2022-05-03-20-08-35.gh-issue-92154.IqMcAJ.rst b/Misc/NEWS.d/next/C API/2022-05-03-20-08-35.gh-issue-92154.IqMcAJ.rst new file mode 100644 index 0000000000000..7713954fe72e9 --- /dev/null +++ b/Misc/NEWS.d/next/C API/2022-05-03-20-08-35.gh-issue-92154.IqMcAJ.rst @@ -0,0 +1,2 @@ +Added the :c:func:`PyCode_GetCode` function. This function does the +equivalent of the Python code ``getattr(code_object, 'co_code')``. diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index 9073f33e226bd..26d8d38f2f795 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -5931,6 +5931,29 @@ get_feature_macros(PyObject *self, PyObject *Py_UNUSED(args)) return result; } +static PyObject * +test_code_api(PyObject *self, PyObject *Py_UNUSED(args)) +{ + PyCodeObject *co = PyCode_NewEmpty("_testcapi", "dummy", 1); + if (co == NULL) { + return NULL; + } + PyObject *co_code = PyCode_GetCode(co); + if (co_code == NULL) { + Py_DECREF(co); + return NULL; + } + assert(PyBytes_CheckExact(co_code)); + if (PyObject_Length(co_code) == 0) { + PyErr_SetString(PyExc_ValueError, "empty co_code"); + Py_DECREF(co); + Py_DECREF(co_code); + return NULL; + } + Py_DECREF(co); + Py_DECREF(co_code); + Py_RETURN_NONE; +} static PyObject *negative_dictoffset(PyObject *, PyObject *); static PyObject *test_buildvalue_issue38913(PyObject *, PyObject *); @@ -6227,6 +6250,7 @@ static PyMethodDef TestMethods[] = { {"frame_getbuiltins", frame_getbuiltins, METH_O, NULL}, {"frame_getlasti", frame_getlasti, METH_O, NULL}, {"get_feature_macros", get_feature_macros, METH_NOARGS, NULL}, + {"test_code_api", test_code_api, METH_NOARGS, NULL}, {NULL, NULL} /* sentinel */ }; diff --git a/Objects/codeobject.c b/Objects/codeobject.c index e3e4ca159a632..9f922dabeac63 100644 --- a/Objects/codeobject.c +++ b/Objects/codeobject.c @@ -1370,6 +1370,11 @@ _PyCode_GetCode(PyCodeObject *co) return code; } +PyObject * +PyCode_GetCode(PyCodeObject *co) +{ + return _PyCode_GetCode(co); +} /****************** * PyCode_Type From webhook-mailer at python.org Tue May 3 09:21:50 2022 From: webhook-mailer at python.org (JelleZijlstra) Date: Tue, 03 May 2022 13:21:50 -0000 Subject: [Python-checkins] bpo-44863: Allow generic typing.TypedDict (#27663) Message-ID: https://github.com/python/cpython/commit/f6f36cc26978e3036a6c5c068fca5b8135f27ef3 commit: f6f36cc26978e3036a6c5c068fca5b8135f27ef3 branch: main author: Samodya Abey <379594+sransara at users.noreply.github.com> committer: JelleZijlstra date: 2022-05-03T07:21:42-06:00 summary: bpo-44863: Allow generic typing.TypedDict (#27663) Co-authored-by: Ken Jin <28750310+Fidget-Spinner at users.noreply.github.com> Co-authored-by: Yurii Karabas <1998uriyyo at gmail.com> Co-authored-by: Jelle Zijlstra Co-authored-by: Serhiy Storchaka files: A Misc/NEWS.d/next/Library/2021-09-03-07-56-48.bpo-44863.udgz95.rst M Doc/library/typing.rst M Doc/whatsnew/3.11.rst M Lib/test/_typed_dict_helper.py M Lib/test/test_typing.py M Lib/typing.py diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst index 05ac05767f32e..c9fc944fdeb56 100644 --- a/Doc/library/typing.rst +++ b/Doc/library/typing.rst @@ -1738,7 +1738,7 @@ These are not used in annotations. They are building blocks for declaring types. z: int A ``TypedDict`` cannot inherit from a non-TypedDict class, - notably including :class:`Generic`. For example:: + except for :class:`Generic`. For example:: class X(TypedDict): x: int @@ -1755,6 +1755,12 @@ These are not used in annotations. They are building blocks for declaring types. T = TypeVar('T') class XT(X, Generic[T]): pass # raises TypeError + A ``TypedDict`` can be generic:: + + class Group(TypedDict, Generic[T]): + key: T + group: list[T] + A ``TypedDict`` can be introspected via annotations dicts (see :ref:`annotations-howto` for more information on annotations best practices), :attr:`__total__`, :attr:`__required_keys__`, and :attr:`__optional_keys__`. @@ -1802,6 +1808,9 @@ These are not used in annotations. They are building blocks for declaring types. .. versionadded:: 3.8 + .. versionchanged:: 3.11 + Added support for generic ``TypedDict``\ s. + Generic concrete collections ---------------------------- diff --git a/Doc/whatsnew/3.11.rst b/Doc/whatsnew/3.11.rst index c19f158f57a31..2f32b56423de7 100644 --- a/Doc/whatsnew/3.11.rst +++ b/Doc/whatsnew/3.11.rst @@ -715,7 +715,10 @@ For major changes, see :ref:`new-feat-related-type-hints-311`. to clear all registered overloads of a function. (Contributed by Jelle Zijlstra in :gh:`89263`.) -* :class:`~typing.NamedTuple` subclasses can be generic. +* :data:`typing.TypedDict` subclasses can now be generic. (Contributed by + Samodya Abey in :gh:`89026`.) + +* :class:`~typing.NamedTuple` subclasses can now be generic. (Contributed by Serhiy Storchaka in :issue:`43923`.) diff --git a/Lib/test/_typed_dict_helper.py b/Lib/test/_typed_dict_helper.py index 3328330c995b3..9df0ede7d40ee 100644 --- a/Lib/test/_typed_dict_helper.py +++ b/Lib/test/_typed_dict_helper.py @@ -13,12 +13,18 @@ class Bar(_typed_dict_helper.Foo, total=False): from __future__ import annotations -from typing import Annotated, Optional, Required, TypedDict +from typing import Annotated, Generic, Optional, Required, TypedDict, TypeVar + OptionalIntType = Optional[int] class Foo(TypedDict): a: OptionalIntType +T = TypeVar("T") + +class FooGeneric(TypedDict, Generic[T]): + a: Optional[T] + class VeryAnnotated(TypedDict, total=False): a: Annotated[Annotated[Annotated[Required[int], "a"], "b"], "c"] diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index 08f7d0211eafb..55e18c08537df 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -4530,9 +4530,16 @@ class Point2D(TypedDict): x: int y: int +class Point2DGeneric(Generic[T], TypedDict): + a: T + b: T + class Bar(_typed_dict_helper.Foo, total=False): b: int +class BarGeneric(_typed_dict_helper.FooGeneric[T], total=False): + b: int + class LabelPoint2D(Point2D, Label): ... class Options(TypedDict, total=False): @@ -5890,6 +5897,17 @@ def test_pickle(self): EmpDnew = pickle.loads(ZZ) self.assertEqual(EmpDnew({'name': 'jane', 'id': 37}), jane) + def test_pickle_generic(self): + point = Point2DGeneric(a=5.0, b=3.0) + for proto in range(pickle.HIGHEST_PROTOCOL + 1): + z = pickle.dumps(point, proto) + point2 = pickle.loads(z) + self.assertEqual(point2, point) + self.assertEqual(point2, {'a': 5.0, 'b': 3.0}) + ZZ = pickle.dumps(Point2DGeneric, proto) + Point2DGenericNew = pickle.loads(ZZ) + self.assertEqual(Point2DGenericNew({'a': 5.0, 'b': 3.0}), point) + def test_optional(self): EmpD = TypedDict('EmpD', {'name': str, 'id': int}) @@ -6074,6 +6092,124 @@ def test_get_type_hints(self): {'a': typing.Optional[int], 'b': int} ) + def test_get_type_hints_generic(self): + self.assertEqual( + get_type_hints(BarGeneric), + {'a': typing.Optional[T], 'b': int} + ) + + class FooBarGeneric(BarGeneric[int]): + c: str + + self.assertEqual( + get_type_hints(FooBarGeneric), + {'a': typing.Optional[T], 'b': int, 'c': str} + ) + + def test_generic_inheritance(self): + class A(TypedDict, Generic[T]): + a: T + + self.assertEqual(A.__bases__, (Generic, dict)) + self.assertEqual(A.__orig_bases__, (TypedDict, Generic[T])) + self.assertEqual(A.__mro__, (A, Generic, dict, object)) + self.assertEqual(A.__parameters__, (T,)) + self.assertEqual(A[str].__parameters__, ()) + self.assertEqual(A[str].__args__, (str,)) + + class A2(Generic[T], TypedDict): + a: T + + self.assertEqual(A2.__bases__, (Generic, dict)) + self.assertEqual(A2.__orig_bases__, (Generic[T], TypedDict)) + self.assertEqual(A2.__mro__, (A2, Generic, dict, object)) + self.assertEqual(A2.__parameters__, (T,)) + self.assertEqual(A2[str].__parameters__, ()) + self.assertEqual(A2[str].__args__, (str,)) + + class B(A[KT], total=False): + b: KT + + self.assertEqual(B.__bases__, (Generic, dict)) + self.assertEqual(B.__orig_bases__, (A[KT],)) + self.assertEqual(B.__mro__, (B, Generic, dict, object)) + self.assertEqual(B.__parameters__, (KT,)) + self.assertEqual(B.__total__, False) + self.assertEqual(B.__optional_keys__, frozenset(['b'])) + self.assertEqual(B.__required_keys__, frozenset(['a'])) + + self.assertEqual(B[str].__parameters__, ()) + self.assertEqual(B[str].__args__, (str,)) + self.assertEqual(B[str].__origin__, B) + + class C(B[int]): + c: int + + self.assertEqual(C.__bases__, (Generic, dict)) + self.assertEqual(C.__orig_bases__, (B[int],)) + self.assertEqual(C.__mro__, (C, Generic, dict, object)) + self.assertEqual(C.__parameters__, ()) + self.assertEqual(C.__total__, True) + self.assertEqual(C.__optional_keys__, frozenset(['b'])) + self.assertEqual(C.__required_keys__, frozenset(['a', 'c'])) + assert C.__annotations__ == { + 'a': T, + 'b': KT, + 'c': int, + } + with self.assertRaises(TypeError): + C[str] + + + class Point3D(Point2DGeneric[T], Generic[T, KT]): + c: KT + + self.assertEqual(Point3D.__bases__, (Generic, dict)) + self.assertEqual(Point3D.__orig_bases__, (Point2DGeneric[T], Generic[T, KT])) + self.assertEqual(Point3D.__mro__, (Point3D, Generic, dict, object)) + self.assertEqual(Point3D.__parameters__, (T, KT)) + self.assertEqual(Point3D.__total__, True) + self.assertEqual(Point3D.__optional_keys__, frozenset()) + self.assertEqual(Point3D.__required_keys__, frozenset(['a', 'b', 'c'])) + assert Point3D.__annotations__ == { + 'a': T, + 'b': T, + 'c': KT, + } + self.assertEqual(Point3D[int, str].__origin__, Point3D) + + with self.assertRaises(TypeError): + Point3D[int] + + with self.assertRaises(TypeError): + class Point3D(Point2DGeneric[T], Generic[KT]): + c: KT + + def test_implicit_any_inheritance(self): + class A(TypedDict, Generic[T]): + a: T + + class B(A[KT], total=False): + b: KT + + class WithImplicitAny(B): + c: int + + self.assertEqual(WithImplicitAny.__bases__, (Generic, dict,)) + self.assertEqual(WithImplicitAny.__mro__, (WithImplicitAny, Generic, dict, object)) + # Consistent with GenericTests.test_implicit_any + self.assertEqual(WithImplicitAny.__parameters__, ()) + self.assertEqual(WithImplicitAny.__total__, True) + self.assertEqual(WithImplicitAny.__optional_keys__, frozenset(['b'])) + self.assertEqual(WithImplicitAny.__required_keys__, frozenset(['a', 'c'])) + assert WithImplicitAny.__annotations__ == { + 'a': T, + 'b': KT, + 'c': int, + } + with self.assertRaises(TypeError): + WithImplicitAny[str] + def test_non_generic_subscript(self): # For backward compatibility, subscription works # on arbitrary TypedDict types. diff --git a/Lib/typing.py b/Lib/typing.py index 84f0fd1a8a946..bdc14e39033dc 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -1796,7 +1796,9 @@ def __init_subclass__(cls, *args, **kwargs): if '__orig_bases__' in cls.__dict__: error = Generic in cls.__orig_bases__ else: - error = Generic in cls.__bases__ and cls.__name__ != 'Protocol' + error = (Generic in cls.__bases__ and + cls.__name__ != 'Protocol' and + type(cls) != _TypedDictMeta) if error: raise TypeError("Cannot inherit from plain Generic") if '__orig_bases__' in cls.__dict__: @@ -2868,14 +2870,19 @@ def __new__(cls, name, bases, ns, total=True): Subclasses and instances of TypedDict return actual dictionaries. """ for base in bases: - if type(base) is not _TypedDictMeta: + if type(base) is not _TypedDictMeta and base is not Generic: raise TypeError('cannot inherit from both a TypedDict type ' 'and a non-TypedDict base class') - tp_dict = type.__new__(_TypedDictMeta, name, (dict,), ns) + + if any(issubclass(b, Generic) for b in bases): + generic_base = (Generic,) + else: + generic_base = () + + tp_dict = type.__new__(_TypedDictMeta, name, (*generic_base, dict), ns) annotations = {} own_annotations = ns.get('__annotations__', {}) - own_annotation_keys = set(own_annotations.keys()) msg = "TypedDict('Name', {f0: t0, f1: t1, ...}); each t must be a type" own_annotations = { n: _type_check(tp, msg, module=tp_dict.__module__) diff --git a/Misc/NEWS.d/next/Library/2021-09-03-07-56-48.bpo-44863.udgz95.rst b/Misc/NEWS.d/next/Library/2021-09-03-07-56-48.bpo-44863.udgz95.rst new file mode 100644 index 0000000000000..130856587fd91 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2021-09-03-07-56-48.bpo-44863.udgz95.rst @@ -0,0 +1,4 @@ +Allow :class:`~typing.TypedDict` subclasses to also include +:class:`~typing.Generic` as a base class in class based syntax. Thereby allowing +the user to define a generic ``TypedDict``, just like a user-defined generic but +with ``TypedDict`` semantics. From webhook-mailer at python.org Tue May 3 10:37:40 2022 From: webhook-mailer at python.org (vstinner) Date: Tue, 03 May 2022 14:37:40 -0000 Subject: [Python-checkins] gh-92135: Rename _Py_reinterpret_cast() to _Py_CAST() (#92230) Message-ID: https://github.com/python/cpython/commit/fbd5539a54a1cf79dd9623a24d42d363bf084897 commit: fbd5539a54a1cf79dd9623a24d42d363bf084897 branch: main author: Victor Stinner committer: vstinner date: 2022-05-03T16:37:06+02:00 summary: gh-92135: Rename _Py_reinterpret_cast() to _Py_CAST() (#92230) Rename also _Py_static_cast() to _Py_STATIC_CAST(). files: M Include/cpython/abstract.h M Include/cpython/listobject.h M Include/cpython/methodobject.h M Include/cpython/tupleobject.h M Include/cpython/unicodeobject.h M Include/methodobject.h M Include/object.h M Include/objimpl.h M Include/pyport.h diff --git a/Include/cpython/abstract.h b/Include/cpython/abstract.h index 42f766da99116..77e2cfa02ed07 100644 --- a/Include/cpython/abstract.h +++ b/Include/cpython/abstract.h @@ -51,7 +51,7 @@ PyAPI_FUNC(PyObject *) _PyObject_MakeTpCall( PyObject *keywords); #define PY_VECTORCALL_ARGUMENTS_OFFSET \ - (_Py_static_cast(size_t, 1) << (8 * sizeof(size_t) - 1)) + (_Py_STATIC_CAST(size_t, 1) << (8 * sizeof(size_t) - 1)) static inline Py_ssize_t PyVectorcall_NARGS(size_t n) diff --git a/Include/cpython/listobject.h b/Include/cpython/listobject.h index 298bfcbf1438e..ebbea5ebf1ebc 100644 --- a/Include/cpython/listobject.h +++ b/Include/cpython/listobject.h @@ -26,7 +26,7 @@ PyAPI_FUNC(void) _PyList_DebugMallocStats(FILE *out); /* Cast argument to PyListObject* type. */ #define _PyList_CAST(op) \ - (assert(PyList_Check(op)), _Py_reinterpret_cast(PyListObject*, (op))) + (assert(PyList_Check(op)), _Py_CAST(PyListObject*, (op))) // Macros and static inline functions, trading safety for speed diff --git a/Include/cpython/methodobject.h b/Include/cpython/methodobject.h index 68cecfe05ba1e..bbb67ec762036 100644 --- a/Include/cpython/methodobject.h +++ b/Include/cpython/methodobject.h @@ -9,10 +9,10 @@ PyAPI_DATA(PyTypeObject) PyCMethod_Type; #define _PyCFunctionObject_CAST(func) \ (assert(PyCFunction_Check(func)), \ - _Py_reinterpret_cast(PyCFunctionObject*, (func))) + _Py_CAST(PyCFunctionObject*, (func))) #define _PyCMethodObject_CAST(func) \ (assert(PyCMethod_Check(func)), \ - _Py_reinterpret_cast(PyCMethodObject*, (func))) + _Py_CAST(PyCMethodObject*, (func))) /* Macros for direct access to these values. Type checks are *not* done, so use with care. */ diff --git a/Include/cpython/tupleobject.h b/Include/cpython/tupleobject.h index 8089e2409ce60..d5b810e5f4277 100644 --- a/Include/cpython/tupleobject.h +++ b/Include/cpython/tupleobject.h @@ -15,7 +15,7 @@ PyAPI_FUNC(void) _PyTuple_MaybeUntrack(PyObject *); /* Cast argument to PyTupleObject* type. */ #define _PyTuple_CAST(op) \ - (assert(PyTuple_Check(op)), _Py_reinterpret_cast(PyTupleObject*, (op))) + (assert(PyTuple_Check(op)), _Py_CAST(PyTupleObject*, (op))) // Macros and static inline functions, trading safety for speed diff --git a/Include/cpython/unicodeobject.h b/Include/cpython/unicodeobject.h index 0397f12a8260b..47194ac7829fd 100644 --- a/Include/cpython/unicodeobject.h +++ b/Include/cpython/unicodeobject.h @@ -237,13 +237,13 @@ PyAPI_FUNC(int) _PyUnicode_CheckConsistency( #define _PyASCIIObject_CAST(op) \ (assert(PyUnicode_Check(op)), \ - _Py_reinterpret_cast(PyASCIIObject*, (op))) + _Py_CAST(PyASCIIObject*, (op))) #define _PyCompactUnicodeObject_CAST(op) \ (assert(PyUnicode_Check(op)), \ - _Py_reinterpret_cast(PyCompactUnicodeObject*, (op))) + _Py_CAST(PyCompactUnicodeObject*, (op))) #define _PyUnicodeObject_CAST(op) \ (assert(PyUnicode_Check(op)), \ - _Py_reinterpret_cast(PyUnicodeObject*, (op))) + _Py_CAST(PyUnicodeObject*, (op))) /* --- Flexible String Representation Helper Macros (PEP 393) -------------- */ diff --git a/Include/methodobject.h b/Include/methodobject.h index f4be3858f2f8a..c971d78a640a6 100644 --- a/Include/methodobject.h +++ b/Include/methodobject.h @@ -43,7 +43,7 @@ typedef PyObject *(*PyCMethod)(PyObject *, PyTypeObject *, PyObject *const *, // it triggers an undefined behavior when Python calls it with 2 parameters // (bpo-33012). #define _PyCFunction_CAST(func) \ - _Py_reinterpret_cast(PyCFunction, _Py_reinterpret_cast(void(*)(void), (func))) + _Py_CAST(PyCFunction, _Py_CAST(void(*)(void), (func))) PyAPI_FUNC(PyCFunction) PyCFunction_GetFunction(PyObject *); PyAPI_FUNC(PyObject *) PyCFunction_GetSelf(PyObject *); diff --git a/Include/object.h b/Include/object.h index c51f12b65624d..f93ecce13b409 100644 --- a/Include/object.h +++ b/Include/object.h @@ -104,7 +104,7 @@ struct _object { }; /* Cast argument to PyObject* type. */ -#define _PyObject_CAST(op) _Py_reinterpret_cast(PyObject*, (op)) +#define _PyObject_CAST(op) _Py_CAST(PyObject*, (op)) typedef struct { PyObject ob_base; @@ -112,7 +112,7 @@ typedef struct { } PyVarObject; /* Cast argument to PyVarObject* type. */ -#define _PyVarObject_CAST(op) _Py_reinterpret_cast(PyVarObject*, (op)) +#define _PyVarObject_CAST(op) _Py_CAST(PyVarObject*, (op)) // Test if the 'x' object is the 'y' object, the same as "x is y" in Python. @@ -781,7 +781,7 @@ static inline int PyType_Check(PyObject *op) { #endif #define _PyType_CAST(op) \ - (assert(PyType_Check(op)), _Py_reinterpret_cast(PyTypeObject*, (op))) + (assert(PyType_Check(op)), _Py_CAST(PyTypeObject*, (op))) static inline int PyType_CheckExact(PyObject *op) { return Py_IS_TYPE(op, &PyType_Type); diff --git a/Include/objimpl.h b/Include/objimpl.h index c8e57c9755749..4fa670e71ab46 100644 --- a/Include/objimpl.h +++ b/Include/objimpl.h @@ -182,9 +182,9 @@ PyAPI_FUNC(void) PyObject_GC_UnTrack(void *); PyAPI_FUNC(void) PyObject_GC_Del(void *); #define PyObject_GC_New(type, typeobj) \ - _Py_reinterpret_cast(type*, _PyObject_GC_New(typeobj)) + _Py_CAST(type*, _PyObject_GC_New(typeobj)) #define PyObject_GC_NewVar(type, typeobj, n) \ - _Py_reinterpret_cast(type*, _PyObject_GC_NewVar((typeobj), (n))) + _Py_CAST(type*, _PyObject_GC_NewVar((typeobj), (n))) PyAPI_FUNC(int) PyObject_GC_IsTracked(PyObject *); PyAPI_FUNC(int) PyObject_GC_IsFinalized(PyObject *); diff --git a/Include/pyport.h b/Include/pyport.h index 3f5ce672bdafe..f6270be0ce5c0 100644 --- a/Include/pyport.h +++ b/Include/pyport.h @@ -17,20 +17,20 @@ // Macro to use C++ static_cast<>, reinterpret_cast<> and const_cast<> // in the Python C API. // -// In C++, _Py_reinterpret_cast(type, expr) converts a constant expression to a +// In C++, _Py_CAST(type, expr) converts a constant expression to a // non constant type using const_cast. For example, -// _Py_reinterpret_cast(PyObject*, op) can convert a "const PyObject*" to +// _Py_CAST(PyObject*, op) can convert a "const PyObject*" to // "PyObject*". // // The type argument must not be constant. For example, in C++, -// _Py_reinterpret_cast(const PyObject*, expr) fails with a compiler error. +// _Py_CAST(const PyObject*, expr) fails with a compiler error. #ifdef __cplusplus -# define _Py_static_cast(type, expr) static_cast(expr) -# define _Py_reinterpret_cast(type, expr) \ +# define _Py_STATIC_CAST(type, expr) static_cast(expr) +# define _Py_CAST(type, expr) \ const_cast(reinterpret_cast(expr)) #else -# define _Py_static_cast(type, expr) ((type)(expr)) -# define _Py_reinterpret_cast(type, expr) ((type)(expr)) +# define _Py_STATIC_CAST(type, expr) ((type)(expr)) +# define _Py_CAST(type, expr) ((type)(expr)) #endif @@ -317,10 +317,10 @@ extern "C" { */ #ifdef Py_DEBUG # define Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW) \ - (assert(_Py_static_cast(WIDE, _Py_static_cast(NARROW, (VALUE))) == (VALUE)), \ - _Py_static_cast(NARROW, (VALUE))) + (assert(_Py_STATIC_CAST(WIDE, _Py_STATIC_CAST(NARROW, (VALUE))) == (VALUE)), \ + _Py_STATIC_CAST(NARROW, (VALUE))) #else -# define Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW) _Py_static_cast(NARROW, (VALUE)) +# define Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW) _Py_STATIC_CAST(NARROW, (VALUE)) #endif From webhook-mailer at python.org Tue May 3 10:40:45 2022 From: webhook-mailer at python.org (Fidget-Spinner) Date: Tue, 03 May 2022 14:40:45 -0000 Subject: [Python-checkins] Link to GitHub instead of BPO for CPython bug tracker (GH-92221) Message-ID: https://github.com/python/cpython/commit/9dc4aae8e92cef0590b1130bd5d1c07c1b932b73 commit: 9dc4aae8e92cef0590b1130bd5d1c07c1b932b73 branch: main author: slateny <46876382+slateny at users.noreply.github.com> committer: Fidget-Spinner date: 2022-05-03T22:40:36+08:00 summary: Link to GitHub instead of BPO for CPython bug tracker (GH-92221) files: M Doc/README.rst M Doc/faq/general.rst diff --git a/Doc/README.rst b/Doc/README.rst index c0ac7c4d3d762..4326086e9e352 100644 --- a/Doc/README.rst +++ b/Doc/README.rst @@ -130,7 +130,7 @@ Contributing ============ Bugs in the content should be reported to the -`Python bug tracker `_. +`Python bug tracker `_. Bugs in the toolset should be reported to the tools themselves. diff --git a/Doc/faq/general.rst b/Doc/faq/general.rst index 99534c2ebf6e1..bc4130aaa45c8 100644 --- a/Doc/faq/general.rst +++ b/Doc/faq/general.rst @@ -230,14 +230,8 @@ You can also access the development version of Python through Git. See How do I submit bug reports and patches for Python? --------------------------------------------------- -To report a bug or submit a patch, please use the Roundup installation at -https://bugs.python.org/. - -You must have a Roundup account to report bugs; this makes it possible for us to -contact you if we have follow-up questions. It will also enable Roundup to send -you updates as we act on your bug. If you had previously used SourceForge to -report bugs to Python, you can obtain your Roundup password through Roundup's -`password reset procedure `_. +To report a bug or submit a patch, use the issue tracker at +https://github.com/python/cpython/issues. For more information on how Python is developed, consult `the Python Developer's Guide `_. From webhook-mailer at python.org Tue May 3 10:41:50 2022 From: webhook-mailer at python.org (corona10) Date: Tue, 03 May 2022 14:41:50 -0000 Subject: [Python-checkins] GH-91355: micro-optimize Connection.send_bytes() method (gh-32247) Message-ID: https://github.com/python/cpython/commit/1699128c4891da3bbe23553d709261d88855b93f commit: 1699128c4891da3bbe23553d709261d88855b93f branch: main author: Ma Lin committer: corona10 date: 2022-05-03T23:41:45+09:00 summary: GH-91355: micro-optimize Connection.send_bytes() method (gh-32247) files: M Lib/multiprocessing/connection.py diff --git a/Lib/multiprocessing/connection.py b/Lib/multiprocessing/connection.py index 1cca66d5661e3..65303d29f51f8 100644 --- a/Lib/multiprocessing/connection.py +++ b/Lib/multiprocessing/connection.py @@ -188,10 +188,9 @@ def send_bytes(self, buf, offset=0, size=None): self._check_closed() self._check_writable() m = memoryview(buf) - # HACK for byte-indexing of non-bytewise buffers (e.g. array.array) if m.itemsize > 1: - m = memoryview(bytes(m)) - n = len(m) + m = m.cast('B') + n = m.nbytes if offset < 0: raise ValueError("offset is negative") if n < offset: From webhook-mailer at python.org Tue May 3 10:54:00 2022 From: webhook-mailer at python.org (JelleZijlstra) Date: Tue, 03 May 2022 14:54:00 -0000 Subject: [Python-checkins] gh-90887: posix module: Add more flags for fcopy_file (#31300) Message-ID: https://github.com/python/cpython/commit/04dc4b06a3afc79a658cacca87ee1d93a34653bd commit: 04dc4b06a3afc79a658cacca87ee1d93a34653bd branch: main author: David CARLIER committer: JelleZijlstra date: 2022-05-03T08:53:51-06:00 summary: gh-90887: posix module: Add more flags for fcopy_file (#31300) Closes #90887 Co-authored-by: Jelle Zijlstra files: A Misc/NEWS.d/next/Library/2022-05-02-18-19-46.gh-issue-90887.zQsmfp.rst M Modules/posixmodule.c diff --git a/Misc/NEWS.d/next/Library/2022-05-02-18-19-46.gh-issue-90887.zQsmfp.rst b/Misc/NEWS.d/next/Library/2022-05-02-18-19-46.gh-issue-90887.zQsmfp.rst new file mode 100644 index 0000000000000..089f395105646 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2022-05-02-18-19-46.gh-issue-90887.zQsmfp.rst @@ -0,0 +1 @@ +Adding ``COPYFILE_STAT``, ``COPYFILE_ACL`` and ``COPYFILE_XATTR`` constants for :func:`os.fcopyfile` available in macOs. diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index a7f57804687cd..c55275c6c5511 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -15458,6 +15458,9 @@ all_ins(PyObject *m) #if defined(__APPLE__) if (PyModule_AddIntConstant(m, "_COPYFILE_DATA", COPYFILE_DATA)) return -1; + if (PyModule_AddIntConstant(m, "_COPYFILE_STAT", COPYFILE_STAT)) return -1; + if (PyModule_AddIntConstant(m, "_COPYFILE_ACL", COPYFILE_ACL)) return -1; + if (PyModule_AddIntConstant(m, "_COPYFILE_XATTR", COPYFILE_XATTR)) return -1; #endif #ifdef MS_WINDOWS From webhook-mailer at python.org Tue May 3 10:59:21 2022 From: webhook-mailer at python.org (markshannon) Date: Tue, 03 May 2022 14:59:21 -0000 Subject: [Python-checkins] gh-92031: Deoptimize Static Code at Finalization (GH-92039) Message-ID: https://github.com/python/cpython/commit/b156578bd63a94fe3d80a4c6a8dbc067feba5d06 commit: b156578bd63a94fe3d80a4c6a8dbc067feba5d06 branch: main author: Dennis Sweeney <36520290+sweeneyde at users.noreply.github.com> committer: markshannon date: 2022-05-03T08:59:12-06:00 summary: gh-92031: Deoptimize Static Code at Finalization (GH-92039) files: A Misc/NEWS.d/next/Core and Builtins/2022-04-29-02-50-41.gh-issue-92031.2PpaIN.rst M Include/internal/pycore_opcode.h M Lib/test/test_embed.py M Objects/codeobject.c M Tools/scripts/generate_opcode_h.py diff --git a/Include/internal/pycore_opcode.h b/Include/internal/pycore_opcode.h index eadcba1add0ae..09f6501467133 100644 --- a/Include/internal/pycore_opcode.h +++ b/Include/internal/pycore_opcode.h @@ -16,6 +16,8 @@ extern const uint8_t _PyOpcode_Caches[256]; extern const uint8_t _PyOpcode_Deopt[256]; +extern const uint8_t _PyOpcode_Original[256]; + #ifdef NEED_OPCODE_TABLES static const uint32_t _PyOpcode_RelativeJump[8] = { 0U, @@ -235,6 +237,190 @@ const uint8_t _PyOpcode_Deopt[256] = { [WITH_EXCEPT_START] = WITH_EXCEPT_START, [YIELD_VALUE] = YIELD_VALUE, }; + +const uint8_t _PyOpcode_Original[256] = { + [ASYNC_GEN_WRAP] = ASYNC_GEN_WRAP, + [BEFORE_ASYNC_WITH] = BEFORE_ASYNC_WITH, + [BEFORE_WITH] = BEFORE_WITH, + [BINARY_OP] = BINARY_OP, + [BINARY_OP_ADAPTIVE] = BINARY_OP, + [BINARY_OP_ADD_FLOAT] = BINARY_OP, + [BINARY_OP_ADD_INT] = BINARY_OP, + [BINARY_OP_ADD_UNICODE] = BINARY_OP, + [BINARY_OP_INPLACE_ADD_UNICODE] = BINARY_OP, + [BINARY_OP_MULTIPLY_FLOAT] = BINARY_OP, + [BINARY_OP_MULTIPLY_INT] = BINARY_OP, + [BINARY_OP_SUBTRACT_FLOAT] = BINARY_OP, + [BINARY_OP_SUBTRACT_INT] = BINARY_OP, + [BINARY_SUBSCR] = BINARY_SUBSCR, + [BINARY_SUBSCR_ADAPTIVE] = BINARY_SUBSCR, + [BINARY_SUBSCR_DICT] = BINARY_SUBSCR, + [BINARY_SUBSCR_GETITEM] = BINARY_SUBSCR, + [BINARY_SUBSCR_LIST_INT] = BINARY_SUBSCR, + [BINARY_SUBSCR_TUPLE_INT] = BINARY_SUBSCR, + [BUILD_CONST_KEY_MAP] = BUILD_CONST_KEY_MAP, + [BUILD_LIST] = BUILD_LIST, + [BUILD_MAP] = BUILD_MAP, + [BUILD_SET] = BUILD_SET, + [BUILD_SLICE] = BUILD_SLICE, + [BUILD_STRING] = BUILD_STRING, + [BUILD_TUPLE] = BUILD_TUPLE, + [CACHE] = CACHE, + [CALL] = CALL, + [CALL_ADAPTIVE] = CALL, + [CALL_FUNCTION_EX] = CALL_FUNCTION_EX, + [CALL_PY_EXACT_ARGS] = CALL, + [CALL_PY_WITH_DEFAULTS] = CALL, + [CHECK_EG_MATCH] = CHECK_EG_MATCH, + [CHECK_EXC_MATCH] = CHECK_EXC_MATCH, + [COMPARE_OP] = COMPARE_OP, + [COMPARE_OP_ADAPTIVE] = COMPARE_OP, + [COMPARE_OP_FLOAT_JUMP] = COMPARE_OP, + [COMPARE_OP_INT_JUMP] = COMPARE_OP, + [COMPARE_OP_STR_JUMP] = COMPARE_OP, + [CONTAINS_OP] = CONTAINS_OP, + [COPY] = COPY, + [COPY_FREE_VARS] = COPY_FREE_VARS, + [DELETE_ATTR] = DELETE_ATTR, + [DELETE_DEREF] = DELETE_DEREF, + [DELETE_FAST] = DELETE_FAST, + [DELETE_GLOBAL] = DELETE_GLOBAL, + [DELETE_NAME] = DELETE_NAME, + [DELETE_SUBSCR] = DELETE_SUBSCR, + [DICT_MERGE] = DICT_MERGE, + [DICT_UPDATE] = DICT_UPDATE, + [END_ASYNC_FOR] = END_ASYNC_FOR, + [EXTENDED_ARG] = EXTENDED_ARG_QUICK, + [EXTENDED_ARG_QUICK] = EXTENDED_ARG_QUICK, + [FORMAT_VALUE] = FORMAT_VALUE, + [FOR_ITER] = FOR_ITER, + [GET_AITER] = GET_AITER, + [GET_ANEXT] = GET_ANEXT, + [GET_AWAITABLE] = GET_AWAITABLE, + [GET_ITER] = GET_ITER, + [GET_LEN] = GET_LEN, + [GET_YIELD_FROM_ITER] = GET_YIELD_FROM_ITER, + [IMPORT_FROM] = IMPORT_FROM, + [IMPORT_NAME] = IMPORT_NAME, + [IMPORT_STAR] = IMPORT_STAR, + [IS_OP] = IS_OP, + [JUMP_BACKWARD] = JUMP_BACKWARD, + [JUMP_BACKWARD_NO_INTERRUPT] = JUMP_BACKWARD_NO_INTERRUPT, + [JUMP_BACKWARD_QUICK] = JUMP_BACKWARD, + [JUMP_FORWARD] = JUMP_FORWARD, + [JUMP_IF_FALSE_OR_POP] = JUMP_IF_FALSE_OR_POP, + [JUMP_IF_TRUE_OR_POP] = JUMP_IF_TRUE_OR_POP, + [KW_NAMES] = KW_NAMES, + [LIST_APPEND] = LIST_APPEND, + [LIST_EXTEND] = LIST_EXTEND, + [LIST_TO_TUPLE] = LIST_TO_TUPLE, + [LOAD_ASSERTION_ERROR] = LOAD_ASSERTION_ERROR, + [LOAD_ATTR] = LOAD_ATTR, + [LOAD_ATTR_ADAPTIVE] = LOAD_ATTR, + [LOAD_ATTR_INSTANCE_VALUE] = LOAD_ATTR, + [LOAD_ATTR_MODULE] = LOAD_ATTR, + [LOAD_ATTR_SLOT] = LOAD_ATTR, + [LOAD_ATTR_WITH_HINT] = LOAD_ATTR, + [LOAD_BUILD_CLASS] = LOAD_BUILD_CLASS, + [LOAD_CLASSDEREF] = LOAD_CLASSDEREF, + [LOAD_CLOSURE] = LOAD_CLOSURE, + [LOAD_CONST] = LOAD_CONST, + [LOAD_CONST__LOAD_FAST] = LOAD_CONST, + [LOAD_DEREF] = LOAD_DEREF, + [LOAD_FAST] = LOAD_FAST, + [LOAD_FAST__LOAD_CONST] = LOAD_FAST, + [LOAD_FAST__LOAD_FAST] = LOAD_FAST, + [LOAD_GLOBAL] = LOAD_GLOBAL, + [LOAD_GLOBAL_ADAPTIVE] = LOAD_GLOBAL, + [LOAD_GLOBAL_BUILTIN] = LOAD_GLOBAL, + [LOAD_GLOBAL_MODULE] = LOAD_GLOBAL, + [LOAD_METHOD] = LOAD_METHOD, + [LOAD_METHOD_ADAPTIVE] = LOAD_METHOD, + [LOAD_METHOD_CLASS] = LOAD_METHOD, + [LOAD_METHOD_MODULE] = LOAD_METHOD, + [LOAD_METHOD_NO_DICT] = LOAD_METHOD, + [LOAD_METHOD_WITH_DICT] = LOAD_METHOD, + [LOAD_METHOD_WITH_VALUES] = LOAD_METHOD, + [LOAD_NAME] = LOAD_NAME, + [MAKE_CELL] = MAKE_CELL, + [MAKE_FUNCTION] = MAKE_FUNCTION, + [MAP_ADD] = MAP_ADD, + [MATCH_CLASS] = MATCH_CLASS, + [MATCH_KEYS] = MATCH_KEYS, + [MATCH_MAPPING] = MATCH_MAPPING, + [MATCH_SEQUENCE] = MATCH_SEQUENCE, + [NOP] = NOP, + [POP_EXCEPT] = POP_EXCEPT, + [POP_JUMP_BACKWARD_IF_FALSE] = POP_JUMP_BACKWARD_IF_FALSE, + [POP_JUMP_BACKWARD_IF_NONE] = POP_JUMP_BACKWARD_IF_NONE, + [POP_JUMP_BACKWARD_IF_NOT_NONE] = POP_JUMP_BACKWARD_IF_NOT_NONE, + [POP_JUMP_BACKWARD_IF_TRUE] = POP_JUMP_BACKWARD_IF_TRUE, + [POP_JUMP_FORWARD_IF_FALSE] = POP_JUMP_FORWARD_IF_FALSE, + [POP_JUMP_FORWARD_IF_NONE] = POP_JUMP_FORWARD_IF_NONE, + [POP_JUMP_FORWARD_IF_NOT_NONE] = POP_JUMP_FORWARD_IF_NOT_NONE, + [POP_JUMP_FORWARD_IF_TRUE] = POP_JUMP_FORWARD_IF_TRUE, + [POP_TOP] = POP_TOP, + [PRECALL] = PRECALL, + [PRECALL_ADAPTIVE] = PRECALL, + [PRECALL_BOUND_METHOD] = PRECALL, + [PRECALL_BUILTIN_CLASS] = PRECALL, + [PRECALL_BUILTIN_FAST_WITH_KEYWORDS] = PRECALL, + [PRECALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS] = PRECALL, + [PRECALL_NO_KW_BUILTIN_FAST] = PRECALL, + [PRECALL_NO_KW_BUILTIN_O] = PRECALL, + [PRECALL_NO_KW_ISINSTANCE] = PRECALL, + [PRECALL_NO_KW_LEN] = PRECALL, + [PRECALL_NO_KW_LIST_APPEND] = PRECALL, + [PRECALL_NO_KW_METHOD_DESCRIPTOR_FAST] = PRECALL, + [PRECALL_NO_KW_METHOD_DESCRIPTOR_NOARGS] = PRECALL, + [PRECALL_NO_KW_METHOD_DESCRIPTOR_O] = PRECALL, + [PRECALL_NO_KW_STR_1] = PRECALL, + [PRECALL_NO_KW_TUPLE_1] = PRECALL, + [PRECALL_NO_KW_TYPE_1] = PRECALL, + [PRECALL_PYFUNC] = PRECALL, + [PREP_RERAISE_STAR] = PREP_RERAISE_STAR, + [PRINT_EXPR] = PRINT_EXPR, + [PUSH_EXC_INFO] = PUSH_EXC_INFO, + [PUSH_NULL] = PUSH_NULL, + [RAISE_VARARGS] = RAISE_VARARGS, + [RERAISE] = RERAISE, + [RESUME] = RESUME, + [RESUME_QUICK] = RESUME, + [RETURN_GENERATOR] = RETURN_GENERATOR, + [RETURN_VALUE] = RETURN_VALUE, + [SEND] = SEND, + [SETUP_ANNOTATIONS] = SETUP_ANNOTATIONS, + [SET_ADD] = SET_ADD, + [SET_UPDATE] = SET_UPDATE, + [STORE_ATTR] = STORE_ATTR, + [STORE_ATTR_ADAPTIVE] = STORE_ATTR, + [STORE_ATTR_INSTANCE_VALUE] = STORE_ATTR, + [STORE_ATTR_SLOT] = STORE_ATTR, + [STORE_ATTR_WITH_HINT] = STORE_ATTR, + [STORE_DEREF] = STORE_DEREF, + [STORE_FAST] = STORE_FAST, + [STORE_FAST__LOAD_FAST] = STORE_FAST, + [STORE_FAST__STORE_FAST] = STORE_FAST, + [STORE_GLOBAL] = STORE_GLOBAL, + [STORE_NAME] = STORE_NAME, + [STORE_SUBSCR] = STORE_SUBSCR, + [STORE_SUBSCR_ADAPTIVE] = STORE_SUBSCR, + [STORE_SUBSCR_DICT] = STORE_SUBSCR, + [STORE_SUBSCR_LIST_INT] = STORE_SUBSCR, + [SWAP] = SWAP, + [UNARY_INVERT] = UNARY_INVERT, + [UNARY_NEGATIVE] = UNARY_NEGATIVE, + [UNARY_NOT] = UNARY_NOT, + [UNARY_POSITIVE] = UNARY_POSITIVE, + [UNPACK_EX] = UNPACK_EX, + [UNPACK_SEQUENCE] = UNPACK_SEQUENCE, + [UNPACK_SEQUENCE_ADAPTIVE] = UNPACK_SEQUENCE, + [UNPACK_SEQUENCE_LIST] = UNPACK_SEQUENCE, + [UNPACK_SEQUENCE_TUPLE] = UNPACK_SEQUENCE, + [UNPACK_SEQUENCE_TWO_TUPLE] = UNPACK_SEQUENCE, + [WITH_EXCEPT_START] = WITH_EXCEPT_START, + [YIELD_VALUE] = YIELD_VALUE, +}; #endif // NEED_OPCODE_TABLES #ifdef Py_DEBUG diff --git a/Lib/test/test_embed.py b/Lib/test/test_embed.py index 16d1c7dea6b4f..9bb4bd7e8feb7 100644 --- a/Lib/test/test_embed.py +++ b/Lib/test/test_embed.py @@ -343,6 +343,20 @@ def test_finalize_structseq(self): out, err = self.run_embedded_interpreter("test_repeated_init_exec", code) self.assertEqual(out, 'Tests passed\n' * INIT_LOOPS) + @support.skip_if_pgo_task + def test_quickened_static_code_gets_unquickened_at_Py_FINALIZE(self): + # https://github.com/python/cpython/issues/92031 + code = """if 1: + from importlib._bootstrap import _handle_fromlist + import dis + for name in dis.opmap: + # quicken this frozen code object. + _handle_fromlist(dis, [name], lambda *args: None) + """ + run = self.run_embedded_interpreter + for i in range(50): + out, err = run("test_repeated_init_exec", code, timeout=60) + def test_ucnhash_capi_reset(self): # bpo-47182: unicodeobject.c:ucnhash_capi was not reset on shutdown. code = "print('\\N{digit nine}')" diff --git a/Misc/NEWS.d/next/Core and Builtins/2022-04-29-02-50-41.gh-issue-92031.2PpaIN.rst b/Misc/NEWS.d/next/Core and Builtins/2022-04-29-02-50-41.gh-issue-92031.2PpaIN.rst new file mode 100644 index 0000000000000..6bdefb8afb116 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2022-04-29-02-50-41.gh-issue-92031.2PpaIN.rst @@ -0,0 +1 @@ +Deoptimize statically-allocated code objects during ``Py_FINALIZE()`` so that future ``_PyCode_Quicken`` calls always start with unquickened code. diff --git a/Objects/codeobject.c b/Objects/codeobject.c index 9f922dabeac63..c2b29be1fe869 100644 --- a/Objects/codeobject.c +++ b/Objects/codeobject.c @@ -1350,23 +1350,29 @@ _PyCode_GetFreevars(PyCodeObject *co) return get_localsplus_names(co, CO_FAST_FREE, co->co_nfreevars); } -PyObject * -_PyCode_GetCode(PyCodeObject *co) +static void +deopt_code(_Py_CODEUNIT *instructions, Py_ssize_t len) { - PyObject *code = PyBytes_FromStringAndSize(NULL, _PyCode_NBYTES(co)); - if (code == NULL) { - return NULL; - } - _Py_CODEUNIT *instructions = (_Py_CODEUNIT *)PyBytes_AS_STRING(code); - for (int i = 0; i < Py_SIZE(co); i++) { - _Py_CODEUNIT instruction = _PyCode_CODE(co)[i]; - int opcode = _PyOpcode_Deopt[_Py_OPCODE(instruction)]; + for (int i = 0; i < len; i++) { + _Py_CODEUNIT instruction = instructions[i]; + int opcode = _PyOpcode_Original[_Py_OPCODE(instruction)]; int caches = _PyOpcode_Caches[opcode]; instructions[i] = _Py_MAKECODEUNIT(opcode, _Py_OPARG(instruction)); while (caches--) { instructions[++i] = _Py_MAKECODEUNIT(CACHE, 0); } } +} + +PyObject * +_PyCode_GetCode(PyCodeObject *co) +{ + PyObject *code = PyBytes_FromStringAndSize((const char *)_PyCode_CODE(co), + _PyCode_NBYTES(co)); + if (code == NULL) { + return NULL; + } + deopt_code((_Py_CODEUNIT *)PyBytes_AS_STRING(code), Py_SIZE(co)); return code; } @@ -2076,6 +2082,7 @@ _PyStaticCode_Dealloc(PyCodeObject *co) if (co->co_warmup == 0) { _Py_QuickenedCount--; } + deopt_code(_PyCode_CODE(co), Py_SIZE(co)); co->co_warmup = QUICKENING_INITIAL_WARMUP_VALUE; PyMem_Free(co->co_extra); co->co_extra = NULL; diff --git a/Tools/scripts/generate_opcode_h.py b/Tools/scripts/generate_opcode_h.py index 6a04297879f2c..e1f4f01ae1de0 100644 --- a/Tools/scripts/generate_opcode_h.py +++ b/Tools/scripts/generate_opcode_h.py @@ -117,6 +117,7 @@ def main(opcode_py, outfile='Include/opcode.h', internaloutfile='Include/interna iobj.write("\nextern const uint8_t _PyOpcode_Caches[256];\n") iobj.write("\nextern const uint8_t _PyOpcode_Deopt[256];\n") + iobj.write("\nextern const uint8_t _PyOpcode_Original[256];\n") iobj.write("\n#ifdef NEED_OPCODE_TABLES\n") write_int_array_from_ops("_PyOpcode_RelativeJump", opcode['hasjrel'], iobj) write_int_array_from_ops("_PyOpcode_Jump", opcode['hasjrel'] + opcode['hasjabs'], iobj) @@ -137,6 +138,12 @@ def main(opcode_py, outfile='Include/opcode.h', internaloutfile='Include/interna for opt, deopt in sorted(deoptcodes.items()): iobj.write(f" [{opt}] = {deopt},\n") iobj.write("};\n") + iobj.write("\nconst uint8_t _PyOpcode_Original[256] = {\n") + for opt, deopt in sorted(deoptcodes.items()): + if opt.startswith("EXTENDED_ARG"): + deopt = "EXTENDED_ARG_QUICK" + iobj.write(f" [{opt}] = {deopt},\n") + iobj.write("};\n") iobj.write("#endif // NEED_OPCODE_TABLES\n") fobj.write("\n") From webhook-mailer at python.org Tue May 3 11:56:41 2022 From: webhook-mailer at python.org (JelleZijlstra) Date: Tue, 03 May 2022 15:56:41 -0000 Subject: [Python-checkins] bpo-46604: fix function name in ssl module docstring (#31064) Message-ID: https://github.com/python/cpython/commit/feca9bbd1f6489f2b6d2783bfc22fdb96e45b69f commit: feca9bbd1f6489f2b6d2783bfc22fdb96e45b69f branch: main author: Kossi GLOKPOR <83467320+glk0 at users.noreply.github.com> committer: JelleZijlstra date: 2022-05-03T09:56:24-06:00 summary: bpo-46604: fix function name in ssl module docstring (#31064) The function fetch_server_certificate is replaced by get_server_certificate in the module. I reflected the change in the module docstrings. Co-authored-by: Jelle Zijlstra files: M Lib/ssl.py diff --git a/Lib/ssl.py b/Lib/ssl.py index dafb70a67864c..ebac1d60d52de 100644 --- a/Lib/ssl.py +++ b/Lib/ssl.py @@ -18,9 +18,10 @@ seconds past the Epoch (the time values returned from time.time()) - fetch_server_certificate (HOST, PORT) -- fetch the certificate provided - by the server running on HOST at port PORT. No - validation of the certificate is performed. + get_server_certificate (addr, ssl_version, ca_certs, timeout) -- Retrieve the + certificate from the server at the specified + address and return it as a PEM-encoded string + Integer constants: From webhook-mailer at python.org Tue May 3 12:24:43 2022 From: webhook-mailer at python.org (miss-islington) Date: Tue, 03 May 2022 16:24:43 -0000 Subject: [Python-checkins] bpo-46604: fix function name in ssl module docstring (GH-31064) Message-ID: https://github.com/python/cpython/commit/58f2d2d10aed5edbde85403c17ad2a54eb37db54 commit: 58f2d2d10aed5edbde85403c17ad2a54eb37db54 branch: 3.10 author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com> committer: miss-islington <31488909+miss-islington at users.noreply.github.com> date: 2022-05-03T09:24:39-07:00 summary: bpo-46604: fix function name in ssl module docstring (GH-31064) The function fetch_server_certificate is replaced by get_server_certificate in the module. I reflected the change in the module docstrings. Co-authored-by: Jelle Zijlstra (cherry picked from commit feca9bbd1f6489f2b6d2783bfc22fdb96e45b69f) Co-authored-by: Kossi GLOKPOR <83467320+glk0 at users.noreply.github.com> files: M Lib/ssl.py diff --git a/Lib/ssl.py b/Lib/ssl.py index 181065d2e53ba..b09d684ed0fc6 100644 --- a/Lib/ssl.py +++ b/Lib/ssl.py @@ -18,9 +18,10 @@ seconds past the Epoch (the time values returned from time.time()) - fetch_server_certificate (HOST, PORT) -- fetch the certificate provided - by the server running on HOST at port PORT. No - validation of the certificate is performed. + get_server_certificate (addr, ssl_version, ca_certs, timeout) -- Retrieve the + certificate from the server at the specified + address and return it as a PEM-encoded string + Integer constants: From webhook-mailer at python.org Tue May 3 12:27:48 2022 From: webhook-mailer at python.org (ambv) Date: Tue, 03 May 2022 16:27:48 -0000 Subject: [Python-checkins] gh-89452: Prefer gdbm-compat over ndbm (#92208) Message-ID: https://github.com/python/cpython/commit/6c25bf07e86b6d8d5e50488835f70539f382d7e0 commit: 6c25bf07e86b6d8d5e50488835f70539f382d7e0 branch: main author: ?ukasz Langa committer: ambv date: 2022-05-03T18:27:38+02:00 summary: gh-89452: Prefer gdbm-compat over ndbm (#92208) This makes macOS gdbm provided by Homebrew not segfault through correct selection of the linked library (-lgdbm_compat) *AND* the correct ndbm-style header (gdbm-ndbm.h instead of the invalid ndbm.h). files: A Misc/NEWS.d/next/Build/2022-05-03-03-36-47.gh-issue-89452.NIY0fF.rst M Modules/_dbmmodule.c M configure M configure.ac M setup.py diff --git a/Misc/NEWS.d/next/Build/2022-05-03-03-36-47.gh-issue-89452.NIY0fF.rst b/Misc/NEWS.d/next/Build/2022-05-03-03-36-47.gh-issue-89452.NIY0fF.rst new file mode 100644 index 0000000000000..dd4954d1d6ac2 --- /dev/null +++ b/Misc/NEWS.d/next/Build/2022-05-03-03-36-47.gh-issue-89452.NIY0fF.rst @@ -0,0 +1,2 @@ +gdbm-compat is now preferred over ndbm if both are available on the system. +This allows avoiding the problematic ndbm.h on macOS. diff --git a/Modules/_dbmmodule.c b/Modules/_dbmmodule.c index de8b2304ed8f1..5913b034790e9 100644 --- a/Modules/_dbmmodule.c +++ b/Modules/_dbmmodule.c @@ -12,10 +12,7 @@ /* Some Linux systems install gdbm/ndbm.h, but not ndbm.h. This supports * whichever configure was able to locate. */ -#if defined(USE_NDBM) - #include - static const char which_dbm[] = "GNU gdbm"; /* EMX port of GDBM */ -#elif defined(USE_GDBM_COMPAT) +#if defined(USE_GDBM_COMPAT) #ifdef HAVE_GDBM_NDBM_H #include #elif HAVE_GDBM_DASH_NDBM_H @@ -24,6 +21,9 @@ #error "No gdbm/ndbm.h or gdbm-ndbm.h available" #endif static const char which_dbm[] = "GNU gdbm"; +#elif defined(USE_NDBM) + #include + static const char which_dbm[] = "GNU gdbm"; #elif defined(USE_BERKDB) #ifndef DB_DBM_HSEARCH #define DB_DBM_HSEARCH 1 diff --git a/configure b/configure index 2c47a1e85c145..0f5c2c80f6067 100755 --- a/configure +++ b/configure @@ -13726,7 +13726,7 @@ $as_echo_n "checking for --with-dbmliborder... " >&6; } if test "${with_dbmliborder+set}" = set; then : withval=$with_dbmliborder; else - with_dbmliborder=ndbm:gdbm:bdb + with_dbmliborder=gdbm:ndbm:bdb fi @@ -13749,7 +13749,7 @@ done IFS=$as_save_IFS if test "x$with_dbmliborder" = xerror; then : - as_fn_error $? "proper usage is --with-dbmliborder=db1:db2:... (ndbm:gdbm:bdb)" "$LINENO" 5 + as_fn_error $? "proper usage is --with-dbmliborder=db1:db2:... (gdbm:ndbm:bdb)" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_dbmliborder" >&5 diff --git a/configure.ac b/configure.ac index 62da321a98af1..8c0711d8a9a15 100644 --- a/configure.ac +++ b/configure.ac @@ -3850,7 +3850,7 @@ AC_CHECK_HEADERS([db.h], [ AC_MSG_CHECKING(for --with-dbmliborder) AC_ARG_WITH(dbmliborder, AS_HELP_STRING([--with-dbmliborder=db1:db2:...], [override order to check db backends for dbm; a valid value is a colon separated string with the backend names `ndbm', `gdbm' and `bdb'.]), -[], [with_dbmliborder=ndbm:gdbm:bdb]) +[], [with_dbmliborder=gdbm:ndbm:bdb]) have_gdbm_dbmliborder=no as_save_IFS=$IFS @@ -3865,7 +3865,7 @@ for db in $with_dbmliborder; do done IFS=$as_save_IFS AS_VAR_IF([with_dbmliborder], [error], [ - AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:... (ndbm:gdbm:bdb)]) + AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:... (gdbm:ndbm:bdb)]) ]) AC_MSG_RESULT($with_dbmliborder) diff --git a/setup.py b/setup.py index 60a45cf260f6b..f45cd6de33749 100644 --- a/setup.py +++ b/setup.py @@ -1207,7 +1207,7 @@ def detect_dbm_gdbm(self): if dbm_args: dbm_order = [arg.split('=')[-1] for arg in dbm_args][-1].split(":") else: - dbm_order = "ndbm:gdbm:bdb".split(":") + dbm_order = "gdbm:ndbm:bdb".split(":") dbmext = None for cand in dbm_order: if cand == "ndbm": From webhook-mailer at python.org Tue May 3 12:33:55 2022 From: webhook-mailer at python.org (miss-islington) Date: Tue, 03 May 2022 16:33:55 -0000 Subject: [Python-checkins] bpo-46604: fix function name in ssl module docstring (GH-31064) Message-ID: https://github.com/python/cpython/commit/a23e4722fd51c5829dc747cea2d6cc2cbd17d1a1 commit: a23e4722fd51c5829dc747cea2d6cc2cbd17d1a1 branch: 3.9 author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com> committer: miss-islington <31488909+miss-islington at users.noreply.github.com> date: 2022-05-03T09:33:35-07:00 summary: bpo-46604: fix function name in ssl module docstring (GH-31064) The function fetch_server_certificate is replaced by get_server_certificate in the module. I reflected the change in the module docstrings. Co-authored-by: Jelle Zijlstra (cherry picked from commit feca9bbd1f6489f2b6d2783bfc22fdb96e45b69f) Co-authored-by: Kossi GLOKPOR <83467320+glk0 at users.noreply.github.com> files: M Lib/ssl.py diff --git a/Lib/ssl.py b/Lib/ssl.py index 30f4e5934febf..0e3606b835c6a 100644 --- a/Lib/ssl.py +++ b/Lib/ssl.py @@ -18,9 +18,10 @@ seconds past the Epoch (the time values returned from time.time()) - fetch_server_certificate (HOST, PORT) -- fetch the certificate provided - by the server running on HOST at port PORT. No - validation of the certificate is performed. + get_server_certificate (addr, ssl_version, ca_certs, timeout) -- Retrieve the + certificate from the server at the specified + address and return it as a PEM-encoded string + Integer constants: From webhook-mailer at python.org Tue May 3 12:38:51 2022 From: webhook-mailer at python.org (ambv) Date: Tue, 03 May 2022 16:38:51 -0000 Subject: [Python-checkins] gh-88753: Make BooleanOptionalAction's addition of default to help more similar to other actions (#27808) Message-ID: https://github.com/python/cpython/commit/20490d5018cff4c604b37142323c531f8512b9aa commit: 20490d5018cff4c604b37142323c531f8512b9aa branch: main author: Toshio Kuratomi committer: ambv date: 2022-05-03T18:38:18+02:00 summary: gh-88753: Make BooleanOptionalAction's addition of default to help more similar to other actions (#27808) Help for other actions omit the default value if default is SUPPRESS or already contains the special format string '%(default)'. Add those special cases to BooleanOptionalAction's help formatting too. Fixes https://bugs.python.org/issue44587 so that default=SUPPRESS is not emitted. Fixes https://bugs.python.org/issue38956 as this code will detect whether '%(default)s' has already been specified in the help string. Signed-off-by: Micky Yun Chan (michiboo): Co-authored-by: Micky Yun Chan files: A Misc/NEWS.d/next/Library/2021-08-17-21-41-39.bpo-44587.57OKSz.rst M Lib/argparse.py M Lib/test/test_argparse.py diff --git a/Lib/argparse.py b/Lib/argparse.py index c47aeffc2c3f6..8d1a00ad2207e 100644 --- a/Lib/argparse.py +++ b/Lib/argparse.py @@ -153,6 +153,7 @@ def _copy_items(items): # Formatting Help # =============== + class HelpFormatter(object): """Formatter for generating usage messages and argument help strings. @@ -695,8 +696,19 @@ class ArgumentDefaultsHelpFormatter(HelpFormatter): """ def _get_help_string(self, action): + """ + Add the default value to the option help message. + + ArgumentDefaultsHelpFormatter and BooleanOptionalAction when it isn't + already present. This code will do that, detecting cornercases to + prevent duplicates or cases where it wouldn't make sense to the end + user. + """ help = action.help - if '%(default)' not in action.help: + if help is None: + help = '' + + if '%(default)' not in help: if action.default is not SUPPRESS: defaulting_nargs = [OPTIONAL, ZERO_OR_MORE] if action.option_strings or action.nargs in defaulting_nargs: @@ -704,6 +716,7 @@ def _get_help_string(self, action): return help + class MetavarTypeHelpFormatter(HelpFormatter): """Help message formatter which uses the argument 'type' as the default metavar value (instead of the argument 'dest') @@ -719,7 +732,6 @@ def _get_default_metavar_for_positional(self, action): return action.type.__name__ - # ===================== # Options and Arguments # ===================== @@ -882,9 +894,6 @@ def __init__(self, option_string = '--no-' + option_string[2:] _option_strings.append(option_string) - if help is not None and default is not None and default is not SUPPRESS: - help += " (default: %(default)s)" - super().__init__( option_strings=_option_strings, dest=dest, @@ -896,6 +905,7 @@ def __init__(self, help=help, metavar=metavar) + def __call__(self, parser, namespace, values, option_string=None): if option_string in self.option_strings: setattr(namespace, self.dest, not option_string.startswith('--no-')) diff --git a/Lib/test/test_argparse.py b/Lib/test/test_argparse.py index 794b9df3796df..8509deb93f1e2 100644 --- a/Lib/test/test_argparse.py +++ b/Lib/test/test_argparse.py @@ -3348,6 +3348,7 @@ def _get_parser(self, tester): def _test(self, tester, parser_text): expected_text = getattr(tester, self.func_suffix) expected_text = textwrap.dedent(expected_text) + tester.maxDiff = None tester.assertEqual(expected_text, parser_text) def test_format(self, tester): @@ -3743,7 +3744,7 @@ class TestHelpUsage(HelpTestCase): -w W [W ...] w -x [X ...] x --foo, --no-foo Whether to foo - --bar, --no-bar Whether to bar (default: True) + --bar, --no-bar Whether to bar -f, --foobar, --no-foobar, --barfoo, --no-barfoo --bazz, --no-bazz Bazz! @@ -4423,6 +4424,8 @@ class TestHelpArgumentDefaults(HelpTestCase): Sig('--bar', action='store_true', help='bar help'), Sig('--taz', action=argparse.BooleanOptionalAction, help='Whether to taz it', default=True), + Sig('--corge', action=argparse.BooleanOptionalAction, + help='Whether to corge it', default=argparse.SUPPRESS), Sig('--quux', help="Set the quux", default=42), Sig('spam', help='spam help'), Sig('badger', nargs='?', default='wooden', help='badger help'), @@ -4432,8 +4435,8 @@ class TestHelpArgumentDefaults(HelpTestCase): [Sig('--baz', type=int, default=42, help='baz help')]), ] usage = '''\ - usage: PROG [-h] [--foo FOO] [--bar] [--taz | --no-taz] [--quux QUUX] - [--baz BAZ] + usage: PROG [-h] [--foo FOO] [--bar] [--taz | --no-taz] [--corge | --no-corge] + [--quux QUUX] [--baz BAZ] spam [badger] ''' help = usage + '''\ @@ -4441,20 +4444,21 @@ class TestHelpArgumentDefaults(HelpTestCase): description positional arguments: - spam spam help - badger badger help (default: wooden) + spam spam help + badger badger help (default: wooden) options: - -h, --help show this help message and exit - --foo FOO foo help - oh and by the way, None - --bar bar help (default: False) - --taz, --no-taz Whether to taz it (default: True) - --quux QUUX Set the quux (default: 42) + -h, --help show this help message and exit + --foo FOO foo help - oh and by the way, None + --bar bar help (default: False) + --taz, --no-taz Whether to taz it (default: True) + --corge, --no-corge Whether to corge it + --quux QUUX Set the quux (default: 42) title: description - --baz BAZ baz help (default: 42) + --baz BAZ baz help (default: 42) ''' version = '' diff --git a/Misc/NEWS.d/next/Library/2021-08-17-21-41-39.bpo-44587.57OKSz.rst b/Misc/NEWS.d/next/Library/2021-08-17-21-41-39.bpo-44587.57OKSz.rst new file mode 100644 index 0000000000000..ce9b3a04bc62f --- /dev/null +++ b/Misc/NEWS.d/next/Library/2021-08-17-21-41-39.bpo-44587.57OKSz.rst @@ -0,0 +1,2 @@ +Fix BooleanOptionalAction to not automatically add a default string. If a +default string is desired, use a formatter to add it. From webhook-mailer at python.org Tue May 3 13:20:02 2022 From: webhook-mailer at python.org (gvanrossum) Date: Tue, 03 May 2022 17:20:02 -0000 Subject: [Python-checkins] GH-91752: Skip test_freeze_simple_script when zlib is not available (#91758) Message-ID: https://github.com/python/cpython/commit/77e7a04cd235f1bcd6fc69bcb15e2683c365d637 commit: 77e7a04cd235f1bcd6fc69bcb15e2683c365d637 branch: main author: Abhigyan Bose committer: gvanrossum date: 2022-05-03T10:19:54-07:00 summary: GH-91752: Skip test_freeze_simple_script when zlib is not available (#91758) Fixes GH-91752. files: A Misc/NEWS.d/next/Tests/2022-04-22-19-00-00.gh-issue-91752.Ji27dd.rst M Lib/test/test_tools/test_freeze.py diff --git a/Lib/test/test_tools/test_freeze.py b/Lib/test/test_tools/test_freeze.py index cca3c47f5ac05..2ba36ca208f96 100644 --- a/Lib/test/test_tools/test_freeze.py +++ b/Lib/test/test_tools/test_freeze.py @@ -12,7 +12,7 @@ with imports_under_tool('freeze', 'test'): import freeze as helper - + at support.requires_zlib() @unittest.skipIf(sys.platform.startswith('win'), 'not supported on Windows') @support.skip_if_buildbot('not all buildbots have enough space') class TestFreeze(unittest.TestCase): diff --git a/Misc/NEWS.d/next/Tests/2022-04-22-19-00-00.gh-issue-91752.Ji27dd.rst b/Misc/NEWS.d/next/Tests/2022-04-22-19-00-00.gh-issue-91752.Ji27dd.rst new file mode 100644 index 0000000000000..c02c1f491cc3e --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2022-04-22-19-00-00.gh-issue-91752.Ji27dd.rst @@ -0,0 +1 @@ +Added @requires_zlib to test.test_tools.test_freeze.TestFreeze. From webhook-mailer at python.org Tue May 3 13:21:29 2022 From: webhook-mailer at python.org (JelleZijlstra) Date: Tue, 03 May 2022 17:21:29 -0000 Subject: [Python-checkins] bpo-29890: Test IPv*Interface construction with tuple argument (#30862) Message-ID: https://github.com/python/cpython/commit/b295a92c50b128e494f47c28f12b8e9eac2927ea commit: b295a92c50b128e494f47c28f12b8e9eac2927ea branch: main author: Humbled Drugman committer: JelleZijlstra date: 2022-05-03T11:21:24-06:00 summary: bpo-29890: Test IPv*Interface construction with tuple argument (#30862) Co-authored-by: Jelle Zijlstra files: A Misc/NEWS.d/next/Tests/2022-01-24-21-31-09.bpo-29890.zEG-ra.rst M Lib/test/test_ipaddress.py diff --git a/Lib/test/test_ipaddress.py b/Lib/test/test_ipaddress.py index e5162e86cb5dc..c9ae7dab387ce 100644 --- a/Lib/test/test_ipaddress.py +++ b/Lib/test/test_ipaddress.py @@ -579,6 +579,10 @@ def assertBadAddress(addr, details): assertBadAddress("1.2.3.256", re.escape("256 (> 255)")) def test_valid_netmask(self): + self.assertEqual(str(self.factory(('192.0.2.0', 24))), '192.0.2.0/24') + self.assertEqual(str(self.factory(('192.0.2.0', '24'))), '192.0.2.0/24') + self.assertEqual(str(self.factory(('192.0.2.0', '255.255.255.0'))), + '192.0.2.0/24') self.assertEqual(str(self.factory('192.0.2.0/255.255.255.0')), '192.0.2.0/24') for i in range(0, 33): @@ -739,6 +743,10 @@ def assertBadAddress(addr, details): def test_valid_netmask(self): # We only support CIDR for IPv6, because expanded netmasks are not # standard notation. + self.assertEqual(str(self.factory(('2001:db8::', 32))), + '2001:db8::/32') + self.assertEqual(str(self.factory(('2001:db8::', '32'))), + '2001:db8::/32') self.assertEqual(str(self.factory('2001:db8::/32')), '2001:db8::/32') for i in range(0, 129): # Generate and re-parse the CIDR format (trivial). diff --git a/Misc/NEWS.d/next/Tests/2022-01-24-21-31-09.bpo-29890.zEG-ra.rst b/Misc/NEWS.d/next/Tests/2022-01-24-21-31-09.bpo-29890.zEG-ra.rst new file mode 100644 index 0000000000000..38a06a2f9b6be --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2022-01-24-21-31-09.bpo-29890.zEG-ra.rst @@ -0,0 +1,2 @@ +Add tests for :class:`ipaddress.IPv4Interface` and :class:`ipaddress.IPv6Interface` construction with tuple arguments. +Original patch and tests by louisom. From webhook-mailer at python.org Tue May 3 13:33:26 2022 From: webhook-mailer at python.org (JelleZijlstra) Date: Tue, 03 May 2022 17:33:26 -0000 Subject: [Python-checkins] bpo-46696: Add socket.SO_INCOMING_CPU constant (#31237) Message-ID: https://github.com/python/cpython/commit/d5dfcd4489e25c1b6e985fb6b8a700c8a49c68df commit: d5dfcd4489e25c1b6e985fb6b8a700c8a49c68df branch: main author: David CARLIER committer: JelleZijlstra date: 2022-05-03T11:33:11-06:00 summary: bpo-46696: Add socket.SO_INCOMING_CPU constant (#31237) Co-authored-by: Jelle Zijlstra files: A Misc/NEWS.d/next/Library/2022-02-09-21-40-02.bpo-46696.nPXRno.rst M Doc/library/socket.rst M Modules/socketmodule.c diff --git a/Doc/library/socket.rst b/Doc/library/socket.rst index 3b1912cff88a4..ee1aee5278b3b 100755 --- a/Doc/library/socket.rst +++ b/Doc/library/socket.rst @@ -575,6 +575,15 @@ Constants .. availability:: FreeBSD. +.. data:: SO_INCOMING_CPU + + Constant to optimize CPU locality, to be used in conjunction with + :data:`SO_REUSEPORT`. + + .. versionadded:: 3.11 + + .. availability:: Linux >= 3.9 + Functions ^^^^^^^^^ diff --git a/Misc/NEWS.d/next/Library/2022-02-09-21-40-02.bpo-46696.nPXRno.rst b/Misc/NEWS.d/next/Library/2022-02-09-21-40-02.bpo-46696.nPXRno.rst new file mode 100644 index 0000000000000..04c41887afd6e --- /dev/null +++ b/Misc/NEWS.d/next/Library/2022-02-09-21-40-02.bpo-46696.nPXRno.rst @@ -0,0 +1 @@ +Add ``SO_INCOMING_CPU`` constant to :mod:`socket`. diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index 9ecabaf973074..c650b25c09509 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -7505,6 +7505,9 @@ PyInit__socket(void) #ifdef SO_EXCLUSIVEADDRUSE PyModule_AddIntMacro(m, SO_EXCLUSIVEADDRUSE); #endif +#ifdef SO_INCOMING_CPU + PyModule_AddIntMacro(m, SO_INCOMING_CPU); +#endif #ifdef SO_KEEPALIVE PyModule_AddIntMacro(m, SO_KEEPALIVE); From webhook-mailer at python.org Tue May 3 13:48:37 2022 From: webhook-mailer at python.org (JelleZijlstra) Date: Tue, 03 May 2022 17:48:37 -0000 Subject: [Python-checkins] gh-92206: Improve scoping of sqlite3 reset statement helper (#92241) Message-ID: https://github.com/python/cpython/commit/415944379f9dae46e391315c9ccb17e45f9917da commit: 415944379f9dae46e391315c9ccb17e45f9917da branch: main author: Erlend Egeberg Aasland committer: JelleZijlstra date: 2022-05-03T11:48:24-06:00 summary: gh-92206: Improve scoping of sqlite3 reset statement helper (#92241) files: M Modules/_sqlite/cursor.c M Modules/_sqlite/statement.c M Modules/_sqlite/statement.h diff --git a/Modules/_sqlite/cursor.c b/Modules/_sqlite/cursor.c index 84f481792ddd3..0e903ade5bdfb 100644 --- a/Modules/_sqlite/cursor.c +++ b/Modules/_sqlite/cursor.c @@ -101,6 +101,24 @@ pysqlite_cursor_init_impl(pysqlite_Cursor *self, return 0; } +static inline int +stmt_reset(pysqlite_Statement *self) +{ + int rc = SQLITE_OK; + + if (self->in_use && self->st) { + Py_BEGIN_ALLOW_THREADS + rc = sqlite3_reset(self->st); + Py_END_ALLOW_THREADS + + if (rc == SQLITE_OK) { + self->in_use = 0; + } + } + + return rc; +} + static int cursor_traverse(pysqlite_Cursor *self, visitproc visit, void *arg) { @@ -124,7 +142,7 @@ cursor_clear(pysqlite_Cursor *self) Py_CLEAR(self->row_factory); if (self->statement) { /* Reset the statement if the user has not closed the cursor */ - pysqlite_statement_reset(self->statement); + stmt_reset(self->statement); Py_CLEAR(self->statement); } @@ -544,7 +562,7 @@ _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* operation if (self->statement != NULL) { /* There is an active statement */ - pysqlite_statement_reset(self->statement); + stmt_reset(self->statement); } /* reset description and rowcount */ @@ -553,7 +571,7 @@ _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* operation self->rowcount = 0L; if (self->statement) { - (void)pysqlite_statement_reset(self->statement); + (void)stmt_reset(self->statement); } PyObject *stmt = get_statement_from_cache(self, operation); @@ -577,7 +595,7 @@ _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* operation } } - pysqlite_statement_reset(self->statement); + stmt_reset(self->statement); pysqlite_statement_mark_dirty(self->statement); /* We start a transaction implicitly before a DML statement. @@ -614,7 +632,7 @@ _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* operation PyErr_Clear(); } } - (void)pysqlite_statement_reset(self->statement); + (void)stmt_reset(self->statement); _pysqlite_seterror(state, self->connection->db); goto error; } @@ -663,12 +681,12 @@ _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* operation } if (rc == SQLITE_DONE && !multiple) { - pysqlite_statement_reset(self->statement); + stmt_reset(self->statement); Py_CLEAR(self->statement); } if (multiple) { - pysqlite_statement_reset(self->statement); + stmt_reset(self->statement); } Py_XDECREF(parameters); } @@ -824,7 +842,7 @@ pysqlite_cursor_iternext(pysqlite_Cursor *self) sqlite3_stmt *stmt = self->statement->st; assert(stmt != NULL); if (sqlite3_data_count(stmt) == 0) { - (void)pysqlite_statement_reset(self->statement); + (void)stmt_reset(self->statement); Py_CLEAR(self->statement); return NULL; } @@ -835,7 +853,7 @@ pysqlite_cursor_iternext(pysqlite_Cursor *self) } int rc = stmt_step(stmt); if (rc == SQLITE_DONE) { - (void)pysqlite_statement_reset(self->statement); + (void)stmt_reset(self->statement); } else if (rc != SQLITE_ROW) { (void)_pysqlite_seterror(self->connection->state, @@ -1005,7 +1023,7 @@ pysqlite_cursor_close_impl(pysqlite_Cursor *self) } if (self->statement) { - (void)pysqlite_statement_reset(self->statement); + (void)stmt_reset(self->statement); Py_CLEAR(self->statement); } diff --git a/Modules/_sqlite/statement.c b/Modules/_sqlite/statement.c index baa1b71a8daa4..2f2f4b2d85089 100644 --- a/Modules/_sqlite/statement.c +++ b/Modules/_sqlite/statement.c @@ -366,25 +366,6 @@ pysqlite_statement_bind_parameters(pysqlite_state *state, } } -int pysqlite_statement_reset(pysqlite_Statement* self) -{ - int rc; - - rc = SQLITE_OK; - - if (self->in_use && self->st) { - Py_BEGIN_ALLOW_THREADS - rc = sqlite3_reset(self->st); - Py_END_ALLOW_THREADS - - if (rc == SQLITE_OK) { - self->in_use = 0; - } - } - - return rc; -} - void pysqlite_statement_mark_dirty(pysqlite_Statement* self) { self->in_use = 1; diff --git a/Modules/_sqlite/statement.h b/Modules/_sqlite/statement.h index b901c43c479ae..5b55e2fbcb8f9 100644 --- a/Modules/_sqlite/statement.h +++ b/Modules/_sqlite/statement.h @@ -44,7 +44,6 @@ void pysqlite_statement_bind_parameters(pysqlite_state *state, pysqlite_Statement *self, PyObject *parameters); -int pysqlite_statement_reset(pysqlite_Statement* self); void pysqlite_statement_mark_dirty(pysqlite_Statement* self); int pysqlite_statement_setup_types(PyObject *module); From webhook-mailer at python.org Tue May 3 14:15:07 2022 From: webhook-mailer at python.org (vstinner) Date: Tue, 03 May 2022 18:15:07 -0000 Subject: [Python-checkins] gh-89653: PEP 670: Convert PyBytes macros to functions (#91990) Message-ID: https://github.com/python/cpython/commit/2eca5dad0a783153318e91e3e25f16a38a632bfd commit: 2eca5dad0a783153318e91e3e25f16a38a632bfd branch: main author: Victor Stinner committer: vstinner date: 2022-05-03T20:14:58+02:00 summary: gh-89653: PEP 670: Convert PyBytes macros to functions (#91990) Convert the following macros to static inline functions: * PyByteArray_AS_STRING() * PyByteArray_GET_SIZE() * PyBytes_AS_STRING() * PyBytes_GET_SIZE() Limited C API version 3.11 no longer casts arguments. Add _PyBytes_CAST() and _PyByteArray_CAST() macros. files: M Doc/c-api/bytearray.rst M Doc/c-api/bytes.rst M Include/cpython/bytearrayobject.h M Include/cpython/bytesobject.h diff --git a/Doc/c-api/bytearray.rst b/Doc/c-api/bytearray.rst index 85a7d1373c2a8..4bf3cfe100cd0 100644 --- a/Doc/c-api/bytearray.rst +++ b/Doc/c-api/bytearray.rst @@ -77,9 +77,9 @@ These macros trade safety for speed and they don't check pointers. .. c:function:: char* PyByteArray_AS_STRING(PyObject *bytearray) - Macro version of :c:func:`PyByteArray_AsString`. + Similar to :c:func:`PyByteArray_AsString`, but without error checking. .. c:function:: Py_ssize_t PyByteArray_GET_SIZE(PyObject *bytearray) - Macro version of :c:func:`PyByteArray_Size`. + Similar to :c:func:`PyByteArray_Size`, but without error checking. diff --git a/Doc/c-api/bytes.rst b/Doc/c-api/bytes.rst index 32c7b80dc7ac6..d47f0422e6100 100644 --- a/Doc/c-api/bytes.rst +++ b/Doc/c-api/bytes.rst @@ -134,7 +134,7 @@ called with a non-bytes parameter. .. c:function:: Py_ssize_t PyBytes_GET_SIZE(PyObject *o) - Macro form of :c:func:`PyBytes_Size` but without error checking. + Similar to :c:func:`PyBytes_Size`, but without error checking. .. c:function:: char* PyBytes_AsString(PyObject *o) @@ -151,7 +151,7 @@ called with a non-bytes parameter. .. c:function:: char* PyBytes_AS_STRING(PyObject *string) - Macro form of :c:func:`PyBytes_AsString` but without error checking. + Similar to :c:func:`PyBytes_AsString`, but without error checking. .. c:function:: int PyBytes_AsStringAndSize(PyObject *obj, char **buffer, Py_ssize_t *length) diff --git a/Include/cpython/bytearrayobject.h b/Include/cpython/bytearrayobject.h index 569b0cd036986..5114169c28091 100644 --- a/Include/cpython/bytearrayobject.h +++ b/Include/cpython/bytearrayobject.h @@ -11,10 +11,28 @@ typedef struct { Py_ssize_t ob_exports; /* How many buffer exports */ } PyByteArrayObject; -/* Macros, trading safety for speed */ -#define PyByteArray_AS_STRING(self) \ - (assert(PyByteArray_Check(self)), \ - Py_SIZE(self) ? ((PyByteArrayObject *)(self))->ob_start : _PyByteArray_empty_string) -#define PyByteArray_GET_SIZE(self) (assert(PyByteArray_Check(self)), Py_SIZE(self)) - PyAPI_DATA(char) _PyByteArray_empty_string[]; + +/* Macros and static inline functions, trading safety for speed */ +#define _PyByteArray_CAST(op) \ + (assert(PyByteArray_Check(op)), _Py_CAST(PyByteArrayObject*, op)) + +static inline char* PyByteArray_AS_STRING(PyObject *op) +{ + PyByteArrayObject *self = _PyByteArray_CAST(op); + if (Py_SIZE(self)) { + return self->ob_start; + } + return _PyByteArray_empty_string; +} +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 +# define PyByteArray_AS_STRING(self) PyByteArray_AS_STRING(_PyObject_CAST(self)) +#endif + +static inline Py_ssize_t PyByteArray_GET_SIZE(PyObject *op) { + PyByteArrayObject *self = _PyByteArray_CAST(op); + return Py_SIZE(self); +} +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 +# define PyByteArray_GET_SIZE(self) PyByteArray_GET_SIZE(_PyObject_CAST(self)) +#endif diff --git a/Include/cpython/bytesobject.h b/Include/cpython/bytesobject.h index 2c6d631f0b21e..53343661f0ec4 100644 --- a/Include/cpython/bytesobject.h +++ b/Include/cpython/bytesobject.h @@ -28,10 +28,25 @@ PyAPI_FUNC(PyObject*) _PyBytes_FromHex( PyAPI_FUNC(PyObject *) _PyBytes_DecodeEscape(const char *, Py_ssize_t, const char *, const char **); -/* Macro, trading safety for speed */ -#define PyBytes_AS_STRING(op) (assert(PyBytes_Check(op)), \ - (((PyBytesObject *)(op))->ob_sval)) -#define PyBytes_GET_SIZE(op) (assert(PyBytes_Check(op)),Py_SIZE(op)) +/* Macros and static inline functions, trading safety for speed */ +#define _PyBytes_CAST(op) \ + (assert(PyBytes_Check(op)), _Py_CAST(PyBytesObject*, op)) + +static inline char* PyBytes_AS_STRING(PyObject *op) +{ + return _PyBytes_CAST(op)->ob_sval; +} +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 +# define PyBytes_AS_STRING(op) PyBytes_AS_STRING(_PyObject_CAST(op)) +#endif + +static inline Py_ssize_t PyBytes_GET_SIZE(PyObject *op) { + PyBytesObject *self = _PyBytes_CAST(op); + return Py_SIZE(self); +} +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 +# define PyBytes_GET_SIZE(self) PyBytes_GET_SIZE(_PyObject_CAST(self)) +#endif /* _PyBytes_Join(sep, x) is like sep.join(x). sep must be PyBytesObject*, x must be an iterable object. */ From webhook-mailer at python.org Tue May 3 14:18:20 2022 From: webhook-mailer at python.org (JelleZijlstra) Date: Tue, 03 May 2022 18:18:20 -0000 Subject: [Python-checkins] gh-89289: Harden sqlite3.Connection init (#92214) Message-ID: https://github.com/python/cpython/commit/c278474df97de310535425c207136bf26c663e0b commit: c278474df97de310535425c207136bf26c663e0b branch: main author: Erlend Egeberg Aasland committer: JelleZijlstra date: 2022-05-03T12:18:11-06:00 summary: gh-89289: Harden sqlite3.Connection init (#92214) - Make sure SQLite resources are freed if database open fails - Remove unneeded branches if init is aborted files: M Modules/_sqlite/connection.c diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c index 75d29704695c6..793bc0b6aef0d 100644 --- a/Modules/_sqlite/connection.c +++ b/Modules/_sqlite/connection.c @@ -226,27 +226,27 @@ pysqlite_connection_init_impl(pysqlite_Connection *self, pysqlite_state *state = pysqlite_get_state_by_type(Py_TYPE(self)); if (rc != SQLITE_OK) { _pysqlite_seterror(state, db); - return -1; + goto error; } // Create LRU statement cache; returns a new reference. PyObject *statement_cache = new_statement_cache(self, state, cache_size); if (statement_cache == NULL) { - return -1; + goto error; } /* Create lists of weak references to cursors and blobs */ PyObject *cursors = PyList_New(0); if (cursors == NULL) { - Py_XDECREF(statement_cache); - return -1; + Py_DECREF(statement_cache); + goto error; } PyObject *blobs = PyList_New(0); if (blobs == NULL) { - Py_XDECREF(statement_cache); - Py_XDECREF(cursors); - return -1; + Py_DECREF(statement_cache); + Py_DECREF(cursors); + goto error; } // Init connection state members. @@ -279,11 +279,18 @@ pysqlite_connection_init_impl(pysqlite_Connection *self, self->NotSupportedError = state->NotSupportedError; if (PySys_Audit("sqlite3.connect/handle", "O", self) < 0) { - return -1; + return -1; // Don't goto error; at this point, dealloc will clean up. } self->initialized = 1; return 0; + +error: + // There are no statements or other SQLite objects attached to the + // database, so sqlite3_close() should always return SQLITE_OK. + rc = sqlite3_close(db); + assert(rc == SQLITE_OK), rc; + return -1; } #define VISIT_CALLBACK_CONTEXT(ctx) \ From webhook-mailer at python.org Tue May 3 14:18:41 2022 From: webhook-mailer at python.org (miss-islington) Date: Tue, 03 May 2022 18:18:41 -0000 Subject: [Python-checkins] bpo-29890: Test IPv*Interface construction with tuple argument (GH-30862) Message-ID: https://github.com/python/cpython/commit/30681d6655f1d25fd8ca10df0e2088a17733742c commit: 30681d6655f1d25fd8ca10df0e2088a17733742c branch: 3.10 author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com> committer: miss-islington <31488909+miss-islington at users.noreply.github.com> date: 2022-05-03T11:18:31-07:00 summary: bpo-29890: Test IPv*Interface construction with tuple argument (GH-30862) Co-authored-by: Jelle Zijlstra (cherry picked from commit b295a92c50b128e494f47c28f12b8e9eac2927ea) Co-authored-by: Humbled Drugman files: A Misc/NEWS.d/next/Tests/2022-01-24-21-31-09.bpo-29890.zEG-ra.rst M Lib/test/test_ipaddress.py diff --git a/Lib/test/test_ipaddress.py b/Lib/test/test_ipaddress.py index b2bb609ea8b4b..f012af052322d 100644 --- a/Lib/test/test_ipaddress.py +++ b/Lib/test/test_ipaddress.py @@ -580,6 +580,10 @@ def assertBadAddress(addr, details): assertBadAddress("1.2.3.256", re.escape("256 (> 255)")) def test_valid_netmask(self): + self.assertEqual(str(self.factory(('192.0.2.0', 24))), '192.0.2.0/24') + self.assertEqual(str(self.factory(('192.0.2.0', '24'))), '192.0.2.0/24') + self.assertEqual(str(self.factory(('192.0.2.0', '255.255.255.0'))), + '192.0.2.0/24') self.assertEqual(str(self.factory('192.0.2.0/255.255.255.0')), '192.0.2.0/24') for i in range(0, 33): @@ -740,6 +744,10 @@ def assertBadAddress(addr, details): def test_valid_netmask(self): # We only support CIDR for IPv6, because expanded netmasks are not # standard notation. + self.assertEqual(str(self.factory(('2001:db8::', 32))), + '2001:db8::/32') + self.assertEqual(str(self.factory(('2001:db8::', '32'))), + '2001:db8::/32') self.assertEqual(str(self.factory('2001:db8::/32')), '2001:db8::/32') for i in range(0, 129): # Generate and re-parse the CIDR format (trivial). diff --git a/Misc/NEWS.d/next/Tests/2022-01-24-21-31-09.bpo-29890.zEG-ra.rst b/Misc/NEWS.d/next/Tests/2022-01-24-21-31-09.bpo-29890.zEG-ra.rst new file mode 100644 index 0000000000000..38a06a2f9b6be --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2022-01-24-21-31-09.bpo-29890.zEG-ra.rst @@ -0,0 +1,2 @@ +Add tests for :class:`ipaddress.IPv4Interface` and :class:`ipaddress.IPv6Interface` construction with tuple arguments. +Original patch and tests by louisom. From webhook-mailer at python.org Tue May 3 14:18:46 2022 From: webhook-mailer at python.org (miss-islington) Date: Tue, 03 May 2022 18:18:46 -0000 Subject: [Python-checkins] bpo-29890: Test IPv*Interface construction with tuple argument (GH-30862) Message-ID: https://github.com/python/cpython/commit/4ede78104522dfd27d31d3a1b6dfaa673398e612 commit: 4ede78104522dfd27d31d3a1b6dfaa673398e612 branch: 3.9 author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com> committer: miss-islington <31488909+miss-islington at users.noreply.github.com> date: 2022-05-03T11:18:42-07:00 summary: bpo-29890: Test IPv*Interface construction with tuple argument (GH-30862) Co-authored-by: Jelle Zijlstra (cherry picked from commit b295a92c50b128e494f47c28f12b8e9eac2927ea) Co-authored-by: Humbled Drugman files: A Misc/NEWS.d/next/Tests/2022-01-24-21-31-09.bpo-29890.zEG-ra.rst M Lib/test/test_ipaddress.py diff --git a/Lib/test/test_ipaddress.py b/Lib/test/test_ipaddress.py index 224412749340f..90897f6bedb86 100644 --- a/Lib/test/test_ipaddress.py +++ b/Lib/test/test_ipaddress.py @@ -580,6 +580,10 @@ def assertBadAddress(addr, details): assertBadAddress("1.2.3.256", re.escape("256 (> 255)")) def test_valid_netmask(self): + self.assertEqual(str(self.factory(('192.0.2.0', 24))), '192.0.2.0/24') + self.assertEqual(str(self.factory(('192.0.2.0', '24'))), '192.0.2.0/24') + self.assertEqual(str(self.factory(('192.0.2.0', '255.255.255.0'))), + '192.0.2.0/24') self.assertEqual(str(self.factory('192.0.2.0/255.255.255.0')), '192.0.2.0/24') for i in range(0, 33): @@ -740,6 +744,10 @@ def assertBadAddress(addr, details): def test_valid_netmask(self): # We only support CIDR for IPv6, because expanded netmasks are not # standard notation. + self.assertEqual(str(self.factory(('2001:db8::', 32))), + '2001:db8::/32') + self.assertEqual(str(self.factory(('2001:db8::', '32'))), + '2001:db8::/32') self.assertEqual(str(self.factory('2001:db8::/32')), '2001:db8::/32') for i in range(0, 129): # Generate and re-parse the CIDR format (trivial). diff --git a/Misc/NEWS.d/next/Tests/2022-01-24-21-31-09.bpo-29890.zEG-ra.rst b/Misc/NEWS.d/next/Tests/2022-01-24-21-31-09.bpo-29890.zEG-ra.rst new file mode 100644 index 0000000000000..38a06a2f9b6be --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2022-01-24-21-31-09.bpo-29890.zEG-ra.rst @@ -0,0 +1,2 @@ +Add tests for :class:`ipaddress.IPv4Interface` and :class:`ipaddress.IPv6Interface` construction with tuple arguments. +Original patch and tests by louisom. From webhook-mailer at python.org Tue May 3 14:25:53 2022 From: webhook-mailer at python.org (vstinner) Date: Tue, 03 May 2022 18:25:53 -0000 Subject: [Python-checkins] gh-91320: Argument Clinic uses _PyCFunction_CAST() (#32210) Message-ID: https://github.com/python/cpython/commit/b270b82f1137ff25ee263eafd31503d760f3403d commit: b270b82f1137ff25ee263eafd31503d760f3403d branch: main author: Victor Stinner committer: vstinner date: 2022-05-03T20:25:41+02:00 summary: gh-91320: Argument Clinic uses _PyCFunction_CAST() (#32210) Replace "(PyCFunction)(void(*)(void))func" cast with _PyCFunction_CAST(func). files: M Lib/test/clinic.test M Modules/_io/clinic/_iomodule.c.h M Modules/_io/clinic/bufferedio.c.h M Modules/_io/clinic/bytesio.c.h M Modules/_io/clinic/fileio.c.h M Modules/_io/clinic/iobase.c.h M Modules/_io/clinic/stringio.c.h M Modules/_io/clinic/textio.c.h M Modules/_io/clinic/winconsoleio.c.h M Modules/_multiprocessing/clinic/multiprocessing.c.h M Modules/_multiprocessing/clinic/posixshmem.c.h M Modules/_multiprocessing/clinic/semaphore.c.h M Modules/_sqlite/clinic/blob.c.h M Modules/_sqlite/clinic/connection.c.h M Modules/_sqlite/clinic/cursor.c.h M Modules/_sqlite/clinic/module.c.h M Modules/_sre/clinic/sre.c.h M Modules/_ssl/clinic/cert.c.h M Modules/cjkcodecs/clinic/multibytecodec.c.h M Modules/clinic/_abc.c.h M Modules/clinic/_asynciomodule.c.h M Modules/clinic/_bisectmodule.c.h M Modules/clinic/_bz2module.c.h M Modules/clinic/_codecsmodule.c.h M Modules/clinic/_collectionsmodule.c.h M Modules/clinic/_cryptmodule.c.h M Modules/clinic/_csv.c.h M Modules/clinic/_curses_panel.c.h M Modules/clinic/_cursesmodule.c.h M Modules/clinic/_datetimemodule.c.h M Modules/clinic/_dbmmodule.c.h M Modules/clinic/_elementtree.c.h M Modules/clinic/_gdbmmodule.c.h M Modules/clinic/_hashopenssl.c.h M Modules/clinic/_heapqmodule.c.h M Modules/clinic/_localemodule.c.h M Modules/clinic/_lsprof.c.h M Modules/clinic/_lzmamodule.c.h M Modules/clinic/_opcode.c.h M Modules/clinic/_operator.c.h M Modules/clinic/_pickle.c.h M Modules/clinic/_queuemodule.c.h M Modules/clinic/_randommodule.c.h M Modules/clinic/_ssl.c.h M Modules/clinic/_statisticsmodule.c.h M Modules/clinic/_struct.c.h M Modules/clinic/_testmultiphase.c.h M Modules/clinic/_tkinter.c.h M Modules/clinic/_tracemalloc.c.h M Modules/clinic/_weakref.c.h M Modules/clinic/_winapi.c.h M Modules/clinic/arraymodule.c.h M Modules/clinic/audioop.c.h M Modules/clinic/binascii.c.h M Modules/clinic/cmathmodule.c.h M Modules/clinic/fcntlmodule.c.h M Modules/clinic/gcmodule.c.h M Modules/clinic/grpmodule.c.h M Modules/clinic/itertoolsmodule.c.h M Modules/clinic/mathmodule.c.h M Modules/clinic/md5module.c.h M Modules/clinic/overlapped.c.h M Modules/clinic/posixmodule.c.h M Modules/clinic/pyexpat.c.h M Modules/clinic/readline.c.h M Modules/clinic/resource.c.h M Modules/clinic/selectmodule.c.h M Modules/clinic/sha1module.c.h M Modules/clinic/sha256module.c.h M Modules/clinic/sha512module.c.h M Modules/clinic/signalmodule.c.h M Modules/clinic/symtablemodule.c.h M Modules/clinic/termios.c.h M Modules/clinic/unicodedata.c.h M Modules/clinic/zlibmodule.c.h M Objects/clinic/bytearrayobject.c.h M Objects/clinic/bytesobject.c.h M Objects/clinic/codeobject.c.h M Objects/clinic/dictobject.c.h M Objects/clinic/floatobject.c.h M Objects/clinic/listobject.c.h M Objects/clinic/longobject.c.h M Objects/clinic/memoryobject.c.h M Objects/clinic/odictobject.c.h M Objects/clinic/tupleobject.c.h M Objects/clinic/unicodeobject.c.h M Objects/stringlib/clinic/transmogrify.h.h M PC/clinic/_msi.c.h M PC/clinic/_testconsole.c.h M PC/clinic/msvcrtmodule.c.h M PC/clinic/winreg.c.h M PC/clinic/winsound.c.h M Python/clinic/_warnings.c.h M Python/clinic/bltinmodule.c.h M Python/clinic/context.c.h M Python/clinic/import.c.h M Python/clinic/marshal.c.h M Python/clinic/sysmodule.c.h M Tools/clinic/clinic.py diff --git a/Lib/test/clinic.test b/Lib/test/clinic.test index d2934b3f211ac..9ef3610ba10c0 100644 --- a/Lib/test/clinic.test +++ b/Lib/test/clinic.test @@ -21,7 +21,7 @@ PyDoc_STRVAR(test_object_converter__doc__, "\n"); #define TEST_OBJECT_CONVERTER_METHODDEF \ - {"test_object_converter", (PyCFunction)(void(*)(void))test_object_converter, METH_FASTCALL, test_object_converter__doc__}, + {"test_object_converter", _PyCFunction_CAST(test_object_converter), METH_FASTCALL, test_object_converter__doc__}, static PyObject * test_object_converter_impl(PyObject *module, PyObject *a, PyObject *b, @@ -58,7 +58,7 @@ exit: static PyObject * test_object_converter_impl(PyObject *module, PyObject *a, PyObject *b, PyObject *c, PyUnicode_Object *d) -/*[clinic end generated code: output=a78312d933df9ea1 input=005e6a8a711a869b]*/ +/*[clinic end generated code: output=886f4f9b598726b6 input=005e6a8a711a869b]*/ /*[clinic input] @@ -97,7 +97,7 @@ PyDoc_STRVAR(test_objects_converter__doc__, "\n"); #define TEST_OBJECTS_CONVERTER_METHODDEF \ - {"test_objects_converter", (PyCFunction)(void(*)(void))test_objects_converter, METH_FASTCALL, test_objects_converter__doc__}, + {"test_objects_converter", _PyCFunction_CAST(test_objects_converter), METH_FASTCALL, test_objects_converter__doc__}, static PyObject * test_objects_converter_impl(PyObject *module, PyObject *a, PyObject *b); @@ -126,7 +126,7 @@ exit: static PyObject * test_objects_converter_impl(PyObject *module, PyObject *a, PyObject *b) -/*[clinic end generated code: output=0e461f38d3b2bd08 input=4cbb3d9edd2a36f3]*/ +/*[clinic end generated code: output=fc26328b79d46bb7 input=4cbb3d9edd2a36f3]*/ /*[clinic input] @@ -153,7 +153,7 @@ PyDoc_STRVAR(test_object_converter_subclass_of__doc__, "\n"); #define TEST_OBJECT_CONVERTER_SUBCLASS_OF_METHODDEF \ - {"test_object_converter_subclass_of", (PyCFunction)(void(*)(void))test_object_converter_subclass_of, METH_FASTCALL, test_object_converter_subclass_of__doc__}, + {"test_object_converter_subclass_of", _PyCFunction_CAST(test_object_converter_subclass_of), METH_FASTCALL, test_object_converter_subclass_of__doc__}, static PyObject * test_object_converter_subclass_of_impl(PyObject *module, PyObject *a, @@ -240,7 +240,7 @@ test_object_converter_subclass_of_impl(PyObject *module, PyObject *a, PyObject *b, PyObject *c, PyObject *d, PyObject *e, PyObject *f, PyObject *g, PyObject *h, PyObject *i, PyObject *j) -/*[clinic end generated code: output=dcf7772bf0c876dd input=31b06b772d5f983e]*/ +/*[clinic end generated code: output=e4b07c9a54479a40 input=31b06b772d5f983e]*/ /*[clinic input] @@ -385,7 +385,7 @@ PyDoc_STRVAR(test_bool_converter__doc__, "\n"); #define TEST_BOOL_CONVERTER_METHODDEF \ - {"test_bool_converter", (PyCFunction)(void(*)(void))test_bool_converter, METH_FASTCALL, test_bool_converter__doc__}, + {"test_bool_converter", _PyCFunction_CAST(test_bool_converter), METH_FASTCALL, test_bool_converter__doc__}, static PyObject * test_bool_converter_impl(PyObject *module, int a, int b, int c); @@ -431,7 +431,7 @@ exit: static PyObject * test_bool_converter_impl(PyObject *module, int a, int b, int c) -/*[clinic end generated code: output=b5ec6409d942e0f9 input=939854fa9f248c60]*/ +/*[clinic end generated code: output=27f0e653a70b9be3 input=939854fa9f248c60]*/ /*[clinic input] @@ -463,7 +463,7 @@ PyDoc_STRVAR(test_char_converter__doc__, "\n"); #define TEST_CHAR_CONVERTER_METHODDEF \ - {"test_char_converter", (PyCFunction)(void(*)(void))test_char_converter, METH_FASTCALL, test_char_converter__doc__}, + {"test_char_converter", _PyCFunction_CAST(test_char_converter), METH_FASTCALL, test_char_converter__doc__}, static PyObject * test_char_converter_impl(PyObject *module, char a, char b, char c, char d, @@ -685,7 +685,7 @@ static PyObject * test_char_converter_impl(PyObject *module, char a, char b, char c, char d, char e, char f, char g, char h, char i, char j, char k, char l, char m, char n) -/*[clinic end generated code: output=9d3aaf5d6857ec9e input=e42330417a44feac]*/ +/*[clinic end generated code: output=98589f02422fe6b1 input=e42330417a44feac]*/ /*[clinic input] @@ -704,7 +704,7 @@ PyDoc_STRVAR(test_unsigned_char_converter__doc__, "\n"); #define TEST_UNSIGNED_CHAR_CONVERTER_METHODDEF \ - {"test_unsigned_char_converter", (PyCFunction)(void(*)(void))test_unsigned_char_converter, METH_FASTCALL, test_unsigned_char_converter__doc__}, + {"test_unsigned_char_converter", _PyCFunction_CAST(test_unsigned_char_converter), METH_FASTCALL, test_unsigned_char_converter__doc__}, static PyObject * test_unsigned_char_converter_impl(PyObject *module, unsigned char a, @@ -787,7 +787,7 @@ exit: static PyObject * test_unsigned_char_converter_impl(PyObject *module, unsigned char a, unsigned char b, unsigned char c) -/*[clinic end generated code: output=c0a6ab3144481466 input=021414060993e289]*/ +/*[clinic end generated code: output=45920dbedc22eb55 input=021414060993e289]*/ /*[clinic input] @@ -804,7 +804,7 @@ PyDoc_STRVAR(test_short_converter__doc__, "\n"); #define TEST_SHORT_CONVERTER_METHODDEF \ - {"test_short_converter", (PyCFunction)(void(*)(void))test_short_converter, METH_FASTCALL, test_short_converter__doc__}, + {"test_short_converter", _PyCFunction_CAST(test_short_converter), METH_FASTCALL, test_short_converter__doc__}, static PyObject * test_short_converter_impl(PyObject *module, short a); @@ -849,7 +849,7 @@ exit: static PyObject * test_short_converter_impl(PyObject *module, short a) -/*[clinic end generated code: output=3ccda4bd08b6e4b4 input=6a8a7a509a498ff4]*/ +/*[clinic end generated code: output=a580945bd6963d45 input=6a8a7a509a498ff4]*/ /*[clinic input] @@ -868,7 +868,7 @@ PyDoc_STRVAR(test_unsigned_short_converter__doc__, "\n"); #define TEST_UNSIGNED_SHORT_CONVERTER_METHODDEF \ - {"test_unsigned_short_converter", (PyCFunction)(void(*)(void))test_unsigned_short_converter, METH_FASTCALL, test_unsigned_short_converter__doc__}, + {"test_unsigned_short_converter", _PyCFunction_CAST(test_unsigned_short_converter), METH_FASTCALL, test_unsigned_short_converter__doc__}, static PyObject * test_unsigned_short_converter_impl(PyObject *module, unsigned short a, @@ -914,7 +914,7 @@ exit: static PyObject * test_unsigned_short_converter_impl(PyObject *module, unsigned short a, unsigned short b, unsigned short c) -/*[clinic end generated code: output=576b5ce48424f351 input=cdfd8eff3d9176b4]*/ +/*[clinic end generated code: output=e6e990df729114fc input=cdfd8eff3d9176b4]*/ /*[clinic input] @@ -934,7 +934,7 @@ PyDoc_STRVAR(test_int_converter__doc__, "\n"); #define TEST_INT_CONVERTER_METHODDEF \ - {"test_int_converter", (PyCFunction)(void(*)(void))test_int_converter, METH_FASTCALL, test_int_converter__doc__}, + {"test_int_converter", _PyCFunction_CAST(test_int_converter), METH_FASTCALL, test_int_converter__doc__}, static PyObject * test_int_converter_impl(PyObject *module, int a, int b, int c, myenum d); @@ -996,7 +996,7 @@ exit: static PyObject * test_int_converter_impl(PyObject *module, int a, int b, int c, myenum d) -/*[clinic end generated code: output=8a1a7b02ebe9eeac input=d20541fc1ca0553e]*/ +/*[clinic end generated code: output=800993036e078c07 input=d20541fc1ca0553e]*/ /*[clinic input] @@ -1015,7 +1015,7 @@ PyDoc_STRVAR(test_unsigned_int_converter__doc__, "\n"); #define TEST_UNSIGNED_INT_CONVERTER_METHODDEF \ - {"test_unsigned_int_converter", (PyCFunction)(void(*)(void))test_unsigned_int_converter, METH_FASTCALL, test_unsigned_int_converter__doc__}, + {"test_unsigned_int_converter", _PyCFunction_CAST(test_unsigned_int_converter), METH_FASTCALL, test_unsigned_int_converter__doc__}, static PyObject * test_unsigned_int_converter_impl(PyObject *module, unsigned int a, @@ -1061,7 +1061,7 @@ exit: static PyObject * test_unsigned_int_converter_impl(PyObject *module, unsigned int a, unsigned int b, unsigned int c) -/*[clinic end generated code: output=4f53904bfa1a0250 input=5533534828b62fc0]*/ +/*[clinic end generated code: output=f9cdbe410ccc98a3 input=5533534828b62fc0]*/ /*[clinic input] @@ -1078,7 +1078,7 @@ PyDoc_STRVAR(test_long_converter__doc__, "\n"); #define TEST_LONG_CONVERTER_METHODDEF \ - {"test_long_converter", (PyCFunction)(void(*)(void))test_long_converter, METH_FASTCALL, test_long_converter__doc__}, + {"test_long_converter", _PyCFunction_CAST(test_long_converter), METH_FASTCALL, test_long_converter__doc__}, static PyObject * test_long_converter_impl(PyObject *module, long a); @@ -1108,7 +1108,7 @@ exit: static PyObject * test_long_converter_impl(PyObject *module, long a) -/*[clinic end generated code: output=e5e7883fddcf4218 input=d2179e3c9cdcde89]*/ +/*[clinic end generated code: output=02b3a83495c1d236 input=d2179e3c9cdcde89]*/ /*[clinic input] @@ -1127,7 +1127,7 @@ PyDoc_STRVAR(test_unsigned_long_converter__doc__, "\n"); #define TEST_UNSIGNED_LONG_CONVERTER_METHODDEF \ - {"test_unsigned_long_converter", (PyCFunction)(void(*)(void))test_unsigned_long_converter, METH_FASTCALL, test_unsigned_long_converter__doc__}, + {"test_unsigned_long_converter", _PyCFunction_CAST(test_unsigned_long_converter), METH_FASTCALL, test_unsigned_long_converter__doc__}, static PyObject * test_unsigned_long_converter_impl(PyObject *module, unsigned long a, @@ -1174,7 +1174,7 @@ exit: static PyObject * test_unsigned_long_converter_impl(PyObject *module, unsigned long a, unsigned long b, unsigned long c) -/*[clinic end generated code: output=87c6b29fa217026e input=f450d94cae1ef73b]*/ +/*[clinic end generated code: output=540bb0ba2894e1fe input=f450d94cae1ef73b]*/ /*[clinic input] @@ -1191,7 +1191,7 @@ PyDoc_STRVAR(test_long_long_converter__doc__, "\n"); #define TEST_LONG_LONG_CONVERTER_METHODDEF \ - {"test_long_long_converter", (PyCFunction)(void(*)(void))test_long_long_converter, METH_FASTCALL, test_long_long_converter__doc__}, + {"test_long_long_converter", _PyCFunction_CAST(test_long_long_converter), METH_FASTCALL, test_long_long_converter__doc__}, static PyObject * test_long_long_converter_impl(PyObject *module, long long a); @@ -1221,7 +1221,7 @@ exit: static PyObject * test_long_long_converter_impl(PyObject *module, long long a) -/*[clinic end generated code: output=0488ac9e8c1d77bb input=d5fc81577ff4dd02]*/ +/*[clinic end generated code: output=f9d4ed79ad2db857 input=d5fc81577ff4dd02]*/ /*[clinic input] @@ -1240,7 +1240,7 @@ PyDoc_STRVAR(test_unsigned_long_long_converter__doc__, "\n"); #define TEST_UNSIGNED_LONG_LONG_CONVERTER_METHODDEF \ - {"test_unsigned_long_long_converter", (PyCFunction)(void(*)(void))test_unsigned_long_long_converter, METH_FASTCALL, test_unsigned_long_long_converter__doc__}, + {"test_unsigned_long_long_converter", _PyCFunction_CAST(test_unsigned_long_long_converter), METH_FASTCALL, test_unsigned_long_long_converter__doc__}, static PyObject * test_unsigned_long_long_converter_impl(PyObject *module, @@ -1291,7 +1291,7 @@ test_unsigned_long_long_converter_impl(PyObject *module, unsigned long long a, unsigned long long b, unsigned long long c) -/*[clinic end generated code: output=aad2c7b43db2f190 input=a15115dc41866ff4]*/ +/*[clinic end generated code: output=3d69994f618b46bb input=a15115dc41866ff4]*/ /*[clinic input] @@ -1310,7 +1310,7 @@ PyDoc_STRVAR(test_Py_ssize_t_converter__doc__, "\n"); #define TEST_PY_SSIZE_T_CONVERTER_METHODDEF \ - {"test_Py_ssize_t_converter", (PyCFunction)(void(*)(void))test_Py_ssize_t_converter, METH_FASTCALL, test_Py_ssize_t_converter__doc__}, + {"test_Py_ssize_t_converter", _PyCFunction_CAST(test_Py_ssize_t_converter), METH_FASTCALL, test_Py_ssize_t_converter__doc__}, static PyObject * test_Py_ssize_t_converter_impl(PyObject *module, Py_ssize_t a, Py_ssize_t b, @@ -1373,7 +1373,7 @@ exit: static PyObject * test_Py_ssize_t_converter_impl(PyObject *module, Py_ssize_t a, Py_ssize_t b, Py_ssize_t c) -/*[clinic end generated code: output=3bf73f9fdfeab468 input=3855f184bb3f299d]*/ +/*[clinic end generated code: output=48214bc3d01f4dd7 input=3855f184bb3f299d]*/ /*[clinic input] @@ -1392,7 +1392,7 @@ PyDoc_STRVAR(test_slice_index_converter__doc__, "\n"); #define TEST_SLICE_INDEX_CONVERTER_METHODDEF \ - {"test_slice_index_converter", (PyCFunction)(void(*)(void))test_slice_index_converter, METH_FASTCALL, test_slice_index_converter__doc__}, + {"test_slice_index_converter", _PyCFunction_CAST(test_slice_index_converter), METH_FASTCALL, test_slice_index_converter__doc__}, static PyObject * test_slice_index_converter_impl(PyObject *module, Py_ssize_t a, Py_ssize_t b, @@ -1437,7 +1437,7 @@ exit: static PyObject * test_slice_index_converter_impl(PyObject *module, Py_ssize_t a, Py_ssize_t b, Py_ssize_t c) -/*[clinic end generated code: output=2148703cd3c6e941 input=edeadb0ee126f531]*/ +/*[clinic end generated code: output=67506ed999361212 input=edeadb0ee126f531]*/ /*[clinic input] @@ -1454,7 +1454,7 @@ PyDoc_STRVAR(test_size_t_converter__doc__, "\n"); #define TEST_SIZE_T_CONVERTER_METHODDEF \ - {"test_size_t_converter", (PyCFunction)(void(*)(void))test_size_t_converter, METH_FASTCALL, test_size_t_converter__doc__}, + {"test_size_t_converter", _PyCFunction_CAST(test_size_t_converter), METH_FASTCALL, test_size_t_converter__doc__}, static PyObject * test_size_t_converter_impl(PyObject *module, size_t a); @@ -1483,7 +1483,7 @@ exit: static PyObject * test_size_t_converter_impl(PyObject *module, size_t a) -/*[clinic end generated code: output=8a91a9ca8a92dabb input=52e93a0fed0f1fb3]*/ +/*[clinic end generated code: output=1653ecb5cbf775aa input=52e93a0fed0f1fb3]*/ /*[clinic input] @@ -1500,7 +1500,7 @@ PyDoc_STRVAR(test_float_converter__doc__, "\n"); #define TEST_FLOAT_CONVERTER_METHODDEF \ - {"test_float_converter", (PyCFunction)(void(*)(void))test_float_converter, METH_FASTCALL, test_float_converter__doc__}, + {"test_float_converter", _PyCFunction_CAST(test_float_converter), METH_FASTCALL, test_float_converter__doc__}, static PyObject * test_float_converter_impl(PyObject *module, float a); @@ -1536,7 +1536,7 @@ exit: static PyObject * test_float_converter_impl(PyObject *module, float a) -/*[clinic end generated code: output=6b9c7443d2601cea input=259c0d98eca35034]*/ +/*[clinic end generated code: output=36ad006990a8a91e input=259c0d98eca35034]*/ /*[clinic input] @@ -1553,7 +1553,7 @@ PyDoc_STRVAR(test_double_converter__doc__, "\n"); #define TEST_DOUBLE_CONVERTER_METHODDEF \ - {"test_double_converter", (PyCFunction)(void(*)(void))test_double_converter, METH_FASTCALL, test_double_converter__doc__}, + {"test_double_converter", _PyCFunction_CAST(test_double_converter), METH_FASTCALL, test_double_converter__doc__}, static PyObject * test_double_converter_impl(PyObject *module, double a); @@ -1589,7 +1589,7 @@ exit: static PyObject * test_double_converter_impl(PyObject *module, double a) -/*[clinic end generated code: output=5b7b9a0f0791b2cc input=c6a9945706a41c27]*/ +/*[clinic end generated code: output=7435925592bac795 input=c6a9945706a41c27]*/ /*[clinic input] @@ -1654,7 +1654,7 @@ PyDoc_STRVAR(test_str_converter__doc__, "\n"); #define TEST_STR_CONVERTER_METHODDEF \ - {"test_str_converter", (PyCFunction)(void(*)(void))test_str_converter, METH_FASTCALL, test_str_converter__doc__}, + {"test_str_converter", _PyCFunction_CAST(test_str_converter), METH_FASTCALL, test_str_converter__doc__}, static PyObject * test_str_converter_impl(PyObject *module, const char *a, const char *b, @@ -1695,7 +1695,7 @@ test_str_converter_impl(PyObject *module, const char *a, const char *b, const char *f, Py_ssize_t f_length, const char *g, Py_ssize_t g_length, const char *h, Py_ssize_t h_length) -/*[clinic end generated code: output=5def009caa2fd1ac input=8afe9da8185cd38c]*/ +/*[clinic end generated code: output=82cb06d5237ef062 input=8afe9da8185cd38c]*/ /*[clinic input] @@ -1716,7 +1716,7 @@ PyDoc_STRVAR(test_str_converter_encoding__doc__, "\n"); #define TEST_STR_CONVERTER_ENCODING_METHODDEF \ - {"test_str_converter_encoding", (PyCFunction)(void(*)(void))test_str_converter_encoding, METH_FASTCALL, test_str_converter_encoding__doc__}, + {"test_str_converter_encoding", _PyCFunction_CAST(test_str_converter_encoding), METH_FASTCALL, test_str_converter_encoding__doc__}, static PyObject * test_str_converter_encoding_impl(PyObject *module, char *a, char *b, char *c, @@ -1770,7 +1770,7 @@ static PyObject * test_str_converter_encoding_impl(PyObject *module, char *a, char *b, char *c, char *d, Py_ssize_t d_length, char *e, Py_ssize_t e_length) -/*[clinic end generated code: output=5cae635c092334cb input=eb4c38e1f898f402]*/ +/*[clinic end generated code: output=8acb886a3843f3bc input=eb4c38e1f898f402]*/ /*[clinic input] @@ -1791,7 +1791,7 @@ PyDoc_STRVAR(test_Py_UNICODE_converter__doc__, "\n"); #define TEST_PY_UNICODE_CONVERTER_METHODDEF \ - {"test_Py_UNICODE_converter", (PyCFunction)(void(*)(void))test_Py_UNICODE_converter, METH_FASTCALL, test_Py_UNICODE_converter__doc__}, + {"test_Py_UNICODE_converter", _PyCFunction_CAST(test_Py_UNICODE_converter), METH_FASTCALL, test_Py_UNICODE_converter__doc__}, static PyObject * test_Py_UNICODE_converter_impl(PyObject *module, const Py_UNICODE *a, @@ -1839,7 +1839,7 @@ test_Py_UNICODE_converter_impl(PyObject *module, const Py_UNICODE *a, const Py_UNICODE *b, const Py_UNICODE *c, const Py_UNICODE *d, Py_ssize_t d_length, const Py_UNICODE *e, Py_ssize_t e_length) -/*[clinic end generated code: output=65d6607da302afd0 input=064a3b68ad7f04b0]*/ +/*[clinic end generated code: output=45e92604de227552 input=064a3b68ad7f04b0]*/ /*[clinic input] @@ -1860,7 +1860,7 @@ PyDoc_STRVAR(test_Py_buffer_converter__doc__, "\n"); #define TEST_PY_BUFFER_CONVERTER_METHODDEF \ - {"test_Py_buffer_converter", (PyCFunction)(void(*)(void))test_Py_buffer_converter, METH_FASTCALL, test_Py_buffer_converter__doc__}, + {"test_Py_buffer_converter", _PyCFunction_CAST(test_Py_buffer_converter), METH_FASTCALL, test_Py_buffer_converter__doc__}, static PyObject * test_Py_buffer_converter_impl(PyObject *module, Py_buffer *a, Py_buffer *b, @@ -1910,7 +1910,7 @@ exit: static PyObject * test_Py_buffer_converter_impl(PyObject *module, Py_buffer *a, Py_buffer *b, Py_buffer *c, Py_buffer *d, Py_buffer *e) -/*[clinic end generated code: output=5760c82faa2ed61f input=6a9da0f56f9525fd]*/ +/*[clinic end generated code: output=a153b71b4f45f952 input=6a9da0f56f9525fd]*/ /*[clinic input] @@ -1927,7 +1927,7 @@ PyDoc_STRVAR(test_keywords__doc__, "\n"); #define TEST_KEYWORDS_METHODDEF \ - {"test_keywords", (PyCFunction)(void(*)(void))test_keywords, METH_FASTCALL|METH_KEYWORDS, test_keywords__doc__}, + {"test_keywords", _PyCFunction_CAST(test_keywords), METH_FASTCALL|METH_KEYWORDS, test_keywords__doc__}, static PyObject * test_keywords_impl(PyObject *module, PyObject *a, PyObject *b); @@ -1956,7 +1956,7 @@ exit: static PyObject * test_keywords_impl(PyObject *module, PyObject *a, PyObject *b) -/*[clinic end generated code: output=4be6cf045ea8242e input=0d3484844749c05b]*/ +/*[clinic end generated code: output=c03a52cfca192d3b input=0d3484844749c05b]*/ /*[clinic input] @@ -1974,7 +1974,7 @@ PyDoc_STRVAR(test_keywords_kwonly__doc__, "\n"); #define TEST_KEYWORDS_KWONLY_METHODDEF \ - {"test_keywords_kwonly", (PyCFunction)(void(*)(void))test_keywords_kwonly, METH_FASTCALL|METH_KEYWORDS, test_keywords_kwonly__doc__}, + {"test_keywords_kwonly", _PyCFunction_CAST(test_keywords_kwonly), METH_FASTCALL|METH_KEYWORDS, test_keywords_kwonly__doc__}, static PyObject * test_keywords_kwonly_impl(PyObject *module, PyObject *a, PyObject *b); @@ -2003,7 +2003,7 @@ exit: static PyObject * test_keywords_kwonly_impl(PyObject *module, PyObject *a, PyObject *b) -/*[clinic end generated code: output=d63c4977a7a80713 input=384adc78bfa0bff7]*/ +/*[clinic end generated code: output=4704adcb6c7df928 input=384adc78bfa0bff7]*/ /*[clinic input] @@ -2021,7 +2021,7 @@ PyDoc_STRVAR(test_keywords_opt__doc__, "\n"); #define TEST_KEYWORDS_OPT_METHODDEF \ - {"test_keywords_opt", (PyCFunction)(void(*)(void))test_keywords_opt, METH_FASTCALL|METH_KEYWORDS, test_keywords_opt__doc__}, + {"test_keywords_opt", _PyCFunction_CAST(test_keywords_opt), METH_FASTCALL|METH_KEYWORDS, test_keywords_opt__doc__}, static PyObject * test_keywords_opt_impl(PyObject *module, PyObject *a, PyObject *b, @@ -2064,7 +2064,7 @@ exit: static PyObject * test_keywords_opt_impl(PyObject *module, PyObject *a, PyObject *b, PyObject *c) -/*[clinic end generated code: output=e5e50d114d8fc10a input=eda7964f784f4607]*/ +/*[clinic end generated code: output=de3ee1039da35fa1 input=eda7964f784f4607]*/ /*[clinic input] @@ -2084,7 +2084,7 @@ PyDoc_STRVAR(test_keywords_opt_kwonly__doc__, "\n"); #define TEST_KEYWORDS_OPT_KWONLY_METHODDEF \ - {"test_keywords_opt_kwonly", (PyCFunction)(void(*)(void))test_keywords_opt_kwonly, METH_FASTCALL|METH_KEYWORDS, test_keywords_opt_kwonly__doc__}, + {"test_keywords_opt_kwonly", _PyCFunction_CAST(test_keywords_opt_kwonly), METH_FASTCALL|METH_KEYWORDS, test_keywords_opt_kwonly__doc__}, static PyObject * test_keywords_opt_kwonly_impl(PyObject *module, PyObject *a, PyObject *b, @@ -2138,7 +2138,7 @@ exit: static PyObject * test_keywords_opt_kwonly_impl(PyObject *module, PyObject *a, PyObject *b, PyObject *c, PyObject *d) -/*[clinic end generated code: output=3f065cb8309b9317 input=209387a4815e5082]*/ +/*[clinic end generated code: output=996394678586854e input=209387a4815e5082]*/ /*[clinic input] @@ -2157,7 +2157,7 @@ PyDoc_STRVAR(test_keywords_kwonly_opt__doc__, "\n"); #define TEST_KEYWORDS_KWONLY_OPT_METHODDEF \ - {"test_keywords_kwonly_opt", (PyCFunction)(void(*)(void))test_keywords_kwonly_opt, METH_FASTCALL|METH_KEYWORDS, test_keywords_kwonly_opt__doc__}, + {"test_keywords_kwonly_opt", _PyCFunction_CAST(test_keywords_kwonly_opt), METH_FASTCALL|METH_KEYWORDS, test_keywords_kwonly_opt__doc__}, static PyObject * test_keywords_kwonly_opt_impl(PyObject *module, PyObject *a, PyObject *b, @@ -2200,7 +2200,7 @@ exit: static PyObject * test_keywords_kwonly_opt_impl(PyObject *module, PyObject *a, PyObject *b, PyObject *c) -/*[clinic end generated code: output=94edba5484e1681e input=18393cc64fa000f4]*/ +/*[clinic end generated code: output=4ea9947a903a2f24 input=18393cc64fa000f4]*/ /*[clinic input] @@ -2218,7 +2218,7 @@ PyDoc_STRVAR(test_posonly_keywords__doc__, "\n"); #define TEST_POSONLY_KEYWORDS_METHODDEF \ - {"test_posonly_keywords", (PyCFunction)(void(*)(void))test_posonly_keywords, METH_FASTCALL|METH_KEYWORDS, test_posonly_keywords__doc__}, + {"test_posonly_keywords", _PyCFunction_CAST(test_posonly_keywords), METH_FASTCALL|METH_KEYWORDS, test_posonly_keywords__doc__}, static PyObject * test_posonly_keywords_impl(PyObject *module, PyObject *a, PyObject *b); @@ -2247,7 +2247,7 @@ exit: static PyObject * test_posonly_keywords_impl(PyObject *module, PyObject *a, PyObject *b) -/*[clinic end generated code: output=eca1507f0182ffb0 input=1767b0ebdf06060e]*/ +/*[clinic end generated code: output=478aad346a188a80 input=1767b0ebdf06060e]*/ /*[clinic input] @@ -2266,7 +2266,7 @@ PyDoc_STRVAR(test_posonly_kwonly__doc__, "\n"); #define TEST_POSONLY_KWONLY_METHODDEF \ - {"test_posonly_kwonly", (PyCFunction)(void(*)(void))test_posonly_kwonly, METH_FASTCALL|METH_KEYWORDS, test_posonly_kwonly__doc__}, + {"test_posonly_kwonly", _PyCFunction_CAST(test_posonly_kwonly), METH_FASTCALL|METH_KEYWORDS, test_posonly_kwonly__doc__}, static PyObject * test_posonly_kwonly_impl(PyObject *module, PyObject *a, PyObject *c); @@ -2295,7 +2295,7 @@ exit: static PyObject * test_posonly_kwonly_impl(PyObject *module, PyObject *a, PyObject *c) -/*[clinic end generated code: output=3e14655646b66e9a input=9042f2818f664839]*/ +/*[clinic end generated code: output=d747975a0b28e9c2 input=9042f2818f664839]*/ /*[clinic input] @@ -2315,7 +2315,7 @@ PyDoc_STRVAR(test_posonly_keywords_kwonly__doc__, "\n"); #define TEST_POSONLY_KEYWORDS_KWONLY_METHODDEF \ - {"test_posonly_keywords_kwonly", (PyCFunction)(void(*)(void))test_posonly_keywords_kwonly, METH_FASTCALL|METH_KEYWORDS, test_posonly_keywords_kwonly__doc__}, + {"test_posonly_keywords_kwonly", _PyCFunction_CAST(test_posonly_keywords_kwonly), METH_FASTCALL|METH_KEYWORDS, test_posonly_keywords_kwonly__doc__}, static PyObject * test_posonly_keywords_kwonly_impl(PyObject *module, PyObject *a, PyObject *b, @@ -2348,7 +2348,7 @@ exit: static PyObject * test_posonly_keywords_kwonly_impl(PyObject *module, PyObject *a, PyObject *b, PyObject *c) -/*[clinic end generated code: output=de57172fc97a626e input=29546ebdca492fea]*/ +/*[clinic end generated code: output=5b99f692f8ddaa4a input=29546ebdca492fea]*/ /*[clinic input] @@ -2368,7 +2368,7 @@ PyDoc_STRVAR(test_posonly_keywords_opt__doc__, "\n"); #define TEST_POSONLY_KEYWORDS_OPT_METHODDEF \ - {"test_posonly_keywords_opt", (PyCFunction)(void(*)(void))test_posonly_keywords_opt, METH_FASTCALL|METH_KEYWORDS, test_posonly_keywords_opt__doc__}, + {"test_posonly_keywords_opt", _PyCFunction_CAST(test_posonly_keywords_opt), METH_FASTCALL|METH_KEYWORDS, test_posonly_keywords_opt__doc__}, static PyObject * test_posonly_keywords_opt_impl(PyObject *module, PyObject *a, PyObject *b, @@ -2413,7 +2413,7 @@ exit: static PyObject * test_posonly_keywords_opt_impl(PyObject *module, PyObject *a, PyObject *b, PyObject *c, PyObject *d) -/*[clinic end generated code: output=8bc6b44a25d4b716 input=cdf5a9625e554e9b]*/ +/*[clinic end generated code: output=fd5dfbac5727aebb input=cdf5a9625e554e9b]*/ /*[clinic input] @@ -2432,7 +2432,7 @@ PyDoc_STRVAR(test_posonly_keywords_opt2__doc__, "\n"); #define TEST_POSONLY_KEYWORDS_OPT2_METHODDEF \ - {"test_posonly_keywords_opt2", (PyCFunction)(void(*)(void))test_posonly_keywords_opt2, METH_FASTCALL|METH_KEYWORDS, test_posonly_keywords_opt2__doc__}, + {"test_posonly_keywords_opt2", _PyCFunction_CAST(test_posonly_keywords_opt2), METH_FASTCALL|METH_KEYWORDS, test_posonly_keywords_opt2__doc__}, static PyObject * test_posonly_keywords_opt2_impl(PyObject *module, PyObject *a, PyObject *b, @@ -2475,7 +2475,7 @@ exit: static PyObject * test_posonly_keywords_opt2_impl(PyObject *module, PyObject *a, PyObject *b, PyObject *c) -/*[clinic end generated code: output=a870c45a6510ba91 input=1581299d21d16f14]*/ +/*[clinic end generated code: output=777f58ac70775420 input=1581299d21d16f14]*/ /*[clinic input] @@ -2495,7 +2495,7 @@ PyDoc_STRVAR(test_posonly_opt_keywords_opt__doc__, "\n"); #define TEST_POSONLY_OPT_KEYWORDS_OPT_METHODDEF \ - {"test_posonly_opt_keywords_opt", (PyCFunction)(void(*)(void))test_posonly_opt_keywords_opt, METH_FASTCALL|METH_KEYWORDS, test_posonly_opt_keywords_opt__doc__}, + {"test_posonly_opt_keywords_opt", _PyCFunction_CAST(test_posonly_opt_keywords_opt), METH_FASTCALL|METH_KEYWORDS, test_posonly_opt_keywords_opt__doc__}, static PyObject * test_posonly_opt_keywords_opt_impl(PyObject *module, PyObject *a, @@ -2545,7 +2545,7 @@ exit: static PyObject * test_posonly_opt_keywords_opt_impl(PyObject *module, PyObject *a, PyObject *b, PyObject *c, PyObject *d) -/*[clinic end generated code: output=9ae3d52e071d3b7f input=408798ec3d42949f]*/ +/*[clinic end generated code: output=2c18b8edff78ed22 input=408798ec3d42949f]*/ /*[clinic input] @@ -2566,7 +2566,7 @@ PyDoc_STRVAR(test_posonly_kwonly_opt__doc__, "\n"); #define TEST_POSONLY_KWONLY_OPT_METHODDEF \ - {"test_posonly_kwonly_opt", (PyCFunction)(void(*)(void))test_posonly_kwonly_opt, METH_FASTCALL|METH_KEYWORDS, test_posonly_kwonly_opt__doc__}, + {"test_posonly_kwonly_opt", _PyCFunction_CAST(test_posonly_kwonly_opt), METH_FASTCALL|METH_KEYWORDS, test_posonly_kwonly_opt__doc__}, static PyObject * test_posonly_kwonly_opt_impl(PyObject *module, PyObject *a, PyObject *b, @@ -2611,7 +2611,7 @@ exit: static PyObject * test_posonly_kwonly_opt_impl(PyObject *module, PyObject *a, PyObject *b, PyObject *c, PyObject *d) -/*[clinic end generated code: output=fb001f586ba68549 input=8d8e5643bbbc2309]*/ +/*[clinic end generated code: output=8db9ab5602e1efaf input=8d8e5643bbbc2309]*/ /*[clinic input] @@ -2631,7 +2631,7 @@ PyDoc_STRVAR(test_posonly_kwonly_opt2__doc__, "\n"); #define TEST_POSONLY_KWONLY_OPT2_METHODDEF \ - {"test_posonly_kwonly_opt2", (PyCFunction)(void(*)(void))test_posonly_kwonly_opt2, METH_FASTCALL|METH_KEYWORDS, test_posonly_kwonly_opt2__doc__}, + {"test_posonly_kwonly_opt2", _PyCFunction_CAST(test_posonly_kwonly_opt2), METH_FASTCALL|METH_KEYWORDS, test_posonly_kwonly_opt2__doc__}, static PyObject * test_posonly_kwonly_opt2_impl(PyObject *module, PyObject *a, PyObject *b, @@ -2674,7 +2674,7 @@ exit: static PyObject * test_posonly_kwonly_opt2_impl(PyObject *module, PyObject *a, PyObject *b, PyObject *c) -/*[clinic end generated code: output=51aae7cac77b458a input=f7e5eed94f75fff0]*/ +/*[clinic end generated code: output=6cfe546265d85d2c input=f7e5eed94f75fff0]*/ /*[clinic input] @@ -2695,7 +2695,7 @@ PyDoc_STRVAR(test_posonly_opt_kwonly_opt__doc__, "\n"); #define TEST_POSONLY_OPT_KWONLY_OPT_METHODDEF \ - {"test_posonly_opt_kwonly_opt", (PyCFunction)(void(*)(void))test_posonly_opt_kwonly_opt, METH_FASTCALL|METH_KEYWORDS, test_posonly_opt_kwonly_opt__doc__}, + {"test_posonly_opt_kwonly_opt", _PyCFunction_CAST(test_posonly_opt_kwonly_opt), METH_FASTCALL|METH_KEYWORDS, test_posonly_opt_kwonly_opt__doc__}, static PyObject * test_posonly_opt_kwonly_opt_impl(PyObject *module, PyObject *a, PyObject *b, @@ -2745,7 +2745,7 @@ exit: static PyObject * test_posonly_opt_kwonly_opt_impl(PyObject *module, PyObject *a, PyObject *b, PyObject *c, PyObject *d) -/*[clinic end generated code: output=68844c45143d1668 input=1e557dc979d120fd]*/ +/*[clinic end generated code: output=8b5e21a30cad22b7 input=1e557dc979d120fd]*/ /*[clinic input] @@ -2767,7 +2767,7 @@ PyDoc_STRVAR(test_posonly_keywords_kwonly_opt__doc__, "\n"); #define TEST_POSONLY_KEYWORDS_KWONLY_OPT_METHODDEF \ - {"test_posonly_keywords_kwonly_opt", (PyCFunction)(void(*)(void))test_posonly_keywords_kwonly_opt, METH_FASTCALL|METH_KEYWORDS, test_posonly_keywords_kwonly_opt__doc__}, + {"test_posonly_keywords_kwonly_opt", _PyCFunction_CAST(test_posonly_keywords_kwonly_opt), METH_FASTCALL|METH_KEYWORDS, test_posonly_keywords_kwonly_opt__doc__}, static PyObject * test_posonly_keywords_kwonly_opt_impl(PyObject *module, PyObject *a, @@ -2816,7 +2816,7 @@ static PyObject * test_posonly_keywords_kwonly_opt_impl(PyObject *module, PyObject *a, PyObject *b, PyObject *c, PyObject *d, PyObject *e) -/*[clinic end generated code: output=996ff645551897ac input=c3884a4f956fdc89]*/ +/*[clinic end generated code: output=950b9ace38b8b4a7 input=c3884a4f956fdc89]*/ /*[clinic input] @@ -2837,7 +2837,7 @@ PyDoc_STRVAR(test_posonly_keywords_kwonly_opt2__doc__, "\n"); #define TEST_POSONLY_KEYWORDS_KWONLY_OPT2_METHODDEF \ - {"test_posonly_keywords_kwonly_opt2", (PyCFunction)(void(*)(void))test_posonly_keywords_kwonly_opt2, METH_FASTCALL|METH_KEYWORDS, test_posonly_keywords_kwonly_opt2__doc__}, + {"test_posonly_keywords_kwonly_opt2", _PyCFunction_CAST(test_posonly_keywords_kwonly_opt2), METH_FASTCALL|METH_KEYWORDS, test_posonly_keywords_kwonly_opt2__doc__}, static PyObject * test_posonly_keywords_kwonly_opt2_impl(PyObject *module, PyObject *a, @@ -2882,7 +2882,7 @@ exit: static PyObject * test_posonly_keywords_kwonly_opt2_impl(PyObject *module, PyObject *a, PyObject *b, PyObject *c, PyObject *d) -/*[clinic end generated code: output=e5a3e992fd4b28b3 input=68d01d7c0f6dafb0]*/ +/*[clinic end generated code: output=fb6951a21b517317 input=68d01d7c0f6dafb0]*/ /*[clinic input] @@ -2905,7 +2905,7 @@ PyDoc_STRVAR(test_posonly_keywords_opt_kwonly_opt__doc__, "\n"); #define TEST_POSONLY_KEYWORDS_OPT_KWONLY_OPT_METHODDEF \ - {"test_posonly_keywords_opt_kwonly_opt", (PyCFunction)(void(*)(void))test_posonly_keywords_opt_kwonly_opt, METH_FASTCALL|METH_KEYWORDS, test_posonly_keywords_opt_kwonly_opt__doc__}, + {"test_posonly_keywords_opt_kwonly_opt", _PyCFunction_CAST(test_posonly_keywords_opt_kwonly_opt), METH_FASTCALL|METH_KEYWORDS, test_posonly_keywords_opt_kwonly_opt__doc__}, static PyObject * test_posonly_keywords_opt_kwonly_opt_impl(PyObject *module, PyObject *a, @@ -2963,7 +2963,7 @@ static PyObject * test_posonly_keywords_opt_kwonly_opt_impl(PyObject *module, PyObject *a, PyObject *b, PyObject *c, PyObject *d, PyObject *e) -/*[clinic end generated code: output=ff9fb6c3d2cbbaa4 input=d0883d45876f186c]*/ +/*[clinic end generated code: output=4db10815a99a857e input=d0883d45876f186c]*/ /*[clinic input] @@ -2986,7 +2986,7 @@ PyDoc_STRVAR(test_posonly_keywords_opt2_kwonly_opt__doc__, "\n"); #define TEST_POSONLY_KEYWORDS_OPT2_KWONLY_OPT_METHODDEF \ - {"test_posonly_keywords_opt2_kwonly_opt", (PyCFunction)(void(*)(void))test_posonly_keywords_opt2_kwonly_opt, METH_FASTCALL|METH_KEYWORDS, test_posonly_keywords_opt2_kwonly_opt__doc__}, + {"test_posonly_keywords_opt2_kwonly_opt", _PyCFunction_CAST(test_posonly_keywords_opt2_kwonly_opt), METH_FASTCALL|METH_KEYWORDS, test_posonly_keywords_opt2_kwonly_opt__doc__}, static PyObject * test_posonly_keywords_opt2_kwonly_opt_impl(PyObject *module, PyObject *a, @@ -3049,7 +3049,7 @@ static PyObject * test_posonly_keywords_opt2_kwonly_opt_impl(PyObject *module, PyObject *a, PyObject *b, PyObject *c, PyObject *d, PyObject *e) -/*[clinic end generated code: output=c809d7a84a2205e1 input=c95e2e1ec93035ad]*/ +/*[clinic end generated code: output=0416689b23ebf66e input=c95e2e1ec93035ad]*/ /*[clinic input] @@ -3073,7 +3073,7 @@ PyDoc_STRVAR(test_posonly_opt_keywords_opt_kwonly_opt__doc__, "\n"); #define TEST_POSONLY_OPT_KEYWORDS_OPT_KWONLY_OPT_METHODDEF \ - {"test_posonly_opt_keywords_opt_kwonly_opt", (PyCFunction)(void(*)(void))test_posonly_opt_keywords_opt_kwonly_opt, METH_FASTCALL|METH_KEYWORDS, test_posonly_opt_keywords_opt_kwonly_opt__doc__}, + {"test_posonly_opt_keywords_opt_kwonly_opt", _PyCFunction_CAST(test_posonly_opt_keywords_opt_kwonly_opt), METH_FASTCALL|METH_KEYWORDS, test_posonly_opt_keywords_opt_kwonly_opt__doc__}, static PyObject * test_posonly_opt_keywords_opt_kwonly_opt_impl(PyObject *module, PyObject *a, @@ -3145,7 +3145,7 @@ test_posonly_opt_keywords_opt_kwonly_opt_impl(PyObject *module, PyObject *a, PyObject *b, PyObject *c, PyObject *d, PyObject *e, PyObject *f) -/*[clinic end generated code: output=719e4f6c224402d4 input=9914857713c5bbf8]*/ +/*[clinic end generated code: output=8892a137a8c8f46f input=9914857713c5bbf8]*/ /*[clinic input] test_keyword_only_parameter @@ -3162,7 +3162,7 @@ PyDoc_STRVAR(test_keyword_only_parameter__doc__, "\n"); #define TEST_KEYWORD_ONLY_PARAMETER_METHODDEF \ - {"test_keyword_only_parameter", (PyCFunction)(void(*)(void))test_keyword_only_parameter, METH_FASTCALL|METH_KEYWORDS, test_keyword_only_parameter__doc__}, + {"test_keyword_only_parameter", _PyCFunction_CAST(test_keyword_only_parameter), METH_FASTCALL|METH_KEYWORDS, test_keyword_only_parameter__doc__}, static PyObject * test_keyword_only_parameter_impl(PyObject *module, PyBytesObject *co_lnotab); @@ -3198,7 +3198,7 @@ exit: static PyObject * test_keyword_only_parameter_impl(PyObject *module, PyBytesObject *co_lnotab) -/*[clinic end generated code: output=f25914b402039493 input=303df5046c7e37a3]*/ +/*[clinic end generated code: output=332b5f4b444c5d55 input=303df5046c7e37a3]*/ /*[clinic input] @@ -3321,7 +3321,7 @@ PyDoc_STRVAR(test_vararg_and_posonly__doc__, "\n"); #define TEST_VARARG_AND_POSONLY_METHODDEF \ - {"test_vararg_and_posonly", (PyCFunction)(void(*)(void))test_vararg_and_posonly, METH_FASTCALL, test_vararg_and_posonly__doc__}, + {"test_vararg_and_posonly", _PyCFunction_CAST(test_vararg_and_posonly), METH_FASTCALL, test_vararg_and_posonly__doc__}, static PyObject * test_vararg_and_posonly_impl(PyObject *module, PyObject *a, PyObject *args); @@ -3350,7 +3350,7 @@ exit: static PyObject * test_vararg_and_posonly_impl(PyObject *module, PyObject *a, PyObject *args) -/*[clinic end generated code: output=ada613d2d87c9341 input=08dc2bf7afbf1613]*/ +/*[clinic end generated code: output=548bca3a127c22c1 input=08dc2bf7afbf1613]*/ /*[clinic input] test_vararg @@ -3367,7 +3367,7 @@ PyDoc_STRVAR(test_vararg__doc__, "\n"); #define TEST_VARARG_METHODDEF \ - {"test_vararg", (PyCFunction)(void(*)(void))test_vararg, METH_FASTCALL|METH_KEYWORDS, test_vararg__doc__}, + {"test_vararg", _PyCFunction_CAST(test_vararg), METH_FASTCALL|METH_KEYWORDS, test_vararg__doc__}, static PyObject * test_vararg_impl(PyObject *module, PyObject *a, PyObject *args); @@ -3398,7 +3398,7 @@ exit: static PyObject * test_vararg_impl(PyObject *module, PyObject *a, PyObject *args) -/*[clinic end generated code: output=f721025731c3bfe8 input=81d33815ad1bae6e]*/ +/*[clinic end generated code: output=a2baf8c1fade41d2 input=81d33815ad1bae6e]*/ /*[clinic input] test_vararg_with_default @@ -3416,7 +3416,7 @@ PyDoc_STRVAR(test_vararg_with_default__doc__, "\n"); #define TEST_VARARG_WITH_DEFAULT_METHODDEF \ - {"test_vararg_with_default", (PyCFunction)(void(*)(void))test_vararg_with_default, METH_FASTCALL|METH_KEYWORDS, test_vararg_with_default__doc__}, + {"test_vararg_with_default", _PyCFunction_CAST(test_vararg_with_default), METH_FASTCALL|METH_KEYWORDS, test_vararg_with_default__doc__}, static PyObject * test_vararg_with_default_impl(PyObject *module, PyObject *a, PyObject *args, @@ -3458,7 +3458,7 @@ exit: static PyObject * test_vararg_with_default_impl(PyObject *module, PyObject *a, PyObject *args, int b) -/*[clinic end generated code: output=63b34d3241c52fda input=6e110b54acd9b22d]*/ +/*[clinic end generated code: output=3821d282c29f8616 input=6e110b54acd9b22d]*/ /*[clinic input] test_vararg_with_only_defaults @@ -3476,7 +3476,7 @@ PyDoc_STRVAR(test_vararg_with_only_defaults__doc__, "\n"); #define TEST_VARARG_WITH_ONLY_DEFAULTS_METHODDEF \ - {"test_vararg_with_only_defaults", (PyCFunction)(void(*)(void))test_vararg_with_only_defaults, METH_FASTCALL|METH_KEYWORDS, test_vararg_with_only_defaults__doc__}, + {"test_vararg_with_only_defaults", _PyCFunction_CAST(test_vararg_with_only_defaults), METH_FASTCALL|METH_KEYWORDS, test_vararg_with_only_defaults__doc__}, static PyObject * test_vararg_with_only_defaults_impl(PyObject *module, PyObject *args, int b, @@ -3523,4 +3523,4 @@ exit: static PyObject * test_vararg_with_only_defaults_impl(PyObject *module, PyObject *args, int b, PyObject *c) -/*[clinic end generated code: output=dc29ce6ebc2ec10c input=fa56a709a035666e]*/ +/*[clinic end generated code: output=7e393689e6ce61a3 input=fa56a709a035666e]*/ diff --git a/Modules/_io/clinic/_iomodule.c.h b/Modules/_io/clinic/_iomodule.c.h index 1fdbe6835c717..0249dd184b1d3 100644 --- a/Modules/_io/clinic/_iomodule.c.h +++ b/Modules/_io/clinic/_iomodule.c.h @@ -122,7 +122,7 @@ PyDoc_STRVAR(_io_open__doc__, "opened in a binary mode."); #define _IO_OPEN_METHODDEF \ - {"open", (PyCFunction)(void(*)(void))_io_open, METH_FASTCALL|METH_KEYWORDS, _io_open__doc__}, + {"open", _PyCFunction_CAST(_io_open), METH_FASTCALL|METH_KEYWORDS, _io_open__doc__}, static PyObject * _io_open_impl(PyObject *module, PyObject *file, const char *mode, @@ -284,7 +284,7 @@ PyDoc_STRVAR(_io_text_encoding__doc__, "However, please consider using encoding=\"utf-8\" for new APIs."); #define _IO_TEXT_ENCODING_METHODDEF \ - {"text_encoding", (PyCFunction)(void(*)(void))_io_text_encoding, METH_FASTCALL, _io_text_encoding__doc__}, + {"text_encoding", _PyCFunction_CAST(_io_text_encoding), METH_FASTCALL, _io_text_encoding__doc__}, static PyObject * _io_text_encoding_impl(PyObject *module, PyObject *encoding, int stacklevel); @@ -324,7 +324,7 @@ PyDoc_STRVAR(_io_open_code__doc__, "with calling open(path, \'rb\')."); #define _IO_OPEN_CODE_METHODDEF \ - {"open_code", (PyCFunction)(void(*)(void))_io_open_code, METH_FASTCALL|METH_KEYWORDS, _io_open_code__doc__}, + {"open_code", _PyCFunction_CAST(_io_open_code), METH_FASTCALL|METH_KEYWORDS, _io_open_code__doc__}, static PyObject * _io_open_code_impl(PyObject *module, PyObject *path); @@ -355,4 +355,4 @@ _io_open_code(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObjec exit: return return_value; } -/*[clinic end generated code: output=e562f29e3c2533a6 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=c4d7e4ef878985f8 input=a9049054013a1b77]*/ diff --git a/Modules/_io/clinic/bufferedio.c.h b/Modules/_io/clinic/bufferedio.c.h index 2fd02329dc3e7..3700451232c16 100644 --- a/Modules/_io/clinic/bufferedio.c.h +++ b/Modules/_io/clinic/bufferedio.c.h @@ -103,7 +103,7 @@ PyDoc_STRVAR(_io__Buffered_peek__doc__, "\n"); #define _IO__BUFFERED_PEEK_METHODDEF \ - {"peek", (PyCFunction)(void(*)(void))_io__Buffered_peek, METH_FASTCALL, _io__Buffered_peek__doc__}, + {"peek", _PyCFunction_CAST(_io__Buffered_peek), METH_FASTCALL, _io__Buffered_peek__doc__}, static PyObject * _io__Buffered_peek_impl(buffered *self, Py_ssize_t size); @@ -145,7 +145,7 @@ PyDoc_STRVAR(_io__Buffered_read__doc__, "\n"); #define _IO__BUFFERED_READ_METHODDEF \ - {"read", (PyCFunction)(void(*)(void))_io__Buffered_read, METH_FASTCALL, _io__Buffered_read__doc__}, + {"read", _PyCFunction_CAST(_io__Buffered_read), METH_FASTCALL, _io__Buffered_read__doc__}, static PyObject * _io__Buffered_read_impl(buffered *self, Py_ssize_t n); @@ -178,7 +178,7 @@ PyDoc_STRVAR(_io__Buffered_read1__doc__, "\n"); #define _IO__BUFFERED_READ1_METHODDEF \ - {"read1", (PyCFunction)(void(*)(void))_io__Buffered_read1, METH_FASTCALL, _io__Buffered_read1__doc__}, + {"read1", _PyCFunction_CAST(_io__Buffered_read1), METH_FASTCALL, _io__Buffered_read1__doc__}, static PyObject * _io__Buffered_read1_impl(buffered *self, Py_ssize_t n); @@ -294,7 +294,7 @@ PyDoc_STRVAR(_io__Buffered_readline__doc__, "\n"); #define _IO__BUFFERED_READLINE_METHODDEF \ - {"readline", (PyCFunction)(void(*)(void))_io__Buffered_readline, METH_FASTCALL, _io__Buffered_readline__doc__}, + {"readline", _PyCFunction_CAST(_io__Buffered_readline), METH_FASTCALL, _io__Buffered_readline__doc__}, static PyObject * _io__Buffered_readline_impl(buffered *self, Py_ssize_t size); @@ -327,7 +327,7 @@ PyDoc_STRVAR(_io__Buffered_seek__doc__, "\n"); #define _IO__BUFFERED_SEEK_METHODDEF \ - {"seek", (PyCFunction)(void(*)(void))_io__Buffered_seek, METH_FASTCALL, _io__Buffered_seek__doc__}, + {"seek", _PyCFunction_CAST(_io__Buffered_seek), METH_FASTCALL, _io__Buffered_seek__doc__}, static PyObject * _io__Buffered_seek_impl(buffered *self, PyObject *targetobj, int whence); @@ -363,7 +363,7 @@ PyDoc_STRVAR(_io__Buffered_truncate__doc__, "\n"); #define _IO__BUFFERED_TRUNCATE_METHODDEF \ - {"truncate", (PyCFunction)(void(*)(void))_io__Buffered_truncate, METH_FASTCALL, _io__Buffered_truncate__doc__}, + {"truncate", _PyCFunction_CAST(_io__Buffered_truncate), METH_FASTCALL, _io__Buffered_truncate__doc__}, static PyObject * _io__Buffered_truncate_impl(buffered *self, PyObject *pos); @@ -638,4 +638,4 @@ _io_BufferedRandom___init__(PyObject *self, PyObject *args, PyObject *kwargs) exit: return return_value; } -/*[clinic end generated code: output=79138a088729b5ee input=a9049054013a1b77]*/ +/*[clinic end generated code: output=820461c6b0e29e48 input=a9049054013a1b77]*/ diff --git a/Modules/_io/clinic/bytesio.c.h b/Modules/_io/clinic/bytesio.c.h index 5ea80ae01c14e..049d3473110f7 100644 --- a/Modules/_io/clinic/bytesio.c.h +++ b/Modules/_io/clinic/bytesio.c.h @@ -158,7 +158,7 @@ PyDoc_STRVAR(_io_BytesIO_read__doc__, "Return an empty bytes object at EOF."); #define _IO_BYTESIO_READ_METHODDEF \ - {"read", (PyCFunction)(void(*)(void))_io_BytesIO_read, METH_FASTCALL, _io_BytesIO_read__doc__}, + {"read", _PyCFunction_CAST(_io_BytesIO_read), METH_FASTCALL, _io_BytesIO_read__doc__}, static PyObject * _io_BytesIO_read_impl(bytesio *self, Py_ssize_t size); @@ -195,7 +195,7 @@ PyDoc_STRVAR(_io_BytesIO_read1__doc__, "Return an empty bytes object at EOF."); #define _IO_BYTESIO_READ1_METHODDEF \ - {"read1", (PyCFunction)(void(*)(void))_io_BytesIO_read1, METH_FASTCALL, _io_BytesIO_read1__doc__}, + {"read1", _PyCFunction_CAST(_io_BytesIO_read1), METH_FASTCALL, _io_BytesIO_read1__doc__}, static PyObject * _io_BytesIO_read1_impl(bytesio *self, Py_ssize_t size); @@ -233,7 +233,7 @@ PyDoc_STRVAR(_io_BytesIO_readline__doc__, "Return an empty bytes object at EOF."); #define _IO_BYTESIO_READLINE_METHODDEF \ - {"readline", (PyCFunction)(void(*)(void))_io_BytesIO_readline, METH_FASTCALL, _io_BytesIO_readline__doc__}, + {"readline", _PyCFunction_CAST(_io_BytesIO_readline), METH_FASTCALL, _io_BytesIO_readline__doc__}, static PyObject * _io_BytesIO_readline_impl(bytesio *self, Py_ssize_t size); @@ -271,7 +271,7 @@ PyDoc_STRVAR(_io_BytesIO_readlines__doc__, "total number of bytes in the lines returned."); #define _IO_BYTESIO_READLINES_METHODDEF \ - {"readlines", (PyCFunction)(void(*)(void))_io_BytesIO_readlines, METH_FASTCALL, _io_BytesIO_readlines__doc__}, + {"readlines", _PyCFunction_CAST(_io_BytesIO_readlines), METH_FASTCALL, _io_BytesIO_readlines__doc__}, static PyObject * _io_BytesIO_readlines_impl(bytesio *self, PyObject *arg); @@ -347,7 +347,7 @@ PyDoc_STRVAR(_io_BytesIO_truncate__doc__, "The current file position is unchanged. Returns the new size."); #define _IO_BYTESIO_TRUNCATE_METHODDEF \ - {"truncate", (PyCFunction)(void(*)(void))_io_BytesIO_truncate, METH_FASTCALL, _io_BytesIO_truncate__doc__}, + {"truncate", _PyCFunction_CAST(_io_BytesIO_truncate), METH_FASTCALL, _io_BytesIO_truncate__doc__}, static PyObject * _io_BytesIO_truncate_impl(bytesio *self, Py_ssize_t size); @@ -387,7 +387,7 @@ PyDoc_STRVAR(_io_BytesIO_seek__doc__, "Returns the new absolute position."); #define _IO_BYTESIO_SEEK_METHODDEF \ - {"seek", (PyCFunction)(void(*)(void))_io_BytesIO_seek, METH_FASTCALL, _io_BytesIO_seek__doc__}, + {"seek", _PyCFunction_CAST(_io_BytesIO_seek), METH_FASTCALL, _io_BytesIO_seek__doc__}, static PyObject * _io_BytesIO_seek_impl(bytesio *self, Py_ssize_t pos, int whence); @@ -505,4 +505,4 @@ _io_BytesIO___init__(PyObject *self, PyObject *args, PyObject *kwargs) exit: return return_value; } -/*[clinic end generated code: output=49a32140eb8c5555 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=93d9700a6cf395b8 input=a9049054013a1b77]*/ diff --git a/Modules/_io/clinic/fileio.c.h b/Modules/_io/clinic/fileio.c.h index 9b237c156d373..bb0b36c8502ab 100644 --- a/Modules/_io/clinic/fileio.c.h +++ b/Modules/_io/clinic/fileio.c.h @@ -245,7 +245,7 @@ PyDoc_STRVAR(_io_FileIO_read__doc__, "Return an empty bytes object at EOF."); #define _IO_FILEIO_READ_METHODDEF \ - {"read", (PyCFunction)(void(*)(void))_io_FileIO_read, METH_FASTCALL, _io_FileIO_read__doc__}, + {"read", _PyCFunction_CAST(_io_FileIO_read), METH_FASTCALL, _io_FileIO_read__doc__}, static PyObject * _io_FileIO_read_impl(fileio *self, Py_ssize_t size); @@ -327,7 +327,7 @@ PyDoc_STRVAR(_io_FileIO_seek__doc__, "Note that not all file objects are seekable."); #define _IO_FILEIO_SEEK_METHODDEF \ - {"seek", (PyCFunction)(void(*)(void))_io_FileIO_seek, METH_FASTCALL, _io_FileIO_seek__doc__}, + {"seek", _PyCFunction_CAST(_io_FileIO_seek), METH_FASTCALL, _io_FileIO_seek__doc__}, static PyObject * _io_FileIO_seek_impl(fileio *self, PyObject *pos, int whence); @@ -389,7 +389,7 @@ PyDoc_STRVAR(_io_FileIO_truncate__doc__, "The current file position is changed to the value of size."); #define _IO_FILEIO_TRUNCATE_METHODDEF \ - {"truncate", (PyCFunction)(void(*)(void))_io_FileIO_truncate, METH_FASTCALL, _io_FileIO_truncate__doc__}, + {"truncate", _PyCFunction_CAST(_io_FileIO_truncate), METH_FASTCALL, _io_FileIO_truncate__doc__}, static PyObject * _io_FileIO_truncate_impl(fileio *self, PyObject *posobj); @@ -437,4 +437,4 @@ _io_FileIO_isatty(fileio *self, PyObject *Py_UNUSED(ignored)) #ifndef _IO_FILEIO_TRUNCATE_METHODDEF #define _IO_FILEIO_TRUNCATE_METHODDEF #endif /* !defined(_IO_FILEIO_TRUNCATE_METHODDEF) */ -/*[clinic end generated code: output=3479912ec0f7e029 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=fdcf0f9277d44415 input=a9049054013a1b77]*/ diff --git a/Modules/_io/clinic/iobase.c.h b/Modules/_io/clinic/iobase.c.h index 4fd6e18c4efd2..ed3fdc9bb122d 100644 --- a/Modules/_io/clinic/iobase.c.h +++ b/Modules/_io/clinic/iobase.c.h @@ -174,7 +174,7 @@ PyDoc_STRVAR(_io__IOBase_readline__doc__, "terminator(s) recognized."); #define _IO__IOBASE_READLINE_METHODDEF \ - {"readline", (PyCFunction)(void(*)(void))_io__IOBase_readline, METH_FASTCALL, _io__IOBase_readline__doc__}, + {"readline", _PyCFunction_CAST(_io__IOBase_readline), METH_FASTCALL, _io__IOBase_readline__doc__}, static PyObject * _io__IOBase_readline_impl(PyObject *self, Py_ssize_t limit); @@ -212,7 +212,7 @@ PyDoc_STRVAR(_io__IOBase_readlines__doc__, "lines so far exceeds hint."); #define _IO__IOBASE_READLINES_METHODDEF \ - {"readlines", (PyCFunction)(void(*)(void))_io__IOBase_readlines, METH_FASTCALL, _io__IOBase_readlines__doc__}, + {"readlines", _PyCFunction_CAST(_io__IOBase_readlines), METH_FASTCALL, _io__IOBase_readlines__doc__}, static PyObject * _io__IOBase_readlines_impl(PyObject *self, Py_ssize_t hint); @@ -257,7 +257,7 @@ PyDoc_STRVAR(_io__RawIOBase_read__doc__, "\n"); #define _IO__RAWIOBASE_READ_METHODDEF \ - {"read", (PyCFunction)(void(*)(void))_io__RawIOBase_read, METH_FASTCALL, _io__RawIOBase_read__doc__}, + {"read", _PyCFunction_CAST(_io__RawIOBase_read), METH_FASTCALL, _io__RawIOBase_read__doc__}, static PyObject * _io__RawIOBase_read_impl(PyObject *self, Py_ssize_t n); @@ -310,4 +310,4 @@ _io__RawIOBase_readall(PyObject *self, PyObject *Py_UNUSED(ignored)) { return _io__RawIOBase_readall_impl(self); } -/*[clinic end generated code: output=83c1361a7a51ca84 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=0362e134da2d8641 input=a9049054013a1b77]*/ diff --git a/Modules/_io/clinic/stringio.c.h b/Modules/_io/clinic/stringio.c.h index 147ef668a0b09..6758ee05f9104 100644 --- a/Modules/_io/clinic/stringio.c.h +++ b/Modules/_io/clinic/stringio.c.h @@ -48,7 +48,7 @@ PyDoc_STRVAR(_io_StringIO_read__doc__, "is reached. Return an empty string at EOF."); #define _IO_STRINGIO_READ_METHODDEF \ - {"read", (PyCFunction)(void(*)(void))_io_StringIO_read, METH_FASTCALL, _io_StringIO_read__doc__}, + {"read", _PyCFunction_CAST(_io_StringIO_read), METH_FASTCALL, _io_StringIO_read__doc__}, static PyObject * _io_StringIO_read_impl(stringio *self, Py_ssize_t size); @@ -84,7 +84,7 @@ PyDoc_STRVAR(_io_StringIO_readline__doc__, "Returns an empty string if EOF is hit immediately."); #define _IO_STRINGIO_READLINE_METHODDEF \ - {"readline", (PyCFunction)(void(*)(void))_io_StringIO_readline, METH_FASTCALL, _io_StringIO_readline__doc__}, + {"readline", _PyCFunction_CAST(_io_StringIO_readline), METH_FASTCALL, _io_StringIO_readline__doc__}, static PyObject * _io_StringIO_readline_impl(stringio *self, Py_ssize_t size); @@ -122,7 +122,7 @@ PyDoc_STRVAR(_io_StringIO_truncate__doc__, "Returns the new absolute position."); #define _IO_STRINGIO_TRUNCATE_METHODDEF \ - {"truncate", (PyCFunction)(void(*)(void))_io_StringIO_truncate, METH_FASTCALL, _io_StringIO_truncate__doc__}, + {"truncate", _PyCFunction_CAST(_io_StringIO_truncate), METH_FASTCALL, _io_StringIO_truncate__doc__}, static PyObject * _io_StringIO_truncate_impl(stringio *self, Py_ssize_t size); @@ -162,7 +162,7 @@ PyDoc_STRVAR(_io_StringIO_seek__doc__, "Returns the new absolute position."); #define _IO_STRINGIO_SEEK_METHODDEF \ - {"seek", (PyCFunction)(void(*)(void))_io_StringIO_seek, METH_FASTCALL, _io_StringIO_seek__doc__}, + {"seek", _PyCFunction_CAST(_io_StringIO_seek), METH_FASTCALL, _io_StringIO_seek__doc__}, static PyObject * _io_StringIO_seek_impl(stringio *self, Py_ssize_t pos, int whence); @@ -338,4 +338,4 @@ _io_StringIO_seekable(stringio *self, PyObject *Py_UNUSED(ignored)) { return _io_StringIO_seekable_impl(self); } -/*[clinic end generated code: output=eea93dcab10d0a97 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=3207dc548c305ad8 input=a9049054013a1b77]*/ diff --git a/Modules/_io/clinic/textio.c.h b/Modules/_io/clinic/textio.c.h index 7e81eb370fab4..907785b2beaf9 100644 --- a/Modules/_io/clinic/textio.c.h +++ b/Modules/_io/clinic/textio.c.h @@ -60,7 +60,7 @@ PyDoc_STRVAR(_io_IncrementalNewlineDecoder_decode__doc__, "\n"); #define _IO_INCREMENTALNEWLINEDECODER_DECODE_METHODDEF \ - {"decode", (PyCFunction)(void(*)(void))_io_IncrementalNewlineDecoder_decode, METH_FASTCALL|METH_KEYWORDS, _io_IncrementalNewlineDecoder_decode__doc__}, + {"decode", _PyCFunction_CAST(_io_IncrementalNewlineDecoder_decode), METH_FASTCALL|METH_KEYWORDS, _io_IncrementalNewlineDecoder_decode__doc__}, static PyObject * _io_IncrementalNewlineDecoder_decode_impl(nldecoder_object *self, @@ -285,7 +285,7 @@ PyDoc_STRVAR(_io_TextIOWrapper_reconfigure__doc__, "This also does an implicit stream flush."); #define _IO_TEXTIOWRAPPER_RECONFIGURE_METHODDEF \ - {"reconfigure", (PyCFunction)(void(*)(void))_io_TextIOWrapper_reconfigure, METH_FASTCALL|METH_KEYWORDS, _io_TextIOWrapper_reconfigure__doc__}, + {"reconfigure", _PyCFunction_CAST(_io_TextIOWrapper_reconfigure), METH_FASTCALL|METH_KEYWORDS, _io_TextIOWrapper_reconfigure__doc__}, static PyObject * _io_TextIOWrapper_reconfigure_impl(textio *self, PyObject *encoding, @@ -400,7 +400,7 @@ PyDoc_STRVAR(_io_TextIOWrapper_read__doc__, "\n"); #define _IO_TEXTIOWRAPPER_READ_METHODDEF \ - {"read", (PyCFunction)(void(*)(void))_io_TextIOWrapper_read, METH_FASTCALL, _io_TextIOWrapper_read__doc__}, + {"read", _PyCFunction_CAST(_io_TextIOWrapper_read), METH_FASTCALL, _io_TextIOWrapper_read__doc__}, static PyObject * _io_TextIOWrapper_read_impl(textio *self, Py_ssize_t n); @@ -433,7 +433,7 @@ PyDoc_STRVAR(_io_TextIOWrapper_readline__doc__, "\n"); #define _IO_TEXTIOWRAPPER_READLINE_METHODDEF \ - {"readline", (PyCFunction)(void(*)(void))_io_TextIOWrapper_readline, METH_FASTCALL, _io_TextIOWrapper_readline__doc__}, + {"readline", _PyCFunction_CAST(_io_TextIOWrapper_readline), METH_FASTCALL, _io_TextIOWrapper_readline__doc__}, static PyObject * _io_TextIOWrapper_readline_impl(textio *self, Py_ssize_t size); @@ -475,7 +475,7 @@ PyDoc_STRVAR(_io_TextIOWrapper_seek__doc__, "\n"); #define _IO_TEXTIOWRAPPER_SEEK_METHODDEF \ - {"seek", (PyCFunction)(void(*)(void))_io_TextIOWrapper_seek, METH_FASTCALL, _io_TextIOWrapper_seek__doc__}, + {"seek", _PyCFunction_CAST(_io_TextIOWrapper_seek), METH_FASTCALL, _io_TextIOWrapper_seek__doc__}, static PyObject * _io_TextIOWrapper_seek_impl(textio *self, PyObject *cookieObj, int whence); @@ -528,7 +528,7 @@ PyDoc_STRVAR(_io_TextIOWrapper_truncate__doc__, "\n"); #define _IO_TEXTIOWRAPPER_TRUNCATE_METHODDEF \ - {"truncate", (PyCFunction)(void(*)(void))_io_TextIOWrapper_truncate, METH_FASTCALL, _io_TextIOWrapper_truncate__doc__}, + {"truncate", _PyCFunction_CAST(_io_TextIOWrapper_truncate), METH_FASTCALL, _io_TextIOWrapper_truncate__doc__}, static PyObject * _io_TextIOWrapper_truncate_impl(textio *self, PyObject *pos); @@ -671,4 +671,4 @@ _io_TextIOWrapper_close(textio *self, PyObject *Py_UNUSED(ignored)) { return _io_TextIOWrapper_close_impl(self); } -/*[clinic end generated code: output=e88abad34e31c0cb input=a9049054013a1b77]*/ +/*[clinic end generated code: output=bb78b568b24759d6 input=a9049054013a1b77]*/ diff --git a/Modules/_io/clinic/winconsoleio.c.h b/Modules/_io/clinic/winconsoleio.c.h index 84e73dcaf70d4..75102a3d37156 100644 --- a/Modules/_io/clinic/winconsoleio.c.h +++ b/Modules/_io/clinic/winconsoleio.c.h @@ -249,7 +249,7 @@ PyDoc_STRVAR(_io__WindowsConsoleIO_read__doc__, "Return an empty bytes object at EOF."); #define _IO__WINDOWSCONSOLEIO_READ_METHODDEF \ - {"read", (PyCFunction)(void(*)(void))_io__WindowsConsoleIO_read, METH_FASTCALL, _io__WindowsConsoleIO_read__doc__}, + {"read", _PyCFunction_CAST(_io__WindowsConsoleIO_read), METH_FASTCALL, _io__WindowsConsoleIO_read__doc__}, static PyObject * _io__WindowsConsoleIO_read_impl(winconsoleio *self, Py_ssize_t size); @@ -378,4 +378,4 @@ _io__WindowsConsoleIO_isatty(winconsoleio *self, PyObject *Py_UNUSED(ignored)) #ifndef _IO__WINDOWSCONSOLEIO_ISATTY_METHODDEF #define _IO__WINDOWSCONSOLEIO_ISATTY_METHODDEF #endif /* !defined(_IO__WINDOWSCONSOLEIO_ISATTY_METHODDEF) */ -/*[clinic end generated code: output=48080572ffee22f5 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=2d8648fab31ec60e input=a9049054013a1b77]*/ diff --git a/Modules/_multiprocessing/clinic/multiprocessing.c.h b/Modules/_multiprocessing/clinic/multiprocessing.c.h index 7096442bd0b52..e9953215aca7d 100644 --- a/Modules/_multiprocessing/clinic/multiprocessing.c.h +++ b/Modules/_multiprocessing/clinic/multiprocessing.c.h @@ -40,7 +40,7 @@ PyDoc_STRVAR(_multiprocessing_recv__doc__, "\n"); #define _MULTIPROCESSING_RECV_METHODDEF \ - {"recv", (PyCFunction)(void(*)(void))_multiprocessing_recv, METH_FASTCALL, _multiprocessing_recv__doc__}, + {"recv", _PyCFunction_CAST(_multiprocessing_recv), METH_FASTCALL, _multiprocessing_recv__doc__}, static PyObject * _multiprocessing_recv_impl(PyObject *module, HANDLE handle, int size); @@ -72,7 +72,7 @@ PyDoc_STRVAR(_multiprocessing_send__doc__, "\n"); #define _MULTIPROCESSING_SEND_METHODDEF \ - {"send", (PyCFunction)(void(*)(void))_multiprocessing_send, METH_FASTCALL, _multiprocessing_send__doc__}, + {"send", _PyCFunction_CAST(_multiprocessing_send), METH_FASTCALL, _multiprocessing_send__doc__}, static PyObject * _multiprocessing_send_impl(PyObject *module, HANDLE handle, Py_buffer *buf); @@ -148,4 +148,4 @@ _multiprocessing_sem_unlink(PyObject *module, PyObject *arg) #ifndef _MULTIPROCESSING_SEND_METHODDEF #define _MULTIPROCESSING_SEND_METHODDEF #endif /* !defined(_MULTIPROCESSING_SEND_METHODDEF) */ -/*[clinic end generated code: output=418191c446cd5751 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=d3bbf69de578db7b input=a9049054013a1b77]*/ diff --git a/Modules/_multiprocessing/clinic/posixshmem.c.h b/Modules/_multiprocessing/clinic/posixshmem.c.h index 3424b10a569f8..be21f836b955a 100644 --- a/Modules/_multiprocessing/clinic/posixshmem.c.h +++ b/Modules/_multiprocessing/clinic/posixshmem.c.h @@ -11,7 +11,7 @@ PyDoc_STRVAR(_posixshmem_shm_open__doc__, "Open a shared memory object. Returns a file descriptor (integer)."); #define _POSIXSHMEM_SHM_OPEN_METHODDEF \ - {"shm_open", (PyCFunction)(void(*)(void))_posixshmem_shm_open, METH_FASTCALL|METH_KEYWORDS, _posixshmem_shm_open__doc__}, + {"shm_open", _PyCFunction_CAST(_posixshmem_shm_open), METH_FASTCALL|METH_KEYWORDS, _posixshmem_shm_open__doc__}, static int _posixshmem_shm_open_impl(PyObject *module, PyObject *path, int flags, @@ -79,7 +79,7 @@ PyDoc_STRVAR(_posixshmem_shm_unlink__doc__, "region."); #define _POSIXSHMEM_SHM_UNLINK_METHODDEF \ - {"shm_unlink", (PyCFunction)(void(*)(void))_posixshmem_shm_unlink, METH_FASTCALL|METH_KEYWORDS, _posixshmem_shm_unlink__doc__}, + {"shm_unlink", _PyCFunction_CAST(_posixshmem_shm_unlink), METH_FASTCALL|METH_KEYWORDS, _posixshmem_shm_unlink__doc__}, static PyObject * _posixshmem_shm_unlink_impl(PyObject *module, PyObject *path); @@ -120,4 +120,4 @@ _posixshmem_shm_unlink(PyObject *module, PyObject *const *args, Py_ssize_t nargs #ifndef _POSIXSHMEM_SHM_UNLINK_METHODDEF #define _POSIXSHMEM_SHM_UNLINK_METHODDEF #endif /* !defined(_POSIXSHMEM_SHM_UNLINK_METHODDEF) */ -/*[clinic end generated code: output=bca8e78d0f43ef1a input=a9049054013a1b77]*/ +/*[clinic end generated code: output=a6db931a47d36e1b input=a9049054013a1b77]*/ diff --git a/Modules/_multiprocessing/clinic/semaphore.c.h b/Modules/_multiprocessing/clinic/semaphore.c.h index 018447ad137ba..adb47476c0187 100644 --- a/Modules/_multiprocessing/clinic/semaphore.c.h +++ b/Modules/_multiprocessing/clinic/semaphore.c.h @@ -11,7 +11,7 @@ PyDoc_STRVAR(_multiprocessing_SemLock_acquire__doc__, "Acquire the semaphore/lock."); #define _MULTIPROCESSING_SEMLOCK_ACQUIRE_METHODDEF \ - {"acquire", (PyCFunction)(void(*)(void))_multiprocessing_SemLock_acquire, METH_FASTCALL|METH_KEYWORDS, _multiprocessing_SemLock_acquire__doc__}, + {"acquire", _PyCFunction_CAST(_multiprocessing_SemLock_acquire), METH_FASTCALL|METH_KEYWORDS, _multiprocessing_SemLock_acquire__doc__}, static PyObject * _multiprocessing_SemLock_acquire_impl(SemLockObject *self, int blocking, @@ -85,7 +85,7 @@ PyDoc_STRVAR(_multiprocessing_SemLock_acquire__doc__, "Acquire the semaphore/lock."); #define _MULTIPROCESSING_SEMLOCK_ACQUIRE_METHODDEF \ - {"acquire", (PyCFunction)(void(*)(void))_multiprocessing_SemLock_acquire, METH_FASTCALL|METH_KEYWORDS, _multiprocessing_SemLock_acquire__doc__}, + {"acquire", _PyCFunction_CAST(_multiprocessing_SemLock_acquire), METH_FASTCALL|METH_KEYWORDS, _multiprocessing_SemLock_acquire__doc__}, static PyObject * _multiprocessing_SemLock_acquire_impl(SemLockObject *self, int blocking, @@ -220,7 +220,7 @@ PyDoc_STRVAR(_multiprocessing_SemLock__rebuild__doc__, "\n"); #define _MULTIPROCESSING_SEMLOCK__REBUILD_METHODDEF \ - {"_rebuild", (PyCFunction)(void(*)(void))_multiprocessing_SemLock__rebuild, METH_FASTCALL|METH_CLASS, _multiprocessing_SemLock__rebuild__doc__}, + {"_rebuild", _PyCFunction_CAST(_multiprocessing_SemLock__rebuild), METH_FASTCALL|METH_CLASS, _multiprocessing_SemLock__rebuild__doc__}, static PyObject * _multiprocessing_SemLock__rebuild_impl(PyTypeObject *type, SEM_HANDLE handle, @@ -389,7 +389,7 @@ PyDoc_STRVAR(_multiprocessing_SemLock___exit____doc__, "Exit the semaphore/lock."); #define _MULTIPROCESSING_SEMLOCK___EXIT___METHODDEF \ - {"__exit__", (PyCFunction)(void(*)(void))_multiprocessing_SemLock___exit__, METH_FASTCALL, _multiprocessing_SemLock___exit____doc__}, + {"__exit__", _PyCFunction_CAST(_multiprocessing_SemLock___exit__), METH_FASTCALL, _multiprocessing_SemLock___exit____doc__}, static PyObject * _multiprocessing_SemLock___exit___impl(SemLockObject *self, @@ -467,4 +467,4 @@ _multiprocessing_SemLock___exit__(SemLockObject *self, PyObject *const *args, Py #ifndef _MULTIPROCESSING_SEMLOCK___EXIT___METHODDEF #define _MULTIPROCESSING_SEMLOCK___EXIT___METHODDEF #endif /* !defined(_MULTIPROCESSING_SEMLOCK___EXIT___METHODDEF) */ -/*[clinic end generated code: output=fde05a081b5bdba4 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=64ba32544811c9e6 input=a9049054013a1b77]*/ diff --git a/Modules/_sqlite/clinic/blob.c.h b/Modules/_sqlite/clinic/blob.c.h index 237877a9b37f1..b467c99e2eb5f 100644 --- a/Modules/_sqlite/clinic/blob.c.h +++ b/Modules/_sqlite/clinic/blob.c.h @@ -34,7 +34,7 @@ PyDoc_STRVAR(blob_read__doc__, "end of the blob."); #define BLOB_READ_METHODDEF \ - {"read", (PyCFunction)(void(*)(void))blob_read, METH_FASTCALL, blob_read__doc__}, + {"read", _PyCFunction_CAST(blob_read), METH_FASTCALL, blob_read__doc__}, static PyObject * blob_read_impl(pysqlite_Blob *self, int length); @@ -112,7 +112,7 @@ PyDoc_STRVAR(blob_seek__doc__, "and os.SEEK_END (seek relative to the blob\'s end)."); #define BLOB_SEEK_METHODDEF \ - {"seek", (PyCFunction)(void(*)(void))blob_seek, METH_FASTCALL, blob_seek__doc__}, + {"seek", _PyCFunction_CAST(blob_seek), METH_FASTCALL, blob_seek__doc__}, static PyObject * blob_seek_impl(pysqlite_Blob *self, int offset, int origin); @@ -188,7 +188,7 @@ PyDoc_STRVAR(blob_exit__doc__, "Blob context manager exit."); #define BLOB_EXIT_METHODDEF \ - {"__exit__", (PyCFunction)(void(*)(void))blob_exit, METH_FASTCALL, blob_exit__doc__}, + {"__exit__", _PyCFunction_CAST(blob_exit), METH_FASTCALL, blob_exit__doc__}, static PyObject * blob_exit_impl(pysqlite_Blob *self, PyObject *type, PyObject *val, @@ -213,4 +213,4 @@ blob_exit(pysqlite_Blob *self, PyObject *const *args, Py_ssize_t nargs) exit: return return_value; } -/*[clinic end generated code: output=ca2400862c18dadb input=a9049054013a1b77]*/ +/*[clinic end generated code: output=382cbf0977bb158a input=a9049054013a1b77]*/ diff --git a/Modules/_sqlite/clinic/connection.c.h b/Modules/_sqlite/clinic/connection.c.h index b012c4d4bbfa3..1e27c5e0afb12 100644 --- a/Modules/_sqlite/clinic/connection.c.h +++ b/Modules/_sqlite/clinic/connection.c.h @@ -115,7 +115,7 @@ PyDoc_STRVAR(pysqlite_connection_cursor__doc__, "Return a cursor for the connection."); #define PYSQLITE_CONNECTION_CURSOR_METHODDEF \ - {"cursor", (PyCFunction)(void(*)(void))pysqlite_connection_cursor, METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_cursor__doc__}, + {"cursor", _PyCFunction_CAST(pysqlite_connection_cursor), METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_cursor__doc__}, static PyObject * pysqlite_connection_cursor_impl(pysqlite_Connection *self, PyObject *factory); @@ -163,7 +163,7 @@ PyDoc_STRVAR(blobopen__doc__, " Database name."); #define BLOBOPEN_METHODDEF \ - {"blobopen", (PyCFunction)(void(*)(void))blobopen, METH_FASTCALL|METH_KEYWORDS, blobopen__doc__}, + {"blobopen", _PyCFunction_CAST(blobopen), METH_FASTCALL|METH_KEYWORDS, blobopen__doc__}, static PyObject * blobopen_impl(pysqlite_Connection *self, const char *table, const char *col, @@ -310,7 +310,7 @@ PyDoc_STRVAR(pysqlite_connection_create_function__doc__, "Creates a new function."); #define PYSQLITE_CONNECTION_CREATE_FUNCTION_METHODDEF \ - {"create_function", (PyCFunction)(void(*)(void))pysqlite_connection_create_function, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_create_function__doc__}, + {"create_function", _PyCFunction_CAST(pysqlite_connection_create_function), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_create_function__doc__}, static PyObject * pysqlite_connection_create_function_impl(pysqlite_Connection *self, @@ -385,7 +385,7 @@ PyDoc_STRVAR(create_window_function__doc__, " Set to None to clear the window function."); #define CREATE_WINDOW_FUNCTION_METHODDEF \ - {"create_window_function", (PyCFunction)(void(*)(void))create_window_function, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, create_window_function__doc__}, + {"create_window_function", _PyCFunction_CAST(create_window_function), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, create_window_function__doc__}, static PyObject * create_window_function_impl(pysqlite_Connection *self, PyTypeObject *cls, @@ -440,7 +440,7 @@ PyDoc_STRVAR(pysqlite_connection_create_aggregate__doc__, "Creates a new aggregate."); #define PYSQLITE_CONNECTION_CREATE_AGGREGATE_METHODDEF \ - {"create_aggregate", (PyCFunction)(void(*)(void))pysqlite_connection_create_aggregate, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_create_aggregate__doc__}, + {"create_aggregate", _PyCFunction_CAST(pysqlite_connection_create_aggregate), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_create_aggregate__doc__}, static PyObject * pysqlite_connection_create_aggregate_impl(pysqlite_Connection *self, @@ -494,7 +494,7 @@ PyDoc_STRVAR(pysqlite_connection_set_authorizer__doc__, "Sets authorizer callback."); #define PYSQLITE_CONNECTION_SET_AUTHORIZER_METHODDEF \ - {"set_authorizer", (PyCFunction)(void(*)(void))pysqlite_connection_set_authorizer, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_set_authorizer__doc__}, + {"set_authorizer", _PyCFunction_CAST(pysqlite_connection_set_authorizer), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_set_authorizer__doc__}, static PyObject * pysqlite_connection_set_authorizer_impl(pysqlite_Connection *self, @@ -528,7 +528,7 @@ PyDoc_STRVAR(pysqlite_connection_set_progress_handler__doc__, "Sets progress handler callback."); #define PYSQLITE_CONNECTION_SET_PROGRESS_HANDLER_METHODDEF \ - {"set_progress_handler", (PyCFunction)(void(*)(void))pysqlite_connection_set_progress_handler, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_set_progress_handler__doc__}, + {"set_progress_handler", _PyCFunction_CAST(pysqlite_connection_set_progress_handler), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_set_progress_handler__doc__}, static PyObject * pysqlite_connection_set_progress_handler_impl(pysqlite_Connection *self, @@ -567,7 +567,7 @@ PyDoc_STRVAR(pysqlite_connection_set_trace_callback__doc__, "Sets a trace callback called for each SQL statement (passed as unicode)."); #define PYSQLITE_CONNECTION_SET_TRACE_CALLBACK_METHODDEF \ - {"set_trace_callback", (PyCFunction)(void(*)(void))pysqlite_connection_set_trace_callback, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_set_trace_callback__doc__}, + {"set_trace_callback", _PyCFunction_CAST(pysqlite_connection_set_trace_callback), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_set_trace_callback__doc__}, static PyObject * pysqlite_connection_set_trace_callback_impl(pysqlite_Connection *self, @@ -676,7 +676,7 @@ PyDoc_STRVAR(pysqlite_connection_execute__doc__, "Executes an SQL statement."); #define PYSQLITE_CONNECTION_EXECUTE_METHODDEF \ - {"execute", (PyCFunction)(void(*)(void))pysqlite_connection_execute, METH_FASTCALL, pysqlite_connection_execute__doc__}, + {"execute", _PyCFunction_CAST(pysqlite_connection_execute), METH_FASTCALL, pysqlite_connection_execute__doc__}, static PyObject * pysqlite_connection_execute_impl(pysqlite_Connection *self, PyObject *sql, @@ -718,7 +718,7 @@ PyDoc_STRVAR(pysqlite_connection_executemany__doc__, "Repeatedly executes an SQL statement."); #define PYSQLITE_CONNECTION_EXECUTEMANY_METHODDEF \ - {"executemany", (PyCFunction)(void(*)(void))pysqlite_connection_executemany, METH_FASTCALL, pysqlite_connection_executemany__doc__}, + {"executemany", _PyCFunction_CAST(pysqlite_connection_executemany), METH_FASTCALL, pysqlite_connection_executemany__doc__}, static PyObject * pysqlite_connection_executemany_impl(pysqlite_Connection *self, @@ -802,7 +802,7 @@ PyDoc_STRVAR(pysqlite_connection_backup__doc__, "Makes a backup of the database."); #define PYSQLITE_CONNECTION_BACKUP_METHODDEF \ - {"backup", (PyCFunction)(void(*)(void))pysqlite_connection_backup, METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_backup__doc__}, + {"backup", _PyCFunction_CAST(pysqlite_connection_backup), METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_backup__doc__}, static PyObject * pysqlite_connection_backup_impl(pysqlite_Connection *self, @@ -893,7 +893,7 @@ PyDoc_STRVAR(pysqlite_connection_create_collation__doc__, "Creates a collation function."); #define PYSQLITE_CONNECTION_CREATE_COLLATION_METHODDEF \ - {"create_collation", (PyCFunction)(void(*)(void))pysqlite_connection_create_collation, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_create_collation__doc__}, + {"create_collation", _PyCFunction_CAST(pysqlite_connection_create_collation), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_create_collation__doc__}, static PyObject * pysqlite_connection_create_collation_impl(pysqlite_Connection *self, @@ -952,7 +952,7 @@ PyDoc_STRVAR(serialize__doc__, "were backed up to disk."); #define SERIALIZE_METHODDEF \ - {"serialize", (PyCFunction)(void(*)(void))serialize, METH_FASTCALL|METH_KEYWORDS, serialize__doc__}, + {"serialize", _PyCFunction_CAST(serialize), METH_FASTCALL|METH_KEYWORDS, serialize__doc__}, static PyObject * serialize_impl(pysqlite_Connection *self, const char *name); @@ -1017,7 +1017,7 @@ PyDoc_STRVAR(deserialize__doc__, "currently in a read transaction or is involved in a backup operation."); #define DESERIALIZE_METHODDEF \ - {"deserialize", (PyCFunction)(void(*)(void))deserialize, METH_FASTCALL|METH_KEYWORDS, deserialize__doc__}, + {"deserialize", _PyCFunction_CAST(deserialize), METH_FASTCALL|METH_KEYWORDS, deserialize__doc__}, static PyObject * deserialize_impl(pysqlite_Connection *self, Py_buffer *data, @@ -1114,7 +1114,7 @@ PyDoc_STRVAR(pysqlite_connection_exit__doc__, "If there was any exception, a rollback takes place; otherwise we commit."); #define PYSQLITE_CONNECTION_EXIT_METHODDEF \ - {"__exit__", (PyCFunction)(void(*)(void))pysqlite_connection_exit, METH_FASTCALL, pysqlite_connection_exit__doc__}, + {"__exit__", _PyCFunction_CAST(pysqlite_connection_exit), METH_FASTCALL, pysqlite_connection_exit__doc__}, static PyObject * pysqlite_connection_exit_impl(pysqlite_Connection *self, PyObject *exc_type, @@ -1157,7 +1157,7 @@ PyDoc_STRVAR(setlimit__doc__, "the prior value of the limit is returned."); #define SETLIMIT_METHODDEF \ - {"setlimit", (PyCFunction)(void(*)(void))setlimit, METH_FASTCALL, setlimit__doc__}, + {"setlimit", _PyCFunction_CAST(setlimit), METH_FASTCALL, setlimit__doc__}, static PyObject * setlimit_impl(pysqlite_Connection *self, int category, int limit); @@ -1236,4 +1236,4 @@ getlimit(pysqlite_Connection *self, PyObject *arg) #ifndef DESERIALIZE_METHODDEF #define DESERIALIZE_METHODDEF #endif /* !defined(DESERIALIZE_METHODDEF) */ -/*[clinic end generated code: output=6c9432a9fe0a4f5e input=a9049054013a1b77]*/ +/*[clinic end generated code: output=d21767843c480a10 input=a9049054013a1b77]*/ diff --git a/Modules/_sqlite/clinic/cursor.c.h b/Modules/_sqlite/clinic/cursor.c.h index 561d17f45b8e7..b29c333074888 100644 --- a/Modules/_sqlite/clinic/cursor.c.h +++ b/Modules/_sqlite/clinic/cursor.c.h @@ -38,7 +38,7 @@ PyDoc_STRVAR(pysqlite_cursor_execute__doc__, "Executes an SQL statement."); #define PYSQLITE_CURSOR_EXECUTE_METHODDEF \ - {"execute", (PyCFunction)(void(*)(void))pysqlite_cursor_execute, METH_FASTCALL, pysqlite_cursor_execute__doc__}, + {"execute", _PyCFunction_CAST(pysqlite_cursor_execute), METH_FASTCALL, pysqlite_cursor_execute__doc__}, static PyObject * pysqlite_cursor_execute_impl(pysqlite_Cursor *self, PyObject *sql, @@ -80,7 +80,7 @@ PyDoc_STRVAR(pysqlite_cursor_executemany__doc__, "Repeatedly executes an SQL statement."); #define PYSQLITE_CURSOR_EXECUTEMANY_METHODDEF \ - {"executemany", (PyCFunction)(void(*)(void))pysqlite_cursor_executemany, METH_FASTCALL, pysqlite_cursor_executemany__doc__}, + {"executemany", _PyCFunction_CAST(pysqlite_cursor_executemany), METH_FASTCALL, pysqlite_cursor_executemany__doc__}, static PyObject * pysqlite_cursor_executemany_impl(pysqlite_Cursor *self, PyObject *sql, @@ -177,7 +177,7 @@ PyDoc_STRVAR(pysqlite_cursor_fetchmany__doc__, " The default value is set by the Cursor.arraysize attribute."); #define PYSQLITE_CURSOR_FETCHMANY_METHODDEF \ - {"fetchmany", (PyCFunction)(void(*)(void))pysqlite_cursor_fetchmany, METH_FASTCALL|METH_KEYWORDS, pysqlite_cursor_fetchmany__doc__}, + {"fetchmany", _PyCFunction_CAST(pysqlite_cursor_fetchmany), METH_FASTCALL|METH_KEYWORDS, pysqlite_cursor_fetchmany__doc__}, static PyObject * pysqlite_cursor_fetchmany_impl(pysqlite_Cursor *self, int maxrows); @@ -244,7 +244,7 @@ PyDoc_STRVAR(pysqlite_cursor_setoutputsize__doc__, "Required by DB-API. Does nothing in sqlite3."); #define PYSQLITE_CURSOR_SETOUTPUTSIZE_METHODDEF \ - {"setoutputsize", (PyCFunction)(void(*)(void))pysqlite_cursor_setoutputsize, METH_FASTCALL, pysqlite_cursor_setoutputsize__doc__}, + {"setoutputsize", _PyCFunction_CAST(pysqlite_cursor_setoutputsize), METH_FASTCALL, pysqlite_cursor_setoutputsize__doc__}, static PyObject * pysqlite_cursor_setoutputsize_impl(pysqlite_Cursor *self, PyObject *size, @@ -289,4 +289,4 @@ pysqlite_cursor_close(pysqlite_Cursor *self, PyObject *Py_UNUSED(ignored)) { return pysqlite_cursor_close_impl(self); } -/*[clinic end generated code: output=bde165664155b2bf input=a9049054013a1b77]*/ +/*[clinic end generated code: output=2b9c6a3ca8a8caff input=a9049054013a1b77]*/ diff --git a/Modules/_sqlite/clinic/module.c.h b/Modules/_sqlite/clinic/module.c.h index f3e0e054a3d2f..8f7008adef2b1 100644 --- a/Modules/_sqlite/clinic/module.c.h +++ b/Modules/_sqlite/clinic/module.c.h @@ -14,7 +14,7 @@ PyDoc_STRVAR(pysqlite_connect__doc__, "in RAM instead of on disk."); #define PYSQLITE_CONNECT_METHODDEF \ - {"connect", (PyCFunction)(void(*)(void))pysqlite_connect, METH_FASTCALL|METH_KEYWORDS, pysqlite_connect__doc__}, + {"connect", _PyCFunction_CAST(pysqlite_connect), METH_FASTCALL|METH_KEYWORDS, pysqlite_connect__doc__}, static PyObject * pysqlite_connect_impl(PyObject *module, PyObject *database, double timeout, @@ -121,7 +121,7 @@ PyDoc_STRVAR(pysqlite_complete_statement__doc__, "Checks if a string contains a complete SQL statement."); #define PYSQLITE_COMPLETE_STATEMENT_METHODDEF \ - {"complete_statement", (PyCFunction)(void(*)(void))pysqlite_complete_statement, METH_FASTCALL|METH_KEYWORDS, pysqlite_complete_statement__doc__}, + {"complete_statement", _PyCFunction_CAST(pysqlite_complete_statement), METH_FASTCALL|METH_KEYWORDS, pysqlite_complete_statement__doc__}, static PyObject * pysqlite_complete_statement_impl(PyObject *module, const char *statement); @@ -170,7 +170,7 @@ PyDoc_STRVAR(pysqlite_enable_shared_cache__doc__, "the cache=shared query parameter."); #define PYSQLITE_ENABLE_SHARED_CACHE_METHODDEF \ - {"enable_shared_cache", (PyCFunction)(void(*)(void))pysqlite_enable_shared_cache, METH_FASTCALL|METH_KEYWORDS, pysqlite_enable_shared_cache__doc__}, + {"enable_shared_cache", _PyCFunction_CAST(pysqlite_enable_shared_cache), METH_FASTCALL|METH_KEYWORDS, pysqlite_enable_shared_cache__doc__}, static PyObject * pysqlite_enable_shared_cache_impl(PyObject *module, int do_enable); @@ -205,7 +205,7 @@ PyDoc_STRVAR(pysqlite_register_adapter__doc__, "Registers an adapter with sqlite3\'s adapter registry."); #define PYSQLITE_REGISTER_ADAPTER_METHODDEF \ - {"register_adapter", (PyCFunction)(void(*)(void))pysqlite_register_adapter, METH_FASTCALL, pysqlite_register_adapter__doc__}, + {"register_adapter", _PyCFunction_CAST(pysqlite_register_adapter), METH_FASTCALL, pysqlite_register_adapter__doc__}, static PyObject * pysqlite_register_adapter_impl(PyObject *module, PyTypeObject *type, @@ -236,7 +236,7 @@ PyDoc_STRVAR(pysqlite_register_converter__doc__, "Registers a converter with sqlite3."); #define PYSQLITE_REGISTER_CONVERTER_METHODDEF \ - {"register_converter", (PyCFunction)(void(*)(void))pysqlite_register_converter, METH_FASTCALL, pysqlite_register_converter__doc__}, + {"register_converter", _PyCFunction_CAST(pysqlite_register_converter), METH_FASTCALL, pysqlite_register_converter__doc__}, static PyObject * pysqlite_register_converter_impl(PyObject *module, PyObject *orig_name, @@ -302,7 +302,7 @@ PyDoc_STRVAR(pysqlite_adapt__doc__, "Adapt given object to given protocol."); #define PYSQLITE_ADAPT_METHODDEF \ - {"adapt", (PyCFunction)(void(*)(void))pysqlite_adapt, METH_FASTCALL, pysqlite_adapt__doc__}, + {"adapt", _PyCFunction_CAST(pysqlite_adapt), METH_FASTCALL, pysqlite_adapt__doc__}, static PyObject * pysqlite_adapt_impl(PyObject *module, PyObject *obj, PyObject *proto, @@ -334,4 +334,4 @@ pysqlite_adapt(PyObject *module, PyObject *const *args, Py_ssize_t nargs) exit: return return_value; } -/*[clinic end generated code: output=2cf05d1b089c7be4 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=d846459943008a9c input=a9049054013a1b77]*/ diff --git a/Modules/_sre/clinic/sre.c.h b/Modules/_sre/clinic/sre.c.h index c1b247ef7e9dd..e243c756e1f97 100644 --- a/Modules/_sre/clinic/sre.c.h +++ b/Modules/_sre/clinic/sre.c.h @@ -164,7 +164,7 @@ PyDoc_STRVAR(_sre_SRE_Pattern_match__doc__, "Matches zero or more characters at the beginning of the string."); #define _SRE_SRE_PATTERN_MATCH_METHODDEF \ - {"match", (PyCFunction)(void(*)(void))_sre_SRE_Pattern_match, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_match__doc__}, + {"match", _PyCFunction_CAST(_sre_SRE_Pattern_match), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_match__doc__}, static PyObject * _sre_SRE_Pattern_match_impl(PatternObject *self, PyTypeObject *cls, @@ -234,7 +234,7 @@ PyDoc_STRVAR(_sre_SRE_Pattern_fullmatch__doc__, "Matches against all of the string."); #define _SRE_SRE_PATTERN_FULLMATCH_METHODDEF \ - {"fullmatch", (PyCFunction)(void(*)(void))_sre_SRE_Pattern_fullmatch, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_fullmatch__doc__}, + {"fullmatch", _PyCFunction_CAST(_sre_SRE_Pattern_fullmatch), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_fullmatch__doc__}, static PyObject * _sre_SRE_Pattern_fullmatch_impl(PatternObject *self, PyTypeObject *cls, @@ -306,7 +306,7 @@ PyDoc_STRVAR(_sre_SRE_Pattern_search__doc__, "Return None if no position in the string matches."); #define _SRE_SRE_PATTERN_SEARCH_METHODDEF \ - {"search", (PyCFunction)(void(*)(void))_sre_SRE_Pattern_search, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_search__doc__}, + {"search", _PyCFunction_CAST(_sre_SRE_Pattern_search), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_search__doc__}, static PyObject * _sre_SRE_Pattern_search_impl(PatternObject *self, PyTypeObject *cls, @@ -376,7 +376,7 @@ PyDoc_STRVAR(_sre_SRE_Pattern_findall__doc__, "Return a list of all non-overlapping matches of pattern in string."); #define _SRE_SRE_PATTERN_FINDALL_METHODDEF \ - {"findall", (PyCFunction)(void(*)(void))_sre_SRE_Pattern_findall, METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_findall__doc__}, + {"findall", _PyCFunction_CAST(_sre_SRE_Pattern_findall), METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_findall__doc__}, static PyObject * _sre_SRE_Pattern_findall_impl(PatternObject *self, PyObject *string, @@ -447,7 +447,7 @@ PyDoc_STRVAR(_sre_SRE_Pattern_finditer__doc__, "For each match, the iterator returns a match object."); #define _SRE_SRE_PATTERN_FINDITER_METHODDEF \ - {"finditer", (PyCFunction)(void(*)(void))_sre_SRE_Pattern_finditer, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_finditer__doc__}, + {"finditer", _PyCFunction_CAST(_sre_SRE_Pattern_finditer), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_finditer__doc__}, static PyObject * _sre_SRE_Pattern_finditer_impl(PatternObject *self, PyTypeObject *cls, @@ -516,7 +516,7 @@ PyDoc_STRVAR(_sre_SRE_Pattern_scanner__doc__, "\n"); #define _SRE_SRE_PATTERN_SCANNER_METHODDEF \ - {"scanner", (PyCFunction)(void(*)(void))_sre_SRE_Pattern_scanner, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_scanner__doc__}, + {"scanner", _PyCFunction_CAST(_sre_SRE_Pattern_scanner), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_scanner__doc__}, static PyObject * _sre_SRE_Pattern_scanner_impl(PatternObject *self, PyTypeObject *cls, @@ -586,7 +586,7 @@ PyDoc_STRVAR(_sre_SRE_Pattern_split__doc__, "Split string by the occurrences of pattern."); #define _SRE_SRE_PATTERN_SPLIT_METHODDEF \ - {"split", (PyCFunction)(void(*)(void))_sre_SRE_Pattern_split, METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_split__doc__}, + {"split", _PyCFunction_CAST(_sre_SRE_Pattern_split), METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_split__doc__}, static PyObject * _sre_SRE_Pattern_split_impl(PatternObject *self, PyObject *string, @@ -637,7 +637,7 @@ PyDoc_STRVAR(_sre_SRE_Pattern_sub__doc__, "Return the string obtained by replacing the leftmost non-overlapping occurrences of pattern in string by the replacement repl."); #define _SRE_SRE_PATTERN_SUB_METHODDEF \ - {"sub", (PyCFunction)(void(*)(void))_sre_SRE_Pattern_sub, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_sub__doc__}, + {"sub", _PyCFunction_CAST(_sre_SRE_Pattern_sub), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_sub__doc__}, static PyObject * _sre_SRE_Pattern_sub_impl(PatternObject *self, PyTypeObject *cls, @@ -690,7 +690,7 @@ PyDoc_STRVAR(_sre_SRE_Pattern_subn__doc__, "Return the tuple (new_string, number_of_subs_made) found by replacing the leftmost non-overlapping occurrences of pattern with the replacement repl."); #define _SRE_SRE_PATTERN_SUBN_METHODDEF \ - {"subn", (PyCFunction)(void(*)(void))_sre_SRE_Pattern_subn, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_subn__doc__}, + {"subn", _PyCFunction_CAST(_sre_SRE_Pattern_subn), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_subn__doc__}, static PyObject * _sre_SRE_Pattern_subn_impl(PatternObject *self, PyTypeObject *cls, @@ -769,7 +769,7 @@ PyDoc_STRVAR(_sre_compile__doc__, "\n"); #define _SRE_COMPILE_METHODDEF \ - {"compile", (PyCFunction)(void(*)(void))_sre_compile, METH_FASTCALL|METH_KEYWORDS, _sre_compile__doc__}, + {"compile", _PyCFunction_CAST(_sre_compile), METH_FASTCALL|METH_KEYWORDS, _sre_compile__doc__}, static PyObject * _sre_compile_impl(PyObject *module, PyObject *pattern, int flags, @@ -852,7 +852,7 @@ PyDoc_STRVAR(_sre_SRE_Match_expand__doc__, "Return the string obtained by doing backslash substitution on the string template, as done by the sub() method."); #define _SRE_SRE_MATCH_EXPAND_METHODDEF \ - {"expand", (PyCFunction)(void(*)(void))_sre_SRE_Match_expand, METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Match_expand__doc__}, + {"expand", _PyCFunction_CAST(_sre_SRE_Match_expand), METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Match_expand__doc__}, static PyObject * _sre_SRE_Match_expand_impl(MatchObject *self, PyObject *template); @@ -887,7 +887,7 @@ PyDoc_STRVAR(_sre_SRE_Match_groups__doc__, " Is used for groups that did not participate in the match."); #define _SRE_SRE_MATCH_GROUPS_METHODDEF \ - {"groups", (PyCFunction)(void(*)(void))_sre_SRE_Match_groups, METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Match_groups__doc__}, + {"groups", _PyCFunction_CAST(_sre_SRE_Match_groups), METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Match_groups__doc__}, static PyObject * _sre_SRE_Match_groups_impl(MatchObject *self, PyObject *default_value); @@ -927,7 +927,7 @@ PyDoc_STRVAR(_sre_SRE_Match_groupdict__doc__, " Is used for groups that did not participate in the match."); #define _SRE_SRE_MATCH_GROUPDICT_METHODDEF \ - {"groupdict", (PyCFunction)(void(*)(void))_sre_SRE_Match_groupdict, METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Match_groupdict__doc__}, + {"groupdict", _PyCFunction_CAST(_sre_SRE_Match_groupdict), METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Match_groupdict__doc__}, static PyObject * _sre_SRE_Match_groupdict_impl(MatchObject *self, PyObject *default_value); @@ -964,7 +964,7 @@ PyDoc_STRVAR(_sre_SRE_Match_start__doc__, "Return index of the start of the substring matched by group."); #define _SRE_SRE_MATCH_START_METHODDEF \ - {"start", (PyCFunction)(void(*)(void))_sre_SRE_Match_start, METH_FASTCALL, _sre_SRE_Match_start__doc__}, + {"start", _PyCFunction_CAST(_sre_SRE_Match_start), METH_FASTCALL, _sre_SRE_Match_start__doc__}, static Py_ssize_t _sre_SRE_Match_start_impl(MatchObject *self, PyObject *group); @@ -1001,7 +1001,7 @@ PyDoc_STRVAR(_sre_SRE_Match_end__doc__, "Return index of the end of the substring matched by group."); #define _SRE_SRE_MATCH_END_METHODDEF \ - {"end", (PyCFunction)(void(*)(void))_sre_SRE_Match_end, METH_FASTCALL, _sre_SRE_Match_end__doc__}, + {"end", _PyCFunction_CAST(_sre_SRE_Match_end), METH_FASTCALL, _sre_SRE_Match_end__doc__}, static Py_ssize_t _sre_SRE_Match_end_impl(MatchObject *self, PyObject *group); @@ -1038,7 +1038,7 @@ PyDoc_STRVAR(_sre_SRE_Match_span__doc__, "For match object m, return the 2-tuple (m.start(group), m.end(group))."); #define _SRE_SRE_MATCH_SPAN_METHODDEF \ - {"span", (PyCFunction)(void(*)(void))_sre_SRE_Match_span, METH_FASTCALL, _sre_SRE_Match_span__doc__}, + {"span", _PyCFunction_CAST(_sre_SRE_Match_span), METH_FASTCALL, _sre_SRE_Match_span__doc__}, static PyObject * _sre_SRE_Match_span_impl(MatchObject *self, PyObject *group); @@ -1094,7 +1094,7 @@ PyDoc_STRVAR(_sre_SRE_Scanner_match__doc__, "\n"); #define _SRE_SRE_SCANNER_MATCH_METHODDEF \ - {"match", (PyCFunction)(void(*)(void))_sre_SRE_Scanner_match, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Scanner_match__doc__}, + {"match", _PyCFunction_CAST(_sre_SRE_Scanner_match), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Scanner_match__doc__}, static PyObject * _sre_SRE_Scanner_match_impl(ScannerObject *self, PyTypeObject *cls); @@ -1115,7 +1115,7 @@ PyDoc_STRVAR(_sre_SRE_Scanner_search__doc__, "\n"); #define _SRE_SRE_SCANNER_SEARCH_METHODDEF \ - {"search", (PyCFunction)(void(*)(void))_sre_SRE_Scanner_search, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Scanner_search__doc__}, + {"search", _PyCFunction_CAST(_sre_SRE_Scanner_search), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Scanner_search__doc__}, static PyObject * _sre_SRE_Scanner_search_impl(ScannerObject *self, PyTypeObject *cls); @@ -1129,4 +1129,4 @@ _sre_SRE_Scanner_search(ScannerObject *self, PyTypeObject *cls, PyObject *const } return _sre_SRE_Scanner_search_impl(self, cls); } -/*[clinic end generated code: output=8d8200b2177cd667 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=97e7ce058366760b input=a9049054013a1b77]*/ diff --git a/Modules/_ssl/clinic/cert.c.h b/Modules/_ssl/clinic/cert.c.h index c4377128b36e2..53cedabc3f7b4 100644 --- a/Modules/_ssl/clinic/cert.c.h +++ b/Modules/_ssl/clinic/cert.c.h @@ -8,7 +8,7 @@ PyDoc_STRVAR(_ssl_Certificate_public_bytes__doc__, "\n"); #define _SSL_CERTIFICATE_PUBLIC_BYTES_METHODDEF \ - {"public_bytes", (PyCFunction)(void(*)(void))_ssl_Certificate_public_bytes, METH_FASTCALL|METH_KEYWORDS, _ssl_Certificate_public_bytes__doc__}, + {"public_bytes", _PyCFunction_CAST(_ssl_Certificate_public_bytes), METH_FASTCALL|METH_KEYWORDS, _ssl_Certificate_public_bytes__doc__}, static PyObject * _ssl_Certificate_public_bytes_impl(PySSLCertificate *self, int format); @@ -57,4 +57,4 @@ _ssl_Certificate_get_info(PySSLCertificate *self, PyObject *Py_UNUSED(ignored)) { return _ssl_Certificate_get_info_impl(self); } -/*[clinic end generated code: output=569d161749ead2da input=a9049054013a1b77]*/ +/*[clinic end generated code: output=18885c4d167d5244 input=a9049054013a1b77]*/ diff --git a/Modules/cjkcodecs/clinic/multibytecodec.c.h b/Modules/cjkcodecs/clinic/multibytecodec.c.h index 60515245490f7..8f850aa8195ca 100644 --- a/Modules/cjkcodecs/clinic/multibytecodec.c.h +++ b/Modules/cjkcodecs/clinic/multibytecodec.c.h @@ -14,7 +14,7 @@ PyDoc_STRVAR(_multibytecodec_MultibyteCodec_encode__doc__, "registered with codecs.register_error that can handle UnicodeEncodeErrors."); #define _MULTIBYTECODEC_MULTIBYTECODEC_ENCODE_METHODDEF \ - {"encode", (PyCFunction)(void(*)(void))_multibytecodec_MultibyteCodec_encode, METH_FASTCALL|METH_KEYWORDS, _multibytecodec_MultibyteCodec_encode__doc__}, + {"encode", _PyCFunction_CAST(_multibytecodec_MultibyteCodec_encode), METH_FASTCALL|METH_KEYWORDS, _multibytecodec_MultibyteCodec_encode__doc__}, static PyObject * _multibytecodec_MultibyteCodec_encode_impl(MultibyteCodecObject *self, @@ -77,7 +77,7 @@ PyDoc_STRVAR(_multibytecodec_MultibyteCodec_decode__doc__, "codecs.register_error that is able to handle UnicodeDecodeErrors.\""); #define _MULTIBYTECODEC_MULTIBYTECODEC_DECODE_METHODDEF \ - {"decode", (PyCFunction)(void(*)(void))_multibytecodec_MultibyteCodec_decode, METH_FASTCALL|METH_KEYWORDS, _multibytecodec_MultibyteCodec_decode__doc__}, + {"decode", _PyCFunction_CAST(_multibytecodec_MultibyteCodec_decode), METH_FASTCALL|METH_KEYWORDS, _multibytecodec_MultibyteCodec_decode__doc__}, static PyObject * _multibytecodec_MultibyteCodec_decode_impl(MultibyteCodecObject *self, @@ -145,7 +145,7 @@ PyDoc_STRVAR(_multibytecodec_MultibyteIncrementalEncoder_encode__doc__, "\n"); #define _MULTIBYTECODEC_MULTIBYTEINCREMENTALENCODER_ENCODE_METHODDEF \ - {"encode", (PyCFunction)(void(*)(void))_multibytecodec_MultibyteIncrementalEncoder_encode, METH_FASTCALL|METH_KEYWORDS, _multibytecodec_MultibyteIncrementalEncoder_encode__doc__}, + {"encode", _PyCFunction_CAST(_multibytecodec_MultibyteIncrementalEncoder_encode), METH_FASTCALL|METH_KEYWORDS, _multibytecodec_MultibyteIncrementalEncoder_encode__doc__}, static PyObject * _multibytecodec_MultibyteIncrementalEncoder_encode_impl(MultibyteIncrementalEncoderObject *self, @@ -251,7 +251,7 @@ PyDoc_STRVAR(_multibytecodec_MultibyteIncrementalDecoder_decode__doc__, "\n"); #define _MULTIBYTECODEC_MULTIBYTEINCREMENTALDECODER_DECODE_METHODDEF \ - {"decode", (PyCFunction)(void(*)(void))_multibytecodec_MultibyteIncrementalDecoder_decode, METH_FASTCALL|METH_KEYWORDS, _multibytecodec_MultibyteIncrementalDecoder_decode__doc__}, + {"decode", _PyCFunction_CAST(_multibytecodec_MultibyteIncrementalDecoder_decode), METH_FASTCALL|METH_KEYWORDS, _multibytecodec_MultibyteIncrementalDecoder_decode__doc__}, static PyObject * _multibytecodec_MultibyteIncrementalDecoder_decode_impl(MultibyteIncrementalDecoderObject *self, @@ -368,7 +368,7 @@ PyDoc_STRVAR(_multibytecodec_MultibyteStreamReader_read__doc__, "\n"); #define _MULTIBYTECODEC_MULTIBYTESTREAMREADER_READ_METHODDEF \ - {"read", (PyCFunction)(void(*)(void))_multibytecodec_MultibyteStreamReader_read, METH_FASTCALL, _multibytecodec_MultibyteStreamReader_read__doc__}, + {"read", _PyCFunction_CAST(_multibytecodec_MultibyteStreamReader_read), METH_FASTCALL, _multibytecodec_MultibyteStreamReader_read__doc__}, static PyObject * _multibytecodec_MultibyteStreamReader_read_impl(MultibyteStreamReaderObject *self, @@ -400,7 +400,7 @@ PyDoc_STRVAR(_multibytecodec_MultibyteStreamReader_readline__doc__, "\n"); #define _MULTIBYTECODEC_MULTIBYTESTREAMREADER_READLINE_METHODDEF \ - {"readline", (PyCFunction)(void(*)(void))_multibytecodec_MultibyteStreamReader_readline, METH_FASTCALL, _multibytecodec_MultibyteStreamReader_readline__doc__}, + {"readline", _PyCFunction_CAST(_multibytecodec_MultibyteStreamReader_readline), METH_FASTCALL, _multibytecodec_MultibyteStreamReader_readline__doc__}, static PyObject * _multibytecodec_MultibyteStreamReader_readline_impl(MultibyteStreamReaderObject *self, @@ -432,7 +432,7 @@ PyDoc_STRVAR(_multibytecodec_MultibyteStreamReader_readlines__doc__, "\n"); #define _MULTIBYTECODEC_MULTIBYTESTREAMREADER_READLINES_METHODDEF \ - {"readlines", (PyCFunction)(void(*)(void))_multibytecodec_MultibyteStreamReader_readlines, METH_FASTCALL, _multibytecodec_MultibyteStreamReader_readlines__doc__}, + {"readlines", _PyCFunction_CAST(_multibytecodec_MultibyteStreamReader_readlines), METH_FASTCALL, _multibytecodec_MultibyteStreamReader_readlines__doc__}, static PyObject * _multibytecodec_MultibyteStreamReader_readlines_impl(MultibyteStreamReaderObject *self, @@ -481,7 +481,7 @@ PyDoc_STRVAR(_multibytecodec_MultibyteStreamWriter_write__doc__, "\n"); #define _MULTIBYTECODEC_MULTIBYTESTREAMWRITER_WRITE_METHODDEF \ - {"write", (PyCFunction)(void(*)(void))_multibytecodec_MultibyteStreamWriter_write, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _multibytecodec_MultibyteStreamWriter_write__doc__}, + {"write", _PyCFunction_CAST(_multibytecodec_MultibyteStreamWriter_write), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _multibytecodec_MultibyteStreamWriter_write__doc__}, static PyObject * _multibytecodec_MultibyteStreamWriter_write_impl(MultibyteStreamWriterObject *self, @@ -514,7 +514,7 @@ PyDoc_STRVAR(_multibytecodec_MultibyteStreamWriter_writelines__doc__, "\n"); #define _MULTIBYTECODEC_MULTIBYTESTREAMWRITER_WRITELINES_METHODDEF \ - {"writelines", (PyCFunction)(void(*)(void))_multibytecodec_MultibyteStreamWriter_writelines, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _multibytecodec_MultibyteStreamWriter_writelines__doc__}, + {"writelines", _PyCFunction_CAST(_multibytecodec_MultibyteStreamWriter_writelines), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _multibytecodec_MultibyteStreamWriter_writelines__doc__}, static PyObject * _multibytecodec_MultibyteStreamWriter_writelines_impl(MultibyteStreamWriterObject *self, @@ -547,7 +547,7 @@ PyDoc_STRVAR(_multibytecodec_MultibyteStreamWriter_reset__doc__, "\n"); #define _MULTIBYTECODEC_MULTIBYTESTREAMWRITER_RESET_METHODDEF \ - {"reset", (PyCFunction)(void(*)(void))_multibytecodec_MultibyteStreamWriter_reset, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _multibytecodec_MultibyteStreamWriter_reset__doc__}, + {"reset", _PyCFunction_CAST(_multibytecodec_MultibyteStreamWriter_reset), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _multibytecodec_MultibyteStreamWriter_reset__doc__}, static PyObject * _multibytecodec_MultibyteStreamWriter_reset_impl(MultibyteStreamWriterObject *self, @@ -570,4 +570,4 @@ PyDoc_STRVAR(_multibytecodec___create_codec__doc__, #define _MULTIBYTECODEC___CREATE_CODEC_METHODDEF \ {"__create_codec", (PyCFunction)_multibytecodec___create_codec, METH_O, _multibytecodec___create_codec__doc__}, -/*[clinic end generated code: output=0ee00c9f6883afe9 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=9e4e3da5ca3c8288 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_abc.c.h b/Modules/clinic/_abc.c.h index 62c6552ba645d..8d3832e1b83d2 100644 --- a/Modules/clinic/_abc.c.h +++ b/Modules/clinic/_abc.c.h @@ -53,7 +53,7 @@ PyDoc_STRVAR(_abc__abc_register__doc__, "Internal ABC helper for subclasss registration. Should be never used outside abc module."); #define _ABC__ABC_REGISTER_METHODDEF \ - {"_abc_register", (PyCFunction)(void(*)(void))_abc__abc_register, METH_FASTCALL, _abc__abc_register__doc__}, + {"_abc_register", _PyCFunction_CAST(_abc__abc_register), METH_FASTCALL, _abc__abc_register__doc__}, static PyObject * _abc__abc_register_impl(PyObject *module, PyObject *self, PyObject *subclass); @@ -83,7 +83,7 @@ PyDoc_STRVAR(_abc__abc_instancecheck__doc__, "Internal ABC helper for instance checks. Should be never used outside abc module."); #define _ABC__ABC_INSTANCECHECK_METHODDEF \ - {"_abc_instancecheck", (PyCFunction)(void(*)(void))_abc__abc_instancecheck, METH_FASTCALL, _abc__abc_instancecheck__doc__}, + {"_abc_instancecheck", _PyCFunction_CAST(_abc__abc_instancecheck), METH_FASTCALL, _abc__abc_instancecheck__doc__}, static PyObject * _abc__abc_instancecheck_impl(PyObject *module, PyObject *self, @@ -114,7 +114,7 @@ PyDoc_STRVAR(_abc__abc_subclasscheck__doc__, "Internal ABC helper for subclasss checks. Should be never used outside abc module."); #define _ABC__ABC_SUBCLASSCHECK_METHODDEF \ - {"_abc_subclasscheck", (PyCFunction)(void(*)(void))_abc__abc_subclasscheck, METH_FASTCALL, _abc__abc_subclasscheck__doc__}, + {"_abc_subclasscheck", _PyCFunction_CAST(_abc__abc_subclasscheck), METH_FASTCALL, _abc__abc_subclasscheck__doc__}, static PyObject * _abc__abc_subclasscheck_impl(PyObject *module, PyObject *self, @@ -159,4 +159,4 @@ _abc_get_cache_token(PyObject *module, PyObject *Py_UNUSED(ignored)) { return _abc_get_cache_token_impl(module); } -/*[clinic end generated code: output=2544b4b5ae50a089 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=babb3ce445fa9b21 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_asynciomodule.c.h b/Modules/clinic/_asynciomodule.c.h index 163b0f95691b3..7cc27b8289598 100644 --- a/Modules/clinic/_asynciomodule.c.h +++ b/Modules/clinic/_asynciomodule.c.h @@ -129,7 +129,7 @@ PyDoc_STRVAR(_asyncio_Future_add_done_callback__doc__, "scheduled with call_soon."); #define _ASYNCIO_FUTURE_ADD_DONE_CALLBACK_METHODDEF \ - {"add_done_callback", (PyCFunction)(void(*)(void))_asyncio_Future_add_done_callback, METH_FASTCALL|METH_KEYWORDS, _asyncio_Future_add_done_callback__doc__}, + {"add_done_callback", _PyCFunction_CAST(_asyncio_Future_add_done_callback), METH_FASTCALL|METH_KEYWORDS, _asyncio_Future_add_done_callback__doc__}, static PyObject * _asyncio_Future_add_done_callback_impl(FutureObj *self, PyObject *fn, @@ -184,7 +184,7 @@ PyDoc_STRVAR(_asyncio_Future_cancel__doc__, "return True."); #define _ASYNCIO_FUTURE_CANCEL_METHODDEF \ - {"cancel", (PyCFunction)(void(*)(void))_asyncio_Future_cancel, METH_FASTCALL|METH_KEYWORDS, _asyncio_Future_cancel__doc__}, + {"cancel", _PyCFunction_CAST(_asyncio_Future_cancel), METH_FASTCALL|METH_KEYWORDS, _asyncio_Future_cancel__doc__}, static PyObject * _asyncio_Future_cancel_impl(FutureObj *self, PyObject *msg); @@ -392,7 +392,7 @@ PyDoc_STRVAR(_asyncio_Task_cancel__doc__, "This also increases the task\'s count of cancellation requests."); #define _ASYNCIO_TASK_CANCEL_METHODDEF \ - {"cancel", (PyCFunction)(void(*)(void))_asyncio_Task_cancel, METH_FASTCALL|METH_KEYWORDS, _asyncio_Task_cancel__doc__}, + {"cancel", _PyCFunction_CAST(_asyncio_Task_cancel), METH_FASTCALL|METH_KEYWORDS, _asyncio_Task_cancel__doc__}, static PyObject * _asyncio_Task_cancel_impl(TaskObj *self, PyObject *msg); @@ -473,7 +473,7 @@ PyDoc_STRVAR(_asyncio_Task__check_future__doc__, "Return False if task and future loops are not compatible."); #define _ASYNCIO_TASK__CHECK_FUTURE_METHODDEF \ - {"_check_future", (PyCFunction)(void(*)(void))_asyncio_Task__check_future, METH_FASTCALL|METH_KEYWORDS, _asyncio_Task__check_future__doc__}, + {"_check_future", _PyCFunction_CAST(_asyncio_Task__check_future), METH_FASTCALL|METH_KEYWORDS, _asyncio_Task__check_future__doc__}, static int _asyncio_Task__check_future_impl(TaskObj *self, PyObject *future); @@ -528,7 +528,7 @@ PyDoc_STRVAR(_asyncio_Task_get_stack__doc__, "returned for a suspended coroutine."); #define _ASYNCIO_TASK_GET_STACK_METHODDEF \ - {"get_stack", (PyCFunction)(void(*)(void))_asyncio_Task_get_stack, METH_FASTCALL|METH_KEYWORDS, _asyncio_Task_get_stack__doc__}, + {"get_stack", _PyCFunction_CAST(_asyncio_Task_get_stack), METH_FASTCALL|METH_KEYWORDS, _asyncio_Task_get_stack__doc__}, static PyObject * _asyncio_Task_get_stack_impl(TaskObj *self, PyObject *limit); @@ -571,7 +571,7 @@ PyDoc_STRVAR(_asyncio_Task_print_stack__doc__, "to sys.stderr."); #define _ASYNCIO_TASK_PRINT_STACK_METHODDEF \ - {"print_stack", (PyCFunction)(void(*)(void))_asyncio_Task_print_stack, METH_FASTCALL|METH_KEYWORDS, _asyncio_Task_print_stack__doc__}, + {"print_stack", _PyCFunction_CAST(_asyncio_Task_print_stack), METH_FASTCALL|METH_KEYWORDS, _asyncio_Task_print_stack__doc__}, static PyObject * _asyncio_Task_print_stack_impl(TaskObj *self, PyObject *limit, @@ -731,7 +731,7 @@ PyDoc_STRVAR(_asyncio__get_event_loop__doc__, "\n"); #define _ASYNCIO__GET_EVENT_LOOP_METHODDEF \ - {"_get_event_loop", (PyCFunction)(void(*)(void))_asyncio__get_event_loop, METH_FASTCALL|METH_KEYWORDS, _asyncio__get_event_loop__doc__}, + {"_get_event_loop", _PyCFunction_CAST(_asyncio__get_event_loop), METH_FASTCALL|METH_KEYWORDS, _asyncio__get_event_loop__doc__}, static PyObject * _asyncio__get_event_loop_impl(PyObject *module, int stacklevel); @@ -793,7 +793,7 @@ PyDoc_STRVAR(_asyncio__register_task__doc__, "Returns None."); #define _ASYNCIO__REGISTER_TASK_METHODDEF \ - {"_register_task", (PyCFunction)(void(*)(void))_asyncio__register_task, METH_FASTCALL|METH_KEYWORDS, _asyncio__register_task__doc__}, + {"_register_task", _PyCFunction_CAST(_asyncio__register_task), METH_FASTCALL|METH_KEYWORDS, _asyncio__register_task__doc__}, static PyObject * _asyncio__register_task_impl(PyObject *module, PyObject *task); @@ -827,7 +827,7 @@ PyDoc_STRVAR(_asyncio__unregister_task__doc__, "Returns None."); #define _ASYNCIO__UNREGISTER_TASK_METHODDEF \ - {"_unregister_task", (PyCFunction)(void(*)(void))_asyncio__unregister_task, METH_FASTCALL|METH_KEYWORDS, _asyncio__unregister_task__doc__}, + {"_unregister_task", _PyCFunction_CAST(_asyncio__unregister_task), METH_FASTCALL|METH_KEYWORDS, _asyncio__unregister_task__doc__}, static PyObject * _asyncio__unregister_task_impl(PyObject *module, PyObject *task); @@ -863,7 +863,7 @@ PyDoc_STRVAR(_asyncio__enter_task__doc__, "Returns None."); #define _ASYNCIO__ENTER_TASK_METHODDEF \ - {"_enter_task", (PyCFunction)(void(*)(void))_asyncio__enter_task, METH_FASTCALL|METH_KEYWORDS, _asyncio__enter_task__doc__}, + {"_enter_task", _PyCFunction_CAST(_asyncio__enter_task), METH_FASTCALL|METH_KEYWORDS, _asyncio__enter_task__doc__}, static PyObject * _asyncio__enter_task_impl(PyObject *module, PyObject *loop, PyObject *task); @@ -901,7 +901,7 @@ PyDoc_STRVAR(_asyncio__leave_task__doc__, "Returns None."); #define _ASYNCIO__LEAVE_TASK_METHODDEF \ - {"_leave_task", (PyCFunction)(void(*)(void))_asyncio__leave_task, METH_FASTCALL|METH_KEYWORDS, _asyncio__leave_task__doc__}, + {"_leave_task", _PyCFunction_CAST(_asyncio__leave_task), METH_FASTCALL|METH_KEYWORDS, _asyncio__leave_task__doc__}, static PyObject * _asyncio__leave_task_impl(PyObject *module, PyObject *loop, PyObject *task); @@ -927,4 +927,4 @@ _asyncio__leave_task(PyObject *module, PyObject *const *args, Py_ssize_t nargs, exit: return return_value; } -/*[clinic end generated code: output=fdb7129263a8712e input=a9049054013a1b77]*/ +/*[clinic end generated code: output=eccf150c9c30efd5 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_bisectmodule.c.h b/Modules/clinic/_bisectmodule.c.h index f118f4bbf8628..2f0a3575cc5ce 100644 --- a/Modules/clinic/_bisectmodule.c.h +++ b/Modules/clinic/_bisectmodule.c.h @@ -16,7 +16,7 @@ PyDoc_STRVAR(_bisect_bisect_right__doc__, "slice of a to be searched."); #define _BISECT_BISECT_RIGHT_METHODDEF \ - {"bisect_right", (PyCFunction)(void(*)(void))_bisect_bisect_right, METH_FASTCALL|METH_KEYWORDS, _bisect_bisect_right__doc__}, + {"bisect_right", _PyCFunction_CAST(_bisect_bisect_right), METH_FASTCALL|METH_KEYWORDS, _bisect_bisect_right__doc__}, static Py_ssize_t _bisect_bisect_right_impl(PyObject *module, PyObject *a, PyObject *x, @@ -99,7 +99,7 @@ PyDoc_STRVAR(_bisect_insort_right__doc__, "slice of a to be searched."); #define _BISECT_INSORT_RIGHT_METHODDEF \ - {"insort_right", (PyCFunction)(void(*)(void))_bisect_insort_right, METH_FASTCALL|METH_KEYWORDS, _bisect_insort_right__doc__}, + {"insort_right", _PyCFunction_CAST(_bisect_insort_right), METH_FASTCALL|METH_KEYWORDS, _bisect_insort_right__doc__}, static PyObject * _bisect_insort_right_impl(PyObject *module, PyObject *a, PyObject *x, @@ -179,7 +179,7 @@ PyDoc_STRVAR(_bisect_bisect_left__doc__, "slice of a to be searched."); #define _BISECT_BISECT_LEFT_METHODDEF \ - {"bisect_left", (PyCFunction)(void(*)(void))_bisect_bisect_left, METH_FASTCALL|METH_KEYWORDS, _bisect_bisect_left__doc__}, + {"bisect_left", _PyCFunction_CAST(_bisect_bisect_left), METH_FASTCALL|METH_KEYWORDS, _bisect_bisect_left__doc__}, static Py_ssize_t _bisect_bisect_left_impl(PyObject *module, PyObject *a, PyObject *x, @@ -262,7 +262,7 @@ PyDoc_STRVAR(_bisect_insort_left__doc__, "slice of a to be searched."); #define _BISECT_INSORT_LEFT_METHODDEF \ - {"insort_left", (PyCFunction)(void(*)(void))_bisect_insort_left, METH_FASTCALL|METH_KEYWORDS, _bisect_insort_left__doc__}, + {"insort_left", _PyCFunction_CAST(_bisect_insort_left), METH_FASTCALL|METH_KEYWORDS, _bisect_insort_left__doc__}, static PyObject * _bisect_insort_left_impl(PyObject *module, PyObject *a, PyObject *x, @@ -327,4 +327,4 @@ _bisect_insort_left(PyObject *module, PyObject *const *args, Py_ssize_t nargs, P exit: return return_value; } -/*[clinic end generated code: output=aeb97db6db79bf96 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=ee8c32ff8d3d1fac input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_bz2module.c.h b/Modules/clinic/_bz2module.c.h index 71ad0b135718a..3ed72f8bceb17 100644 --- a/Modules/clinic/_bz2module.c.h +++ b/Modules/clinic/_bz2module.c.h @@ -85,7 +85,7 @@ PyDoc_STRVAR(_bz2_BZ2Decompressor_decompress__doc__, "the unused_data attribute."); #define _BZ2_BZ2DECOMPRESSOR_DECOMPRESS_METHODDEF \ - {"decompress", (PyCFunction)(void(*)(void))_bz2_BZ2Decompressor_decompress, METH_FASTCALL|METH_KEYWORDS, _bz2_BZ2Decompressor_decompress__doc__}, + {"decompress", _PyCFunction_CAST(_bz2_BZ2Decompressor_decompress), METH_FASTCALL|METH_KEYWORDS, _bz2_BZ2Decompressor_decompress__doc__}, static PyObject * _bz2_BZ2Decompressor_decompress_impl(BZ2Decompressor *self, Py_buffer *data, @@ -139,4 +139,4 @@ _bz2_BZ2Decompressor_decompress(BZ2Decompressor *self, PyObject *const *args, Py return return_value; } -/*[clinic end generated code: output=ed10705d7a9fd598 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=a1175204a414fe2a input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_codecsmodule.c.h b/Modules/clinic/_codecsmodule.c.h index 855ac77a7f73f..29e9d5ea86aa2 100644 --- a/Modules/clinic/_codecsmodule.c.h +++ b/Modules/clinic/_codecsmodule.c.h @@ -76,7 +76,7 @@ PyDoc_STRVAR(_codecs_encode__doc__, "codecs.register_error that can handle ValueErrors."); #define _CODECS_ENCODE_METHODDEF \ - {"encode", (PyCFunction)(void(*)(void))_codecs_encode, METH_FASTCALL|METH_KEYWORDS, _codecs_encode__doc__}, + {"encode", _PyCFunction_CAST(_codecs_encode), METH_FASTCALL|METH_KEYWORDS, _codecs_encode__doc__}, static PyObject * _codecs_encode_impl(PyObject *module, PyObject *obj, const char *encoding, @@ -153,7 +153,7 @@ PyDoc_STRVAR(_codecs_decode__doc__, "codecs.register_error that can handle ValueErrors."); #define _CODECS_DECODE_METHODDEF \ - {"decode", (PyCFunction)(void(*)(void))_codecs_decode, METH_FASTCALL|METH_KEYWORDS, _codecs_decode__doc__}, + {"decode", _PyCFunction_CAST(_codecs_decode), METH_FASTCALL|METH_KEYWORDS, _codecs_decode__doc__}, static PyObject * _codecs_decode_impl(PyObject *module, PyObject *obj, const char *encoding, @@ -223,7 +223,7 @@ PyDoc_STRVAR(_codecs_escape_decode__doc__, "\n"); #define _CODECS_ESCAPE_DECODE_METHODDEF \ - {"escape_decode", (PyCFunction)(void(*)(void))_codecs_escape_decode, METH_FASTCALL, _codecs_escape_decode__doc__}, + {"escape_decode", _PyCFunction_CAST(_codecs_escape_decode), METH_FASTCALL, _codecs_escape_decode__doc__}, static PyObject * _codecs_escape_decode_impl(PyObject *module, Py_buffer *data, @@ -295,7 +295,7 @@ PyDoc_STRVAR(_codecs_escape_encode__doc__, "\n"); #define _CODECS_ESCAPE_ENCODE_METHODDEF \ - {"escape_encode", (PyCFunction)(void(*)(void))_codecs_escape_encode, METH_FASTCALL, _codecs_escape_encode__doc__}, + {"escape_encode", _PyCFunction_CAST(_codecs_escape_encode), METH_FASTCALL, _codecs_escape_encode__doc__}, static PyObject * _codecs_escape_encode_impl(PyObject *module, PyObject *data, @@ -350,7 +350,7 @@ PyDoc_STRVAR(_codecs_utf_7_decode__doc__, "\n"); #define _CODECS_UTF_7_DECODE_METHODDEF \ - {"utf_7_decode", (PyCFunction)(void(*)(void))_codecs_utf_7_decode, METH_FASTCALL, _codecs_utf_7_decode__doc__}, + {"utf_7_decode", _PyCFunction_CAST(_codecs_utf_7_decode), METH_FASTCALL, _codecs_utf_7_decode__doc__}, static PyObject * _codecs_utf_7_decode_impl(PyObject *module, Py_buffer *data, @@ -420,7 +420,7 @@ PyDoc_STRVAR(_codecs_utf_8_decode__doc__, "\n"); #define _CODECS_UTF_8_DECODE_METHODDEF \ - {"utf_8_decode", (PyCFunction)(void(*)(void))_codecs_utf_8_decode, METH_FASTCALL, _codecs_utf_8_decode__doc__}, + {"utf_8_decode", _PyCFunction_CAST(_codecs_utf_8_decode), METH_FASTCALL, _codecs_utf_8_decode__doc__}, static PyObject * _codecs_utf_8_decode_impl(PyObject *module, Py_buffer *data, @@ -490,7 +490,7 @@ PyDoc_STRVAR(_codecs_utf_16_decode__doc__, "\n"); #define _CODECS_UTF_16_DECODE_METHODDEF \ - {"utf_16_decode", (PyCFunction)(void(*)(void))_codecs_utf_16_decode, METH_FASTCALL, _codecs_utf_16_decode__doc__}, + {"utf_16_decode", _PyCFunction_CAST(_codecs_utf_16_decode), METH_FASTCALL, _codecs_utf_16_decode__doc__}, static PyObject * _codecs_utf_16_decode_impl(PyObject *module, Py_buffer *data, @@ -560,7 +560,7 @@ PyDoc_STRVAR(_codecs_utf_16_le_decode__doc__, "\n"); #define _CODECS_UTF_16_LE_DECODE_METHODDEF \ - {"utf_16_le_decode", (PyCFunction)(void(*)(void))_codecs_utf_16_le_decode, METH_FASTCALL, _codecs_utf_16_le_decode__doc__}, + {"utf_16_le_decode", _PyCFunction_CAST(_codecs_utf_16_le_decode), METH_FASTCALL, _codecs_utf_16_le_decode__doc__}, static PyObject * _codecs_utf_16_le_decode_impl(PyObject *module, Py_buffer *data, @@ -630,7 +630,7 @@ PyDoc_STRVAR(_codecs_utf_16_be_decode__doc__, "\n"); #define _CODECS_UTF_16_BE_DECODE_METHODDEF \ - {"utf_16_be_decode", (PyCFunction)(void(*)(void))_codecs_utf_16_be_decode, METH_FASTCALL, _codecs_utf_16_be_decode__doc__}, + {"utf_16_be_decode", _PyCFunction_CAST(_codecs_utf_16_be_decode), METH_FASTCALL, _codecs_utf_16_be_decode__doc__}, static PyObject * _codecs_utf_16_be_decode_impl(PyObject *module, Py_buffer *data, @@ -701,7 +701,7 @@ PyDoc_STRVAR(_codecs_utf_16_ex_decode__doc__, "\n"); #define _CODECS_UTF_16_EX_DECODE_METHODDEF \ - {"utf_16_ex_decode", (PyCFunction)(void(*)(void))_codecs_utf_16_ex_decode, METH_FASTCALL, _codecs_utf_16_ex_decode__doc__}, + {"utf_16_ex_decode", _PyCFunction_CAST(_codecs_utf_16_ex_decode), METH_FASTCALL, _codecs_utf_16_ex_decode__doc__}, static PyObject * _codecs_utf_16_ex_decode_impl(PyObject *module, Py_buffer *data, @@ -779,7 +779,7 @@ PyDoc_STRVAR(_codecs_utf_32_decode__doc__, "\n"); #define _CODECS_UTF_32_DECODE_METHODDEF \ - {"utf_32_decode", (PyCFunction)(void(*)(void))_codecs_utf_32_decode, METH_FASTCALL, _codecs_utf_32_decode__doc__}, + {"utf_32_decode", _PyCFunction_CAST(_codecs_utf_32_decode), METH_FASTCALL, _codecs_utf_32_decode__doc__}, static PyObject * _codecs_utf_32_decode_impl(PyObject *module, Py_buffer *data, @@ -849,7 +849,7 @@ PyDoc_STRVAR(_codecs_utf_32_le_decode__doc__, "\n"); #define _CODECS_UTF_32_LE_DECODE_METHODDEF \ - {"utf_32_le_decode", (PyCFunction)(void(*)(void))_codecs_utf_32_le_decode, METH_FASTCALL, _codecs_utf_32_le_decode__doc__}, + {"utf_32_le_decode", _PyCFunction_CAST(_codecs_utf_32_le_decode), METH_FASTCALL, _codecs_utf_32_le_decode__doc__}, static PyObject * _codecs_utf_32_le_decode_impl(PyObject *module, Py_buffer *data, @@ -919,7 +919,7 @@ PyDoc_STRVAR(_codecs_utf_32_be_decode__doc__, "\n"); #define _CODECS_UTF_32_BE_DECODE_METHODDEF \ - {"utf_32_be_decode", (PyCFunction)(void(*)(void))_codecs_utf_32_be_decode, METH_FASTCALL, _codecs_utf_32_be_decode__doc__}, + {"utf_32_be_decode", _PyCFunction_CAST(_codecs_utf_32_be_decode), METH_FASTCALL, _codecs_utf_32_be_decode__doc__}, static PyObject * _codecs_utf_32_be_decode_impl(PyObject *module, Py_buffer *data, @@ -990,7 +990,7 @@ PyDoc_STRVAR(_codecs_utf_32_ex_decode__doc__, "\n"); #define _CODECS_UTF_32_EX_DECODE_METHODDEF \ - {"utf_32_ex_decode", (PyCFunction)(void(*)(void))_codecs_utf_32_ex_decode, METH_FASTCALL, _codecs_utf_32_ex_decode__doc__}, + {"utf_32_ex_decode", _PyCFunction_CAST(_codecs_utf_32_ex_decode), METH_FASTCALL, _codecs_utf_32_ex_decode__doc__}, static PyObject * _codecs_utf_32_ex_decode_impl(PyObject *module, Py_buffer *data, @@ -1068,7 +1068,7 @@ PyDoc_STRVAR(_codecs_unicode_escape_decode__doc__, "\n"); #define _CODECS_UNICODE_ESCAPE_DECODE_METHODDEF \ - {"unicode_escape_decode", (PyCFunction)(void(*)(void))_codecs_unicode_escape_decode, METH_FASTCALL, _codecs_unicode_escape_decode__doc__}, + {"unicode_escape_decode", _PyCFunction_CAST(_codecs_unicode_escape_decode), METH_FASTCALL, _codecs_unicode_escape_decode__doc__}, static PyObject * _codecs_unicode_escape_decode_impl(PyObject *module, Py_buffer *data, @@ -1148,7 +1148,7 @@ PyDoc_STRVAR(_codecs_raw_unicode_escape_decode__doc__, "\n"); #define _CODECS_RAW_UNICODE_ESCAPE_DECODE_METHODDEF \ - {"raw_unicode_escape_decode", (PyCFunction)(void(*)(void))_codecs_raw_unicode_escape_decode, METH_FASTCALL, _codecs_raw_unicode_escape_decode__doc__}, + {"raw_unicode_escape_decode", _PyCFunction_CAST(_codecs_raw_unicode_escape_decode), METH_FASTCALL, _codecs_raw_unicode_escape_decode__doc__}, static PyObject * _codecs_raw_unicode_escape_decode_impl(PyObject *module, Py_buffer *data, @@ -1228,7 +1228,7 @@ PyDoc_STRVAR(_codecs_latin_1_decode__doc__, "\n"); #define _CODECS_LATIN_1_DECODE_METHODDEF \ - {"latin_1_decode", (PyCFunction)(void(*)(void))_codecs_latin_1_decode, METH_FASTCALL, _codecs_latin_1_decode__doc__}, + {"latin_1_decode", _PyCFunction_CAST(_codecs_latin_1_decode), METH_FASTCALL, _codecs_latin_1_decode__doc__}, static PyObject * _codecs_latin_1_decode_impl(PyObject *module, Py_buffer *data, @@ -1290,7 +1290,7 @@ PyDoc_STRVAR(_codecs_ascii_decode__doc__, "\n"); #define _CODECS_ASCII_DECODE_METHODDEF \ - {"ascii_decode", (PyCFunction)(void(*)(void))_codecs_ascii_decode, METH_FASTCALL, _codecs_ascii_decode__doc__}, + {"ascii_decode", _PyCFunction_CAST(_codecs_ascii_decode), METH_FASTCALL, _codecs_ascii_decode__doc__}, static PyObject * _codecs_ascii_decode_impl(PyObject *module, Py_buffer *data, @@ -1352,7 +1352,7 @@ PyDoc_STRVAR(_codecs_charmap_decode__doc__, "\n"); #define _CODECS_CHARMAP_DECODE_METHODDEF \ - {"charmap_decode", (PyCFunction)(void(*)(void))_codecs_charmap_decode, METH_FASTCALL, _codecs_charmap_decode__doc__}, + {"charmap_decode", _PyCFunction_CAST(_codecs_charmap_decode), METH_FASTCALL, _codecs_charmap_decode__doc__}, static PyObject * _codecs_charmap_decode_impl(PyObject *module, Py_buffer *data, @@ -1421,7 +1421,7 @@ PyDoc_STRVAR(_codecs_mbcs_decode__doc__, "\n"); #define _CODECS_MBCS_DECODE_METHODDEF \ - {"mbcs_decode", (PyCFunction)(void(*)(void))_codecs_mbcs_decode, METH_FASTCALL, _codecs_mbcs_decode__doc__}, + {"mbcs_decode", _PyCFunction_CAST(_codecs_mbcs_decode), METH_FASTCALL, _codecs_mbcs_decode__doc__}, static PyObject * _codecs_mbcs_decode_impl(PyObject *module, Py_buffer *data, @@ -1495,7 +1495,7 @@ PyDoc_STRVAR(_codecs_oem_decode__doc__, "\n"); #define _CODECS_OEM_DECODE_METHODDEF \ - {"oem_decode", (PyCFunction)(void(*)(void))_codecs_oem_decode, METH_FASTCALL, _codecs_oem_decode__doc__}, + {"oem_decode", _PyCFunction_CAST(_codecs_oem_decode), METH_FASTCALL, _codecs_oem_decode__doc__}, static PyObject * _codecs_oem_decode_impl(PyObject *module, Py_buffer *data, @@ -1569,7 +1569,7 @@ PyDoc_STRVAR(_codecs_code_page_decode__doc__, "\n"); #define _CODECS_CODE_PAGE_DECODE_METHODDEF \ - {"code_page_decode", (PyCFunction)(void(*)(void))_codecs_code_page_decode, METH_FASTCALL, _codecs_code_page_decode__doc__}, + {"code_page_decode", _PyCFunction_CAST(_codecs_code_page_decode), METH_FASTCALL, _codecs_code_page_decode__doc__}, static PyObject * _codecs_code_page_decode_impl(PyObject *module, int codepage, @@ -1646,7 +1646,7 @@ PyDoc_STRVAR(_codecs_readbuffer_encode__doc__, "\n"); #define _CODECS_READBUFFER_ENCODE_METHODDEF \ - {"readbuffer_encode", (PyCFunction)(void(*)(void))_codecs_readbuffer_encode, METH_FASTCALL, _codecs_readbuffer_encode__doc__}, + {"readbuffer_encode", _PyCFunction_CAST(_codecs_readbuffer_encode), METH_FASTCALL, _codecs_readbuffer_encode__doc__}, static PyObject * _codecs_readbuffer_encode_impl(PyObject *module, Py_buffer *data, @@ -1718,7 +1718,7 @@ PyDoc_STRVAR(_codecs_utf_7_encode__doc__, "\n"); #define _CODECS_UTF_7_ENCODE_METHODDEF \ - {"utf_7_encode", (PyCFunction)(void(*)(void))_codecs_utf_7_encode, METH_FASTCALL, _codecs_utf_7_encode__doc__}, + {"utf_7_encode", _PyCFunction_CAST(_codecs_utf_7_encode), METH_FASTCALL, _codecs_utf_7_encode__doc__}, static PyObject * _codecs_utf_7_encode_impl(PyObject *module, PyObject *str, @@ -1776,7 +1776,7 @@ PyDoc_STRVAR(_codecs_utf_8_encode__doc__, "\n"); #define _CODECS_UTF_8_ENCODE_METHODDEF \ - {"utf_8_encode", (PyCFunction)(void(*)(void))_codecs_utf_8_encode, METH_FASTCALL, _codecs_utf_8_encode__doc__}, + {"utf_8_encode", _PyCFunction_CAST(_codecs_utf_8_encode), METH_FASTCALL, _codecs_utf_8_encode__doc__}, static PyObject * _codecs_utf_8_encode_impl(PyObject *module, PyObject *str, @@ -1834,7 +1834,7 @@ PyDoc_STRVAR(_codecs_utf_16_encode__doc__, "\n"); #define _CODECS_UTF_16_ENCODE_METHODDEF \ - {"utf_16_encode", (PyCFunction)(void(*)(void))_codecs_utf_16_encode, METH_FASTCALL, _codecs_utf_16_encode__doc__}, + {"utf_16_encode", _PyCFunction_CAST(_codecs_utf_16_encode), METH_FASTCALL, _codecs_utf_16_encode__doc__}, static PyObject * _codecs_utf_16_encode_impl(PyObject *module, PyObject *str, @@ -1900,7 +1900,7 @@ PyDoc_STRVAR(_codecs_utf_16_le_encode__doc__, "\n"); #define _CODECS_UTF_16_LE_ENCODE_METHODDEF \ - {"utf_16_le_encode", (PyCFunction)(void(*)(void))_codecs_utf_16_le_encode, METH_FASTCALL, _codecs_utf_16_le_encode__doc__}, + {"utf_16_le_encode", _PyCFunction_CAST(_codecs_utf_16_le_encode), METH_FASTCALL, _codecs_utf_16_le_encode__doc__}, static PyObject * _codecs_utf_16_le_encode_impl(PyObject *module, PyObject *str, @@ -1958,7 +1958,7 @@ PyDoc_STRVAR(_codecs_utf_16_be_encode__doc__, "\n"); #define _CODECS_UTF_16_BE_ENCODE_METHODDEF \ - {"utf_16_be_encode", (PyCFunction)(void(*)(void))_codecs_utf_16_be_encode, METH_FASTCALL, _codecs_utf_16_be_encode__doc__}, + {"utf_16_be_encode", _PyCFunction_CAST(_codecs_utf_16_be_encode), METH_FASTCALL, _codecs_utf_16_be_encode__doc__}, static PyObject * _codecs_utf_16_be_encode_impl(PyObject *module, PyObject *str, @@ -2016,7 +2016,7 @@ PyDoc_STRVAR(_codecs_utf_32_encode__doc__, "\n"); #define _CODECS_UTF_32_ENCODE_METHODDEF \ - {"utf_32_encode", (PyCFunction)(void(*)(void))_codecs_utf_32_encode, METH_FASTCALL, _codecs_utf_32_encode__doc__}, + {"utf_32_encode", _PyCFunction_CAST(_codecs_utf_32_encode), METH_FASTCALL, _codecs_utf_32_encode__doc__}, static PyObject * _codecs_utf_32_encode_impl(PyObject *module, PyObject *str, @@ -2082,7 +2082,7 @@ PyDoc_STRVAR(_codecs_utf_32_le_encode__doc__, "\n"); #define _CODECS_UTF_32_LE_ENCODE_METHODDEF \ - {"utf_32_le_encode", (PyCFunction)(void(*)(void))_codecs_utf_32_le_encode, METH_FASTCALL, _codecs_utf_32_le_encode__doc__}, + {"utf_32_le_encode", _PyCFunction_CAST(_codecs_utf_32_le_encode), METH_FASTCALL, _codecs_utf_32_le_encode__doc__}, static PyObject * _codecs_utf_32_le_encode_impl(PyObject *module, PyObject *str, @@ -2140,7 +2140,7 @@ PyDoc_STRVAR(_codecs_utf_32_be_encode__doc__, "\n"); #define _CODECS_UTF_32_BE_ENCODE_METHODDEF \ - {"utf_32_be_encode", (PyCFunction)(void(*)(void))_codecs_utf_32_be_encode, METH_FASTCALL, _codecs_utf_32_be_encode__doc__}, + {"utf_32_be_encode", _PyCFunction_CAST(_codecs_utf_32_be_encode), METH_FASTCALL, _codecs_utf_32_be_encode__doc__}, static PyObject * _codecs_utf_32_be_encode_impl(PyObject *module, PyObject *str, @@ -2198,7 +2198,7 @@ PyDoc_STRVAR(_codecs_unicode_escape_encode__doc__, "\n"); #define _CODECS_UNICODE_ESCAPE_ENCODE_METHODDEF \ - {"unicode_escape_encode", (PyCFunction)(void(*)(void))_codecs_unicode_escape_encode, METH_FASTCALL, _codecs_unicode_escape_encode__doc__}, + {"unicode_escape_encode", _PyCFunction_CAST(_codecs_unicode_escape_encode), METH_FASTCALL, _codecs_unicode_escape_encode__doc__}, static PyObject * _codecs_unicode_escape_encode_impl(PyObject *module, PyObject *str, @@ -2256,7 +2256,7 @@ PyDoc_STRVAR(_codecs_raw_unicode_escape_encode__doc__, "\n"); #define _CODECS_RAW_UNICODE_ESCAPE_ENCODE_METHODDEF \ - {"raw_unicode_escape_encode", (PyCFunction)(void(*)(void))_codecs_raw_unicode_escape_encode, METH_FASTCALL, _codecs_raw_unicode_escape_encode__doc__}, + {"raw_unicode_escape_encode", _PyCFunction_CAST(_codecs_raw_unicode_escape_encode), METH_FASTCALL, _codecs_raw_unicode_escape_encode__doc__}, static PyObject * _codecs_raw_unicode_escape_encode_impl(PyObject *module, PyObject *str, @@ -2314,7 +2314,7 @@ PyDoc_STRVAR(_codecs_latin_1_encode__doc__, "\n"); #define _CODECS_LATIN_1_ENCODE_METHODDEF \ - {"latin_1_encode", (PyCFunction)(void(*)(void))_codecs_latin_1_encode, METH_FASTCALL, _codecs_latin_1_encode__doc__}, + {"latin_1_encode", _PyCFunction_CAST(_codecs_latin_1_encode), METH_FASTCALL, _codecs_latin_1_encode__doc__}, static PyObject * _codecs_latin_1_encode_impl(PyObject *module, PyObject *str, @@ -2372,7 +2372,7 @@ PyDoc_STRVAR(_codecs_ascii_encode__doc__, "\n"); #define _CODECS_ASCII_ENCODE_METHODDEF \ - {"ascii_encode", (PyCFunction)(void(*)(void))_codecs_ascii_encode, METH_FASTCALL, _codecs_ascii_encode__doc__}, + {"ascii_encode", _PyCFunction_CAST(_codecs_ascii_encode), METH_FASTCALL, _codecs_ascii_encode__doc__}, static PyObject * _codecs_ascii_encode_impl(PyObject *module, PyObject *str, @@ -2430,7 +2430,7 @@ PyDoc_STRVAR(_codecs_charmap_encode__doc__, "\n"); #define _CODECS_CHARMAP_ENCODE_METHODDEF \ - {"charmap_encode", (PyCFunction)(void(*)(void))_codecs_charmap_encode, METH_FASTCALL, _codecs_charmap_encode__doc__}, + {"charmap_encode", _PyCFunction_CAST(_codecs_charmap_encode), METH_FASTCALL, _codecs_charmap_encode__doc__}, static PyObject * _codecs_charmap_encode_impl(PyObject *module, PyObject *str, @@ -2526,7 +2526,7 @@ PyDoc_STRVAR(_codecs_mbcs_encode__doc__, "\n"); #define _CODECS_MBCS_ENCODE_METHODDEF \ - {"mbcs_encode", (PyCFunction)(void(*)(void))_codecs_mbcs_encode, METH_FASTCALL, _codecs_mbcs_encode__doc__}, + {"mbcs_encode", _PyCFunction_CAST(_codecs_mbcs_encode), METH_FASTCALL, _codecs_mbcs_encode__doc__}, static PyObject * _codecs_mbcs_encode_impl(PyObject *module, PyObject *str, const char *errors); @@ -2587,7 +2587,7 @@ PyDoc_STRVAR(_codecs_oem_encode__doc__, "\n"); #define _CODECS_OEM_ENCODE_METHODDEF \ - {"oem_encode", (PyCFunction)(void(*)(void))_codecs_oem_encode, METH_FASTCALL, _codecs_oem_encode__doc__}, + {"oem_encode", _PyCFunction_CAST(_codecs_oem_encode), METH_FASTCALL, _codecs_oem_encode__doc__}, static PyObject * _codecs_oem_encode_impl(PyObject *module, PyObject *str, const char *errors); @@ -2648,7 +2648,7 @@ PyDoc_STRVAR(_codecs_code_page_encode__doc__, "\n"); #define _CODECS_CODE_PAGE_ENCODE_METHODDEF \ - {"code_page_encode", (PyCFunction)(void(*)(void))_codecs_code_page_encode, METH_FASTCALL, _codecs_code_page_encode__doc__}, + {"code_page_encode", _PyCFunction_CAST(_codecs_code_page_encode), METH_FASTCALL, _codecs_code_page_encode__doc__}, static PyObject * _codecs_code_page_encode_impl(PyObject *module, int code_page, PyObject *str, @@ -2718,7 +2718,7 @@ PyDoc_STRVAR(_codecs_register_error__doc__, "error and must return a (replacement, new position) tuple."); #define _CODECS_REGISTER_ERROR_METHODDEF \ - {"register_error", (PyCFunction)(void(*)(void))_codecs_register_error, METH_FASTCALL, _codecs_register_error__doc__}, + {"register_error", _PyCFunction_CAST(_codecs_register_error), METH_FASTCALL, _codecs_register_error__doc__}, static PyObject * _codecs_register_error_impl(PyObject *module, const char *errors, @@ -2817,4 +2817,4 @@ _codecs_lookup_error(PyObject *module, PyObject *arg) #ifndef _CODECS_CODE_PAGE_ENCODE_METHODDEF #define _CODECS_CODE_PAGE_ENCODE_METHODDEF #endif /* !defined(_CODECS_CODE_PAGE_ENCODE_METHODDEF) */ -/*[clinic end generated code: output=814dae36b6f885cb input=a9049054013a1b77]*/ +/*[clinic end generated code: output=92250568c3a6f0a0 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_collectionsmodule.c.h b/Modules/clinic/_collectionsmodule.c.h index 2875b3cd26628..e53acd6afb446 100644 --- a/Modules/clinic/_collectionsmodule.c.h +++ b/Modules/clinic/_collectionsmodule.c.h @@ -9,7 +9,7 @@ PyDoc_STRVAR(_collections__count_elements__doc__, "Count elements in the iterable, updating the mapping"); #define _COLLECTIONS__COUNT_ELEMENTS_METHODDEF \ - {"_count_elements", (PyCFunction)(void(*)(void))_collections__count_elements, METH_FASTCALL, _collections__count_elements__doc__}, + {"_count_elements", _PyCFunction_CAST(_collections__count_elements), METH_FASTCALL, _collections__count_elements__doc__}, static PyObject * _collections__count_elements_impl(PyObject *module, PyObject *mapping, @@ -69,4 +69,4 @@ tuplegetter_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) exit: return return_value; } -/*[clinic end generated code: output=3dfa12a35e655844 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=36b0948c4676c831 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_cryptmodule.c.h b/Modules/clinic/_cryptmodule.c.h index ea91d7c130b8c..401d04623e43c 100644 --- a/Modules/clinic/_cryptmodule.c.h +++ b/Modules/clinic/_cryptmodule.c.h @@ -14,7 +14,7 @@ PyDoc_STRVAR(crypt_crypt__doc__, "results for a given *word*."); #define CRYPT_CRYPT_METHODDEF \ - {"crypt", (PyCFunction)(void(*)(void))crypt_crypt, METH_FASTCALL, crypt_crypt__doc__}, + {"crypt", _PyCFunction_CAST(crypt_crypt), METH_FASTCALL, crypt_crypt__doc__}, static PyObject * crypt_crypt_impl(PyObject *module, const char *word, const char *salt); @@ -60,4 +60,4 @@ crypt_crypt(PyObject *module, PyObject *const *args, Py_ssize_t nargs) exit: return return_value; } -/*[clinic end generated code: output=549de0d43b030126 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=6f61ab29e361f9d0 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_csv.c.h b/Modules/clinic/_csv.c.h index 41c0cdde7482a..ae5dec74a173e 100644 --- a/Modules/clinic/_csv.c.h +++ b/Modules/clinic/_csv.c.h @@ -31,7 +31,7 @@ PyDoc_STRVAR(_csv_unregister_dialect__doc__, " csv.unregister_dialect(name)"); #define _CSV_UNREGISTER_DIALECT_METHODDEF \ - {"unregister_dialect", (PyCFunction)(void(*)(void))_csv_unregister_dialect, METH_FASTCALL|METH_KEYWORDS, _csv_unregister_dialect__doc__}, + {"unregister_dialect", _PyCFunction_CAST(_csv_unregister_dialect), METH_FASTCALL|METH_KEYWORDS, _csv_unregister_dialect__doc__}, static PyObject * _csv_unregister_dialect_impl(PyObject *module, PyObject *name); @@ -65,7 +65,7 @@ PyDoc_STRVAR(_csv_get_dialect__doc__, " dialect = csv.get_dialect(name)"); #define _CSV_GET_DIALECT_METHODDEF \ - {"get_dialect", (PyCFunction)(void(*)(void))_csv_get_dialect, METH_FASTCALL|METH_KEYWORDS, _csv_get_dialect__doc__}, + {"get_dialect", _PyCFunction_CAST(_csv_get_dialect), METH_FASTCALL|METH_KEYWORDS, _csv_get_dialect__doc__}, static PyObject * _csv_get_dialect_impl(PyObject *module, PyObject *name); @@ -102,7 +102,7 @@ PyDoc_STRVAR(_csv_field_size_limit__doc__, "the old limit is returned"); #define _CSV_FIELD_SIZE_LIMIT_METHODDEF \ - {"field_size_limit", (PyCFunction)(void(*)(void))_csv_field_size_limit, METH_FASTCALL|METH_KEYWORDS, _csv_field_size_limit__doc__}, + {"field_size_limit", _PyCFunction_CAST(_csv_field_size_limit), METH_FASTCALL|METH_KEYWORDS, _csv_field_size_limit__doc__}, static PyObject * _csv_field_size_limit_impl(PyObject *module, PyObject *new_limit); @@ -131,4 +131,4 @@ _csv_field_size_limit(PyObject *module, PyObject *const *args, Py_ssize_t nargs, exit: return return_value; } -/*[clinic end generated code: output=d51f3c42e9b88802 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=6235abc491b02188 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_curses_panel.c.h b/Modules/clinic/_curses_panel.c.h index e4642b58332de..31101c1011ccd 100644 --- a/Modules/clinic/_curses_panel.c.h +++ b/Modules/clinic/_curses_panel.c.h @@ -9,7 +9,7 @@ PyDoc_STRVAR(_curses_panel_panel_bottom__doc__, "Push the panel to the bottom of the stack."); #define _CURSES_PANEL_PANEL_BOTTOM_METHODDEF \ - {"bottom", (PyCFunction)(void(*)(void))_curses_panel_panel_bottom, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _curses_panel_panel_bottom__doc__}, + {"bottom", _PyCFunction_CAST(_curses_panel_panel_bottom), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _curses_panel_panel_bottom__doc__}, static PyObject * _curses_panel_panel_bottom_impl(PyCursesPanelObject *self, PyTypeObject *cls); @@ -33,7 +33,7 @@ PyDoc_STRVAR(_curses_panel_panel_hide__doc__, "This does not delete the object, it just makes the window on screen invisible."); #define _CURSES_PANEL_PANEL_HIDE_METHODDEF \ - {"hide", (PyCFunction)(void(*)(void))_curses_panel_panel_hide, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _curses_panel_panel_hide__doc__}, + {"hide", _PyCFunction_CAST(_curses_panel_panel_hide), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _curses_panel_panel_hide__doc__}, static PyObject * _curses_panel_panel_hide_impl(PyCursesPanelObject *self, PyTypeObject *cls); @@ -55,7 +55,7 @@ PyDoc_STRVAR(_curses_panel_panel_show__doc__, "Display the panel (which might have been hidden)."); #define _CURSES_PANEL_PANEL_SHOW_METHODDEF \ - {"show", (PyCFunction)(void(*)(void))_curses_panel_panel_show, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _curses_panel_panel_show__doc__}, + {"show", _PyCFunction_CAST(_curses_panel_panel_show), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _curses_panel_panel_show__doc__}, static PyObject * _curses_panel_panel_show_impl(PyCursesPanelObject *self, PyTypeObject *cls); @@ -77,7 +77,7 @@ PyDoc_STRVAR(_curses_panel_panel_top__doc__, "Push panel to the top of the stack."); #define _CURSES_PANEL_PANEL_TOP_METHODDEF \ - {"top", (PyCFunction)(void(*)(void))_curses_panel_panel_top, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _curses_panel_panel_top__doc__}, + {"top", _PyCFunction_CAST(_curses_panel_panel_top), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _curses_panel_panel_top__doc__}, static PyObject * _curses_panel_panel_top_impl(PyCursesPanelObject *self, PyTypeObject *cls); @@ -153,7 +153,7 @@ PyDoc_STRVAR(_curses_panel_panel_move__doc__, "Move the panel to the screen coordinates (y, x)."); #define _CURSES_PANEL_PANEL_MOVE_METHODDEF \ - {"move", (PyCFunction)(void(*)(void))_curses_panel_panel_move, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _curses_panel_panel_move__doc__}, + {"move", _PyCFunction_CAST(_curses_panel_panel_move), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _curses_panel_panel_move__doc__}, static PyObject * _curses_panel_panel_move_impl(PyCursesPanelObject *self, PyTypeObject *cls, @@ -212,7 +212,7 @@ PyDoc_STRVAR(_curses_panel_panel_replace__doc__, "Change the window associated with the panel to the window win."); #define _CURSES_PANEL_PANEL_REPLACE_METHODDEF \ - {"replace", (PyCFunction)(void(*)(void))_curses_panel_panel_replace, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _curses_panel_panel_replace__doc__}, + {"replace", _PyCFunction_CAST(_curses_panel_panel_replace), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _curses_panel_panel_replace__doc__}, static PyObject * _curses_panel_panel_replace_impl(PyCursesPanelObject *self, @@ -250,7 +250,7 @@ PyDoc_STRVAR(_curses_panel_panel_set_userptr__doc__, "Set the panel\'s user pointer to obj."); #define _CURSES_PANEL_PANEL_SET_USERPTR_METHODDEF \ - {"set_userptr", (PyCFunction)(void(*)(void))_curses_panel_panel_set_userptr, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _curses_panel_panel_set_userptr__doc__}, + {"set_userptr", _PyCFunction_CAST(_curses_panel_panel_set_userptr), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _curses_panel_panel_set_userptr__doc__}, static PyObject * _curses_panel_panel_set_userptr_impl(PyCursesPanelObject *self, @@ -283,7 +283,7 @@ PyDoc_STRVAR(_curses_panel_panel_userptr__doc__, "Return the user pointer for the panel."); #define _CURSES_PANEL_PANEL_USERPTR_METHODDEF \ - {"userptr", (PyCFunction)(void(*)(void))_curses_panel_panel_userptr, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _curses_panel_panel_userptr__doc__}, + {"userptr", _PyCFunction_CAST(_curses_panel_panel_userptr), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _curses_panel_panel_userptr__doc__}, static PyObject * _curses_panel_panel_userptr_impl(PyCursesPanelObject *self, @@ -383,4 +383,4 @@ _curses_panel_update_panels(PyObject *module, PyObject *Py_UNUSED(ignored)) { return _curses_panel_update_panels_impl(module); } -/*[clinic end generated code: output=c552457e8067bb0a input=a9049054013a1b77]*/ +/*[clinic end generated code: output=c471aed62bc31e79 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_cursesmodule.c.h b/Modules/clinic/_cursesmodule.c.h index 9c9611685b78e..c7d1eca6559b6 100644 --- a/Modules/clinic/_cursesmodule.c.h +++ b/Modules/clinic/_cursesmodule.c.h @@ -233,7 +233,7 @@ PyDoc_STRVAR(_curses_window_bkgd__doc__, " Background attributes."); #define _CURSES_WINDOW_BKGD_METHODDEF \ - {"bkgd", (PyCFunction)(void(*)(void))_curses_window_bkgd, METH_FASTCALL, _curses_window_bkgd__doc__}, + {"bkgd", _PyCFunction_CAST(_curses_window_bkgd), METH_FASTCALL, _curses_window_bkgd__doc__}, static PyObject * _curses_window_bkgd_impl(PyCursesWindowObject *self, PyObject *ch, long attr); @@ -359,7 +359,7 @@ PyDoc_STRVAR(_curses_window_bkgdset__doc__, " Background attributes."); #define _CURSES_WINDOW_BKGDSET_METHODDEF \ - {"bkgdset", (PyCFunction)(void(*)(void))_curses_window_bkgdset, METH_FASTCALL, _curses_window_bkgdset__doc__}, + {"bkgdset", _PyCFunction_CAST(_curses_window_bkgdset), METH_FASTCALL, _curses_window_bkgdset__doc__}, static PyObject * _curses_window_bkgdset_impl(PyCursesWindowObject *self, PyObject *ch, @@ -422,7 +422,7 @@ PyDoc_STRVAR(_curses_window_border__doc__, "used for that parameter."); #define _CURSES_WINDOW_BORDER_METHODDEF \ - {"border", (PyCFunction)(void(*)(void))_curses_window_border, METH_FASTCALL, _curses_window_border__doc__}, + {"border", _PyCFunction_CAST(_curses_window_border), METH_FASTCALL, _curses_window_border__doc__}, static PyObject * _curses_window_border_impl(PyCursesWindowObject *self, PyObject *ls, @@ -642,7 +642,7 @@ PyDoc_STRVAR(_curses_window_echochar__doc__, " Attributes for the character."); #define _CURSES_WINDOW_ECHOCHAR_METHODDEF \ - {"echochar", (PyCFunction)(void(*)(void))_curses_window_echochar, METH_FASTCALL, _curses_window_echochar__doc__}, + {"echochar", _PyCFunction_CAST(_curses_window_echochar), METH_FASTCALL, _curses_window_echochar__doc__}, static PyObject * _curses_window_echochar_impl(PyCursesWindowObject *self, PyObject *ch, @@ -687,7 +687,7 @@ PyDoc_STRVAR(_curses_window_enclose__doc__, " X-coordinate."); #define _CURSES_WINDOW_ENCLOSE_METHODDEF \ - {"enclose", (PyCFunction)(void(*)(void))_curses_window_enclose, METH_FASTCALL, _curses_window_enclose__doc__}, + {"enclose", _PyCFunction_CAST(_curses_window_enclose), METH_FASTCALL, _curses_window_enclose__doc__}, static PyObject * _curses_window_enclose_impl(PyCursesWindowObject *self, int y, int x); @@ -1487,7 +1487,7 @@ PyDoc_STRVAR(_curses_window_redrawln__doc__, "They should be completely redrawn on the next refresh() call."); #define _CURSES_WINDOW_REDRAWLN_METHODDEF \ - {"redrawln", (PyCFunction)(void(*)(void))_curses_window_redrawln, METH_FASTCALL, _curses_window_redrawln__doc__}, + {"redrawln", _PyCFunction_CAST(_curses_window_redrawln), METH_FASTCALL, _curses_window_redrawln__doc__}, static PyObject * _curses_window_redrawln_impl(PyCursesWindowObject *self, int beg, int num); @@ -1585,7 +1585,7 @@ PyDoc_STRVAR(_curses_window_setscrreg__doc__, "All scrolling actions will take place in this region."); #define _CURSES_WINDOW_SETSCRREG_METHODDEF \ - {"setscrreg", (PyCFunction)(void(*)(void))_curses_window_setscrreg, METH_FASTCALL, _curses_window_setscrreg__doc__}, + {"setscrreg", _PyCFunction_CAST(_curses_window_setscrreg), METH_FASTCALL, _curses_window_setscrreg__doc__}, static PyObject * _curses_window_setscrreg_impl(PyCursesWindowObject *self, int top, @@ -1918,7 +1918,7 @@ PyDoc_STRVAR(_curses_cbreak__doc__, "Calling first raw() then cbreak() leaves the terminal in cbreak mode."); #define _CURSES_CBREAK_METHODDEF \ - {"cbreak", (PyCFunction)(void(*)(void))_curses_cbreak, METH_FASTCALL, _curses_cbreak__doc__}, + {"cbreak", _PyCFunction_CAST(_curses_cbreak), METH_FASTCALL, _curses_cbreak__doc__}, static PyObject * _curses_cbreak_impl(PyObject *module, int flag); @@ -2154,7 +2154,7 @@ PyDoc_STRVAR(_curses_echo__doc__, "In echo mode, each character input is echoed to the screen as it is entered."); #define _CURSES_ECHO_METHODDEF \ - {"echo", (PyCFunction)(void(*)(void))_curses_echo, METH_FASTCALL, _curses_echo__doc__}, + {"echo", _PyCFunction_CAST(_curses_echo), METH_FASTCALL, _curses_echo__doc__}, static PyObject * _curses_echo_impl(PyObject *module, int flag); @@ -2319,7 +2319,7 @@ PyDoc_STRVAR(_curses_ungetmouse__doc__, "The following getmouse() will return the given state data."); #define _CURSES_UNGETMOUSE_METHODDEF \ - {"ungetmouse", (PyCFunction)(void(*)(void))_curses_ungetmouse, METH_FASTCALL, _curses_ungetmouse__doc__}, + {"ungetmouse", _PyCFunction_CAST(_curses_ungetmouse), METH_FASTCALL, _curses_ungetmouse__doc__}, static PyObject * _curses_ungetmouse_impl(PyObject *module, short id, int x, int y, int z, @@ -2551,7 +2551,7 @@ PyDoc_STRVAR(_curses_init_color__doc__, "most terminals; it is active only if can_change_color() returns true."); #define _CURSES_INIT_COLOR_METHODDEF \ - {"init_color", (PyCFunction)(void(*)(void))_curses_init_color, METH_FASTCALL, _curses_init_color__doc__}, + {"init_color", _PyCFunction_CAST(_curses_init_color), METH_FASTCALL, _curses_init_color__doc__}, static PyObject * _curses_init_color_impl(PyObject *module, int color_number, short r, short g, @@ -2604,7 +2604,7 @@ PyDoc_STRVAR(_curses_init_pair__doc__, "all occurrences of that color-pair are changed to the new definition."); #define _CURSES_INIT_PAIR_METHODDEF \ - {"init_pair", (PyCFunction)(void(*)(void))_curses_init_pair, METH_FASTCALL, _curses_init_pair__doc__}, + {"init_pair", _PyCFunction_CAST(_curses_init_pair), METH_FASTCALL, _curses_init_pair__doc__}, static PyObject * _curses_init_pair_impl(PyObject *module, int pair_number, int fg, int bg); @@ -2669,7 +2669,7 @@ PyDoc_STRVAR(_curses_setupterm__doc__, " If not supplied, the file descriptor for sys.stdout will be used."); #define _CURSES_SETUPTERM_METHODDEF \ - {"setupterm", (PyCFunction)(void(*)(void))_curses_setupterm, METH_FASTCALL|METH_KEYWORDS, _curses_setupterm__doc__}, + {"setupterm", _PyCFunction_CAST(_curses_setupterm), METH_FASTCALL|METH_KEYWORDS, _curses_setupterm__doc__}, static PyObject * _curses_setupterm_impl(PyObject *module, const char *term, int fd); @@ -2913,7 +2913,7 @@ PyDoc_STRVAR(_curses_is_term_resized__doc__, " Width."); #define _CURSES_IS_TERM_RESIZED_METHODDEF \ - {"is_term_resized", (PyCFunction)(void(*)(void))_curses_is_term_resized, METH_FASTCALL, _curses_is_term_resized__doc__}, + {"is_term_resized", _PyCFunction_CAST(_curses_is_term_resized), METH_FASTCALL, _curses_is_term_resized__doc__}, static PyObject * _curses_is_term_resized_impl(PyObject *module, int nlines, int ncols); @@ -3165,7 +3165,7 @@ PyDoc_STRVAR(_curses_newpad__doc__, " Width."); #define _CURSES_NEWPAD_METHODDEF \ - {"newpad", (PyCFunction)(void(*)(void))_curses_newpad, METH_FASTCALL, _curses_newpad__doc__}, + {"newpad", _PyCFunction_CAST(_curses_newpad), METH_FASTCALL, _curses_newpad__doc__}, static PyObject * _curses_newpad_impl(PyObject *module, int nlines, int ncols); @@ -3262,7 +3262,7 @@ PyDoc_STRVAR(_curses_nl__doc__, "newline into return and line-feed on output. Newline mode is initially on."); #define _CURSES_NL_METHODDEF \ - {"nl", (PyCFunction)(void(*)(void))_curses_nl, METH_FASTCALL, _curses_nl__doc__}, + {"nl", _PyCFunction_CAST(_curses_nl), METH_FASTCALL, _curses_nl__doc__}, static PyObject * _curses_nl_impl(PyObject *module, int flag); @@ -3494,7 +3494,7 @@ PyDoc_STRVAR(_curses_qiflush__doc__, "will be flushed when the INTR, QUIT and SUSP characters are read."); #define _CURSES_QIFLUSH_METHODDEF \ - {"qiflush", (PyCFunction)(void(*)(void))_curses_qiflush, METH_FASTCALL, _curses_qiflush__doc__}, + {"qiflush", _PyCFunction_CAST(_curses_qiflush), METH_FASTCALL, _curses_qiflush__doc__}, static PyObject * _curses_qiflush_impl(PyObject *module, int flag); @@ -3557,7 +3557,7 @@ PyDoc_STRVAR(_curses_raw__doc__, "curses input functions one by one."); #define _CURSES_RAW_METHODDEF \ - {"raw", (PyCFunction)(void(*)(void))_curses_raw, METH_FASTCALL, _curses_raw__doc__}, + {"raw", _PyCFunction_CAST(_curses_raw), METH_FASTCALL, _curses_raw__doc__}, static PyObject * _curses_raw_impl(PyObject *module, int flag); @@ -3656,7 +3656,7 @@ PyDoc_STRVAR(_curses_resizeterm__doc__, "window dimensions (in particular the SIGWINCH handler)."); #define _CURSES_RESIZETERM_METHODDEF \ - {"resizeterm", (PyCFunction)(void(*)(void))_curses_resizeterm, METH_FASTCALL, _curses_resizeterm__doc__}, + {"resizeterm", _PyCFunction_CAST(_curses_resizeterm), METH_FASTCALL, _curses_resizeterm__doc__}, static PyObject * _curses_resizeterm_impl(PyObject *module, int nlines, int ncols); @@ -3707,7 +3707,7 @@ PyDoc_STRVAR(_curses_resize_term__doc__, "without additional interaction with the application."); #define _CURSES_RESIZE_TERM_METHODDEF \ - {"resize_term", (PyCFunction)(void(*)(void))_curses_resize_term, METH_FASTCALL, _curses_resize_term__doc__}, + {"resize_term", _PyCFunction_CAST(_curses_resize_term), METH_FASTCALL, _curses_resize_term__doc__}, static PyObject * _curses_resize_term_impl(PyObject *module, int nlines, int ncols); @@ -3772,7 +3772,7 @@ PyDoc_STRVAR(_curses_setsyx__doc__, "If y and x are both -1, then leaveok is set."); #define _CURSES_SETSYX_METHODDEF \ - {"setsyx", (PyCFunction)(void(*)(void))_curses_setsyx, METH_FASTCALL, _curses_setsyx__doc__}, + {"setsyx", _PyCFunction_CAST(_curses_setsyx), METH_FASTCALL, _curses_setsyx__doc__}, static PyObject * _curses_setsyx_impl(PyObject *module, int y, int x); @@ -4004,7 +4004,7 @@ PyDoc_STRVAR(_curses_tparm__doc__, " Parameterized byte string obtained from the terminfo database."); #define _CURSES_TPARM_METHODDEF \ - {"tparm", (PyCFunction)(void(*)(void))_curses_tparm, METH_FASTCALL, _curses_tparm__doc__}, + {"tparm", _PyCFunction_CAST(_curses_tparm), METH_FASTCALL, _curses_tparm__doc__}, static PyObject * _curses_tparm_impl(PyObject *module, const char *str, int i1, int i2, int i3, @@ -4284,4 +4284,4 @@ _curses_has_extended_color_support(PyObject *module, PyObject *Py_UNUSED(ignored #ifndef _CURSES_USE_DEFAULT_COLORS_METHODDEF #define _CURSES_USE_DEFAULT_COLORS_METHODDEF #endif /* !defined(_CURSES_USE_DEFAULT_COLORS_METHODDEF) */ -/*[clinic end generated code: output=9efc9943a3ac3741 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=1e2a8a160a0fe811 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_datetimemodule.c.h b/Modules/clinic/_datetimemodule.c.h index 7bd7c1986dc7b..31d2f75f7a86a 100644 --- a/Modules/clinic/_datetimemodule.c.h +++ b/Modules/clinic/_datetimemodule.c.h @@ -65,7 +65,7 @@ PyDoc_STRVAR(datetime_datetime_now__doc__, "If no tz is specified, uses local timezone."); #define DATETIME_DATETIME_NOW_METHODDEF \ - {"now", (PyCFunction)(void(*)(void))datetime_datetime_now, METH_FASTCALL|METH_KEYWORDS|METH_CLASS, datetime_datetime_now__doc__}, + {"now", _PyCFunction_CAST(datetime_datetime_now), METH_FASTCALL|METH_KEYWORDS|METH_CLASS, datetime_datetime_now__doc__}, static PyObject * datetime_datetime_now_impl(PyTypeObject *type, PyObject *tz); @@ -94,4 +94,4 @@ datetime_datetime_now(PyTypeObject *type, PyObject *const *args, Py_ssize_t narg exit: return return_value; } -/*[clinic end generated code: output=f61310936e3d8091 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=1a3da7479e443e17 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_dbmmodule.c.h b/Modules/clinic/_dbmmodule.c.h index a8b41607221f6..8157716a94081 100644 --- a/Modules/clinic/_dbmmodule.c.h +++ b/Modules/clinic/_dbmmodule.c.h @@ -27,7 +27,7 @@ PyDoc_STRVAR(_dbm_dbm_keys__doc__, "Return a list of all keys in the database."); #define _DBM_DBM_KEYS_METHODDEF \ - {"keys", (PyCFunction)(void(*)(void))_dbm_dbm_keys, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _dbm_dbm_keys__doc__}, + {"keys", _PyCFunction_CAST(_dbm_dbm_keys), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _dbm_dbm_keys__doc__}, static PyObject * _dbm_dbm_keys_impl(dbmobject *self, PyTypeObject *cls); @@ -49,7 +49,7 @@ PyDoc_STRVAR(_dbm_dbm_get__doc__, "Return the value for key if present, otherwise default."); #define _DBM_DBM_GET_METHODDEF \ - {"get", (PyCFunction)(void(*)(void))_dbm_dbm_get, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _dbm_dbm_get__doc__}, + {"get", _PyCFunction_CAST(_dbm_dbm_get), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _dbm_dbm_get__doc__}, static PyObject * _dbm_dbm_get_impl(dbmobject *self, PyTypeObject *cls, const char *key, @@ -84,7 +84,7 @@ PyDoc_STRVAR(_dbm_dbm_setdefault__doc__, "If key is not in the database, it is inserted with default as the value."); #define _DBM_DBM_SETDEFAULT_METHODDEF \ - {"setdefault", (PyCFunction)(void(*)(void))_dbm_dbm_setdefault, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _dbm_dbm_setdefault__doc__}, + {"setdefault", _PyCFunction_CAST(_dbm_dbm_setdefault), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _dbm_dbm_setdefault__doc__}, static PyObject * _dbm_dbm_setdefault_impl(dbmobject *self, PyTypeObject *cls, const char *key, @@ -125,7 +125,7 @@ PyDoc_STRVAR(dbmopen__doc__, " (e.g. os.O_RDWR)."); #define DBMOPEN_METHODDEF \ - {"open", (PyCFunction)(void(*)(void))dbmopen, METH_FASTCALL, dbmopen__doc__}, + {"open", _PyCFunction_CAST(dbmopen), METH_FASTCALL, dbmopen__doc__}, static PyObject * dbmopen_impl(PyObject *module, PyObject *filename, const char *flags, @@ -172,4 +172,4 @@ dbmopen(PyObject *module, PyObject *const *args, Py_ssize_t nargs) exit: return return_value; } -/*[clinic end generated code: output=492be70729515fe3 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=5798278a05032d0e input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_elementtree.c.h b/Modules/clinic/_elementtree.c.h index 5ed5a6cadd9d5..047203eefa357 100644 --- a/Modules/clinic/_elementtree.c.h +++ b/Modules/clinic/_elementtree.c.h @@ -158,7 +158,7 @@ PyDoc_STRVAR(_elementtree_Element_find__doc__, "\n"); #define _ELEMENTTREE_ELEMENT_FIND_METHODDEF \ - {"find", (PyCFunction)(void(*)(void))_elementtree_Element_find, METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_find__doc__}, + {"find", _PyCFunction_CAST(_elementtree_Element_find), METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_find__doc__}, static PyObject * _elementtree_Element_find_impl(ElementObject *self, PyObject *path, @@ -197,7 +197,7 @@ PyDoc_STRVAR(_elementtree_Element_findtext__doc__, "\n"); #define _ELEMENTTREE_ELEMENT_FINDTEXT_METHODDEF \ - {"findtext", (PyCFunction)(void(*)(void))_elementtree_Element_findtext, METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_findtext__doc__}, + {"findtext", _PyCFunction_CAST(_elementtree_Element_findtext), METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_findtext__doc__}, static PyObject * _elementtree_Element_findtext_impl(ElementObject *self, PyObject *path, @@ -244,7 +244,7 @@ PyDoc_STRVAR(_elementtree_Element_findall__doc__, "\n"); #define _ELEMENTTREE_ELEMENT_FINDALL_METHODDEF \ - {"findall", (PyCFunction)(void(*)(void))_elementtree_Element_findall, METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_findall__doc__}, + {"findall", _PyCFunction_CAST(_elementtree_Element_findall), METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_findall__doc__}, static PyObject * _elementtree_Element_findall_impl(ElementObject *self, PyObject *path, @@ -283,7 +283,7 @@ PyDoc_STRVAR(_elementtree_Element_iterfind__doc__, "\n"); #define _ELEMENTTREE_ELEMENT_ITERFIND_METHODDEF \ - {"iterfind", (PyCFunction)(void(*)(void))_elementtree_Element_iterfind, METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_iterfind__doc__}, + {"iterfind", _PyCFunction_CAST(_elementtree_Element_iterfind), METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_iterfind__doc__}, static PyObject * _elementtree_Element_iterfind_impl(ElementObject *self, PyObject *path, @@ -322,7 +322,7 @@ PyDoc_STRVAR(_elementtree_Element_get__doc__, "\n"); #define _ELEMENTTREE_ELEMENT_GET_METHODDEF \ - {"get", (PyCFunction)(void(*)(void))_elementtree_Element_get, METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_get__doc__}, + {"get", _PyCFunction_CAST(_elementtree_Element_get), METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_get__doc__}, static PyObject * _elementtree_Element_get_impl(ElementObject *self, PyObject *key, @@ -361,7 +361,7 @@ PyDoc_STRVAR(_elementtree_Element_iter__doc__, "\n"); #define _ELEMENTTREE_ELEMENT_ITER_METHODDEF \ - {"iter", (PyCFunction)(void(*)(void))_elementtree_Element_iter, METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_iter__doc__}, + {"iter", _PyCFunction_CAST(_elementtree_Element_iter), METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_iter__doc__}, static PyObject * _elementtree_Element_iter_impl(ElementObject *self, PyObject *tag); @@ -414,7 +414,7 @@ PyDoc_STRVAR(_elementtree_Element_insert__doc__, "\n"); #define _ELEMENTTREE_ELEMENT_INSERT_METHODDEF \ - {"insert", (PyCFunction)(void(*)(void))_elementtree_Element_insert, METH_FASTCALL, _elementtree_Element_insert__doc__}, + {"insert", _PyCFunction_CAST(_elementtree_Element_insert), METH_FASTCALL, _elementtree_Element_insert__doc__}, static PyObject * _elementtree_Element_insert_impl(ElementObject *self, Py_ssize_t index, @@ -493,7 +493,7 @@ PyDoc_STRVAR(_elementtree_Element_makeelement__doc__, "\n"); #define _ELEMENTTREE_ELEMENT_MAKEELEMENT_METHODDEF \ - {"makeelement", (PyCFunction)(void(*)(void))_elementtree_Element_makeelement, METH_FASTCALL, _elementtree_Element_makeelement__doc__}, + {"makeelement", _PyCFunction_CAST(_elementtree_Element_makeelement), METH_FASTCALL, _elementtree_Element_makeelement__doc__}, static PyObject * _elementtree_Element_makeelement_impl(ElementObject *self, PyObject *tag, @@ -555,7 +555,7 @@ PyDoc_STRVAR(_elementtree_Element_set__doc__, "\n"); #define _ELEMENTTREE_ELEMENT_SET_METHODDEF \ - {"set", (PyCFunction)(void(*)(void))_elementtree_Element_set, METH_FASTCALL, _elementtree_Element_set__doc__}, + {"set", _PyCFunction_CAST(_elementtree_Element_set), METH_FASTCALL, _elementtree_Element_set__doc__}, static PyObject * _elementtree_Element_set_impl(ElementObject *self, PyObject *key, @@ -660,7 +660,7 @@ PyDoc_STRVAR(_elementtree__set_factories__doc__, "For internal use only."); #define _ELEMENTTREE__SET_FACTORIES_METHODDEF \ - {"_set_factories", (PyCFunction)(void(*)(void))_elementtree__set_factories, METH_FASTCALL, _elementtree__set_factories__doc__}, + {"_set_factories", _PyCFunction_CAST(_elementtree__set_factories), METH_FASTCALL, _elementtree__set_factories__doc__}, static PyObject * _elementtree__set_factories_impl(PyObject *module, PyObject *comment_factory, @@ -714,7 +714,7 @@ PyDoc_STRVAR(_elementtree_TreeBuilder_pi__doc__, "\n"); #define _ELEMENTTREE_TREEBUILDER_PI_METHODDEF \ - {"pi", (PyCFunction)(void(*)(void))_elementtree_TreeBuilder_pi, METH_FASTCALL, _elementtree_TreeBuilder_pi__doc__}, + {"pi", _PyCFunction_CAST(_elementtree_TreeBuilder_pi), METH_FASTCALL, _elementtree_TreeBuilder_pi__doc__}, static PyObject * _elementtree_TreeBuilder_pi_impl(TreeBuilderObject *self, PyObject *target, @@ -765,7 +765,7 @@ PyDoc_STRVAR(_elementtree_TreeBuilder_start__doc__, "\n"); #define _ELEMENTTREE_TREEBUILDER_START_METHODDEF \ - {"start", (PyCFunction)(void(*)(void))_elementtree_TreeBuilder_start, METH_FASTCALL, _elementtree_TreeBuilder_start__doc__}, + {"start", _PyCFunction_CAST(_elementtree_TreeBuilder_start), METH_FASTCALL, _elementtree_TreeBuilder_start__doc__}, static PyObject * _elementtree_TreeBuilder_start_impl(TreeBuilderObject *self, PyObject *tag, @@ -887,7 +887,7 @@ PyDoc_STRVAR(_elementtree_XMLParser__setevents__doc__, "\n"); #define _ELEMENTTREE_XMLPARSER__SETEVENTS_METHODDEF \ - {"_setevents", (PyCFunction)(void(*)(void))_elementtree_XMLParser__setevents, METH_FASTCALL, _elementtree_XMLParser__setevents__doc__}, + {"_setevents", _PyCFunction_CAST(_elementtree_XMLParser__setevents), METH_FASTCALL, _elementtree_XMLParser__setevents__doc__}, static PyObject * _elementtree_XMLParser__setevents_impl(XMLParserObject *self, @@ -915,4 +915,4 @@ _elementtree_XMLParser__setevents(XMLParserObject *self, PyObject *const *args, exit: return return_value; } -/*[clinic end generated code: output=992733cfc7390590 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=3fd6fa2ce1aeca76 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_gdbmmodule.c.h b/Modules/clinic/_gdbmmodule.c.h index ced48b99ed325..e4cb1e9477f3a 100644 --- a/Modules/clinic/_gdbmmodule.c.h +++ b/Modules/clinic/_gdbmmodule.c.h @@ -9,7 +9,7 @@ PyDoc_STRVAR(_gdbm_gdbm_get__doc__, "Get the value for key, or default if not present."); #define _GDBM_GDBM_GET_METHODDEF \ - {"get", (PyCFunction)(void(*)(void))_gdbm_gdbm_get, METH_FASTCALL, _gdbm_gdbm_get__doc__}, + {"get", _PyCFunction_CAST(_gdbm_gdbm_get), METH_FASTCALL, _gdbm_gdbm_get__doc__}, static PyObject * _gdbm_gdbm_get_impl(gdbmobject *self, PyObject *key, PyObject *default_value); @@ -43,7 +43,7 @@ PyDoc_STRVAR(_gdbm_gdbm_setdefault__doc__, "Get value for key, or set it to default and return default if not present."); #define _GDBM_GDBM_SETDEFAULT_METHODDEF \ - {"setdefault", (PyCFunction)(void(*)(void))_gdbm_gdbm_setdefault, METH_FASTCALL, _gdbm_gdbm_setdefault__doc__}, + {"setdefault", _PyCFunction_CAST(_gdbm_gdbm_setdefault), METH_FASTCALL, _gdbm_gdbm_setdefault__doc__}, static PyObject * _gdbm_gdbm_setdefault_impl(gdbmobject *self, PyObject *key, @@ -96,7 +96,7 @@ PyDoc_STRVAR(_gdbm_gdbm_keys__doc__, "Get a list of all keys in the database."); #define _GDBM_GDBM_KEYS_METHODDEF \ - {"keys", (PyCFunction)(void(*)(void))_gdbm_gdbm_keys, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _gdbm_gdbm_keys__doc__}, + {"keys", _PyCFunction_CAST(_gdbm_gdbm_keys), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _gdbm_gdbm_keys__doc__}, static PyObject * _gdbm_gdbm_keys_impl(gdbmobject *self, PyTypeObject *cls); @@ -122,7 +122,7 @@ PyDoc_STRVAR(_gdbm_gdbm_firstkey__doc__, "hash values, and won\'t be sorted by the key values."); #define _GDBM_GDBM_FIRSTKEY_METHODDEF \ - {"firstkey", (PyCFunction)(void(*)(void))_gdbm_gdbm_firstkey, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _gdbm_gdbm_firstkey__doc__}, + {"firstkey", _PyCFunction_CAST(_gdbm_gdbm_firstkey), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _gdbm_gdbm_firstkey__doc__}, static PyObject * _gdbm_gdbm_firstkey_impl(gdbmobject *self, PyTypeObject *cls); @@ -152,7 +152,7 @@ PyDoc_STRVAR(_gdbm_gdbm_nextkey__doc__, " k = db.nextkey(k)"); #define _GDBM_GDBM_NEXTKEY_METHODDEF \ - {"nextkey", (PyCFunction)(void(*)(void))_gdbm_gdbm_nextkey, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _gdbm_gdbm_nextkey__doc__}, + {"nextkey", _PyCFunction_CAST(_gdbm_gdbm_nextkey), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _gdbm_gdbm_nextkey__doc__}, static PyObject * _gdbm_gdbm_nextkey_impl(gdbmobject *self, PyTypeObject *cls, const char *key, @@ -190,7 +190,7 @@ PyDoc_STRVAR(_gdbm_gdbm_reorganize__doc__, "kept and reused as new (key,value) pairs are added."); #define _GDBM_GDBM_REORGANIZE_METHODDEF \ - {"reorganize", (PyCFunction)(void(*)(void))_gdbm_gdbm_reorganize, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _gdbm_gdbm_reorganize__doc__}, + {"reorganize", _PyCFunction_CAST(_gdbm_gdbm_reorganize), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _gdbm_gdbm_reorganize__doc__}, static PyObject * _gdbm_gdbm_reorganize_impl(gdbmobject *self, PyTypeObject *cls); @@ -215,7 +215,7 @@ PyDoc_STRVAR(_gdbm_gdbm_sync__doc__, "any unwritten data to be written to the disk."); #define _GDBM_GDBM_SYNC_METHODDEF \ - {"sync", (PyCFunction)(void(*)(void))_gdbm_gdbm_sync, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _gdbm_gdbm_sync__doc__}, + {"sync", _PyCFunction_CAST(_gdbm_gdbm_sync), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _gdbm_gdbm_sync__doc__}, static PyObject * _gdbm_gdbm_sync_impl(gdbmobject *self, PyTypeObject *cls); @@ -258,7 +258,7 @@ PyDoc_STRVAR(dbmopen__doc__, "when the database has to be created. It defaults to octal 0o666."); #define DBMOPEN_METHODDEF \ - {"open", (PyCFunction)(void(*)(void))dbmopen, METH_FASTCALL, dbmopen__doc__}, + {"open", _PyCFunction_CAST(dbmopen), METH_FASTCALL, dbmopen__doc__}, static PyObject * dbmopen_impl(PyObject *module, PyObject *filename, const char *flags, @@ -305,4 +305,4 @@ dbmopen(PyObject *module, PyObject *const *args, Py_ssize_t nargs) exit: return return_value; } -/*[clinic end generated code: output=fe7a0812eb560b23 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=617117d16956ac4d input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_hashopenssl.c.h b/Modules/clinic/_hashopenssl.c.h index de01489e6a3b0..5d84f4ac4e554 100644 --- a/Modules/clinic/_hashopenssl.c.h +++ b/Modules/clinic/_hashopenssl.c.h @@ -74,7 +74,7 @@ PyDoc_STRVAR(EVPXOF_digest__doc__, "Return the digest value as a bytes object."); #define EVPXOF_DIGEST_METHODDEF \ - {"digest", (PyCFunction)(void(*)(void))EVPXOF_digest, METH_FASTCALL|METH_KEYWORDS, EVPXOF_digest__doc__}, + {"digest", _PyCFunction_CAST(EVPXOF_digest), METH_FASTCALL|METH_KEYWORDS, EVPXOF_digest__doc__}, static PyObject * EVPXOF_digest_impl(EVPobject *self, Py_ssize_t length); @@ -121,7 +121,7 @@ PyDoc_STRVAR(EVPXOF_hexdigest__doc__, "Return the digest value as a string of hexadecimal digits."); #define EVPXOF_HEXDIGEST_METHODDEF \ - {"hexdigest", (PyCFunction)(void(*)(void))EVPXOF_hexdigest, METH_FASTCALL|METH_KEYWORDS, EVPXOF_hexdigest__doc__}, + {"hexdigest", _PyCFunction_CAST(EVPXOF_hexdigest), METH_FASTCALL|METH_KEYWORDS, EVPXOF_hexdigest__doc__}, static PyObject * EVPXOF_hexdigest_impl(EVPobject *self, Py_ssize_t length); @@ -171,7 +171,7 @@ PyDoc_STRVAR(EVP_new__doc__, "The MD5 and SHA1 algorithms are always supported."); #define EVP_NEW_METHODDEF \ - {"new", (PyCFunction)(void(*)(void))EVP_new, METH_FASTCALL|METH_KEYWORDS, EVP_new__doc__}, + {"new", _PyCFunction_CAST(EVP_new), METH_FASTCALL|METH_KEYWORDS, EVP_new__doc__}, static PyObject * EVP_new_impl(PyObject *module, PyObject *name_obj, PyObject *data_obj, @@ -225,7 +225,7 @@ PyDoc_STRVAR(_hashlib_openssl_md5__doc__, "Returns a md5 hash object; optionally initialized with a string"); #define _HASHLIB_OPENSSL_MD5_METHODDEF \ - {"openssl_md5", (PyCFunction)(void(*)(void))_hashlib_openssl_md5, METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_md5__doc__}, + {"openssl_md5", _PyCFunction_CAST(_hashlib_openssl_md5), METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_md5__doc__}, static PyObject * _hashlib_openssl_md5_impl(PyObject *module, PyObject *data_obj, @@ -277,7 +277,7 @@ PyDoc_STRVAR(_hashlib_openssl_sha1__doc__, "Returns a sha1 hash object; optionally initialized with a string"); #define _HASHLIB_OPENSSL_SHA1_METHODDEF \ - {"openssl_sha1", (PyCFunction)(void(*)(void))_hashlib_openssl_sha1, METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_sha1__doc__}, + {"openssl_sha1", _PyCFunction_CAST(_hashlib_openssl_sha1), METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_sha1__doc__}, static PyObject * _hashlib_openssl_sha1_impl(PyObject *module, PyObject *data_obj, @@ -329,7 +329,7 @@ PyDoc_STRVAR(_hashlib_openssl_sha224__doc__, "Returns a sha224 hash object; optionally initialized with a string"); #define _HASHLIB_OPENSSL_SHA224_METHODDEF \ - {"openssl_sha224", (PyCFunction)(void(*)(void))_hashlib_openssl_sha224, METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_sha224__doc__}, + {"openssl_sha224", _PyCFunction_CAST(_hashlib_openssl_sha224), METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_sha224__doc__}, static PyObject * _hashlib_openssl_sha224_impl(PyObject *module, PyObject *data_obj, @@ -381,7 +381,7 @@ PyDoc_STRVAR(_hashlib_openssl_sha256__doc__, "Returns a sha256 hash object; optionally initialized with a string"); #define _HASHLIB_OPENSSL_SHA256_METHODDEF \ - {"openssl_sha256", (PyCFunction)(void(*)(void))_hashlib_openssl_sha256, METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_sha256__doc__}, + {"openssl_sha256", _PyCFunction_CAST(_hashlib_openssl_sha256), METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_sha256__doc__}, static PyObject * _hashlib_openssl_sha256_impl(PyObject *module, PyObject *data_obj, @@ -433,7 +433,7 @@ PyDoc_STRVAR(_hashlib_openssl_sha384__doc__, "Returns a sha384 hash object; optionally initialized with a string"); #define _HASHLIB_OPENSSL_SHA384_METHODDEF \ - {"openssl_sha384", (PyCFunction)(void(*)(void))_hashlib_openssl_sha384, METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_sha384__doc__}, + {"openssl_sha384", _PyCFunction_CAST(_hashlib_openssl_sha384), METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_sha384__doc__}, static PyObject * _hashlib_openssl_sha384_impl(PyObject *module, PyObject *data_obj, @@ -485,7 +485,7 @@ PyDoc_STRVAR(_hashlib_openssl_sha512__doc__, "Returns a sha512 hash object; optionally initialized with a string"); #define _HASHLIB_OPENSSL_SHA512_METHODDEF \ - {"openssl_sha512", (PyCFunction)(void(*)(void))_hashlib_openssl_sha512, METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_sha512__doc__}, + {"openssl_sha512", _PyCFunction_CAST(_hashlib_openssl_sha512), METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_sha512__doc__}, static PyObject * _hashlib_openssl_sha512_impl(PyObject *module, PyObject *data_obj, @@ -539,7 +539,7 @@ PyDoc_STRVAR(_hashlib_openssl_sha3_224__doc__, "Returns a sha3-224 hash object; optionally initialized with a string"); #define _HASHLIB_OPENSSL_SHA3_224_METHODDEF \ - {"openssl_sha3_224", (PyCFunction)(void(*)(void))_hashlib_openssl_sha3_224, METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_sha3_224__doc__}, + {"openssl_sha3_224", _PyCFunction_CAST(_hashlib_openssl_sha3_224), METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_sha3_224__doc__}, static PyObject * _hashlib_openssl_sha3_224_impl(PyObject *module, PyObject *data_obj, @@ -595,7 +595,7 @@ PyDoc_STRVAR(_hashlib_openssl_sha3_256__doc__, "Returns a sha3-256 hash object; optionally initialized with a string"); #define _HASHLIB_OPENSSL_SHA3_256_METHODDEF \ - {"openssl_sha3_256", (PyCFunction)(void(*)(void))_hashlib_openssl_sha3_256, METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_sha3_256__doc__}, + {"openssl_sha3_256", _PyCFunction_CAST(_hashlib_openssl_sha3_256), METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_sha3_256__doc__}, static PyObject * _hashlib_openssl_sha3_256_impl(PyObject *module, PyObject *data_obj, @@ -651,7 +651,7 @@ PyDoc_STRVAR(_hashlib_openssl_sha3_384__doc__, "Returns a sha3-384 hash object; optionally initialized with a string"); #define _HASHLIB_OPENSSL_SHA3_384_METHODDEF \ - {"openssl_sha3_384", (PyCFunction)(void(*)(void))_hashlib_openssl_sha3_384, METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_sha3_384__doc__}, + {"openssl_sha3_384", _PyCFunction_CAST(_hashlib_openssl_sha3_384), METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_sha3_384__doc__}, static PyObject * _hashlib_openssl_sha3_384_impl(PyObject *module, PyObject *data_obj, @@ -707,7 +707,7 @@ PyDoc_STRVAR(_hashlib_openssl_sha3_512__doc__, "Returns a sha3-512 hash object; optionally initialized with a string"); #define _HASHLIB_OPENSSL_SHA3_512_METHODDEF \ - {"openssl_sha3_512", (PyCFunction)(void(*)(void))_hashlib_openssl_sha3_512, METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_sha3_512__doc__}, + {"openssl_sha3_512", _PyCFunction_CAST(_hashlib_openssl_sha3_512), METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_sha3_512__doc__}, static PyObject * _hashlib_openssl_sha3_512_impl(PyObject *module, PyObject *data_obj, @@ -763,7 +763,7 @@ PyDoc_STRVAR(_hashlib_openssl_shake_128__doc__, "Returns a shake-128 variable hash object; optionally initialized with a string"); #define _HASHLIB_OPENSSL_SHAKE_128_METHODDEF \ - {"openssl_shake_128", (PyCFunction)(void(*)(void))_hashlib_openssl_shake_128, METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_shake_128__doc__}, + {"openssl_shake_128", _PyCFunction_CAST(_hashlib_openssl_shake_128), METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_shake_128__doc__}, static PyObject * _hashlib_openssl_shake_128_impl(PyObject *module, PyObject *data_obj, @@ -819,7 +819,7 @@ PyDoc_STRVAR(_hashlib_openssl_shake_256__doc__, "Returns a shake-256 variable hash object; optionally initialized with a string"); #define _HASHLIB_OPENSSL_SHAKE_256_METHODDEF \ - {"openssl_shake_256", (PyCFunction)(void(*)(void))_hashlib_openssl_shake_256, METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_shake_256__doc__}, + {"openssl_shake_256", _PyCFunction_CAST(_hashlib_openssl_shake_256), METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_shake_256__doc__}, static PyObject * _hashlib_openssl_shake_256_impl(PyObject *module, PyObject *data_obj, @@ -874,7 +874,7 @@ PyDoc_STRVAR(pbkdf2_hmac__doc__, "Password based key derivation function 2 (PKCS #5 v2.0) with HMAC as pseudorandom function."); #define PBKDF2_HMAC_METHODDEF \ - {"pbkdf2_hmac", (PyCFunction)(void(*)(void))pbkdf2_hmac, METH_FASTCALL|METH_KEYWORDS, pbkdf2_hmac__doc__}, + {"pbkdf2_hmac", _PyCFunction_CAST(pbkdf2_hmac), METH_FASTCALL|METH_KEYWORDS, pbkdf2_hmac__doc__}, static PyObject * pbkdf2_hmac_impl(PyObject *module, const char *hash_name, @@ -960,7 +960,7 @@ PyDoc_STRVAR(_hashlib_scrypt__doc__, "scrypt password-based key derivation function."); #define _HASHLIB_SCRYPT_METHODDEF \ - {"scrypt", (PyCFunction)(void(*)(void))_hashlib_scrypt, METH_FASTCALL|METH_KEYWORDS, _hashlib_scrypt__doc__}, + {"scrypt", _PyCFunction_CAST(_hashlib_scrypt), METH_FASTCALL|METH_KEYWORDS, _hashlib_scrypt__doc__}, static PyObject * _hashlib_scrypt_impl(PyObject *module, Py_buffer *password, Py_buffer *salt, @@ -1077,7 +1077,7 @@ PyDoc_STRVAR(_hashlib_hmac_singleshot__doc__, "Single-shot HMAC."); #define _HASHLIB_HMAC_SINGLESHOT_METHODDEF \ - {"hmac_digest", (PyCFunction)(void(*)(void))_hashlib_hmac_singleshot, METH_FASTCALL|METH_KEYWORDS, _hashlib_hmac_singleshot__doc__}, + {"hmac_digest", _PyCFunction_CAST(_hashlib_hmac_singleshot), METH_FASTCALL|METH_KEYWORDS, _hashlib_hmac_singleshot__doc__}, static PyObject * _hashlib_hmac_singleshot_impl(PyObject *module, Py_buffer *key, @@ -1135,7 +1135,7 @@ PyDoc_STRVAR(_hashlib_hmac_new__doc__, "Return a new hmac object."); #define _HASHLIB_HMAC_NEW_METHODDEF \ - {"hmac_new", (PyCFunction)(void(*)(void))_hashlib_hmac_new, METH_FASTCALL|METH_KEYWORDS, _hashlib_hmac_new__doc__}, + {"hmac_new", _PyCFunction_CAST(_hashlib_hmac_new), METH_FASTCALL|METH_KEYWORDS, _hashlib_hmac_new__doc__}, static PyObject * _hashlib_hmac_new_impl(PyObject *module, Py_buffer *key, PyObject *msg_obj, @@ -1211,7 +1211,7 @@ PyDoc_STRVAR(_hashlib_HMAC_update__doc__, "Update the HMAC object with msg."); #define _HASHLIB_HMAC_UPDATE_METHODDEF \ - {"update", (PyCFunction)(void(*)(void))_hashlib_HMAC_update, METH_FASTCALL|METH_KEYWORDS, _hashlib_HMAC_update__doc__}, + {"update", _PyCFunction_CAST(_hashlib_HMAC_update), METH_FASTCALL|METH_KEYWORDS, _hashlib_HMAC_update__doc__}, static PyObject * _hashlib_HMAC_update_impl(HMACobject *self, PyObject *msg); @@ -1327,7 +1327,7 @@ PyDoc_STRVAR(_hashlib_compare_digest__doc__, "types and lengths of a and b--but not their values."); #define _HASHLIB_COMPARE_DIGEST_METHODDEF \ - {"compare_digest", (PyCFunction)(void(*)(void))_hashlib_compare_digest, METH_FASTCALL, _hashlib_compare_digest__doc__}, + {"compare_digest", _PyCFunction_CAST(_hashlib_compare_digest), METH_FASTCALL, _hashlib_compare_digest__doc__}, static PyObject * _hashlib_compare_digest_impl(PyObject *module, PyObject *a, PyObject *b); @@ -1385,4 +1385,4 @@ _hashlib_compare_digest(PyObject *module, PyObject *const *args, Py_ssize_t narg #ifndef _HASHLIB_SCRYPT_METHODDEF #define _HASHLIB_SCRYPT_METHODDEF #endif /* !defined(_HASHLIB_SCRYPT_METHODDEF) */ -/*[clinic end generated code: output=162369cb9d43f1cc input=a9049054013a1b77]*/ +/*[clinic end generated code: output=69f2374071bff707 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_heapqmodule.c.h b/Modules/clinic/_heapqmodule.c.h index a894315a766c2..8d73b5b48d6a0 100644 --- a/Modules/clinic/_heapqmodule.c.h +++ b/Modules/clinic/_heapqmodule.c.h @@ -9,7 +9,7 @@ PyDoc_STRVAR(_heapq_heappush__doc__, "Push item onto heap, maintaining the heap invariant."); #define _HEAPQ_HEAPPUSH_METHODDEF \ - {"heappush", (PyCFunction)(void(*)(void))_heapq_heappush, METH_FASTCALL, _heapq_heappush__doc__}, + {"heappush", _PyCFunction_CAST(_heapq_heappush), METH_FASTCALL, _heapq_heappush__doc__}, static PyObject * _heapq_heappush_impl(PyObject *module, PyObject *heap, PyObject *item); @@ -80,7 +80,7 @@ PyDoc_STRVAR(_heapq_heapreplace__doc__, " item = heapreplace(heap, item)"); #define _HEAPQ_HEAPREPLACE_METHODDEF \ - {"heapreplace", (PyCFunction)(void(*)(void))_heapq_heapreplace, METH_FASTCALL, _heapq_heapreplace__doc__}, + {"heapreplace", _PyCFunction_CAST(_heapq_heapreplace), METH_FASTCALL, _heapq_heapreplace__doc__}, static PyObject * _heapq_heapreplace_impl(PyObject *module, PyObject *heap, PyObject *item); @@ -117,7 +117,7 @@ PyDoc_STRVAR(_heapq_heappushpop__doc__, "a separate call to heappop()."); #define _HEAPQ_HEAPPUSHPOP_METHODDEF \ - {"heappushpop", (PyCFunction)(void(*)(void))_heapq_heappushpop, METH_FASTCALL, _heapq_heappushpop__doc__}, + {"heappushpop", _PyCFunction_CAST(_heapq_heappushpop), METH_FASTCALL, _heapq_heappushpop__doc__}, static PyObject * _heapq_heappushpop_impl(PyObject *module, PyObject *heap, PyObject *item); @@ -209,7 +209,7 @@ PyDoc_STRVAR(_heapq__heapreplace_max__doc__, "Maxheap variant of heapreplace."); #define _HEAPQ__HEAPREPLACE_MAX_METHODDEF \ - {"_heapreplace_max", (PyCFunction)(void(*)(void))_heapq__heapreplace_max, METH_FASTCALL, _heapq__heapreplace_max__doc__}, + {"_heapreplace_max", _PyCFunction_CAST(_heapq__heapreplace_max), METH_FASTCALL, _heapq__heapreplace_max__doc__}, static PyObject * _heapq__heapreplace_max_impl(PyObject *module, PyObject *heap, @@ -265,4 +265,4 @@ _heapq__heapify_max(PyObject *module, PyObject *arg) exit: return return_value; } -/*[clinic end generated code: output=9975cf51762878d5 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=9a22715a8bf0c91d input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_localemodule.c.h b/Modules/clinic/_localemodule.c.h index 2958127e430de..0694263573947 100644 --- a/Modules/clinic/_localemodule.c.h +++ b/Modules/clinic/_localemodule.c.h @@ -9,7 +9,7 @@ PyDoc_STRVAR(_locale_setlocale__doc__, "Activates/queries locale processing."); #define _LOCALE_SETLOCALE_METHODDEF \ - {"setlocale", (PyCFunction)(void(*)(void))_locale_setlocale, METH_FASTCALL, _locale_setlocale__doc__}, + {"setlocale", _PyCFunction_CAST(_locale_setlocale), METH_FASTCALL, _locale_setlocale__doc__}, static PyObject * _locale_setlocale_impl(PyObject *module, int category, const char *locale); @@ -83,7 +83,7 @@ PyDoc_STRVAR(_locale_strcoll__doc__, "Compares two strings according to the locale."); #define _LOCALE_STRCOLL_METHODDEF \ - {"strcoll", (PyCFunction)(void(*)(void))_locale_strcoll, METH_FASTCALL, _locale_strcoll__doc__}, + {"strcoll", _PyCFunction_CAST(_locale_strcoll), METH_FASTCALL, _locale_strcoll__doc__}, static PyObject * _locale_strcoll_impl(PyObject *module, PyObject *os1, PyObject *os2); @@ -265,7 +265,7 @@ PyDoc_STRVAR(_locale_dgettext__doc__, "Return translation of msg in domain."); #define _LOCALE_DGETTEXT_METHODDEF \ - {"dgettext", (PyCFunction)(void(*)(void))_locale_dgettext, METH_FASTCALL, _locale_dgettext__doc__}, + {"dgettext", _PyCFunction_CAST(_locale_dgettext), METH_FASTCALL, _locale_dgettext__doc__}, static PyObject * _locale_dgettext_impl(PyObject *module, const char *domain, const char *in); @@ -328,7 +328,7 @@ PyDoc_STRVAR(_locale_dcgettext__doc__, "Return translation of msg in domain and category."); #define _LOCALE_DCGETTEXT_METHODDEF \ - {"dcgettext", (PyCFunction)(void(*)(void))_locale_dcgettext, METH_FASTCALL, _locale_dcgettext__doc__}, + {"dcgettext", _PyCFunction_CAST(_locale_dcgettext), METH_FASTCALL, _locale_dcgettext__doc__}, static PyObject * _locale_dcgettext_impl(PyObject *module, const char *domain, @@ -443,7 +443,7 @@ PyDoc_STRVAR(_locale_bindtextdomain__doc__, "Bind the C library\'s domain to dir."); #define _LOCALE_BINDTEXTDOMAIN_METHODDEF \ - {"bindtextdomain", (PyCFunction)(void(*)(void))_locale_bindtextdomain, METH_FASTCALL, _locale_bindtextdomain__doc__}, + {"bindtextdomain", _PyCFunction_CAST(_locale_bindtextdomain), METH_FASTCALL, _locale_bindtextdomain__doc__}, static PyObject * _locale_bindtextdomain_impl(PyObject *module, const char *domain, @@ -490,7 +490,7 @@ PyDoc_STRVAR(_locale_bind_textdomain_codeset__doc__, "Bind the C library\'s domain to codeset."); #define _LOCALE_BIND_TEXTDOMAIN_CODESET_METHODDEF \ - {"bind_textdomain_codeset", (PyCFunction)(void(*)(void))_locale_bind_textdomain_codeset, METH_FASTCALL, _locale_bind_textdomain_codeset__doc__}, + {"bind_textdomain_codeset", _PyCFunction_CAST(_locale_bind_textdomain_codeset), METH_FASTCALL, _locale_bind_textdomain_codeset__doc__}, static PyObject * _locale_bind_textdomain_codeset_impl(PyObject *module, const char *domain, @@ -602,4 +602,4 @@ _locale_getencoding(PyObject *module, PyObject *Py_UNUSED(ignored)) #ifndef _LOCALE_BIND_TEXTDOMAIN_CODESET_METHODDEF #define _LOCALE_BIND_TEXTDOMAIN_CODESET_METHODDEF #endif /* !defined(_LOCALE_BIND_TEXTDOMAIN_CODESET_METHODDEF) */ -/*[clinic end generated code: output=ea71e9b94bdaa47d input=a9049054013a1b77]*/ +/*[clinic end generated code: output=cfde12e987960245 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_lsprof.c.h b/Modules/clinic/_lsprof.c.h index b0adb746974ab..dfc003eb54774 100644 --- a/Modules/clinic/_lsprof.c.h +++ b/Modules/clinic/_lsprof.c.h @@ -31,7 +31,7 @@ PyDoc_STRVAR(_lsprof_Profiler_getstats__doc__, " inlinetime inline time (not in further subcalls)"); #define _LSPROF_PROFILER_GETSTATS_METHODDEF \ - {"getstats", (PyCFunction)(void(*)(void))_lsprof_Profiler_getstats, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _lsprof_Profiler_getstats__doc__}, + {"getstats", _PyCFunction_CAST(_lsprof_Profiler_getstats), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _lsprof_Profiler_getstats__doc__}, static PyObject * _lsprof_Profiler_getstats_impl(ProfilerObject *self, PyTypeObject *cls); @@ -45,4 +45,4 @@ _lsprof_Profiler_getstats(ProfilerObject *self, PyTypeObject *cls, PyObject *con } return _lsprof_Profiler_getstats_impl(self, cls); } -/*[clinic end generated code: output=57c7b6b0b8666429 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=0615a53cce828f06 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_lzmamodule.c.h b/Modules/clinic/_lzmamodule.c.h index 526031ade3b96..d98af74b4aaca 100644 --- a/Modules/clinic/_lzmamodule.c.h +++ b/Modules/clinic/_lzmamodule.c.h @@ -85,7 +85,7 @@ PyDoc_STRVAR(_lzma_LZMADecompressor_decompress__doc__, "the unused_data attribute."); #define _LZMA_LZMADECOMPRESSOR_DECOMPRESS_METHODDEF \ - {"decompress", (PyCFunction)(void(*)(void))_lzma_LZMADecompressor_decompress, METH_FASTCALL|METH_KEYWORDS, _lzma_LZMADecompressor_decompress__doc__}, + {"decompress", _PyCFunction_CAST(_lzma_LZMADecompressor_decompress), METH_FASTCALL|METH_KEYWORDS, _lzma_LZMADecompressor_decompress__doc__}, static PyObject * _lzma_LZMADecompressor_decompress_impl(Decompressor *self, Py_buffer *data, @@ -250,7 +250,7 @@ PyDoc_STRVAR(_lzma__decode_filter_properties__doc__, "The result does not include the filter ID itself, only the options."); #define _LZMA__DECODE_FILTER_PROPERTIES_METHODDEF \ - {"_decode_filter_properties", (PyCFunction)(void(*)(void))_lzma__decode_filter_properties, METH_FASTCALL, _lzma__decode_filter_properties__doc__}, + {"_decode_filter_properties", _PyCFunction_CAST(_lzma__decode_filter_properties), METH_FASTCALL, _lzma__decode_filter_properties__doc__}, static PyObject * _lzma__decode_filter_properties_impl(PyObject *module, lzma_vli filter_id, @@ -286,4 +286,4 @@ _lzma__decode_filter_properties(PyObject *module, PyObject *const *args, Py_ssiz return return_value; } -/*[clinic end generated code: output=867b9e334053b679 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=bce20bac13b0f252 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_opcode.c.h b/Modules/clinic/_opcode.c.h index 6ef303bb05e7c..d7e96a95c084f 100644 --- a/Modules/clinic/_opcode.c.h +++ b/Modules/clinic/_opcode.c.h @@ -9,7 +9,7 @@ PyDoc_STRVAR(_opcode_stack_effect__doc__, "Compute the stack effect of the opcode."); #define _OPCODE_STACK_EFFECT_METHODDEF \ - {"stack_effect", (PyCFunction)(void(*)(void))_opcode_stack_effect, METH_FASTCALL|METH_KEYWORDS, _opcode_stack_effect__doc__}, + {"stack_effect", _PyCFunction_CAST(_opcode_stack_effect), METH_FASTCALL|METH_KEYWORDS, _opcode_stack_effect__doc__}, static int _opcode_stack_effect_impl(PyObject *module, int opcode, PyObject *oparg, @@ -74,4 +74,4 @@ _opcode_get_specialization_stats(PyObject *module, PyObject *Py_UNUSED(ignored)) { return _opcode_get_specialization_stats_impl(module); } -/*[clinic end generated code: output=1699b4b1488b49c1 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=b904260bf022f953 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_operator.c.h b/Modules/clinic/_operator.c.h index bda2eba6d12a2..3b5be7bf2c07a 100644 --- a/Modules/clinic/_operator.c.h +++ b/Modules/clinic/_operator.c.h @@ -37,7 +37,7 @@ PyDoc_STRVAR(_operator_add__doc__, "Same as a + b."); #define _OPERATOR_ADD_METHODDEF \ - {"add", (PyCFunction)(void(*)(void))_operator_add, METH_FASTCALL, _operator_add__doc__}, + {"add", _PyCFunction_CAST(_operator_add), METH_FASTCALL, _operator_add__doc__}, static PyObject * _operator_add_impl(PyObject *module, PyObject *a, PyObject *b); @@ -67,7 +67,7 @@ PyDoc_STRVAR(_operator_sub__doc__, "Same as a - b."); #define _OPERATOR_SUB_METHODDEF \ - {"sub", (PyCFunction)(void(*)(void))_operator_sub, METH_FASTCALL, _operator_sub__doc__}, + {"sub", _PyCFunction_CAST(_operator_sub), METH_FASTCALL, _operator_sub__doc__}, static PyObject * _operator_sub_impl(PyObject *module, PyObject *a, PyObject *b); @@ -97,7 +97,7 @@ PyDoc_STRVAR(_operator_mul__doc__, "Same as a * b."); #define _OPERATOR_MUL_METHODDEF \ - {"mul", (PyCFunction)(void(*)(void))_operator_mul, METH_FASTCALL, _operator_mul__doc__}, + {"mul", _PyCFunction_CAST(_operator_mul), METH_FASTCALL, _operator_mul__doc__}, static PyObject * _operator_mul_impl(PyObject *module, PyObject *a, PyObject *b); @@ -127,7 +127,7 @@ PyDoc_STRVAR(_operator_matmul__doc__, "Same as a @ b."); #define _OPERATOR_MATMUL_METHODDEF \ - {"matmul", (PyCFunction)(void(*)(void))_operator_matmul, METH_FASTCALL, _operator_matmul__doc__}, + {"matmul", _PyCFunction_CAST(_operator_matmul), METH_FASTCALL, _operator_matmul__doc__}, static PyObject * _operator_matmul_impl(PyObject *module, PyObject *a, PyObject *b); @@ -157,7 +157,7 @@ PyDoc_STRVAR(_operator_floordiv__doc__, "Same as a // b."); #define _OPERATOR_FLOORDIV_METHODDEF \ - {"floordiv", (PyCFunction)(void(*)(void))_operator_floordiv, METH_FASTCALL, _operator_floordiv__doc__}, + {"floordiv", _PyCFunction_CAST(_operator_floordiv), METH_FASTCALL, _operator_floordiv__doc__}, static PyObject * _operator_floordiv_impl(PyObject *module, PyObject *a, PyObject *b); @@ -187,7 +187,7 @@ PyDoc_STRVAR(_operator_truediv__doc__, "Same as a / b."); #define _OPERATOR_TRUEDIV_METHODDEF \ - {"truediv", (PyCFunction)(void(*)(void))_operator_truediv, METH_FASTCALL, _operator_truediv__doc__}, + {"truediv", _PyCFunction_CAST(_operator_truediv), METH_FASTCALL, _operator_truediv__doc__}, static PyObject * _operator_truediv_impl(PyObject *module, PyObject *a, PyObject *b); @@ -217,7 +217,7 @@ PyDoc_STRVAR(_operator_mod__doc__, "Same as a % b."); #define _OPERATOR_MOD_METHODDEF \ - {"mod", (PyCFunction)(void(*)(void))_operator_mod, METH_FASTCALL, _operator_mod__doc__}, + {"mod", _PyCFunction_CAST(_operator_mod), METH_FASTCALL, _operator_mod__doc__}, static PyObject * _operator_mod_impl(PyObject *module, PyObject *a, PyObject *b); @@ -292,7 +292,7 @@ PyDoc_STRVAR(_operator_lshift__doc__, "Same as a << b."); #define _OPERATOR_LSHIFT_METHODDEF \ - {"lshift", (PyCFunction)(void(*)(void))_operator_lshift, METH_FASTCALL, _operator_lshift__doc__}, + {"lshift", _PyCFunction_CAST(_operator_lshift), METH_FASTCALL, _operator_lshift__doc__}, static PyObject * _operator_lshift_impl(PyObject *module, PyObject *a, PyObject *b); @@ -322,7 +322,7 @@ PyDoc_STRVAR(_operator_rshift__doc__, "Same as a >> b."); #define _OPERATOR_RSHIFT_METHODDEF \ - {"rshift", (PyCFunction)(void(*)(void))_operator_rshift, METH_FASTCALL, _operator_rshift__doc__}, + {"rshift", _PyCFunction_CAST(_operator_rshift), METH_FASTCALL, _operator_rshift__doc__}, static PyObject * _operator_rshift_impl(PyObject *module, PyObject *a, PyObject *b); @@ -380,7 +380,7 @@ PyDoc_STRVAR(_operator_and___doc__, "Same as a & b."); #define _OPERATOR_AND__METHODDEF \ - {"and_", (PyCFunction)(void(*)(void))_operator_and_, METH_FASTCALL, _operator_and___doc__}, + {"and_", _PyCFunction_CAST(_operator_and_), METH_FASTCALL, _operator_and___doc__}, static PyObject * _operator_and__impl(PyObject *module, PyObject *a, PyObject *b); @@ -410,7 +410,7 @@ PyDoc_STRVAR(_operator_xor__doc__, "Same as a ^ b."); #define _OPERATOR_XOR_METHODDEF \ - {"xor", (PyCFunction)(void(*)(void))_operator_xor, METH_FASTCALL, _operator_xor__doc__}, + {"xor", _PyCFunction_CAST(_operator_xor), METH_FASTCALL, _operator_xor__doc__}, static PyObject * _operator_xor_impl(PyObject *module, PyObject *a, PyObject *b); @@ -440,7 +440,7 @@ PyDoc_STRVAR(_operator_or___doc__, "Same as a | b."); #define _OPERATOR_OR__METHODDEF \ - {"or_", (PyCFunction)(void(*)(void))_operator_or_, METH_FASTCALL, _operator_or___doc__}, + {"or_", _PyCFunction_CAST(_operator_or_), METH_FASTCALL, _operator_or___doc__}, static PyObject * _operator_or__impl(PyObject *module, PyObject *a, PyObject *b); @@ -470,7 +470,7 @@ PyDoc_STRVAR(_operator_iadd__doc__, "Same as a += b."); #define _OPERATOR_IADD_METHODDEF \ - {"iadd", (PyCFunction)(void(*)(void))_operator_iadd, METH_FASTCALL, _operator_iadd__doc__}, + {"iadd", _PyCFunction_CAST(_operator_iadd), METH_FASTCALL, _operator_iadd__doc__}, static PyObject * _operator_iadd_impl(PyObject *module, PyObject *a, PyObject *b); @@ -500,7 +500,7 @@ PyDoc_STRVAR(_operator_isub__doc__, "Same as a -= b."); #define _OPERATOR_ISUB_METHODDEF \ - {"isub", (PyCFunction)(void(*)(void))_operator_isub, METH_FASTCALL, _operator_isub__doc__}, + {"isub", _PyCFunction_CAST(_operator_isub), METH_FASTCALL, _operator_isub__doc__}, static PyObject * _operator_isub_impl(PyObject *module, PyObject *a, PyObject *b); @@ -530,7 +530,7 @@ PyDoc_STRVAR(_operator_imul__doc__, "Same as a *= b."); #define _OPERATOR_IMUL_METHODDEF \ - {"imul", (PyCFunction)(void(*)(void))_operator_imul, METH_FASTCALL, _operator_imul__doc__}, + {"imul", _PyCFunction_CAST(_operator_imul), METH_FASTCALL, _operator_imul__doc__}, static PyObject * _operator_imul_impl(PyObject *module, PyObject *a, PyObject *b); @@ -560,7 +560,7 @@ PyDoc_STRVAR(_operator_imatmul__doc__, "Same as a @= b."); #define _OPERATOR_IMATMUL_METHODDEF \ - {"imatmul", (PyCFunction)(void(*)(void))_operator_imatmul, METH_FASTCALL, _operator_imatmul__doc__}, + {"imatmul", _PyCFunction_CAST(_operator_imatmul), METH_FASTCALL, _operator_imatmul__doc__}, static PyObject * _operator_imatmul_impl(PyObject *module, PyObject *a, PyObject *b); @@ -590,7 +590,7 @@ PyDoc_STRVAR(_operator_ifloordiv__doc__, "Same as a //= b."); #define _OPERATOR_IFLOORDIV_METHODDEF \ - {"ifloordiv", (PyCFunction)(void(*)(void))_operator_ifloordiv, METH_FASTCALL, _operator_ifloordiv__doc__}, + {"ifloordiv", _PyCFunction_CAST(_operator_ifloordiv), METH_FASTCALL, _operator_ifloordiv__doc__}, static PyObject * _operator_ifloordiv_impl(PyObject *module, PyObject *a, PyObject *b); @@ -620,7 +620,7 @@ PyDoc_STRVAR(_operator_itruediv__doc__, "Same as a /= b."); #define _OPERATOR_ITRUEDIV_METHODDEF \ - {"itruediv", (PyCFunction)(void(*)(void))_operator_itruediv, METH_FASTCALL, _operator_itruediv__doc__}, + {"itruediv", _PyCFunction_CAST(_operator_itruediv), METH_FASTCALL, _operator_itruediv__doc__}, static PyObject * _operator_itruediv_impl(PyObject *module, PyObject *a, PyObject *b); @@ -650,7 +650,7 @@ PyDoc_STRVAR(_operator_imod__doc__, "Same as a %= b."); #define _OPERATOR_IMOD_METHODDEF \ - {"imod", (PyCFunction)(void(*)(void))_operator_imod, METH_FASTCALL, _operator_imod__doc__}, + {"imod", _PyCFunction_CAST(_operator_imod), METH_FASTCALL, _operator_imod__doc__}, static PyObject * _operator_imod_impl(PyObject *module, PyObject *a, PyObject *b); @@ -680,7 +680,7 @@ PyDoc_STRVAR(_operator_ilshift__doc__, "Same as a <<= b."); #define _OPERATOR_ILSHIFT_METHODDEF \ - {"ilshift", (PyCFunction)(void(*)(void))_operator_ilshift, METH_FASTCALL, _operator_ilshift__doc__}, + {"ilshift", _PyCFunction_CAST(_operator_ilshift), METH_FASTCALL, _operator_ilshift__doc__}, static PyObject * _operator_ilshift_impl(PyObject *module, PyObject *a, PyObject *b); @@ -710,7 +710,7 @@ PyDoc_STRVAR(_operator_irshift__doc__, "Same as a >>= b."); #define _OPERATOR_IRSHIFT_METHODDEF \ - {"irshift", (PyCFunction)(void(*)(void))_operator_irshift, METH_FASTCALL, _operator_irshift__doc__}, + {"irshift", _PyCFunction_CAST(_operator_irshift), METH_FASTCALL, _operator_irshift__doc__}, static PyObject * _operator_irshift_impl(PyObject *module, PyObject *a, PyObject *b); @@ -740,7 +740,7 @@ PyDoc_STRVAR(_operator_iand__doc__, "Same as a &= b."); #define _OPERATOR_IAND_METHODDEF \ - {"iand", (PyCFunction)(void(*)(void))_operator_iand, METH_FASTCALL, _operator_iand__doc__}, + {"iand", _PyCFunction_CAST(_operator_iand), METH_FASTCALL, _operator_iand__doc__}, static PyObject * _operator_iand_impl(PyObject *module, PyObject *a, PyObject *b); @@ -770,7 +770,7 @@ PyDoc_STRVAR(_operator_ixor__doc__, "Same as a ^= b."); #define _OPERATOR_IXOR_METHODDEF \ - {"ixor", (PyCFunction)(void(*)(void))_operator_ixor, METH_FASTCALL, _operator_ixor__doc__}, + {"ixor", _PyCFunction_CAST(_operator_ixor), METH_FASTCALL, _operator_ixor__doc__}, static PyObject * _operator_ixor_impl(PyObject *module, PyObject *a, PyObject *b); @@ -800,7 +800,7 @@ PyDoc_STRVAR(_operator_ior__doc__, "Same as a |= b."); #define _OPERATOR_IOR_METHODDEF \ - {"ior", (PyCFunction)(void(*)(void))_operator_ior, METH_FASTCALL, _operator_ior__doc__}, + {"ior", _PyCFunction_CAST(_operator_ior), METH_FASTCALL, _operator_ior__doc__}, static PyObject * _operator_ior_impl(PyObject *module, PyObject *a, PyObject *b); @@ -830,7 +830,7 @@ PyDoc_STRVAR(_operator_concat__doc__, "Same as a + b, for a and b sequences."); #define _OPERATOR_CONCAT_METHODDEF \ - {"concat", (PyCFunction)(void(*)(void))_operator_concat, METH_FASTCALL, _operator_concat__doc__}, + {"concat", _PyCFunction_CAST(_operator_concat), METH_FASTCALL, _operator_concat__doc__}, static PyObject * _operator_concat_impl(PyObject *module, PyObject *a, PyObject *b); @@ -860,7 +860,7 @@ PyDoc_STRVAR(_operator_iconcat__doc__, "Same as a += b, for a and b sequences."); #define _OPERATOR_ICONCAT_METHODDEF \ - {"iconcat", (PyCFunction)(void(*)(void))_operator_iconcat, METH_FASTCALL, _operator_iconcat__doc__}, + {"iconcat", _PyCFunction_CAST(_operator_iconcat), METH_FASTCALL, _operator_iconcat__doc__}, static PyObject * _operator_iconcat_impl(PyObject *module, PyObject *a, PyObject *b); @@ -890,7 +890,7 @@ PyDoc_STRVAR(_operator_contains__doc__, "Same as b in a (note reversed operands)."); #define _OPERATOR_CONTAINS_METHODDEF \ - {"contains", (PyCFunction)(void(*)(void))_operator_contains, METH_FASTCALL, _operator_contains__doc__}, + {"contains", _PyCFunction_CAST(_operator_contains), METH_FASTCALL, _operator_contains__doc__}, static int _operator_contains_impl(PyObject *module, PyObject *a, PyObject *b); @@ -925,7 +925,7 @@ PyDoc_STRVAR(_operator_indexOf__doc__, "Return the first index of b in a."); #define _OPERATOR_INDEXOF_METHODDEF \ - {"indexOf", (PyCFunction)(void(*)(void))_operator_indexOf, METH_FASTCALL, _operator_indexOf__doc__}, + {"indexOf", _PyCFunction_CAST(_operator_indexOf), METH_FASTCALL, _operator_indexOf__doc__}, static Py_ssize_t _operator_indexOf_impl(PyObject *module, PyObject *a, PyObject *b); @@ -960,7 +960,7 @@ PyDoc_STRVAR(_operator_countOf__doc__, "Return the number of items in a which are, or which equal, b."); #define _OPERATOR_COUNTOF_METHODDEF \ - {"countOf", (PyCFunction)(void(*)(void))_operator_countOf, METH_FASTCALL, _operator_countOf__doc__}, + {"countOf", _PyCFunction_CAST(_operator_countOf), METH_FASTCALL, _operator_countOf__doc__}, static Py_ssize_t _operator_countOf_impl(PyObject *module, PyObject *a, PyObject *b); @@ -995,7 +995,7 @@ PyDoc_STRVAR(_operator_getitem__doc__, "Same as a[b]."); #define _OPERATOR_GETITEM_METHODDEF \ - {"getitem", (PyCFunction)(void(*)(void))_operator_getitem, METH_FASTCALL, _operator_getitem__doc__}, + {"getitem", _PyCFunction_CAST(_operator_getitem), METH_FASTCALL, _operator_getitem__doc__}, static PyObject * _operator_getitem_impl(PyObject *module, PyObject *a, PyObject *b); @@ -1025,7 +1025,7 @@ PyDoc_STRVAR(_operator_setitem__doc__, "Same as a[b] = c."); #define _OPERATOR_SETITEM_METHODDEF \ - {"setitem", (PyCFunction)(void(*)(void))_operator_setitem, METH_FASTCALL, _operator_setitem__doc__}, + {"setitem", _PyCFunction_CAST(_operator_setitem), METH_FASTCALL, _operator_setitem__doc__}, static PyObject * _operator_setitem_impl(PyObject *module, PyObject *a, PyObject *b, @@ -1058,7 +1058,7 @@ PyDoc_STRVAR(_operator_delitem__doc__, "Same as del a[b]."); #define _OPERATOR_DELITEM_METHODDEF \ - {"delitem", (PyCFunction)(void(*)(void))_operator_delitem, METH_FASTCALL, _operator_delitem__doc__}, + {"delitem", _PyCFunction_CAST(_operator_delitem), METH_FASTCALL, _operator_delitem__doc__}, static PyObject * _operator_delitem_impl(PyObject *module, PyObject *a, PyObject *b); @@ -1088,7 +1088,7 @@ PyDoc_STRVAR(_operator_eq__doc__, "Same as a == b."); #define _OPERATOR_EQ_METHODDEF \ - {"eq", (PyCFunction)(void(*)(void))_operator_eq, METH_FASTCALL, _operator_eq__doc__}, + {"eq", _PyCFunction_CAST(_operator_eq), METH_FASTCALL, _operator_eq__doc__}, static PyObject * _operator_eq_impl(PyObject *module, PyObject *a, PyObject *b); @@ -1118,7 +1118,7 @@ PyDoc_STRVAR(_operator_ne__doc__, "Same as a != b."); #define _OPERATOR_NE_METHODDEF \ - {"ne", (PyCFunction)(void(*)(void))_operator_ne, METH_FASTCALL, _operator_ne__doc__}, + {"ne", _PyCFunction_CAST(_operator_ne), METH_FASTCALL, _operator_ne__doc__}, static PyObject * _operator_ne_impl(PyObject *module, PyObject *a, PyObject *b); @@ -1148,7 +1148,7 @@ PyDoc_STRVAR(_operator_lt__doc__, "Same as a < b."); #define _OPERATOR_LT_METHODDEF \ - {"lt", (PyCFunction)(void(*)(void))_operator_lt, METH_FASTCALL, _operator_lt__doc__}, + {"lt", _PyCFunction_CAST(_operator_lt), METH_FASTCALL, _operator_lt__doc__}, static PyObject * _operator_lt_impl(PyObject *module, PyObject *a, PyObject *b); @@ -1178,7 +1178,7 @@ PyDoc_STRVAR(_operator_le__doc__, "Same as a <= b."); #define _OPERATOR_LE_METHODDEF \ - {"le", (PyCFunction)(void(*)(void))_operator_le, METH_FASTCALL, _operator_le__doc__}, + {"le", _PyCFunction_CAST(_operator_le), METH_FASTCALL, _operator_le__doc__}, static PyObject * _operator_le_impl(PyObject *module, PyObject *a, PyObject *b); @@ -1208,7 +1208,7 @@ PyDoc_STRVAR(_operator_gt__doc__, "Same as a > b."); #define _OPERATOR_GT_METHODDEF \ - {"gt", (PyCFunction)(void(*)(void))_operator_gt, METH_FASTCALL, _operator_gt__doc__}, + {"gt", _PyCFunction_CAST(_operator_gt), METH_FASTCALL, _operator_gt__doc__}, static PyObject * _operator_gt_impl(PyObject *module, PyObject *a, PyObject *b); @@ -1238,7 +1238,7 @@ PyDoc_STRVAR(_operator_ge__doc__, "Same as a >= b."); #define _OPERATOR_GE_METHODDEF \ - {"ge", (PyCFunction)(void(*)(void))_operator_ge, METH_FASTCALL, _operator_ge__doc__}, + {"ge", _PyCFunction_CAST(_operator_ge), METH_FASTCALL, _operator_ge__doc__}, static PyObject * _operator_ge_impl(PyObject *module, PyObject *a, PyObject *b); @@ -1268,7 +1268,7 @@ PyDoc_STRVAR(_operator_pow__doc__, "Same as a ** b."); #define _OPERATOR_POW_METHODDEF \ - {"pow", (PyCFunction)(void(*)(void))_operator_pow, METH_FASTCALL, _operator_pow__doc__}, + {"pow", _PyCFunction_CAST(_operator_pow), METH_FASTCALL, _operator_pow__doc__}, static PyObject * _operator_pow_impl(PyObject *module, PyObject *a, PyObject *b); @@ -1298,7 +1298,7 @@ PyDoc_STRVAR(_operator_ipow__doc__, "Same as a **= b."); #define _OPERATOR_IPOW_METHODDEF \ - {"ipow", (PyCFunction)(void(*)(void))_operator_ipow, METH_FASTCALL, _operator_ipow__doc__}, + {"ipow", _PyCFunction_CAST(_operator_ipow), METH_FASTCALL, _operator_ipow__doc__}, static PyObject * _operator_ipow_impl(PyObject *module, PyObject *a, PyObject *b); @@ -1337,7 +1337,7 @@ PyDoc_STRVAR(_operator_is___doc__, "Same as a is b."); #define _OPERATOR_IS__METHODDEF \ - {"is_", (PyCFunction)(void(*)(void))_operator_is_, METH_FASTCALL, _operator_is___doc__}, + {"is_", _PyCFunction_CAST(_operator_is_), METH_FASTCALL, _operator_is___doc__}, static PyObject * _operator_is__impl(PyObject *module, PyObject *a, PyObject *b); @@ -1367,7 +1367,7 @@ PyDoc_STRVAR(_operator_is_not__doc__, "Same as a is not b."); #define _OPERATOR_IS_NOT_METHODDEF \ - {"is_not", (PyCFunction)(void(*)(void))_operator_is_not, METH_FASTCALL, _operator_is_not__doc__}, + {"is_not", _PyCFunction_CAST(_operator_is_not), METH_FASTCALL, _operator_is_not__doc__}, static PyObject * _operator_is_not_impl(PyObject *module, PyObject *a, PyObject *b); @@ -1403,7 +1403,7 @@ PyDoc_STRVAR(_operator_length_hint__doc__, "The result will be an integer >= 0."); #define _OPERATOR_LENGTH_HINT_METHODDEF \ - {"length_hint", (PyCFunction)(void(*)(void))_operator_length_hint, METH_FASTCALL, _operator_length_hint__doc__}, + {"length_hint", _PyCFunction_CAST(_operator_length_hint), METH_FASTCALL, _operator_length_hint__doc__}, static Py_ssize_t _operator_length_hint_impl(PyObject *module, PyObject *obj, @@ -1464,7 +1464,7 @@ PyDoc_STRVAR(_operator__compare_digest__doc__, "types and lengths of a and b--but not their values."); #define _OPERATOR__COMPARE_DIGEST_METHODDEF \ - {"_compare_digest", (PyCFunction)(void(*)(void))_operator__compare_digest, METH_FASTCALL, _operator__compare_digest__doc__}, + {"_compare_digest", _PyCFunction_CAST(_operator__compare_digest), METH_FASTCALL, _operator__compare_digest__doc__}, static PyObject * _operator__compare_digest_impl(PyObject *module, PyObject *a, PyObject *b); @@ -1486,4 +1486,4 @@ _operator__compare_digest(PyObject *module, PyObject *const *args, Py_ssize_t na exit: return return_value; } -/*[clinic end generated code: output=16749e11fda51785 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=44164c4fbd67e5c5 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_pickle.c.h b/Modules/clinic/_pickle.c.h index 136524b6a7134..5dc62fe190176 100644 --- a/Modules/clinic/_pickle.c.h +++ b/Modules/clinic/_pickle.c.h @@ -238,7 +238,7 @@ PyDoc_STRVAR(_pickle_Unpickler_find_class__doc__, "needed. Both arguments passed are str objects."); #define _PICKLE_UNPICKLER_FIND_CLASS_METHODDEF \ - {"find_class", (PyCFunction)(void(*)(void))_pickle_Unpickler_find_class, METH_FASTCALL, _pickle_Unpickler_find_class__doc__}, + {"find_class", _PyCFunction_CAST(_pickle_Unpickler_find_class), METH_FASTCALL, _pickle_Unpickler_find_class__doc__}, static PyObject * _pickle_Unpickler_find_class_impl(UnpicklerObject *self, @@ -486,7 +486,7 @@ PyDoc_STRVAR(_pickle_dump__doc__, "*buffer_callback* is not None and *protocol* is None or smaller than 5."); #define _PICKLE_DUMP_METHODDEF \ - {"dump", (PyCFunction)(void(*)(void))_pickle_dump, METH_FASTCALL|METH_KEYWORDS, _pickle_dump__doc__}, + {"dump", _PyCFunction_CAST(_pickle_dump), METH_FASTCALL|METH_KEYWORDS, _pickle_dump__doc__}, static PyObject * _pickle_dump_impl(PyObject *module, PyObject *obj, PyObject *file, @@ -568,7 +568,7 @@ PyDoc_STRVAR(_pickle_dumps__doc__, "*buffer_callback* is not None and *protocol* is None or smaller than 5."); #define _PICKLE_DUMPS_METHODDEF \ - {"dumps", (PyCFunction)(void(*)(void))_pickle_dumps, METH_FASTCALL|METH_KEYWORDS, _pickle_dumps__doc__}, + {"dumps", _PyCFunction_CAST(_pickle_dumps), METH_FASTCALL|METH_KEYWORDS, _pickle_dumps__doc__}, static PyObject * _pickle_dumps_impl(PyObject *module, PyObject *obj, PyObject *protocol, @@ -652,7 +652,7 @@ PyDoc_STRVAR(_pickle_load__doc__, "string instances as bytes objects."); #define _PICKLE_LOAD_METHODDEF \ - {"load", (PyCFunction)(void(*)(void))_pickle_load, METH_FASTCALL|METH_KEYWORDS, _pickle_load__doc__}, + {"load", _PyCFunction_CAST(_pickle_load), METH_FASTCALL|METH_KEYWORDS, _pickle_load__doc__}, static PyObject * _pickle_load_impl(PyObject *module, PyObject *file, int fix_imports, @@ -755,7 +755,7 @@ PyDoc_STRVAR(_pickle_loads__doc__, "string instances as bytes objects."); #define _PICKLE_LOADS_METHODDEF \ - {"loads", (PyCFunction)(void(*)(void))_pickle_loads, METH_FASTCALL|METH_KEYWORDS, _pickle_loads__doc__}, + {"loads", _PyCFunction_CAST(_pickle_loads), METH_FASTCALL|METH_KEYWORDS, _pickle_loads__doc__}, static PyObject * _pickle_loads_impl(PyObject *module, PyObject *data, int fix_imports, @@ -836,4 +836,4 @@ _pickle_loads(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObjec exit: return return_value; } -/*[clinic end generated code: output=324aad69644beda2 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=1bb1ead3c828e108 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_queuemodule.c.h b/Modules/clinic/_queuemodule.c.h index 056a8ef52e00f..b0b00f8199b54 100644 --- a/Modules/clinic/_queuemodule.c.h +++ b/Modules/clinic/_queuemodule.c.h @@ -42,7 +42,7 @@ PyDoc_STRVAR(_queue_SimpleQueue_put__doc__, "never blocks. They are provided for compatibility with the Queue class."); #define _QUEUE_SIMPLEQUEUE_PUT_METHODDEF \ - {"put", (PyCFunction)(void(*)(void))_queue_SimpleQueue_put, METH_FASTCALL|METH_KEYWORDS, _queue_SimpleQueue_put__doc__}, + {"put", _PyCFunction_CAST(_queue_SimpleQueue_put), METH_FASTCALL|METH_KEYWORDS, _queue_SimpleQueue_put__doc__}, static PyObject * _queue_SimpleQueue_put_impl(simplequeueobject *self, PyObject *item, @@ -95,7 +95,7 @@ PyDoc_STRVAR(_queue_SimpleQueue_put_nowait__doc__, "for compatibility with the Queue class."); #define _QUEUE_SIMPLEQUEUE_PUT_NOWAIT_METHODDEF \ - {"put_nowait", (PyCFunction)(void(*)(void))_queue_SimpleQueue_put_nowait, METH_FASTCALL|METH_KEYWORDS, _queue_SimpleQueue_put_nowait__doc__}, + {"put_nowait", _PyCFunction_CAST(_queue_SimpleQueue_put_nowait), METH_FASTCALL|METH_KEYWORDS, _queue_SimpleQueue_put_nowait__doc__}, static PyObject * _queue_SimpleQueue_put_nowait_impl(simplequeueobject *self, PyObject *item); @@ -135,7 +135,7 @@ PyDoc_STRVAR(_queue_SimpleQueue_get__doc__, "in that case)."); #define _QUEUE_SIMPLEQUEUE_GET_METHODDEF \ - {"get", (PyCFunction)(void(*)(void))_queue_SimpleQueue_get, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _queue_SimpleQueue_get__doc__}, + {"get", _PyCFunction_CAST(_queue_SimpleQueue_get), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _queue_SimpleQueue_get__doc__}, static PyObject * _queue_SimpleQueue_get_impl(simplequeueobject *self, PyTypeObject *cls, @@ -186,7 +186,7 @@ PyDoc_STRVAR(_queue_SimpleQueue_get_nowait__doc__, "raise the Empty exception."); #define _QUEUE_SIMPLEQUEUE_GET_NOWAIT_METHODDEF \ - {"get_nowait", (PyCFunction)(void(*)(void))_queue_SimpleQueue_get_nowait, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _queue_SimpleQueue_get_nowait__doc__}, + {"get_nowait", _PyCFunction_CAST(_queue_SimpleQueue_get_nowait), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _queue_SimpleQueue_get_nowait__doc__}, static PyObject * _queue_SimpleQueue_get_nowait_impl(simplequeueobject *self, @@ -257,4 +257,4 @@ _queue_SimpleQueue_qsize(simplequeueobject *self, PyObject *Py_UNUSED(ignored)) exit: return return_value; } -/*[clinic end generated code: output=36301c405a858f39 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=88ec8033aeb7241c input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_randommodule.c.h b/Modules/clinic/_randommodule.c.h index b3cd435b6f204..503c1f93ed814 100644 --- a/Modules/clinic/_randommodule.c.h +++ b/Modules/clinic/_randommodule.c.h @@ -30,7 +30,7 @@ PyDoc_STRVAR(_random_Random_seed__doc__, "of the current time and the process identifier."); #define _RANDOM_RANDOM_SEED_METHODDEF \ - {"seed", (PyCFunction)(void(*)(void))_random_Random_seed, METH_FASTCALL, _random_Random_seed__doc__}, + {"seed", _PyCFunction_CAST(_random_Random_seed), METH_FASTCALL, _random_Random_seed__doc__}, static PyObject * _random_Random_seed_impl(RandomObject *self, PyObject *n); @@ -109,4 +109,4 @@ _random_Random_getrandbits(RandomObject *self, PyObject *arg) exit: return return_value; } -/*[clinic end generated code: output=cc8a23b2757dc6ba input=a9049054013a1b77]*/ +/*[clinic end generated code: output=d144826cde89e605 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_ssl.c.h b/Modules/clinic/_ssl.c.h index 67eaf3f9609fa..67b125f3d7616 100644 --- a/Modules/clinic/_ssl.c.h +++ b/Modules/clinic/_ssl.c.h @@ -60,7 +60,7 @@ PyDoc_STRVAR(_ssl__SSLSocket_getpeercert__doc__, "return the certificate even if it wasn\'t validated."); #define _SSL__SSLSOCKET_GETPEERCERT_METHODDEF \ - {"getpeercert", (PyCFunction)(void(*)(void))_ssl__SSLSocket_getpeercert, METH_FASTCALL, _ssl__SSLSocket_getpeercert__doc__}, + {"getpeercert", _PyCFunction_CAST(_ssl__SSLSocket_getpeercert), METH_FASTCALL, _ssl__SSLSocket_getpeercert__doc__}, static PyObject * _ssl__SSLSocket_getpeercert_impl(PySSLSocket *self, int binary_mode); @@ -338,7 +338,7 @@ PyDoc_STRVAR(_ssl__SSLSocket_get_channel_binding__doc__, "Only \'tls-unique\' channel binding data from RFC 5929 is supported."); #define _SSL__SSLSOCKET_GET_CHANNEL_BINDING_METHODDEF \ - {"get_channel_binding", (PyCFunction)(void(*)(void))_ssl__SSLSocket_get_channel_binding, METH_FASTCALL|METH_KEYWORDS, _ssl__SSLSocket_get_channel_binding__doc__}, + {"get_channel_binding", _PyCFunction_CAST(_ssl__SSLSocket_get_channel_binding), METH_FASTCALL|METH_KEYWORDS, _ssl__SSLSocket_get_channel_binding__doc__}, static PyObject * _ssl__SSLSocket_get_channel_binding_impl(PySSLSocket *self, @@ -521,7 +521,7 @@ PyDoc_STRVAR(_ssl__SSLContext_load_cert_chain__doc__, "\n"); #define _SSL__SSLCONTEXT_LOAD_CERT_CHAIN_METHODDEF \ - {"load_cert_chain", (PyCFunction)(void(*)(void))_ssl__SSLContext_load_cert_chain, METH_FASTCALL|METH_KEYWORDS, _ssl__SSLContext_load_cert_chain__doc__}, + {"load_cert_chain", _PyCFunction_CAST(_ssl__SSLContext_load_cert_chain), METH_FASTCALL|METH_KEYWORDS, _ssl__SSLContext_load_cert_chain__doc__}, static PyObject * _ssl__SSLContext_load_cert_chain_impl(PySSLContext *self, PyObject *certfile, @@ -567,7 +567,7 @@ PyDoc_STRVAR(_ssl__SSLContext_load_verify_locations__doc__, "\n"); #define _SSL__SSLCONTEXT_LOAD_VERIFY_LOCATIONS_METHODDEF \ - {"load_verify_locations", (PyCFunction)(void(*)(void))_ssl__SSLContext_load_verify_locations, METH_FASTCALL|METH_KEYWORDS, _ssl__SSLContext_load_verify_locations__doc__}, + {"load_verify_locations", _PyCFunction_CAST(_ssl__SSLContext_load_verify_locations), METH_FASTCALL|METH_KEYWORDS, _ssl__SSLContext_load_verify_locations__doc__}, static PyObject * _ssl__SSLContext_load_verify_locations_impl(PySSLContext *self, @@ -629,7 +629,7 @@ PyDoc_STRVAR(_ssl__SSLContext__wrap_socket__doc__, "\n"); #define _SSL__SSLCONTEXT__WRAP_SOCKET_METHODDEF \ - {"_wrap_socket", (PyCFunction)(void(*)(void))_ssl__SSLContext__wrap_socket, METH_FASTCALL|METH_KEYWORDS, _ssl__SSLContext__wrap_socket__doc__}, + {"_wrap_socket", _PyCFunction_CAST(_ssl__SSLContext__wrap_socket), METH_FASTCALL|METH_KEYWORDS, _ssl__SSLContext__wrap_socket__doc__}, static PyObject * _ssl__SSLContext__wrap_socket_impl(PySSLContext *self, PyObject *sock, @@ -697,7 +697,7 @@ PyDoc_STRVAR(_ssl__SSLContext__wrap_bio__doc__, "\n"); #define _SSL__SSLCONTEXT__WRAP_BIO_METHODDEF \ - {"_wrap_bio", (PyCFunction)(void(*)(void))_ssl__SSLContext__wrap_bio, METH_FASTCALL|METH_KEYWORDS, _ssl__SSLContext__wrap_bio__doc__}, + {"_wrap_bio", _PyCFunction_CAST(_ssl__SSLContext__wrap_bio), METH_FASTCALL|METH_KEYWORDS, _ssl__SSLContext__wrap_bio__doc__}, static PyObject * _ssl__SSLContext__wrap_bio_impl(PySSLContext *self, PySSLMemoryBIO *incoming, @@ -844,7 +844,7 @@ PyDoc_STRVAR(_ssl__SSLContext_get_ca_certs__doc__, "been used at least once."); #define _SSL__SSLCONTEXT_GET_CA_CERTS_METHODDEF \ - {"get_ca_certs", (PyCFunction)(void(*)(void))_ssl__SSLContext_get_ca_certs, METH_FASTCALL|METH_KEYWORDS, _ssl__SSLContext_get_ca_certs__doc__}, + {"get_ca_certs", _PyCFunction_CAST(_ssl__SSLContext_get_ca_certs), METH_FASTCALL|METH_KEYWORDS, _ssl__SSLContext_get_ca_certs__doc__}, static PyObject * _ssl__SSLContext_get_ca_certs_impl(PySSLContext *self, int binary_form); @@ -913,7 +913,7 @@ PyDoc_STRVAR(_ssl_MemoryBIO_read__doc__, "distinguish between the two."); #define _SSL_MEMORYBIO_READ_METHODDEF \ - {"read", (PyCFunction)(void(*)(void))_ssl_MemoryBIO_read, METH_FASTCALL, _ssl_MemoryBIO_read__doc__}, + {"read", _PyCFunction_CAST(_ssl_MemoryBIO_read), METH_FASTCALL, _ssl_MemoryBIO_read__doc__}, static PyObject * _ssl_MemoryBIO_read_impl(PySSLMemoryBIO *self, int len); @@ -1009,7 +1009,7 @@ PyDoc_STRVAR(_ssl_RAND_add__doc__, "string. See RFC 4086."); #define _SSL_RAND_ADD_METHODDEF \ - {"RAND_add", (PyCFunction)(void(*)(void))_ssl_RAND_add, METH_FASTCALL, _ssl_RAND_add__doc__}, + {"RAND_add", _PyCFunction_CAST(_ssl_RAND_add), METH_FASTCALL, _ssl_RAND_add__doc__}, static PyObject * _ssl_RAND_add_impl(PyObject *module, Py_buffer *view, double entropy); @@ -1172,7 +1172,7 @@ PyDoc_STRVAR(_ssl_txt2obj__doc__, "long name are also matched."); #define _SSL_TXT2OBJ_METHODDEF \ - {"txt2obj", (PyCFunction)(void(*)(void))_ssl_txt2obj, METH_FASTCALL|METH_KEYWORDS, _ssl_txt2obj__doc__}, + {"txt2obj", _PyCFunction_CAST(_ssl_txt2obj), METH_FASTCALL|METH_KEYWORDS, _ssl_txt2obj__doc__}, static PyObject * _ssl_txt2obj_impl(PyObject *module, const char *txt, int name); @@ -1262,7 +1262,7 @@ PyDoc_STRVAR(_ssl_enum_certificates__doc__, "a set of OIDs or the boolean True."); #define _SSL_ENUM_CERTIFICATES_METHODDEF \ - {"enum_certificates", (PyCFunction)(void(*)(void))_ssl_enum_certificates, METH_FASTCALL|METH_KEYWORDS, _ssl_enum_certificates__doc__}, + {"enum_certificates", _PyCFunction_CAST(_ssl_enum_certificates), METH_FASTCALL|METH_KEYWORDS, _ssl_enum_certificates__doc__}, static PyObject * _ssl_enum_certificates_impl(PyObject *module, const char *store_name); @@ -1315,7 +1315,7 @@ PyDoc_STRVAR(_ssl_enum_crls__doc__, "X509_ASN_ENCODING or PKCS_7_ASN_ENCODING."); #define _SSL_ENUM_CRLS_METHODDEF \ - {"enum_crls", (PyCFunction)(void(*)(void))_ssl_enum_crls, METH_FASTCALL|METH_KEYWORDS, _ssl_enum_crls__doc__}, + {"enum_crls", _PyCFunction_CAST(_ssl_enum_crls), METH_FASTCALL|METH_KEYWORDS, _ssl_enum_crls__doc__}, static PyObject * _ssl_enum_crls_impl(PyObject *module, const char *store_name); @@ -1361,4 +1361,4 @@ _ssl_enum_crls(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObje #ifndef _SSL_ENUM_CRLS_METHODDEF #define _SSL_ENUM_CRLS_METHODDEF #endif /* !defined(_SSL_ENUM_CRLS_METHODDEF) */ -/*[clinic end generated code: output=cd2a53c26eda295e input=a9049054013a1b77]*/ +/*[clinic end generated code: output=2a488dd0cbc777df input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_statisticsmodule.c.h b/Modules/clinic/_statisticsmodule.c.h index 5ff01efddcde8..03543e41af7f5 100644 --- a/Modules/clinic/_statisticsmodule.c.h +++ b/Modules/clinic/_statisticsmodule.c.h @@ -8,7 +8,7 @@ PyDoc_STRVAR(_statistics__normal_dist_inv_cdf__doc__, "\n"); #define _STATISTICS__NORMAL_DIST_INV_CDF_METHODDEF \ - {"_normal_dist_inv_cdf", (PyCFunction)(void(*)(void))_statistics__normal_dist_inv_cdf, METH_FASTCALL, _statistics__normal_dist_inv_cdf__doc__}, + {"_normal_dist_inv_cdf", _PyCFunction_CAST(_statistics__normal_dist_inv_cdf), METH_FASTCALL, _statistics__normal_dist_inv_cdf__doc__}, static double _statistics__normal_dist_inv_cdf_impl(PyObject *module, double p, double mu, @@ -65,4 +65,4 @@ _statistics__normal_dist_inv_cdf(PyObject *module, PyObject *const *args, Py_ssi exit: return return_value; } -/*[clinic end generated code: output=c5826928a238326c input=a9049054013a1b77]*/ +/*[clinic end generated code: output=b807a8243e7801e6 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_struct.c.h b/Modules/clinic/_struct.c.h index b0c1eb4587ae2..39b8ccb5ca49b 100644 --- a/Modules/clinic/_struct.c.h +++ b/Modules/clinic/_struct.c.h @@ -93,7 +93,7 @@ PyDoc_STRVAR(Struct_unpack_from__doc__, "See help(struct) for more on format strings."); #define STRUCT_UNPACK_FROM_METHODDEF \ - {"unpack_from", (PyCFunction)(void(*)(void))Struct_unpack_from, METH_FASTCALL|METH_KEYWORDS, Struct_unpack_from__doc__}, + {"unpack_from", _PyCFunction_CAST(Struct_unpack_from), METH_FASTCALL|METH_KEYWORDS, Struct_unpack_from__doc__}, static PyObject * Struct_unpack_from_impl(PyStructObject *self, Py_buffer *buffer, @@ -226,7 +226,7 @@ PyDoc_STRVAR(unpack__doc__, "See help(struct) for more on format strings."); #define UNPACK_METHODDEF \ - {"unpack", (PyCFunction)(void(*)(void))unpack, METH_FASTCALL, unpack__doc__}, + {"unpack", _PyCFunction_CAST(unpack), METH_FASTCALL, unpack__doc__}, static PyObject * unpack_impl(PyObject *module, PyStructObject *s_object, Py_buffer *buffer); @@ -275,7 +275,7 @@ PyDoc_STRVAR(unpack_from__doc__, "See help(struct) for more on format strings."); #define UNPACK_FROM_METHODDEF \ - {"unpack_from", (PyCFunction)(void(*)(void))unpack_from, METH_FASTCALL|METH_KEYWORDS, unpack_from__doc__}, + {"unpack_from", _PyCFunction_CAST(unpack_from), METH_FASTCALL|METH_KEYWORDS, unpack_from__doc__}, static PyObject * unpack_from_impl(PyObject *module, PyStructObject *s_object, @@ -348,7 +348,7 @@ PyDoc_STRVAR(iter_unpack__doc__, "Requires that the bytes length be a multiple of the format struct size."); #define ITER_UNPACK_METHODDEF \ - {"iter_unpack", (PyCFunction)(void(*)(void))iter_unpack, METH_FASTCALL, iter_unpack__doc__}, + {"iter_unpack", _PyCFunction_CAST(iter_unpack), METH_FASTCALL, iter_unpack__doc__}, static PyObject * iter_unpack_impl(PyObject *module, PyStructObject *s_object, @@ -376,4 +376,4 @@ iter_unpack(PyObject *module, PyObject *const *args, Py_ssize_t nargs) return return_value; } -/*[clinic end generated code: output=a3d3cd900091cb1c input=a9049054013a1b77]*/ +/*[clinic end generated code: output=2065c9b007be631c input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_testmultiphase.c.h b/Modules/clinic/_testmultiphase.c.h index 753670934bf81..eabaea635d50d 100644 --- a/Modules/clinic/_testmultiphase.c.h +++ b/Modules/clinic/_testmultiphase.c.h @@ -12,7 +12,7 @@ PyDoc_STRVAR(_testmultiphase_StateAccessType_get_defining_module__doc__, "module."); #define _TESTMULTIPHASE_STATEACCESSTYPE_GET_DEFINING_MODULE_METHODDEF \ - {"get_defining_module", (PyCFunction)(void(*)(void))_testmultiphase_StateAccessType_get_defining_module, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _testmultiphase_StateAccessType_get_defining_module__doc__}, + {"get_defining_module", _PyCFunction_CAST(_testmultiphase_StateAccessType_get_defining_module), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _testmultiphase_StateAccessType_get_defining_module__doc__}, static PyObject * _testmultiphase_StateAccessType_get_defining_module_impl(StateAccessTypeObject *self, @@ -35,7 +35,7 @@ PyDoc_STRVAR(_testmultiphase_StateAccessType_getmodulebydef_bad_def__doc__, "Test that result of PyType_GetModuleByDef with a bad def is NULL."); #define _TESTMULTIPHASE_STATEACCESSTYPE_GETMODULEBYDEF_BAD_DEF_METHODDEF \ - {"getmodulebydef_bad_def", (PyCFunction)(void(*)(void))_testmultiphase_StateAccessType_getmodulebydef_bad_def, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _testmultiphase_StateAccessType_getmodulebydef_bad_def__doc__}, + {"getmodulebydef_bad_def", _PyCFunction_CAST(_testmultiphase_StateAccessType_getmodulebydef_bad_def), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _testmultiphase_StateAccessType_getmodulebydef_bad_def__doc__}, static PyObject * _testmultiphase_StateAccessType_getmodulebydef_bad_def_impl(StateAccessTypeObject *self, @@ -62,7 +62,7 @@ PyDoc_STRVAR(_testmultiphase_StateAccessType_increment_count_clinic__doc__, "This tests Argument Clinic support for defining_class."); #define _TESTMULTIPHASE_STATEACCESSTYPE_INCREMENT_COUNT_CLINIC_METHODDEF \ - {"increment_count_clinic", (PyCFunction)(void(*)(void))_testmultiphase_StateAccessType_increment_count_clinic, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _testmultiphase_StateAccessType_increment_count_clinic__doc__}, + {"increment_count_clinic", _PyCFunction_CAST(_testmultiphase_StateAccessType_increment_count_clinic), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _testmultiphase_StateAccessType_increment_count_clinic__doc__}, static PyObject * _testmultiphase_StateAccessType_increment_count_clinic_impl(StateAccessTypeObject *self, @@ -118,7 +118,7 @@ PyDoc_STRVAR(_testmultiphase_StateAccessType_get_count__doc__, "Return the value of the module-state counter."); #define _TESTMULTIPHASE_STATEACCESSTYPE_GET_COUNT_METHODDEF \ - {"get_count", (PyCFunction)(void(*)(void))_testmultiphase_StateAccessType_get_count, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _testmultiphase_StateAccessType_get_count__doc__}, + {"get_count", _PyCFunction_CAST(_testmultiphase_StateAccessType_get_count), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _testmultiphase_StateAccessType_get_count__doc__}, static PyObject * _testmultiphase_StateAccessType_get_count_impl(StateAccessTypeObject *self, @@ -133,4 +133,4 @@ _testmultiphase_StateAccessType_get_count(StateAccessTypeObject *self, PyTypeObj } return _testmultiphase_StateAccessType_get_count_impl(self, cls); } -/*[clinic end generated code: output=b41a400ef84f50af input=a9049054013a1b77]*/ +/*[clinic end generated code: output=48739d81c3834078 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_tkinter.c.h b/Modules/clinic/_tkinter.c.h index ea45858d73f21..9103565ead702 100644 --- a/Modules/clinic/_tkinter.c.h +++ b/Modules/clinic/_tkinter.c.h @@ -328,7 +328,7 @@ PyDoc_STRVAR(_tkinter_tkapp_createcommand__doc__, "\n"); #define _TKINTER_TKAPP_CREATECOMMAND_METHODDEF \ - {"createcommand", (PyCFunction)(void(*)(void))_tkinter_tkapp_createcommand, METH_FASTCALL, _tkinter_tkapp_createcommand__doc__}, + {"createcommand", _PyCFunction_CAST(_tkinter_tkapp_createcommand), METH_FASTCALL, _tkinter_tkapp_createcommand__doc__}, static PyObject * _tkinter_tkapp_createcommand_impl(TkappObject *self, const char *name, @@ -408,7 +408,7 @@ PyDoc_STRVAR(_tkinter_tkapp_createfilehandler__doc__, "\n"); #define _TKINTER_TKAPP_CREATEFILEHANDLER_METHODDEF \ - {"createfilehandler", (PyCFunction)(void(*)(void))_tkinter_tkapp_createfilehandler, METH_FASTCALL, _tkinter_tkapp_createfilehandler__doc__}, + {"createfilehandler", _PyCFunction_CAST(_tkinter_tkapp_createfilehandler), METH_FASTCALL, _tkinter_tkapp_createfilehandler__doc__}, static PyObject * _tkinter_tkapp_createfilehandler_impl(TkappObject *self, PyObject *file, @@ -474,7 +474,7 @@ PyDoc_STRVAR(_tkinter_tkapp_createtimerhandler__doc__, "\n"); #define _TKINTER_TKAPP_CREATETIMERHANDLER_METHODDEF \ - {"createtimerhandler", (PyCFunction)(void(*)(void))_tkinter_tkapp_createtimerhandler, METH_FASTCALL, _tkinter_tkapp_createtimerhandler__doc__}, + {"createtimerhandler", _PyCFunction_CAST(_tkinter_tkapp_createtimerhandler), METH_FASTCALL, _tkinter_tkapp_createtimerhandler__doc__}, static PyObject * _tkinter_tkapp_createtimerhandler_impl(TkappObject *self, int milliseconds, @@ -507,7 +507,7 @@ PyDoc_STRVAR(_tkinter_tkapp_mainloop__doc__, "\n"); #define _TKINTER_TKAPP_MAINLOOP_METHODDEF \ - {"mainloop", (PyCFunction)(void(*)(void))_tkinter_tkapp_mainloop, METH_FASTCALL, _tkinter_tkapp_mainloop__doc__}, + {"mainloop", _PyCFunction_CAST(_tkinter_tkapp_mainloop), METH_FASTCALL, _tkinter_tkapp_mainloop__doc__}, static PyObject * _tkinter_tkapp_mainloop_impl(TkappObject *self, int threshold); @@ -541,7 +541,7 @@ PyDoc_STRVAR(_tkinter_tkapp_dooneevent__doc__, "\n"); #define _TKINTER_TKAPP_DOONEEVENT_METHODDEF \ - {"dooneevent", (PyCFunction)(void(*)(void))_tkinter_tkapp_dooneevent, METH_FASTCALL, _tkinter_tkapp_dooneevent__doc__}, + {"dooneevent", _PyCFunction_CAST(_tkinter_tkapp_dooneevent), METH_FASTCALL, _tkinter_tkapp_dooneevent__doc__}, static PyObject * _tkinter_tkapp_dooneevent_impl(TkappObject *self, int flags); @@ -661,7 +661,7 @@ PyDoc_STRVAR(_tkinter_create__doc__, " if not None, then pass -use to wish"); #define _TKINTER_CREATE_METHODDEF \ - {"create", (PyCFunction)(void(*)(void))_tkinter_create, METH_FASTCALL, _tkinter_create__doc__}, + {"create", _PyCFunction_CAST(_tkinter_create), METH_FASTCALL, _tkinter_create__doc__}, static PyObject * _tkinter_create_impl(PyObject *module, const char *screenName, @@ -859,4 +859,4 @@ _tkinter_getbusywaitinterval(PyObject *module, PyObject *Py_UNUSED(ignored)) #ifndef _TKINTER_TKAPP_DELETEFILEHANDLER_METHODDEF #define _TKINTER_TKAPP_DELETEFILEHANDLER_METHODDEF #endif /* !defined(_TKINTER_TKAPP_DELETEFILEHANDLER_METHODDEF) */ -/*[clinic end generated code: output=b6d2dcb488c13aa7 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=b0667ac928eb0c28 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_tracemalloc.c.h b/Modules/clinic/_tracemalloc.c.h index 20afd76f06f11..20c4d5d81b9e9 100644 --- a/Modules/clinic/_tracemalloc.c.h +++ b/Modules/clinic/_tracemalloc.c.h @@ -84,7 +84,7 @@ PyDoc_STRVAR(_tracemalloc_start__doc__, "trace to nframe."); #define _TRACEMALLOC_START_METHODDEF \ - {"start", (PyCFunction)(void(*)(void))_tracemalloc_start, METH_FASTCALL, _tracemalloc_start__doc__}, + {"start", _PyCFunction_CAST(_tracemalloc_start), METH_FASTCALL, _tracemalloc_start__doc__}, static PyObject * _tracemalloc_start_impl(PyObject *module, int nframe); @@ -212,4 +212,4 @@ _tracemalloc_reset_peak(PyObject *module, PyObject *Py_UNUSED(ignored)) { return _tracemalloc_reset_peak_impl(module); } -/*[clinic end generated code: output=bafca0a19b0b0823 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=2ae4fe05f1a340c9 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_weakref.c.h b/Modules/clinic/_weakref.c.h index 02f0168937cde..541cba75e6813 100644 --- a/Modules/clinic/_weakref.c.h +++ b/Modules/clinic/_weakref.c.h @@ -37,7 +37,7 @@ PyDoc_STRVAR(_weakref__remove_dead_weakref__doc__, "Atomically remove key from dict if it points to a dead weakref."); #define _WEAKREF__REMOVE_DEAD_WEAKREF_METHODDEF \ - {"_remove_dead_weakref", (PyCFunction)(void(*)(void))_weakref__remove_dead_weakref, METH_FASTCALL, _weakref__remove_dead_weakref__doc__}, + {"_remove_dead_weakref", _PyCFunction_CAST(_weakref__remove_dead_weakref), METH_FASTCALL, _weakref__remove_dead_weakref__doc__}, static PyObject * _weakref__remove_dead_weakref_impl(PyObject *module, PyObject *dct, @@ -84,7 +84,7 @@ PyDoc_STRVAR(_weakref_proxy__doc__, "proxy when \'object\' is about to be finalized."); #define _WEAKREF_PROXY_METHODDEF \ - {"proxy", (PyCFunction)(void(*)(void))_weakref_proxy, METH_FASTCALL, _weakref_proxy__doc__}, + {"proxy", _PyCFunction_CAST(_weakref_proxy), METH_FASTCALL, _weakref_proxy__doc__}, static PyObject * _weakref_proxy_impl(PyObject *module, PyObject *object, PyObject *callback); @@ -110,4 +110,4 @@ _weakref_proxy(PyObject *module, PyObject *const *args, Py_ssize_t nargs) exit: return return_value; } -/*[clinic end generated code: output=5a10a1fa43722399 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=f4be6b8177fbceb8 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_winapi.c.h b/Modules/clinic/_winapi.c.h index 5bda156d7aa80..9c83d0ba2c545 100644 --- a/Modules/clinic/_winapi.c.h +++ b/Modules/clinic/_winapi.c.h @@ -96,7 +96,7 @@ PyDoc_STRVAR(_winapi_ConnectNamedPipe__doc__, "\n"); #define _WINAPI_CONNECTNAMEDPIPE_METHODDEF \ - {"ConnectNamedPipe", (PyCFunction)(void(*)(void))_winapi_ConnectNamedPipe, METH_FASTCALL|METH_KEYWORDS, _winapi_ConnectNamedPipe__doc__}, + {"ConnectNamedPipe", _PyCFunction_CAST(_winapi_ConnectNamedPipe), METH_FASTCALL|METH_KEYWORDS, _winapi_ConnectNamedPipe__doc__}, static PyObject * _winapi_ConnectNamedPipe_impl(PyObject *module, HANDLE handle, @@ -129,7 +129,7 @@ PyDoc_STRVAR(_winapi_CreateFile__doc__, "\n"); #define _WINAPI_CREATEFILE_METHODDEF \ - {"CreateFile", (PyCFunction)(void(*)(void))_winapi_CreateFile, METH_FASTCALL, _winapi_CreateFile__doc__}, + {"CreateFile", _PyCFunction_CAST(_winapi_CreateFile), METH_FASTCALL, _winapi_CreateFile__doc__}, static HANDLE _winapi_CreateFile_impl(PyObject *module, LPCTSTR file_name, @@ -175,7 +175,7 @@ PyDoc_STRVAR(_winapi_CreateFileMapping__doc__, "\n"); #define _WINAPI_CREATEFILEMAPPING_METHODDEF \ - {"CreateFileMapping", (PyCFunction)(void(*)(void))_winapi_CreateFileMapping, METH_FASTCALL, _winapi_CreateFileMapping__doc__}, + {"CreateFileMapping", _PyCFunction_CAST(_winapi_CreateFileMapping), METH_FASTCALL, _winapi_CreateFileMapping__doc__}, static HANDLE _winapi_CreateFileMapping_impl(PyObject *module, HANDLE file_handle, @@ -223,7 +223,7 @@ PyDoc_STRVAR(_winapi_CreateJunction__doc__, "\n"); #define _WINAPI_CREATEJUNCTION_METHODDEF \ - {"CreateJunction", (PyCFunction)(void(*)(void))_winapi_CreateJunction, METH_FASTCALL, _winapi_CreateJunction__doc__}, + {"CreateJunction", _PyCFunction_CAST(_winapi_CreateJunction), METH_FASTCALL, _winapi_CreateJunction__doc__}, static PyObject * _winapi_CreateJunction_impl(PyObject *module, LPCWSTR src_path, @@ -286,7 +286,7 @@ PyDoc_STRVAR(_winapi_CreateNamedPipe__doc__, "\n"); #define _WINAPI_CREATENAMEDPIPE_METHODDEF \ - {"CreateNamedPipe", (PyCFunction)(void(*)(void))_winapi_CreateNamedPipe, METH_FASTCALL, _winapi_CreateNamedPipe__doc__}, + {"CreateNamedPipe", _PyCFunction_CAST(_winapi_CreateNamedPipe), METH_FASTCALL, _winapi_CreateNamedPipe__doc__}, static HANDLE _winapi_CreateNamedPipe_impl(PyObject *module, LPCTSTR name, DWORD open_mode, @@ -338,7 +338,7 @@ PyDoc_STRVAR(_winapi_CreatePipe__doc__, "Returns a 2-tuple of handles, to the read and write ends of the pipe."); #define _WINAPI_CREATEPIPE_METHODDEF \ - {"CreatePipe", (PyCFunction)(void(*)(void))_winapi_CreatePipe, METH_FASTCALL, _winapi_CreatePipe__doc__}, + {"CreatePipe", _PyCFunction_CAST(_winapi_CreatePipe), METH_FASTCALL, _winapi_CreatePipe__doc__}, static PyObject * _winapi_CreatePipe_impl(PyObject *module, PyObject *pipe_attrs, DWORD size); @@ -379,7 +379,7 @@ PyDoc_STRVAR(_winapi_CreateProcess__doc__, "process ID, and thread ID."); #define _WINAPI_CREATEPROCESS_METHODDEF \ - {"CreateProcess", (PyCFunction)(void(*)(void))_winapi_CreateProcess, METH_FASTCALL, _winapi_CreateProcess__doc__}, + {"CreateProcess", _PyCFunction_CAST(_winapi_CreateProcess), METH_FASTCALL, _winapi_CreateProcess__doc__}, static PyObject * _winapi_CreateProcess_impl(PyObject *module, @@ -436,7 +436,7 @@ PyDoc_STRVAR(_winapi_DuplicateHandle__doc__, "through both handles."); #define _WINAPI_DUPLICATEHANDLE_METHODDEF \ - {"DuplicateHandle", (PyCFunction)(void(*)(void))_winapi_DuplicateHandle, METH_FASTCALL, _winapi_DuplicateHandle__doc__}, + {"DuplicateHandle", _PyCFunction_CAST(_winapi_DuplicateHandle), METH_FASTCALL, _winapi_DuplicateHandle__doc__}, static HANDLE _winapi_DuplicateHandle_impl(PyObject *module, HANDLE source_process_handle, @@ -699,7 +699,7 @@ PyDoc_STRVAR(_winapi_MapViewOfFile__doc__, "\n"); #define _WINAPI_MAPVIEWOFFILE_METHODDEF \ - {"MapViewOfFile", (PyCFunction)(void(*)(void))_winapi_MapViewOfFile, METH_FASTCALL, _winapi_MapViewOfFile__doc__}, + {"MapViewOfFile", _PyCFunction_CAST(_winapi_MapViewOfFile), METH_FASTCALL, _winapi_MapViewOfFile__doc__}, static LPVOID _winapi_MapViewOfFile_impl(PyObject *module, HANDLE file_map, @@ -737,7 +737,7 @@ PyDoc_STRVAR(_winapi_OpenFileMapping__doc__, "\n"); #define _WINAPI_OPENFILEMAPPING_METHODDEF \ - {"OpenFileMapping", (PyCFunction)(void(*)(void))_winapi_OpenFileMapping, METH_FASTCALL, _winapi_OpenFileMapping__doc__}, + {"OpenFileMapping", _PyCFunction_CAST(_winapi_OpenFileMapping), METH_FASTCALL, _winapi_OpenFileMapping__doc__}, static HANDLE _winapi_OpenFileMapping_impl(PyObject *module, DWORD desired_access, @@ -780,7 +780,7 @@ PyDoc_STRVAR(_winapi_OpenProcess__doc__, "\n"); #define _WINAPI_OPENPROCESS_METHODDEF \ - {"OpenProcess", (PyCFunction)(void(*)(void))_winapi_OpenProcess, METH_FASTCALL, _winapi_OpenProcess__doc__}, + {"OpenProcess", _PyCFunction_CAST(_winapi_OpenProcess), METH_FASTCALL, _winapi_OpenProcess__doc__}, static HANDLE _winapi_OpenProcess_impl(PyObject *module, DWORD desired_access, @@ -818,7 +818,7 @@ PyDoc_STRVAR(_winapi_PeekNamedPipe__doc__, "\n"); #define _WINAPI_PEEKNAMEDPIPE_METHODDEF \ - {"PeekNamedPipe", (PyCFunction)(void(*)(void))_winapi_PeekNamedPipe, METH_FASTCALL, _winapi_PeekNamedPipe__doc__}, + {"PeekNamedPipe", _PyCFunction_CAST(_winapi_PeekNamedPipe), METH_FASTCALL, _winapi_PeekNamedPipe__doc__}, static PyObject * _winapi_PeekNamedPipe_impl(PyObject *module, HANDLE handle, int size); @@ -846,7 +846,7 @@ PyDoc_STRVAR(_winapi_ReadFile__doc__, "\n"); #define _WINAPI_READFILE_METHODDEF \ - {"ReadFile", (PyCFunction)(void(*)(void))_winapi_ReadFile, METH_FASTCALL|METH_KEYWORDS, _winapi_ReadFile__doc__}, + {"ReadFile", _PyCFunction_CAST(_winapi_ReadFile), METH_FASTCALL|METH_KEYWORDS, _winapi_ReadFile__doc__}, static PyObject * _winapi_ReadFile_impl(PyObject *module, HANDLE handle, DWORD size, @@ -879,7 +879,7 @@ PyDoc_STRVAR(_winapi_SetNamedPipeHandleState__doc__, "\n"); #define _WINAPI_SETNAMEDPIPEHANDLESTATE_METHODDEF \ - {"SetNamedPipeHandleState", (PyCFunction)(void(*)(void))_winapi_SetNamedPipeHandleState, METH_FASTCALL, _winapi_SetNamedPipeHandleState__doc__}, + {"SetNamedPipeHandleState", _PyCFunction_CAST(_winapi_SetNamedPipeHandleState), METH_FASTCALL, _winapi_SetNamedPipeHandleState__doc__}, static PyObject * _winapi_SetNamedPipeHandleState_impl(PyObject *module, HANDLE named_pipe, @@ -913,7 +913,7 @@ PyDoc_STRVAR(_winapi_TerminateProcess__doc__, "Terminate the specified process and all of its threads."); #define _WINAPI_TERMINATEPROCESS_METHODDEF \ - {"TerminateProcess", (PyCFunction)(void(*)(void))_winapi_TerminateProcess, METH_FASTCALL, _winapi_TerminateProcess__doc__}, + {"TerminateProcess", _PyCFunction_CAST(_winapi_TerminateProcess), METH_FASTCALL, _winapi_TerminateProcess__doc__}, static PyObject * _winapi_TerminateProcess_impl(PyObject *module, HANDLE handle, @@ -973,7 +973,7 @@ PyDoc_STRVAR(_winapi_WaitNamedPipe__doc__, "\n"); #define _WINAPI_WAITNAMEDPIPE_METHODDEF \ - {"WaitNamedPipe", (PyCFunction)(void(*)(void))_winapi_WaitNamedPipe, METH_FASTCALL, _winapi_WaitNamedPipe__doc__}, + {"WaitNamedPipe", _PyCFunction_CAST(_winapi_WaitNamedPipe), METH_FASTCALL, _winapi_WaitNamedPipe__doc__}, static PyObject * _winapi_WaitNamedPipe_impl(PyObject *module, LPCTSTR name, DWORD timeout); @@ -1002,7 +1002,7 @@ PyDoc_STRVAR(_winapi_WaitForMultipleObjects__doc__, "\n"); #define _WINAPI_WAITFORMULTIPLEOBJECTS_METHODDEF \ - {"WaitForMultipleObjects", (PyCFunction)(void(*)(void))_winapi_WaitForMultipleObjects, METH_FASTCALL, _winapi_WaitForMultipleObjects__doc__}, + {"WaitForMultipleObjects", _PyCFunction_CAST(_winapi_WaitForMultipleObjects), METH_FASTCALL, _winapi_WaitForMultipleObjects__doc__}, static PyObject * _winapi_WaitForMultipleObjects_impl(PyObject *module, PyObject *handle_seq, @@ -1037,7 +1037,7 @@ PyDoc_STRVAR(_winapi_WaitForSingleObject__doc__, "in milliseconds."); #define _WINAPI_WAITFORSINGLEOBJECT_METHODDEF \ - {"WaitForSingleObject", (PyCFunction)(void(*)(void))_winapi_WaitForSingleObject, METH_FASTCALL, _winapi_WaitForSingleObject__doc__}, + {"WaitForSingleObject", _PyCFunction_CAST(_winapi_WaitForSingleObject), METH_FASTCALL, _winapi_WaitForSingleObject__doc__}, static long _winapi_WaitForSingleObject_impl(PyObject *module, HANDLE handle, @@ -1071,7 +1071,7 @@ PyDoc_STRVAR(_winapi_WriteFile__doc__, "\n"); #define _WINAPI_WRITEFILE_METHODDEF \ - {"WriteFile", (PyCFunction)(void(*)(void))_winapi_WriteFile, METH_FASTCALL|METH_KEYWORDS, _winapi_WriteFile__doc__}, + {"WriteFile", _PyCFunction_CAST(_winapi_WriteFile), METH_FASTCALL|METH_KEYWORDS, _winapi_WriteFile__doc__}, static PyObject * _winapi_WriteFile_impl(PyObject *module, HANDLE handle, PyObject *buffer, @@ -1121,7 +1121,7 @@ PyDoc_STRVAR(_winapi_GetFileType__doc__, "\n"); #define _WINAPI_GETFILETYPE_METHODDEF \ - {"GetFileType", (PyCFunction)(void(*)(void))_winapi_GetFileType, METH_FASTCALL|METH_KEYWORDS, _winapi_GetFileType__doc__}, + {"GetFileType", _PyCFunction_CAST(_winapi_GetFileType), METH_FASTCALL|METH_KEYWORDS, _winapi_GetFileType__doc__}, static DWORD _winapi_GetFileType_impl(PyObject *module, HANDLE handle); @@ -1159,7 +1159,7 @@ PyDoc_STRVAR(_winapi__mimetypes_read_windows_registry__doc__, "MimeTypes.add_type."); #define _WINAPI__MIMETYPES_READ_WINDOWS_REGISTRY_METHODDEF \ - {"_mimetypes_read_windows_registry", (PyCFunction)(void(*)(void))_winapi__mimetypes_read_windows_registry, METH_FASTCALL|METH_KEYWORDS, _winapi__mimetypes_read_windows_registry__doc__}, + {"_mimetypes_read_windows_registry", _PyCFunction_CAST(_winapi__mimetypes_read_windows_registry), METH_FASTCALL|METH_KEYWORDS, _winapi__mimetypes_read_windows_registry__doc__}, static PyObject * _winapi__mimetypes_read_windows_registry_impl(PyObject *module, @@ -1184,4 +1184,4 @@ _winapi__mimetypes_read_windows_registry(PyObject *module, PyObject *const *args exit: return return_value; } -/*[clinic end generated code: output=ac3623be6e42017c input=a9049054013a1b77]*/ +/*[clinic end generated code: output=a4ede01aede352a4 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/arraymodule.c.h b/Modules/clinic/arraymodule.c.h index 030c6e7e1a487..6358ba2f81fa3 100644 --- a/Modules/clinic/arraymodule.c.h +++ b/Modules/clinic/arraymodule.c.h @@ -47,7 +47,7 @@ PyDoc_STRVAR(array_array_index__doc__, "Raise ValueError if the value is not present."); #define ARRAY_ARRAY_INDEX_METHODDEF \ - {"index", (PyCFunction)(void(*)(void))array_array_index, METH_FASTCALL, array_array_index__doc__}, + {"index", _PyCFunction_CAST(array_array_index), METH_FASTCALL, array_array_index__doc__}, static PyObject * array_array_index_impl(arrayobject *self, PyObject *v, Py_ssize_t start, @@ -102,7 +102,7 @@ PyDoc_STRVAR(array_array_pop__doc__, "i defaults to -1."); #define ARRAY_ARRAY_POP_METHODDEF \ - {"pop", (PyCFunction)(void(*)(void))array_array_pop, METH_FASTCALL, array_array_pop__doc__}, + {"pop", _PyCFunction_CAST(array_array_pop), METH_FASTCALL, array_array_pop__doc__}, static PyObject * array_array_pop_impl(arrayobject *self, Py_ssize_t i); @@ -145,7 +145,7 @@ PyDoc_STRVAR(array_array_extend__doc__, "Append items to the end of the array."); #define ARRAY_ARRAY_EXTEND_METHODDEF \ - {"extend", (PyCFunction)(void(*)(void))array_array_extend, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, array_array_extend__doc__}, + {"extend", _PyCFunction_CAST(array_array_extend), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, array_array_extend__doc__}, static PyObject * array_array_extend_impl(arrayobject *self, PyTypeObject *cls, PyObject *bb); @@ -177,7 +177,7 @@ PyDoc_STRVAR(array_array_insert__doc__, "Insert a new item v into the array before position i."); #define ARRAY_ARRAY_INSERT_METHODDEF \ - {"insert", (PyCFunction)(void(*)(void))array_array_insert, METH_FASTCALL, array_array_insert__doc__}, + {"insert", _PyCFunction_CAST(array_array_insert), METH_FASTCALL, array_array_insert__doc__}, static PyObject * array_array_insert_impl(arrayobject *self, Py_ssize_t i, PyObject *v); @@ -287,7 +287,7 @@ PyDoc_STRVAR(array_array_fromfile__doc__, "Read n objects from the file object f and append them to the end of the array."); #define ARRAY_ARRAY_FROMFILE_METHODDEF \ - {"fromfile", (PyCFunction)(void(*)(void))array_array_fromfile, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, array_array_fromfile__doc__}, + {"fromfile", _PyCFunction_CAST(array_array_fromfile), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, array_array_fromfile__doc__}, static PyObject * array_array_fromfile_impl(arrayobject *self, PyTypeObject *cls, PyObject *f, @@ -333,7 +333,7 @@ PyDoc_STRVAR(array_array_tofile__doc__, "Write all items (as machine values) to the file object f."); #define ARRAY_ARRAY_TOFILE_METHODDEF \ - {"tofile", (PyCFunction)(void(*)(void))array_array_tofile, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, array_array_tofile__doc__}, + {"tofile", _PyCFunction_CAST(array_array_tofile), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, array_array_tofile__doc__}, static PyObject * array_array_tofile_impl(arrayobject *self, PyTypeObject *cls, PyObject *f); @@ -523,7 +523,7 @@ PyDoc_STRVAR(array__array_reconstructor__doc__, "Internal. Used for pickling support."); #define ARRAY__ARRAY_RECONSTRUCTOR_METHODDEF \ - {"_array_reconstructor", (PyCFunction)(void(*)(void))array__array_reconstructor, METH_FASTCALL, array__array_reconstructor__doc__}, + {"_array_reconstructor", _PyCFunction_CAST(array__array_reconstructor), METH_FASTCALL, array__array_reconstructor__doc__}, static PyObject * array__array_reconstructor_impl(PyObject *module, PyTypeObject *arraytype, @@ -574,7 +574,7 @@ PyDoc_STRVAR(array_array___reduce_ex____doc__, "Return state information for pickling."); #define ARRAY_ARRAY___REDUCE_EX___METHODDEF \ - {"__reduce_ex__", (PyCFunction)(void(*)(void))array_array___reduce_ex__, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, array_array___reduce_ex____doc__}, + {"__reduce_ex__", _PyCFunction_CAST(array_array___reduce_ex__), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, array_array___reduce_ex____doc__}, static PyObject * array_array___reduce_ex___impl(arrayobject *self, PyTypeObject *cls, @@ -607,7 +607,7 @@ PyDoc_STRVAR(array_arrayiterator___reduce____doc__, "Return state information for pickling."); #define ARRAY_ARRAYITERATOR___REDUCE___METHODDEF \ - {"__reduce__", (PyCFunction)(void(*)(void))array_arrayiterator___reduce__, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, array_arrayiterator___reduce____doc__}, + {"__reduce__", _PyCFunction_CAST(array_arrayiterator___reduce__), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, array_arrayiterator___reduce____doc__}, static PyObject * array_arrayiterator___reduce___impl(arrayiterobject *self, PyTypeObject *cls); @@ -630,4 +630,4 @@ PyDoc_STRVAR(array_arrayiterator___setstate____doc__, #define ARRAY_ARRAYITERATOR___SETSTATE___METHODDEF \ {"__setstate__", (PyCFunction)array_arrayiterator___setstate__, METH_O, array_arrayiterator___setstate____doc__}, -/*[clinic end generated code: output=7f48d1691fa27442 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=85a5fec90d9615b9 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/audioop.c.h b/Modules/clinic/audioop.c.h index da12bd17b5a60..43103855fa1a2 100644 --- a/Modules/clinic/audioop.c.h +++ b/Modules/clinic/audioop.c.h @@ -9,7 +9,7 @@ PyDoc_STRVAR(audioop_getsample__doc__, "Return the value of sample index from the fragment."); #define AUDIOOP_GETSAMPLE_METHODDEF \ - {"getsample", (PyCFunction)(void(*)(void))audioop_getsample, METH_FASTCALL, audioop_getsample__doc__}, + {"getsample", _PyCFunction_CAST(audioop_getsample), METH_FASTCALL, audioop_getsample__doc__}, static PyObject * audioop_getsample_impl(PyObject *module, Py_buffer *fragment, int width, @@ -67,7 +67,7 @@ PyDoc_STRVAR(audioop_max__doc__, "Return the maximum of the absolute value of all samples in a fragment."); #define AUDIOOP_MAX_METHODDEF \ - {"max", (PyCFunction)(void(*)(void))audioop_max, METH_FASTCALL, audioop_max__doc__}, + {"max", _PyCFunction_CAST(audioop_max), METH_FASTCALL, audioop_max__doc__}, static PyObject * audioop_max_impl(PyObject *module, Py_buffer *fragment, int width); @@ -111,7 +111,7 @@ PyDoc_STRVAR(audioop_minmax__doc__, "Return the minimum and maximum values of all samples in the sound fragment."); #define AUDIOOP_MINMAX_METHODDEF \ - {"minmax", (PyCFunction)(void(*)(void))audioop_minmax, METH_FASTCALL, audioop_minmax__doc__}, + {"minmax", _PyCFunction_CAST(audioop_minmax), METH_FASTCALL, audioop_minmax__doc__}, static PyObject * audioop_minmax_impl(PyObject *module, Py_buffer *fragment, int width); @@ -155,7 +155,7 @@ PyDoc_STRVAR(audioop_avg__doc__, "Return the average over all samples in the fragment."); #define AUDIOOP_AVG_METHODDEF \ - {"avg", (PyCFunction)(void(*)(void))audioop_avg, METH_FASTCALL, audioop_avg__doc__}, + {"avg", _PyCFunction_CAST(audioop_avg), METH_FASTCALL, audioop_avg__doc__}, static PyObject * audioop_avg_impl(PyObject *module, Py_buffer *fragment, int width); @@ -199,7 +199,7 @@ PyDoc_STRVAR(audioop_rms__doc__, "Return the root-mean-square of the fragment, i.e. sqrt(sum(S_i^2)/n)."); #define AUDIOOP_RMS_METHODDEF \ - {"rms", (PyCFunction)(void(*)(void))audioop_rms, METH_FASTCALL, audioop_rms__doc__}, + {"rms", _PyCFunction_CAST(audioop_rms), METH_FASTCALL, audioop_rms__doc__}, static PyObject * audioop_rms_impl(PyObject *module, Py_buffer *fragment, int width); @@ -243,7 +243,7 @@ PyDoc_STRVAR(audioop_findfit__doc__, "Try to match reference as well as possible to a portion of fragment."); #define AUDIOOP_FINDFIT_METHODDEF \ - {"findfit", (PyCFunction)(void(*)(void))audioop_findfit, METH_FASTCALL, audioop_findfit__doc__}, + {"findfit", _PyCFunction_CAST(audioop_findfit), METH_FASTCALL, audioop_findfit__doc__}, static PyObject * audioop_findfit_impl(PyObject *module, Py_buffer *fragment, @@ -295,7 +295,7 @@ PyDoc_STRVAR(audioop_findfactor__doc__, "Return a factor F such that rms(add(fragment, mul(reference, -F))) is minimal."); #define AUDIOOP_FINDFACTOR_METHODDEF \ - {"findfactor", (PyCFunction)(void(*)(void))audioop_findfactor, METH_FASTCALL, audioop_findfactor__doc__}, + {"findfactor", _PyCFunction_CAST(audioop_findfactor), METH_FASTCALL, audioop_findfactor__doc__}, static PyObject * audioop_findfactor_impl(PyObject *module, Py_buffer *fragment, @@ -347,7 +347,7 @@ PyDoc_STRVAR(audioop_findmax__doc__, "Search fragment for a slice of specified number of samples with maximum energy."); #define AUDIOOP_FINDMAX_METHODDEF \ - {"findmax", (PyCFunction)(void(*)(void))audioop_findmax, METH_FASTCALL, audioop_findmax__doc__}, + {"findmax", _PyCFunction_CAST(audioop_findmax), METH_FASTCALL, audioop_findmax__doc__}, static PyObject * audioop_findmax_impl(PyObject *module, Py_buffer *fragment, @@ -400,7 +400,7 @@ PyDoc_STRVAR(audioop_avgpp__doc__, "Return the average peak-peak value over all samples in the fragment."); #define AUDIOOP_AVGPP_METHODDEF \ - {"avgpp", (PyCFunction)(void(*)(void))audioop_avgpp, METH_FASTCALL, audioop_avgpp__doc__}, + {"avgpp", _PyCFunction_CAST(audioop_avgpp), METH_FASTCALL, audioop_avgpp__doc__}, static PyObject * audioop_avgpp_impl(PyObject *module, Py_buffer *fragment, int width); @@ -444,7 +444,7 @@ PyDoc_STRVAR(audioop_maxpp__doc__, "Return the maximum peak-peak value in the sound fragment."); #define AUDIOOP_MAXPP_METHODDEF \ - {"maxpp", (PyCFunction)(void(*)(void))audioop_maxpp, METH_FASTCALL, audioop_maxpp__doc__}, + {"maxpp", _PyCFunction_CAST(audioop_maxpp), METH_FASTCALL, audioop_maxpp__doc__}, static PyObject * audioop_maxpp_impl(PyObject *module, Py_buffer *fragment, int width); @@ -488,7 +488,7 @@ PyDoc_STRVAR(audioop_cross__doc__, "Return the number of zero crossings in the fragment passed as an argument."); #define AUDIOOP_CROSS_METHODDEF \ - {"cross", (PyCFunction)(void(*)(void))audioop_cross, METH_FASTCALL, audioop_cross__doc__}, + {"cross", _PyCFunction_CAST(audioop_cross), METH_FASTCALL, audioop_cross__doc__}, static PyObject * audioop_cross_impl(PyObject *module, Py_buffer *fragment, int width); @@ -532,7 +532,7 @@ PyDoc_STRVAR(audioop_mul__doc__, "Return a fragment that has all samples in the original fragment multiplied by the floating-point value factor."); #define AUDIOOP_MUL_METHODDEF \ - {"mul", (PyCFunction)(void(*)(void))audioop_mul, METH_FASTCALL, audioop_mul__doc__}, + {"mul", _PyCFunction_CAST(audioop_mul), METH_FASTCALL, audioop_mul__doc__}, static PyObject * audioop_mul_impl(PyObject *module, Py_buffer *fragment, int width, @@ -588,7 +588,7 @@ PyDoc_STRVAR(audioop_tomono__doc__, "Convert a stereo fragment to a mono fragment."); #define AUDIOOP_TOMONO_METHODDEF \ - {"tomono", (PyCFunction)(void(*)(void))audioop_tomono, METH_FASTCALL, audioop_tomono__doc__}, + {"tomono", _PyCFunction_CAST(audioop_tomono), METH_FASTCALL, audioop_tomono__doc__}, static PyObject * audioop_tomono_impl(PyObject *module, Py_buffer *fragment, int width, @@ -655,7 +655,7 @@ PyDoc_STRVAR(audioop_tostereo__doc__, "Generate a stereo fragment from a mono fragment."); #define AUDIOOP_TOSTEREO_METHODDEF \ - {"tostereo", (PyCFunction)(void(*)(void))audioop_tostereo, METH_FASTCALL, audioop_tostereo__doc__}, + {"tostereo", _PyCFunction_CAST(audioop_tostereo), METH_FASTCALL, audioop_tostereo__doc__}, static PyObject * audioop_tostereo_impl(PyObject *module, Py_buffer *fragment, int width, @@ -722,7 +722,7 @@ PyDoc_STRVAR(audioop_add__doc__, "Return a fragment which is the addition of the two samples passed as parameters."); #define AUDIOOP_ADD_METHODDEF \ - {"add", (PyCFunction)(void(*)(void))audioop_add, METH_FASTCALL, audioop_add__doc__}, + {"add", _PyCFunction_CAST(audioop_add), METH_FASTCALL, audioop_add__doc__}, static PyObject * audioop_add_impl(PyObject *module, Py_buffer *fragment1, @@ -779,7 +779,7 @@ PyDoc_STRVAR(audioop_bias__doc__, "Return a fragment that is the original fragment with a bias added to each sample."); #define AUDIOOP_BIAS_METHODDEF \ - {"bias", (PyCFunction)(void(*)(void))audioop_bias, METH_FASTCALL, audioop_bias__doc__}, + {"bias", _PyCFunction_CAST(audioop_bias), METH_FASTCALL, audioop_bias__doc__}, static PyObject * audioop_bias_impl(PyObject *module, Py_buffer *fragment, int width, int bias); @@ -828,7 +828,7 @@ PyDoc_STRVAR(audioop_reverse__doc__, "Reverse the samples in a fragment and returns the modified fragment."); #define AUDIOOP_REVERSE_METHODDEF \ - {"reverse", (PyCFunction)(void(*)(void))audioop_reverse, METH_FASTCALL, audioop_reverse__doc__}, + {"reverse", _PyCFunction_CAST(audioop_reverse), METH_FASTCALL, audioop_reverse__doc__}, static PyObject * audioop_reverse_impl(PyObject *module, Py_buffer *fragment, int width); @@ -872,7 +872,7 @@ PyDoc_STRVAR(audioop_byteswap__doc__, "Convert big-endian samples to little-endian and vice versa."); #define AUDIOOP_BYTESWAP_METHODDEF \ - {"byteswap", (PyCFunction)(void(*)(void))audioop_byteswap, METH_FASTCALL, audioop_byteswap__doc__}, + {"byteswap", _PyCFunction_CAST(audioop_byteswap), METH_FASTCALL, audioop_byteswap__doc__}, static PyObject * audioop_byteswap_impl(PyObject *module, Py_buffer *fragment, int width); @@ -916,7 +916,7 @@ PyDoc_STRVAR(audioop_lin2lin__doc__, "Convert samples between 1-, 2-, 3- and 4-byte formats."); #define AUDIOOP_LIN2LIN_METHODDEF \ - {"lin2lin", (PyCFunction)(void(*)(void))audioop_lin2lin, METH_FASTCALL, audioop_lin2lin__doc__}, + {"lin2lin", _PyCFunction_CAST(audioop_lin2lin), METH_FASTCALL, audioop_lin2lin__doc__}, static PyObject * audioop_lin2lin_impl(PyObject *module, Py_buffer *fragment, int width, @@ -967,7 +967,7 @@ PyDoc_STRVAR(audioop_ratecv__doc__, "Convert the frame rate of the input fragment."); #define AUDIOOP_RATECV_METHODDEF \ - {"ratecv", (PyCFunction)(void(*)(void))audioop_ratecv, METH_FASTCALL, audioop_ratecv__doc__}, + {"ratecv", _PyCFunction_CAST(audioop_ratecv), METH_FASTCALL, audioop_ratecv__doc__}, static PyObject * audioop_ratecv_impl(PyObject *module, Py_buffer *fragment, int width, @@ -1047,7 +1047,7 @@ PyDoc_STRVAR(audioop_lin2ulaw__doc__, "Convert samples in the audio fragment to u-LAW encoding."); #define AUDIOOP_LIN2ULAW_METHODDEF \ - {"lin2ulaw", (PyCFunction)(void(*)(void))audioop_lin2ulaw, METH_FASTCALL, audioop_lin2ulaw__doc__}, + {"lin2ulaw", _PyCFunction_CAST(audioop_lin2ulaw), METH_FASTCALL, audioop_lin2ulaw__doc__}, static PyObject * audioop_lin2ulaw_impl(PyObject *module, Py_buffer *fragment, int width); @@ -1091,7 +1091,7 @@ PyDoc_STRVAR(audioop_ulaw2lin__doc__, "Convert sound fragments in u-LAW encoding to linearly encoded sound fragments."); #define AUDIOOP_ULAW2LIN_METHODDEF \ - {"ulaw2lin", (PyCFunction)(void(*)(void))audioop_ulaw2lin, METH_FASTCALL, audioop_ulaw2lin__doc__}, + {"ulaw2lin", _PyCFunction_CAST(audioop_ulaw2lin), METH_FASTCALL, audioop_ulaw2lin__doc__}, static PyObject * audioop_ulaw2lin_impl(PyObject *module, Py_buffer *fragment, int width); @@ -1135,7 +1135,7 @@ PyDoc_STRVAR(audioop_lin2alaw__doc__, "Convert samples in the audio fragment to a-LAW encoding."); #define AUDIOOP_LIN2ALAW_METHODDEF \ - {"lin2alaw", (PyCFunction)(void(*)(void))audioop_lin2alaw, METH_FASTCALL, audioop_lin2alaw__doc__}, + {"lin2alaw", _PyCFunction_CAST(audioop_lin2alaw), METH_FASTCALL, audioop_lin2alaw__doc__}, static PyObject * audioop_lin2alaw_impl(PyObject *module, Py_buffer *fragment, int width); @@ -1179,7 +1179,7 @@ PyDoc_STRVAR(audioop_alaw2lin__doc__, "Convert sound fragments in a-LAW encoding to linearly encoded sound fragments."); #define AUDIOOP_ALAW2LIN_METHODDEF \ - {"alaw2lin", (PyCFunction)(void(*)(void))audioop_alaw2lin, METH_FASTCALL, audioop_alaw2lin__doc__}, + {"alaw2lin", _PyCFunction_CAST(audioop_alaw2lin), METH_FASTCALL, audioop_alaw2lin__doc__}, static PyObject * audioop_alaw2lin_impl(PyObject *module, Py_buffer *fragment, int width); @@ -1223,7 +1223,7 @@ PyDoc_STRVAR(audioop_lin2adpcm__doc__, "Convert samples to 4 bit Intel/DVI ADPCM encoding."); #define AUDIOOP_LIN2ADPCM_METHODDEF \ - {"lin2adpcm", (PyCFunction)(void(*)(void))audioop_lin2adpcm, METH_FASTCALL, audioop_lin2adpcm__doc__}, + {"lin2adpcm", _PyCFunction_CAST(audioop_lin2adpcm), METH_FASTCALL, audioop_lin2adpcm__doc__}, static PyObject * audioop_lin2adpcm_impl(PyObject *module, Py_buffer *fragment, int width, @@ -1270,7 +1270,7 @@ PyDoc_STRVAR(audioop_adpcm2lin__doc__, "Decode an Intel/DVI ADPCM coded fragment to a linear fragment."); #define AUDIOOP_ADPCM2LIN_METHODDEF \ - {"adpcm2lin", (PyCFunction)(void(*)(void))audioop_adpcm2lin, METH_FASTCALL, audioop_adpcm2lin__doc__}, + {"adpcm2lin", _PyCFunction_CAST(audioop_adpcm2lin), METH_FASTCALL, audioop_adpcm2lin__doc__}, static PyObject * audioop_adpcm2lin_impl(PyObject *module, Py_buffer *fragment, int width, @@ -1309,4 +1309,4 @@ audioop_adpcm2lin(PyObject *module, PyObject *const *args, Py_ssize_t nargs) return return_value; } -/*[clinic end generated code: output=840f8c315ebd4946 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=a581c3893ef8ad75 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/binascii.c.h b/Modules/clinic/binascii.c.h index a0ca6d60ce969..2c766eddee8dc 100644 --- a/Modules/clinic/binascii.c.h +++ b/Modules/clinic/binascii.c.h @@ -40,7 +40,7 @@ PyDoc_STRVAR(binascii_b2a_uu__doc__, "Uuencode line of data."); #define BINASCII_B2A_UU_METHODDEF \ - {"b2a_uu", (PyCFunction)(void(*)(void))binascii_b2a_uu, METH_FASTCALL|METH_KEYWORDS, binascii_b2a_uu__doc__}, + {"b2a_uu", _PyCFunction_CAST(binascii_b2a_uu), METH_FASTCALL|METH_KEYWORDS, binascii_b2a_uu__doc__}, static PyObject * binascii_b2a_uu_impl(PyObject *module, Py_buffer *data, int backtick); @@ -97,7 +97,7 @@ PyDoc_STRVAR(binascii_a2b_base64__doc__, " The same applies to excess data after padding (= / ==)."); #define BINASCII_A2B_BASE64_METHODDEF \ - {"a2b_base64", (PyCFunction)(void(*)(void))binascii_a2b_base64, METH_FASTCALL|METH_KEYWORDS, binascii_a2b_base64__doc__}, + {"a2b_base64", _PyCFunction_CAST(binascii_a2b_base64), METH_FASTCALL|METH_KEYWORDS, binascii_a2b_base64__doc__}, static PyObject * binascii_a2b_base64_impl(PyObject *module, Py_buffer *data, int strict_mode); @@ -145,7 +145,7 @@ PyDoc_STRVAR(binascii_b2a_base64__doc__, "Base64-code line of data."); #define BINASCII_B2A_BASE64_METHODDEF \ - {"b2a_base64", (PyCFunction)(void(*)(void))binascii_b2a_base64, METH_FASTCALL|METH_KEYWORDS, binascii_b2a_base64__doc__}, + {"b2a_base64", _PyCFunction_CAST(binascii_b2a_base64), METH_FASTCALL|METH_KEYWORDS, binascii_b2a_base64__doc__}, static PyObject * binascii_b2a_base64_impl(PyObject *module, Py_buffer *data, int newline); @@ -198,7 +198,7 @@ PyDoc_STRVAR(binascii_crc_hqx__doc__, "Compute CRC-CCITT incrementally."); #define BINASCII_CRC_HQX_METHODDEF \ - {"crc_hqx", (PyCFunction)(void(*)(void))binascii_crc_hqx, METH_FASTCALL, binascii_crc_hqx__doc__}, + {"crc_hqx", _PyCFunction_CAST(binascii_crc_hqx), METH_FASTCALL, binascii_crc_hqx__doc__}, static PyObject * binascii_crc_hqx_impl(PyObject *module, Py_buffer *data, unsigned int crc); @@ -242,7 +242,7 @@ PyDoc_STRVAR(binascii_crc32__doc__, "Compute CRC-32 incrementally."); #define BINASCII_CRC32_METHODDEF \ - {"crc32", (PyCFunction)(void(*)(void))binascii_crc32, METH_FASTCALL, binascii_crc32__doc__}, + {"crc32", _PyCFunction_CAST(binascii_crc32), METH_FASTCALL, binascii_crc32__doc__}, static unsigned int binascii_crc32_impl(PyObject *module, Py_buffer *data, unsigned int crc); @@ -312,7 +312,7 @@ PyDoc_STRVAR(binascii_b2a_hex__doc__, "b\'b9_01ef\'"); #define BINASCII_B2A_HEX_METHODDEF \ - {"b2a_hex", (PyCFunction)(void(*)(void))binascii_b2a_hex, METH_FASTCALL|METH_KEYWORDS, binascii_b2a_hex__doc__}, + {"b2a_hex", _PyCFunction_CAST(binascii_b2a_hex), METH_FASTCALL|METH_KEYWORDS, binascii_b2a_hex__doc__}, static PyObject * binascii_b2a_hex_impl(PyObject *module, Py_buffer *data, PyObject *sep, @@ -382,7 +382,7 @@ PyDoc_STRVAR(binascii_hexlify__doc__, "available as \"b2a_hex()\"."); #define BINASCII_HEXLIFY_METHODDEF \ - {"hexlify", (PyCFunction)(void(*)(void))binascii_hexlify, METH_FASTCALL|METH_KEYWORDS, binascii_hexlify__doc__}, + {"hexlify", _PyCFunction_CAST(binascii_hexlify), METH_FASTCALL|METH_KEYWORDS, binascii_hexlify__doc__}, static PyObject * binascii_hexlify_impl(PyObject *module, Py_buffer *data, PyObject *sep, @@ -510,7 +510,7 @@ PyDoc_STRVAR(binascii_a2b_qp__doc__, "Decode a string of qp-encoded data."); #define BINASCII_A2B_QP_METHODDEF \ - {"a2b_qp", (PyCFunction)(void(*)(void))binascii_a2b_qp, METH_FASTCALL|METH_KEYWORDS, binascii_a2b_qp__doc__}, + {"a2b_qp", _PyCFunction_CAST(binascii_a2b_qp), METH_FASTCALL|METH_KEYWORDS, binascii_a2b_qp__doc__}, static PyObject * binascii_a2b_qp_impl(PyObject *module, Py_buffer *data, int header); @@ -562,7 +562,7 @@ PyDoc_STRVAR(binascii_b2a_qp__doc__, "are both encoded. When quotetabs is set, space and tabs are encoded."); #define BINASCII_B2A_QP_METHODDEF \ - {"b2a_qp", (PyCFunction)(void(*)(void))binascii_b2a_qp, METH_FASTCALL|METH_KEYWORDS, binascii_b2a_qp__doc__}, + {"b2a_qp", _PyCFunction_CAST(binascii_b2a_qp), METH_FASTCALL|METH_KEYWORDS, binascii_b2a_qp__doc__}, static PyObject * binascii_b2a_qp_impl(PyObject *module, Py_buffer *data, int quotetabs, @@ -628,4 +628,4 @@ binascii_b2a_qp(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObj return return_value; } -/*[clinic end generated code: output=4162d08536697182 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=ba9ed7b810b8762d input=a9049054013a1b77]*/ diff --git a/Modules/clinic/cmathmodule.c.h b/Modules/clinic/cmathmodule.c.h index 4b6653aa21942..ab556922c029f 100644 --- a/Modules/clinic/cmathmodule.c.h +++ b/Modules/clinic/cmathmodule.c.h @@ -641,7 +641,7 @@ PyDoc_STRVAR(cmath_log__doc__, "If the base not specified, returns the natural logarithm (base e) of z."); #define CMATH_LOG_METHODDEF \ - {"log", (PyCFunction)(void(*)(void))cmath_log, METH_FASTCALL, cmath_log__doc__}, + {"log", _PyCFunction_CAST(cmath_log), METH_FASTCALL, cmath_log__doc__}, static PyObject * cmath_log_impl(PyObject *module, Py_complex x, PyObject *y_obj); @@ -736,7 +736,7 @@ PyDoc_STRVAR(cmath_rect__doc__, "Convert from polar coordinates to rectangular coordinates."); #define CMATH_RECT_METHODDEF \ - {"rect", (PyCFunction)(void(*)(void))cmath_rect, METH_FASTCALL, cmath_rect__doc__}, + {"rect", _PyCFunction_CAST(cmath_rect), METH_FASTCALL, cmath_rect__doc__}, static PyObject * cmath_rect_impl(PyObject *module, double r, double phi); @@ -883,7 +883,7 @@ PyDoc_STRVAR(cmath_isclose__doc__, "not close to anything, even itself. inf and -inf are only close to themselves."); #define CMATH_ISCLOSE_METHODDEF \ - {"isclose", (PyCFunction)(void(*)(void))cmath_isclose, METH_FASTCALL|METH_KEYWORDS, cmath_isclose__doc__}, + {"isclose", _PyCFunction_CAST(cmath_isclose), METH_FASTCALL|METH_KEYWORDS, cmath_isclose__doc__}, static int cmath_isclose_impl(PyObject *module, Py_complex a, Py_complex b, @@ -953,4 +953,4 @@ cmath_isclose(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObjec exit: return return_value; } -/*[clinic end generated code: output=353347db2e808e0d input=a9049054013a1b77]*/ +/*[clinic end generated code: output=b8e445fcd2a3da65 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/fcntlmodule.c.h b/Modules/clinic/fcntlmodule.c.h index adf527fd44311..c41f088ff1528 100644 --- a/Modules/clinic/fcntlmodule.c.h +++ b/Modules/clinic/fcntlmodule.c.h @@ -19,7 +19,7 @@ PyDoc_STRVAR(fcntl_fcntl__doc__, "corresponding to the return value of the fcntl call in the C code."); #define FCNTL_FCNTL_METHODDEF \ - {"fcntl", (PyCFunction)(void(*)(void))fcntl_fcntl, METH_FASTCALL, fcntl_fcntl__doc__}, + {"fcntl", _PyCFunction_CAST(fcntl_fcntl), METH_FASTCALL, fcntl_fcntl__doc__}, static PyObject * fcntl_fcntl_impl(PyObject *module, int fd, int code, PyObject *arg); @@ -87,7 +87,7 @@ PyDoc_STRVAR(fcntl_ioctl__doc__, "code."); #define FCNTL_IOCTL_METHODDEF \ - {"ioctl", (PyCFunction)(void(*)(void))fcntl_ioctl, METH_FASTCALL, fcntl_ioctl__doc__}, + {"ioctl", _PyCFunction_CAST(fcntl_ioctl), METH_FASTCALL, fcntl_ioctl__doc__}, static PyObject * fcntl_ioctl_impl(PyObject *module, int fd, unsigned int code, @@ -140,7 +140,7 @@ PyDoc_STRVAR(fcntl_flock__doc__, "function is emulated using fcntl())."); #define FCNTL_FLOCK_METHODDEF \ - {"flock", (PyCFunction)(void(*)(void))fcntl_flock, METH_FASTCALL, fcntl_flock__doc__}, + {"flock", _PyCFunction_CAST(fcntl_flock), METH_FASTCALL, fcntl_flock__doc__}, static PyObject * fcntl_flock_impl(PyObject *module, int fd, int code); @@ -196,7 +196,7 @@ PyDoc_STRVAR(fcntl_lockf__doc__, " 2 - relative to the end of the file (SEEK_END)"); #define FCNTL_LOCKF_METHODDEF \ - {"lockf", (PyCFunction)(void(*)(void))fcntl_lockf, METH_FASTCALL, fcntl_lockf__doc__}, + {"lockf", _PyCFunction_CAST(fcntl_lockf), METH_FASTCALL, fcntl_lockf__doc__}, static PyObject * fcntl_lockf_impl(PyObject *module, int fd, int code, PyObject *lenobj, @@ -243,4 +243,4 @@ fcntl_lockf(PyObject *module, PyObject *const *args, Py_ssize_t nargs) exit: return return_value; } -/*[clinic end generated code: output=8ea34bd0f7cf25ec input=a9049054013a1b77]*/ +/*[clinic end generated code: output=b8cb14ab35de4c6a input=a9049054013a1b77]*/ diff --git a/Modules/clinic/gcmodule.c.h b/Modules/clinic/gcmodule.c.h index 30efc7e0c2cd7..5391b8be42db9 100644 --- a/Modules/clinic/gcmodule.c.h +++ b/Modules/clinic/gcmodule.c.h @@ -79,7 +79,7 @@ PyDoc_STRVAR(gc_collect__doc__, "The number of unreachable objects is returned."); #define GC_COLLECT_METHODDEF \ - {"collect", (PyCFunction)(void(*)(void))gc_collect, METH_FASTCALL|METH_KEYWORDS, gc_collect__doc__}, + {"collect", _PyCFunction_CAST(gc_collect), METH_FASTCALL|METH_KEYWORDS, gc_collect__doc__}, static Py_ssize_t gc_collect_impl(PyObject *module, int generation); @@ -233,7 +233,7 @@ PyDoc_STRVAR(gc_get_objects__doc__, "that are in that generation."); #define GC_GET_OBJECTS_METHODDEF \ - {"get_objects", (PyCFunction)(void(*)(void))gc_get_objects, METH_FASTCALL|METH_KEYWORDS, gc_get_objects__doc__}, + {"get_objects", _PyCFunction_CAST(gc_get_objects), METH_FASTCALL|METH_KEYWORDS, gc_get_objects__doc__}, static PyObject * gc_get_objects_impl(PyObject *module, Py_ssize_t generation); @@ -372,4 +372,4 @@ gc_get_freeze_count(PyObject *module, PyObject *Py_UNUSED(ignored)) exit: return return_value; } -/*[clinic end generated code: output=61e15f3a549f3ab5 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=71f7136d6e3f2323 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/grpmodule.c.h b/Modules/clinic/grpmodule.c.h index 2e2690ad8d3f1..3dd35e7e6ba07 100644 --- a/Modules/clinic/grpmodule.c.h +++ b/Modules/clinic/grpmodule.c.h @@ -11,7 +11,7 @@ PyDoc_STRVAR(grp_getgrgid__doc__, "If id is not valid, raise KeyError."); #define GRP_GETGRGID_METHODDEF \ - {"getgrgid", (PyCFunction)(void(*)(void))grp_getgrgid, METH_FASTCALL|METH_KEYWORDS, grp_getgrgid__doc__}, + {"getgrgid", _PyCFunction_CAST(grp_getgrgid), METH_FASTCALL|METH_KEYWORDS, grp_getgrgid__doc__}, static PyObject * grp_getgrgid_impl(PyObject *module, PyObject *id); @@ -45,7 +45,7 @@ PyDoc_STRVAR(grp_getgrnam__doc__, "If name is not valid, raise KeyError."); #define GRP_GETGRNAM_METHODDEF \ - {"getgrnam", (PyCFunction)(void(*)(void))grp_getgrnam, METH_FASTCALL|METH_KEYWORDS, grp_getgrnam__doc__}, + {"getgrnam", _PyCFunction_CAST(grp_getgrnam), METH_FASTCALL|METH_KEYWORDS, grp_getgrnam__doc__}, static PyObject * grp_getgrnam_impl(PyObject *module, PyObject *name); @@ -97,4 +97,4 @@ grp_getgrall(PyObject *module, PyObject *Py_UNUSED(ignored)) { return grp_getgrall_impl(module); } -/*[clinic end generated code: output=9b3f26779e4e1a52 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=ba680465f71ed779 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/itertoolsmodule.c.h b/Modules/clinic/itertoolsmodule.c.h index 6a6998082484c..81608ccc089be 100644 --- a/Modules/clinic/itertoolsmodule.c.h +++ b/Modules/clinic/itertoolsmodule.c.h @@ -186,7 +186,7 @@ PyDoc_STRVAR(itertools_tee__doc__, "Returns a tuple of n independent iterators."); #define ITERTOOLS_TEE_METHODDEF \ - {"tee", (PyCFunction)(void(*)(void))itertools_tee, METH_FASTCALL, itertools_tee__doc__}, + {"tee", _PyCFunction_CAST(itertools_tee), METH_FASTCALL, itertools_tee__doc__}, static PyObject * itertools_tee_impl(PyObject *module, PyObject *iterable, Py_ssize_t n); @@ -667,4 +667,4 @@ itertools_count(PyTypeObject *type, PyObject *args, PyObject *kwargs) exit: return return_value; } -/*[clinic end generated code: output=5cb14d4a3fe8aeec input=a9049054013a1b77]*/ +/*[clinic end generated code: output=659251a811ff89ed input=a9049054013a1b77]*/ diff --git a/Modules/clinic/mathmodule.c.h b/Modules/clinic/mathmodule.c.h index 4ea0bb82b8e2c..efabbf9714237 100644 --- a/Modules/clinic/mathmodule.c.h +++ b/Modules/clinic/mathmodule.c.h @@ -112,7 +112,7 @@ PyDoc_STRVAR(math_ldexp__doc__, "This is essentially the inverse of frexp()."); #define MATH_LDEXP_METHODDEF \ - {"ldexp", (PyCFunction)(void(*)(void))math_ldexp, METH_FASTCALL, math_ldexp__doc__}, + {"ldexp", _PyCFunction_CAST(math_ldexp), METH_FASTCALL, math_ldexp__doc__}, static PyObject * math_ldexp_impl(PyObject *module, double x, PyObject *i); @@ -250,7 +250,7 @@ PyDoc_STRVAR(math_fmod__doc__, "x % y may differ."); #define MATH_FMOD_METHODDEF \ - {"fmod", (PyCFunction)(void(*)(void))math_fmod, METH_FASTCALL, math_fmod__doc__}, + {"fmod", _PyCFunction_CAST(math_fmod), METH_FASTCALL, math_fmod__doc__}, static PyObject * math_fmod_impl(PyObject *module, double x, double y); @@ -304,7 +304,7 @@ PyDoc_STRVAR(math_dist__doc__, " sqrt(sum((px - qx) ** 2.0 for px, qx in zip(p, q)))"); #define MATH_DIST_METHODDEF \ - {"dist", (PyCFunction)(void(*)(void))math_dist, METH_FASTCALL, math_dist__doc__}, + {"dist", _PyCFunction_CAST(math_dist), METH_FASTCALL, math_dist__doc__}, static PyObject * math_dist_impl(PyObject *module, PyObject *p, PyObject *q); @@ -334,7 +334,7 @@ PyDoc_STRVAR(math_pow__doc__, "Return x**y (x to the power of y)."); #define MATH_POW_METHODDEF \ - {"pow", (PyCFunction)(void(*)(void))math_pow, METH_FASTCALL, math_pow__doc__}, + {"pow", _PyCFunction_CAST(math_pow), METH_FASTCALL, math_pow__doc__}, static PyObject * math_pow_impl(PyObject *module, double x, double y); @@ -568,7 +568,7 @@ PyDoc_STRVAR(math_isclose__doc__, "only close to themselves."); #define MATH_ISCLOSE_METHODDEF \ - {"isclose", (PyCFunction)(void(*)(void))math_isclose, METH_FASTCALL|METH_KEYWORDS, math_isclose__doc__}, + {"isclose", _PyCFunction_CAST(math_isclose), METH_FASTCALL|METH_KEYWORDS, math_isclose__doc__}, static int math_isclose_impl(PyObject *module, double a, double b, double rel_tol, @@ -664,7 +664,7 @@ PyDoc_STRVAR(math_prod__doc__, "non-numeric types."); #define MATH_PROD_METHODDEF \ - {"prod", (PyCFunction)(void(*)(void))math_prod, METH_FASTCALL|METH_KEYWORDS, math_prod__doc__}, + {"prod", _PyCFunction_CAST(math_prod), METH_FASTCALL|METH_KEYWORDS, math_prod__doc__}, static PyObject * math_prod_impl(PyObject *module, PyObject *iterable, PyObject *start); @@ -712,7 +712,7 @@ PyDoc_STRVAR(math_perm__doc__, "Raises ValueError if either of the arguments are negative."); #define MATH_PERM_METHODDEF \ - {"perm", (PyCFunction)(void(*)(void))math_perm, METH_FASTCALL, math_perm__doc__}, + {"perm", _PyCFunction_CAST(math_perm), METH_FASTCALL, math_perm__doc__}, static PyObject * math_perm_impl(PyObject *module, PyObject *n, PyObject *k); @@ -756,7 +756,7 @@ PyDoc_STRVAR(math_comb__doc__, "Raises ValueError if either of the arguments are negative."); #define MATH_COMB_METHODDEF \ - {"comb", (PyCFunction)(void(*)(void))math_comb, METH_FASTCALL, math_comb__doc__}, + {"comb", _PyCFunction_CAST(math_comb), METH_FASTCALL, math_comb__doc__}, static PyObject * math_comb_impl(PyObject *module, PyObject *n, PyObject *k); @@ -786,7 +786,7 @@ PyDoc_STRVAR(math_nextafter__doc__, "Return the next floating-point value after x towards y."); #define MATH_NEXTAFTER_METHODDEF \ - {"nextafter", (PyCFunction)(void(*)(void))math_nextafter, METH_FASTCALL, math_nextafter__doc__}, + {"nextafter", _PyCFunction_CAST(math_nextafter), METH_FASTCALL, math_nextafter__doc__}, static PyObject * math_nextafter_impl(PyObject *module, double x, double y); @@ -865,4 +865,4 @@ math_ulp(PyObject *module, PyObject *arg) exit: return return_value; } -/*[clinic end generated code: output=6381e7d982ff3711 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=965f99dabaa72165 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/md5module.c.h b/Modules/clinic/md5module.c.h index 0ff09b0050a56..999406ba13518 100644 --- a/Modules/clinic/md5module.c.h +++ b/Modules/clinic/md5module.c.h @@ -9,7 +9,7 @@ PyDoc_STRVAR(MD5Type_copy__doc__, "Return a copy of the hash object."); #define MD5TYPE_COPY_METHODDEF \ - {"copy", (PyCFunction)(void(*)(void))MD5Type_copy, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, MD5Type_copy__doc__}, + {"copy", _PyCFunction_CAST(MD5Type_copy), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, MD5Type_copy__doc__}, static PyObject * MD5Type_copy_impl(MD5object *self, PyTypeObject *cls); @@ -76,7 +76,7 @@ PyDoc_STRVAR(_md5_md5__doc__, "Return a new MD5 hash object; optionally initialized with a string."); #define _MD5_MD5_METHODDEF \ - {"md5", (PyCFunction)(void(*)(void))_md5_md5, METH_FASTCALL|METH_KEYWORDS, _md5_md5__doc__}, + {"md5", _PyCFunction_CAST(_md5_md5), METH_FASTCALL|METH_KEYWORDS, _md5_md5__doc__}, static PyObject * _md5_md5_impl(PyObject *module, PyObject *string, int usedforsecurity); @@ -119,4 +119,4 @@ _md5_md5(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kw exit: return return_value; } -/*[clinic end generated code: output=3061297a669c645c input=a9049054013a1b77]*/ +/*[clinic end generated code: output=e5dac1237beb2788 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/overlapped.c.h b/Modules/clinic/overlapped.c.h index 7e81fc8f97104..2861338317497 100644 --- a/Modules/clinic/overlapped.c.h +++ b/Modules/clinic/overlapped.c.h @@ -9,7 +9,7 @@ PyDoc_STRVAR(_overlapped_CreateIoCompletionPort__doc__, "Create a completion port or register a handle with a port."); #define _OVERLAPPED_CREATEIOCOMPLETIONPORT_METHODDEF \ - {"CreateIoCompletionPort", (PyCFunction)(void(*)(void))_overlapped_CreateIoCompletionPort, METH_FASTCALL, _overlapped_CreateIoCompletionPort__doc__}, + {"CreateIoCompletionPort", _PyCFunction_CAST(_overlapped_CreateIoCompletionPort), METH_FASTCALL, _overlapped_CreateIoCompletionPort__doc__}, static PyObject * _overlapped_CreateIoCompletionPort_impl(PyObject *module, HANDLE FileHandle, @@ -45,7 +45,7 @@ PyDoc_STRVAR(_overlapped_GetQueuedCompletionStatus__doc__, "Wait for up to msecs milliseconds."); #define _OVERLAPPED_GETQUEUEDCOMPLETIONSTATUS_METHODDEF \ - {"GetQueuedCompletionStatus", (PyCFunction)(void(*)(void))_overlapped_GetQueuedCompletionStatus, METH_FASTCALL, _overlapped_GetQueuedCompletionStatus__doc__}, + {"GetQueuedCompletionStatus", _PyCFunction_CAST(_overlapped_GetQueuedCompletionStatus), METH_FASTCALL, _overlapped_GetQueuedCompletionStatus__doc__}, static PyObject * _overlapped_GetQueuedCompletionStatus_impl(PyObject *module, @@ -76,7 +76,7 @@ PyDoc_STRVAR(_overlapped_PostQueuedCompletionStatus__doc__, "Post a message to completion port."); #define _OVERLAPPED_POSTQUEUEDCOMPLETIONSTATUS_METHODDEF \ - {"PostQueuedCompletionStatus", (PyCFunction)(void(*)(void))_overlapped_PostQueuedCompletionStatus, METH_FASTCALL, _overlapped_PostQueuedCompletionStatus__doc__}, + {"PostQueuedCompletionStatus", _PyCFunction_CAST(_overlapped_PostQueuedCompletionStatus), METH_FASTCALL, _overlapped_PostQueuedCompletionStatus__doc__}, static PyObject * _overlapped_PostQueuedCompletionStatus_impl(PyObject *module, @@ -112,7 +112,7 @@ PyDoc_STRVAR(_overlapped_RegisterWaitWithQueue__doc__, "Register wait for Object; when complete CompletionPort is notified."); #define _OVERLAPPED_REGISTERWAITWITHQUEUE_METHODDEF \ - {"RegisterWaitWithQueue", (PyCFunction)(void(*)(void))_overlapped_RegisterWaitWithQueue, METH_FASTCALL, _overlapped_RegisterWaitWithQueue__doc__}, + {"RegisterWaitWithQueue", _PyCFunction_CAST(_overlapped_RegisterWaitWithQueue), METH_FASTCALL, _overlapped_RegisterWaitWithQueue__doc__}, static PyObject * _overlapped_RegisterWaitWithQueue_impl(PyObject *module, HANDLE Object, @@ -173,7 +173,7 @@ PyDoc_STRVAR(_overlapped_UnregisterWaitEx__doc__, "Unregister wait handle."); #define _OVERLAPPED_UNREGISTERWAITEX_METHODDEF \ - {"UnregisterWaitEx", (PyCFunction)(void(*)(void))_overlapped_UnregisterWaitEx, METH_FASTCALL, _overlapped_UnregisterWaitEx__doc__}, + {"UnregisterWaitEx", _PyCFunction_CAST(_overlapped_UnregisterWaitEx), METH_FASTCALL, _overlapped_UnregisterWaitEx__doc__}, static PyObject * _overlapped_UnregisterWaitEx_impl(PyObject *module, HANDLE WaitHandle, @@ -206,7 +206,7 @@ PyDoc_STRVAR(_overlapped_CreateEvent__doc__, "EventAttributes must be None."); #define _OVERLAPPED_CREATEEVENT_METHODDEF \ - {"CreateEvent", (PyCFunction)(void(*)(void))_overlapped_CreateEvent, METH_FASTCALL, _overlapped_CreateEvent__doc__}, + {"CreateEvent", _PyCFunction_CAST(_overlapped_CreateEvent), METH_FASTCALL, _overlapped_CreateEvent__doc__}, static PyObject * _overlapped_CreateEvent_impl(PyObject *module, PyObject *EventAttributes, @@ -300,7 +300,7 @@ PyDoc_STRVAR(_overlapped_BindLocal__doc__, "family should be AF_INET or AF_INET6."); #define _OVERLAPPED_BINDLOCAL_METHODDEF \ - {"BindLocal", (PyCFunction)(void(*)(void))_overlapped_BindLocal, METH_FASTCALL, _overlapped_BindLocal__doc__}, + {"BindLocal", _PyCFunction_CAST(_overlapped_BindLocal), METH_FASTCALL, _overlapped_BindLocal__doc__}, static PyObject * _overlapped_BindLocal_impl(PyObject *module, HANDLE Socket, int Family); @@ -404,7 +404,7 @@ PyDoc_STRVAR(_overlapped_Overlapped_getresult__doc__, "is false and the operation is still pending then an error is raised."); #define _OVERLAPPED_OVERLAPPED_GETRESULT_METHODDEF \ - {"getresult", (PyCFunction)(void(*)(void))_overlapped_Overlapped_getresult, METH_FASTCALL, _overlapped_Overlapped_getresult__doc__}, + {"getresult", _PyCFunction_CAST(_overlapped_Overlapped_getresult), METH_FASTCALL, _overlapped_Overlapped_getresult__doc__}, static PyObject * _overlapped_Overlapped_getresult_impl(OverlappedObject *self, BOOL wait); @@ -432,7 +432,7 @@ PyDoc_STRVAR(_overlapped_Overlapped_ReadFile__doc__, "Start overlapped read."); #define _OVERLAPPED_OVERLAPPED_READFILE_METHODDEF \ - {"ReadFile", (PyCFunction)(void(*)(void))_overlapped_Overlapped_ReadFile, METH_FASTCALL, _overlapped_Overlapped_ReadFile__doc__}, + {"ReadFile", _PyCFunction_CAST(_overlapped_Overlapped_ReadFile), METH_FASTCALL, _overlapped_Overlapped_ReadFile__doc__}, static PyObject * _overlapped_Overlapped_ReadFile_impl(OverlappedObject *self, HANDLE handle, @@ -462,7 +462,7 @@ PyDoc_STRVAR(_overlapped_Overlapped_ReadFileInto__doc__, "Start overlapped receive."); #define _OVERLAPPED_OVERLAPPED_READFILEINTO_METHODDEF \ - {"ReadFileInto", (PyCFunction)(void(*)(void))_overlapped_Overlapped_ReadFileInto, METH_FASTCALL, _overlapped_Overlapped_ReadFileInto__doc__}, + {"ReadFileInto", _PyCFunction_CAST(_overlapped_Overlapped_ReadFileInto), METH_FASTCALL, _overlapped_Overlapped_ReadFileInto__doc__}, static PyObject * _overlapped_Overlapped_ReadFileInto_impl(OverlappedObject *self, @@ -497,7 +497,7 @@ PyDoc_STRVAR(_overlapped_Overlapped_WSARecv__doc__, "Start overlapped receive."); #define _OVERLAPPED_OVERLAPPED_WSARECV_METHODDEF \ - {"WSARecv", (PyCFunction)(void(*)(void))_overlapped_Overlapped_WSARecv, METH_FASTCALL, _overlapped_Overlapped_WSARecv__doc__}, + {"WSARecv", _PyCFunction_CAST(_overlapped_Overlapped_WSARecv), METH_FASTCALL, _overlapped_Overlapped_WSARecv__doc__}, static PyObject * _overlapped_Overlapped_WSARecv_impl(OverlappedObject *self, HANDLE handle, @@ -528,7 +528,7 @@ PyDoc_STRVAR(_overlapped_Overlapped_WSARecvInto__doc__, "Start overlapped receive."); #define _OVERLAPPED_OVERLAPPED_WSARECVINTO_METHODDEF \ - {"WSARecvInto", (PyCFunction)(void(*)(void))_overlapped_Overlapped_WSARecvInto, METH_FASTCALL, _overlapped_Overlapped_WSARecvInto__doc__}, + {"WSARecvInto", _PyCFunction_CAST(_overlapped_Overlapped_WSARecvInto), METH_FASTCALL, _overlapped_Overlapped_WSARecvInto__doc__}, static PyObject * _overlapped_Overlapped_WSARecvInto_impl(OverlappedObject *self, @@ -565,7 +565,7 @@ PyDoc_STRVAR(_overlapped_Overlapped_WriteFile__doc__, "Start overlapped write."); #define _OVERLAPPED_OVERLAPPED_WRITEFILE_METHODDEF \ - {"WriteFile", (PyCFunction)(void(*)(void))_overlapped_Overlapped_WriteFile, METH_FASTCALL, _overlapped_Overlapped_WriteFile__doc__}, + {"WriteFile", _PyCFunction_CAST(_overlapped_Overlapped_WriteFile), METH_FASTCALL, _overlapped_Overlapped_WriteFile__doc__}, static PyObject * _overlapped_Overlapped_WriteFile_impl(OverlappedObject *self, HANDLE handle, @@ -600,7 +600,7 @@ PyDoc_STRVAR(_overlapped_Overlapped_WSASend__doc__, "Start overlapped send."); #define _OVERLAPPED_OVERLAPPED_WSASEND_METHODDEF \ - {"WSASend", (PyCFunction)(void(*)(void))_overlapped_Overlapped_WSASend, METH_FASTCALL, _overlapped_Overlapped_WSASend__doc__}, + {"WSASend", _PyCFunction_CAST(_overlapped_Overlapped_WSASend), METH_FASTCALL, _overlapped_Overlapped_WSASend__doc__}, static PyObject * _overlapped_Overlapped_WSASend_impl(OverlappedObject *self, HANDLE handle, @@ -636,7 +636,7 @@ PyDoc_STRVAR(_overlapped_Overlapped_AcceptEx__doc__, "Start overlapped wait for client to connect."); #define _OVERLAPPED_OVERLAPPED_ACCEPTEX_METHODDEF \ - {"AcceptEx", (PyCFunction)(void(*)(void))_overlapped_Overlapped_AcceptEx, METH_FASTCALL, _overlapped_Overlapped_AcceptEx__doc__}, + {"AcceptEx", _PyCFunction_CAST(_overlapped_Overlapped_AcceptEx), METH_FASTCALL, _overlapped_Overlapped_AcceptEx__doc__}, static PyObject * _overlapped_Overlapped_AcceptEx_impl(OverlappedObject *self, @@ -669,7 +669,7 @@ PyDoc_STRVAR(_overlapped_Overlapped_ConnectEx__doc__, "client_handle should be unbound."); #define _OVERLAPPED_OVERLAPPED_CONNECTEX_METHODDEF \ - {"ConnectEx", (PyCFunction)(void(*)(void))_overlapped_Overlapped_ConnectEx, METH_FASTCALL, _overlapped_Overlapped_ConnectEx__doc__}, + {"ConnectEx", _PyCFunction_CAST(_overlapped_Overlapped_ConnectEx), METH_FASTCALL, _overlapped_Overlapped_ConnectEx__doc__}, static PyObject * _overlapped_Overlapped_ConnectEx_impl(OverlappedObject *self, @@ -699,7 +699,7 @@ PyDoc_STRVAR(_overlapped_Overlapped_DisconnectEx__doc__, "\n"); #define _OVERLAPPED_OVERLAPPED_DISCONNECTEX_METHODDEF \ - {"DisconnectEx", (PyCFunction)(void(*)(void))_overlapped_Overlapped_DisconnectEx, METH_FASTCALL, _overlapped_Overlapped_DisconnectEx__doc__}, + {"DisconnectEx", _PyCFunction_CAST(_overlapped_Overlapped_DisconnectEx), METH_FASTCALL, _overlapped_Overlapped_DisconnectEx__doc__}, static PyObject * _overlapped_Overlapped_DisconnectEx_impl(OverlappedObject *self, @@ -730,7 +730,7 @@ PyDoc_STRVAR(_overlapped_Overlapped_TransmitFile__doc__, "Transmit file data over a connected socket."); #define _OVERLAPPED_OVERLAPPED_TRANSMITFILE_METHODDEF \ - {"TransmitFile", (PyCFunction)(void(*)(void))_overlapped_Overlapped_TransmitFile, METH_FASTCALL, _overlapped_Overlapped_TransmitFile__doc__}, + {"TransmitFile", _PyCFunction_CAST(_overlapped_Overlapped_TransmitFile), METH_FASTCALL, _overlapped_Overlapped_TransmitFile__doc__}, static PyObject * _overlapped_Overlapped_TransmitFile_impl(OverlappedObject *self, @@ -838,7 +838,7 @@ PyDoc_STRVAR(_overlapped_WSAConnect__doc__, "Bind a remote address to a connectionless (UDP) socket."); #define _OVERLAPPED_WSACONNECT_METHODDEF \ - {"WSAConnect", (PyCFunction)(void(*)(void))_overlapped_WSAConnect, METH_FASTCALL, _overlapped_WSAConnect__doc__}, + {"WSAConnect", _PyCFunction_CAST(_overlapped_WSAConnect), METH_FASTCALL, _overlapped_WSAConnect__doc__}, static PyObject * _overlapped_WSAConnect_impl(PyObject *module, HANDLE ConnectSocket, @@ -868,7 +868,7 @@ PyDoc_STRVAR(_overlapped_Overlapped_WSASendTo__doc__, "Start overlapped sendto over a connectionless (UDP) socket."); #define _OVERLAPPED_OVERLAPPED_WSASENDTO_METHODDEF \ - {"WSASendTo", (PyCFunction)(void(*)(void))_overlapped_Overlapped_WSASendTo, METH_FASTCALL, _overlapped_Overlapped_WSASendTo__doc__}, + {"WSASendTo", _PyCFunction_CAST(_overlapped_Overlapped_WSASendTo), METH_FASTCALL, _overlapped_Overlapped_WSASendTo__doc__}, static PyObject * _overlapped_Overlapped_WSASendTo_impl(OverlappedObject *self, HANDLE handle, @@ -906,7 +906,7 @@ PyDoc_STRVAR(_overlapped_Overlapped_WSARecvFrom__doc__, "Start overlapped receive."); #define _OVERLAPPED_OVERLAPPED_WSARECVFROM_METHODDEF \ - {"WSARecvFrom", (PyCFunction)(void(*)(void))_overlapped_Overlapped_WSARecvFrom, METH_FASTCALL, _overlapped_Overlapped_WSARecvFrom__doc__}, + {"WSARecvFrom", _PyCFunction_CAST(_overlapped_Overlapped_WSARecvFrom), METH_FASTCALL, _overlapped_Overlapped_WSARecvFrom__doc__}, static PyObject * _overlapped_Overlapped_WSARecvFrom_impl(OverlappedObject *self, @@ -938,7 +938,7 @@ PyDoc_STRVAR(_overlapped_Overlapped_WSARecvFromInto__doc__, "Start overlapped receive."); #define _OVERLAPPED_OVERLAPPED_WSARECVFROMINTO_METHODDEF \ - {"WSARecvFromInto", (PyCFunction)(void(*)(void))_overlapped_Overlapped_WSARecvFromInto, METH_FASTCALL, _overlapped_Overlapped_WSARecvFromInto__doc__}, + {"WSARecvFromInto", _PyCFunction_CAST(_overlapped_Overlapped_WSARecvFromInto), METH_FASTCALL, _overlapped_Overlapped_WSARecvFromInto__doc__}, static PyObject * _overlapped_Overlapped_WSARecvFromInto_impl(OverlappedObject *self, @@ -968,4 +968,4 @@ _overlapped_Overlapped_WSARecvFromInto(OverlappedObject *self, PyObject *const * return return_value; } -/*[clinic end generated code: output=d19a061ea7398d23 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=b0f15f5c09f1147e input=a9049054013a1b77]*/ diff --git a/Modules/clinic/posixmodule.c.h b/Modules/clinic/posixmodule.c.h index 352dadc9b5627..fdcd5bdd4dc17 100644 --- a/Modules/clinic/posixmodule.c.h +++ b/Modules/clinic/posixmodule.c.h @@ -28,7 +28,7 @@ PyDoc_STRVAR(os_stat__doc__, " an open file descriptor."); #define OS_STAT_METHODDEF \ - {"stat", (PyCFunction)(void(*)(void))os_stat, METH_FASTCALL|METH_KEYWORDS, os_stat__doc__}, + {"stat", _PyCFunction_CAST(os_stat), METH_FASTCALL|METH_KEYWORDS, os_stat__doc__}, static PyObject * os_stat_impl(PyObject *module, path_t *path, int dir_fd, int follow_symlinks); @@ -87,7 +87,7 @@ PyDoc_STRVAR(os_lstat__doc__, "Equivalent to stat(path, follow_symlinks=False)."); #define OS_LSTAT_METHODDEF \ - {"lstat", (PyCFunction)(void(*)(void))os_lstat, METH_FASTCALL|METH_KEYWORDS, os_lstat__doc__}, + {"lstat", _PyCFunction_CAST(os_lstat), METH_FASTCALL|METH_KEYWORDS, os_lstat__doc__}, static PyObject * os_lstat_impl(PyObject *module, path_t *path, int dir_fd); @@ -159,7 +159,7 @@ PyDoc_STRVAR(os_access__doc__, " has the specified access to the path."); #define OS_ACCESS_METHODDEF \ - {"access", (PyCFunction)(void(*)(void))os_access, METH_FASTCALL|METH_KEYWORDS, os_access__doc__}, + {"access", _PyCFunction_CAST(os_access), METH_FASTCALL|METH_KEYWORDS, os_access__doc__}, static int os_access_impl(PyObject *module, path_t *path, int mode, int dir_fd, @@ -297,7 +297,7 @@ PyDoc_STRVAR(os_chdir__doc__, " If this functionality is unavailable, using it raises an exception."); #define OS_CHDIR_METHODDEF \ - {"chdir", (PyCFunction)(void(*)(void))os_chdir, METH_FASTCALL|METH_KEYWORDS, os_chdir__doc__}, + {"chdir", _PyCFunction_CAST(os_chdir), METH_FASTCALL|METH_KEYWORDS, os_chdir__doc__}, static PyObject * os_chdir_impl(PyObject *module, path_t *path); @@ -339,7 +339,7 @@ PyDoc_STRVAR(os_fchdir__doc__, "Equivalent to os.chdir(fd)."); #define OS_FCHDIR_METHODDEF \ - {"fchdir", (PyCFunction)(void(*)(void))os_fchdir, METH_FASTCALL|METH_KEYWORDS, os_fchdir__doc__}, + {"fchdir", _PyCFunction_CAST(os_fchdir), METH_FASTCALL|METH_KEYWORDS, os_fchdir__doc__}, static PyObject * os_fchdir_impl(PyObject *module, int fd); @@ -395,7 +395,7 @@ PyDoc_STRVAR(os_chmod__doc__, " If they are unavailable, using them will raise a NotImplementedError."); #define OS_CHMOD_METHODDEF \ - {"chmod", (PyCFunction)(void(*)(void))os_chmod, METH_FASTCALL|METH_KEYWORDS, os_chmod__doc__}, + {"chmod", _PyCFunction_CAST(os_chmod), METH_FASTCALL|METH_KEYWORDS, os_chmod__doc__}, static PyObject * os_chmod_impl(PyObject *module, path_t *path, int mode, int dir_fd, @@ -461,7 +461,7 @@ PyDoc_STRVAR(os_fchmod__doc__, "Equivalent to os.chmod(fd, mode)."); #define OS_FCHMOD_METHODDEF \ - {"fchmod", (PyCFunction)(void(*)(void))os_fchmod, METH_FASTCALL|METH_KEYWORDS, os_fchmod__doc__}, + {"fchmod", _PyCFunction_CAST(os_fchmod), METH_FASTCALL|METH_KEYWORDS, os_fchmod__doc__}, static PyObject * os_fchmod_impl(PyObject *module, int fd, int mode); @@ -508,7 +508,7 @@ PyDoc_STRVAR(os_lchmod__doc__, "Equivalent to chmod(path, mode, follow_symlinks=False).\""); #define OS_LCHMOD_METHODDEF \ - {"lchmod", (PyCFunction)(void(*)(void))os_lchmod, METH_FASTCALL|METH_KEYWORDS, os_lchmod__doc__}, + {"lchmod", _PyCFunction_CAST(os_lchmod), METH_FASTCALL|METH_KEYWORDS, os_lchmod__doc__}, static PyObject * os_lchmod_impl(PyObject *module, path_t *path, int mode); @@ -560,7 +560,7 @@ PyDoc_STRVAR(os_chflags__doc__, "unavailable, using it will raise a NotImplementedError."); #define OS_CHFLAGS_METHODDEF \ - {"chflags", (PyCFunction)(void(*)(void))os_chflags, METH_FASTCALL|METH_KEYWORDS, os_chflags__doc__}, + {"chflags", _PyCFunction_CAST(os_chflags), METH_FASTCALL|METH_KEYWORDS, os_chflags__doc__}, static PyObject * os_chflags_impl(PyObject *module, path_t *path, unsigned long flags, @@ -621,7 +621,7 @@ PyDoc_STRVAR(os_lchflags__doc__, "Equivalent to chflags(path, flags, follow_symlinks=False)."); #define OS_LCHFLAGS_METHODDEF \ - {"lchflags", (PyCFunction)(void(*)(void))os_lchflags, METH_FASTCALL|METH_KEYWORDS, os_lchflags__doc__}, + {"lchflags", _PyCFunction_CAST(os_lchflags), METH_FASTCALL|METH_KEYWORDS, os_lchflags__doc__}, static PyObject * os_lchflags_impl(PyObject *module, path_t *path, unsigned long flags); @@ -668,7 +668,7 @@ PyDoc_STRVAR(os_chroot__doc__, "Change root directory to path."); #define OS_CHROOT_METHODDEF \ - {"chroot", (PyCFunction)(void(*)(void))os_chroot, METH_FASTCALL|METH_KEYWORDS, os_chroot__doc__}, + {"chroot", _PyCFunction_CAST(os_chroot), METH_FASTCALL|METH_KEYWORDS, os_chroot__doc__}, static PyObject * os_chroot_impl(PyObject *module, path_t *path); @@ -709,7 +709,7 @@ PyDoc_STRVAR(os_fsync__doc__, "Force write of fd to disk."); #define OS_FSYNC_METHODDEF \ - {"fsync", (PyCFunction)(void(*)(void))os_fsync, METH_FASTCALL|METH_KEYWORDS, os_fsync__doc__}, + {"fsync", _PyCFunction_CAST(os_fsync), METH_FASTCALL|METH_KEYWORDS, os_fsync__doc__}, static PyObject * os_fsync_impl(PyObject *module, int fd); @@ -769,7 +769,7 @@ PyDoc_STRVAR(os_fdatasync__doc__, "Force write of fd to disk without forcing update of metadata."); #define OS_FDATASYNC_METHODDEF \ - {"fdatasync", (PyCFunction)(void(*)(void))os_fdatasync, METH_FASTCALL|METH_KEYWORDS, os_fdatasync__doc__}, + {"fdatasync", _PyCFunction_CAST(os_fdatasync), METH_FASTCALL|METH_KEYWORDS, os_fdatasync__doc__}, static PyObject * os_fdatasync_impl(PyObject *module, int fd); @@ -831,7 +831,7 @@ PyDoc_STRVAR(os_chown__doc__, " If they are unavailable, using them will raise a NotImplementedError."); #define OS_CHOWN_METHODDEF \ - {"chown", (PyCFunction)(void(*)(void))os_chown, METH_FASTCALL|METH_KEYWORDS, os_chown__doc__}, + {"chown", _PyCFunction_CAST(os_chown), METH_FASTCALL|METH_KEYWORDS, os_chown__doc__}, static PyObject * os_chown_impl(PyObject *module, path_t *path, uid_t uid, gid_t gid, @@ -902,7 +902,7 @@ PyDoc_STRVAR(os_fchown__doc__, "Equivalent to os.chown(fd, uid, gid)."); #define OS_FCHOWN_METHODDEF \ - {"fchown", (PyCFunction)(void(*)(void))os_fchown, METH_FASTCALL|METH_KEYWORDS, os_fchown__doc__}, + {"fchown", _PyCFunction_CAST(os_fchown), METH_FASTCALL|METH_KEYWORDS, os_fchown__doc__}, static PyObject * os_fchown_impl(PyObject *module, int fd, uid_t uid, gid_t gid); @@ -952,7 +952,7 @@ PyDoc_STRVAR(os_lchown__doc__, "Equivalent to os.chown(path, uid, gid, follow_symlinks=False)."); #define OS_LCHOWN_METHODDEF \ - {"lchown", (PyCFunction)(void(*)(void))os_lchown, METH_FASTCALL|METH_KEYWORDS, os_lchown__doc__}, + {"lchown", _PyCFunction_CAST(os_lchown), METH_FASTCALL|METH_KEYWORDS, os_lchown__doc__}, static PyObject * os_lchown_impl(PyObject *module, path_t *path, uid_t uid, gid_t gid); @@ -1048,7 +1048,7 @@ PyDoc_STRVAR(os_link__doc__, " NotImplementedError."); #define OS_LINK_METHODDEF \ - {"link", (PyCFunction)(void(*)(void))os_link, METH_FASTCALL|METH_KEYWORDS, os_link__doc__}, + {"link", _PyCFunction_CAST(os_link), METH_FASTCALL|METH_KEYWORDS, os_link__doc__}, static PyObject * os_link_impl(PyObject *module, path_t *src, path_t *dst, int src_dir_fd, @@ -1133,7 +1133,7 @@ PyDoc_STRVAR(os_listdir__doc__, "entries \'.\' and \'..\' even if they are present in the directory."); #define OS_LISTDIR_METHODDEF \ - {"listdir", (PyCFunction)(void(*)(void))os_listdir, METH_FASTCALL|METH_KEYWORDS, os_listdir__doc__}, + {"listdir", _PyCFunction_CAST(os_listdir), METH_FASTCALL|METH_KEYWORDS, os_listdir__doc__}, static PyObject * os_listdir_impl(PyObject *module, path_t *path); @@ -1244,7 +1244,7 @@ PyDoc_STRVAR(os__getvolumepathname__doc__, "A helper function for ismount on Win32."); #define OS__GETVOLUMEPATHNAME_METHODDEF \ - {"_getvolumepathname", (PyCFunction)(void(*)(void))os__getvolumepathname, METH_FASTCALL|METH_KEYWORDS, os__getvolumepathname__doc__}, + {"_getvolumepathname", _PyCFunction_CAST(os__getvolumepathname), METH_FASTCALL|METH_KEYWORDS, os__getvolumepathname__doc__}, static PyObject * os__getvolumepathname_impl(PyObject *module, path_t *path); @@ -1285,7 +1285,7 @@ PyDoc_STRVAR(os__path_splitroot__doc__, "Removes everything after the root on Win32."); #define OS__PATH_SPLITROOT_METHODDEF \ - {"_path_splitroot", (PyCFunction)(void(*)(void))os__path_splitroot, METH_FASTCALL|METH_KEYWORDS, os__path_splitroot__doc__}, + {"_path_splitroot", _PyCFunction_CAST(os__path_splitroot), METH_FASTCALL|METH_KEYWORDS, os__path_splitroot__doc__}, static PyObject * os__path_splitroot_impl(PyObject *module, path_t *path); @@ -1324,7 +1324,7 @@ PyDoc_STRVAR(os__path_normpath__doc__, "Basic path normalization."); #define OS__PATH_NORMPATH_METHODDEF \ - {"_path_normpath", (PyCFunction)(void(*)(void))os__path_normpath, METH_FASTCALL|METH_KEYWORDS, os__path_normpath__doc__}, + {"_path_normpath", _PyCFunction_CAST(os__path_normpath), METH_FASTCALL|METH_KEYWORDS, os__path_normpath__doc__}, static PyObject * os__path_normpath_impl(PyObject *module, PyObject *path); @@ -1363,7 +1363,7 @@ PyDoc_STRVAR(os_mkdir__doc__, "The mode argument is ignored on Windows."); #define OS_MKDIR_METHODDEF \ - {"mkdir", (PyCFunction)(void(*)(void))os_mkdir, METH_FASTCALL|METH_KEYWORDS, os_mkdir__doc__}, + {"mkdir", _PyCFunction_CAST(os_mkdir), METH_FASTCALL|METH_KEYWORDS, os_mkdir__doc__}, static PyObject * os_mkdir_impl(PyObject *module, path_t *path, int mode, int dir_fd); @@ -1457,7 +1457,7 @@ PyDoc_STRVAR(os_getpriority__doc__, "Return program scheduling priority."); #define OS_GETPRIORITY_METHODDEF \ - {"getpriority", (PyCFunction)(void(*)(void))os_getpriority, METH_FASTCALL|METH_KEYWORDS, os_getpriority__doc__}, + {"getpriority", _PyCFunction_CAST(os_getpriority), METH_FASTCALL|METH_KEYWORDS, os_getpriority__doc__}, static PyObject * os_getpriority_impl(PyObject *module, int which, int who); @@ -1501,7 +1501,7 @@ PyDoc_STRVAR(os_setpriority__doc__, "Set program scheduling priority."); #define OS_SETPRIORITY_METHODDEF \ - {"setpriority", (PyCFunction)(void(*)(void))os_setpriority, METH_FASTCALL|METH_KEYWORDS, os_setpriority__doc__}, + {"setpriority", _PyCFunction_CAST(os_setpriority), METH_FASTCALL|METH_KEYWORDS, os_setpriority__doc__}, static PyObject * os_setpriority_impl(PyObject *module, int which, int who, int priority); @@ -1554,7 +1554,7 @@ PyDoc_STRVAR(os_rename__doc__, " If they are unavailable, using them will raise a NotImplementedError."); #define OS_RENAME_METHODDEF \ - {"rename", (PyCFunction)(void(*)(void))os_rename, METH_FASTCALL|METH_KEYWORDS, os_rename__doc__}, + {"rename", _PyCFunction_CAST(os_rename), METH_FASTCALL|METH_KEYWORDS, os_rename__doc__}, static PyObject * os_rename_impl(PyObject *module, path_t *src, path_t *dst, int src_dir_fd, @@ -1622,7 +1622,7 @@ PyDoc_STRVAR(os_replace__doc__, " If they are unavailable, using them will raise a NotImplementedError."); #define OS_REPLACE_METHODDEF \ - {"replace", (PyCFunction)(void(*)(void))os_replace, METH_FASTCALL|METH_KEYWORDS, os_replace__doc__}, + {"replace", _PyCFunction_CAST(os_replace), METH_FASTCALL|METH_KEYWORDS, os_replace__doc__}, static PyObject * os_replace_impl(PyObject *module, path_t *src, path_t *dst, int src_dir_fd, @@ -1689,7 +1689,7 @@ PyDoc_STRVAR(os_rmdir__doc__, " If it is unavailable, using it will raise a NotImplementedError."); #define OS_RMDIR_METHODDEF \ - {"rmdir", (PyCFunction)(void(*)(void))os_rmdir, METH_FASTCALL|METH_KEYWORDS, os_rmdir__doc__}, + {"rmdir", _PyCFunction_CAST(os_rmdir), METH_FASTCALL|METH_KEYWORDS, os_rmdir__doc__}, static PyObject * os_rmdir_impl(PyObject *module, path_t *path, int dir_fd); @@ -1737,7 +1737,7 @@ PyDoc_STRVAR(os_system__doc__, "Execute the command in a subshell."); #define OS_SYSTEM_METHODDEF \ - {"system", (PyCFunction)(void(*)(void))os_system, METH_FASTCALL|METH_KEYWORDS, os_system__doc__}, + {"system", _PyCFunction_CAST(os_system), METH_FASTCALL|METH_KEYWORDS, os_system__doc__}, static long os_system_impl(PyObject *module, const Py_UNICODE *command); @@ -1794,7 +1794,7 @@ PyDoc_STRVAR(os_system__doc__, "Execute the command in a subshell."); #define OS_SYSTEM_METHODDEF \ - {"system", (PyCFunction)(void(*)(void))os_system, METH_FASTCALL|METH_KEYWORDS, os_system__doc__}, + {"system", _PyCFunction_CAST(os_system), METH_FASTCALL|METH_KEYWORDS, os_system__doc__}, static long os_system_impl(PyObject *module, PyObject *command); @@ -1875,7 +1875,7 @@ PyDoc_STRVAR(os_unlink__doc__, " If it is unavailable, using it will raise a NotImplementedError."); #define OS_UNLINK_METHODDEF \ - {"unlink", (PyCFunction)(void(*)(void))os_unlink, METH_FASTCALL|METH_KEYWORDS, os_unlink__doc__}, + {"unlink", _PyCFunction_CAST(os_unlink), METH_FASTCALL|METH_KEYWORDS, os_unlink__doc__}, static PyObject * os_unlink_impl(PyObject *module, path_t *path, int dir_fd); @@ -1926,7 +1926,7 @@ PyDoc_STRVAR(os_remove__doc__, " If it is unavailable, using it will raise a NotImplementedError."); #define OS_REMOVE_METHODDEF \ - {"remove", (PyCFunction)(void(*)(void))os_remove, METH_FASTCALL|METH_KEYWORDS, os_remove__doc__}, + {"remove", _PyCFunction_CAST(os_remove), METH_FASTCALL|METH_KEYWORDS, os_remove__doc__}, static PyObject * os_remove_impl(PyObject *module, path_t *path, int dir_fd); @@ -2020,7 +2020,7 @@ PyDoc_STRVAR(os_utime__doc__, " If they are unavailable, using them will raise a NotImplementedError."); #define OS_UTIME_METHODDEF \ - {"utime", (PyCFunction)(void(*)(void))os_utime, METH_FASTCALL|METH_KEYWORDS, os_utime__doc__}, + {"utime", _PyCFunction_CAST(os_utime), METH_FASTCALL|METH_KEYWORDS, os_utime__doc__}, static PyObject * os_utime_impl(PyObject *module, path_t *path, PyObject *times, PyObject *ns, @@ -2095,7 +2095,7 @@ PyDoc_STRVAR(os__exit__doc__, "Exit to the system with specified status, without normal exit processing."); #define OS__EXIT_METHODDEF \ - {"_exit", (PyCFunction)(void(*)(void))os__exit, METH_FASTCALL|METH_KEYWORDS, os__exit__doc__}, + {"_exit", _PyCFunction_CAST(os__exit), METH_FASTCALL|METH_KEYWORDS, os__exit__doc__}, static PyObject * os__exit_impl(PyObject *module, int status); @@ -2137,7 +2137,7 @@ PyDoc_STRVAR(os_execv__doc__, " Tuple or list of strings."); #define OS_EXECV_METHODDEF \ - {"execv", (PyCFunction)(void(*)(void))os_execv, METH_FASTCALL, os_execv__doc__}, + {"execv", _PyCFunction_CAST(os_execv), METH_FASTCALL, os_execv__doc__}, static PyObject * os_execv_impl(PyObject *module, path_t *path, PyObject *argv); @@ -2183,7 +2183,7 @@ PyDoc_STRVAR(os_execve__doc__, " Dictionary of strings mapping to strings."); #define OS_EXECVE_METHODDEF \ - {"execve", (PyCFunction)(void(*)(void))os_execve, METH_FASTCALL|METH_KEYWORDS, os_execve__doc__}, + {"execve", _PyCFunction_CAST(os_execve), METH_FASTCALL|METH_KEYWORDS, os_execve__doc__}, static PyObject * os_execve_impl(PyObject *module, path_t *path, PyObject *argv, PyObject *env); @@ -2251,7 +2251,7 @@ PyDoc_STRVAR(os_posix_spawn__doc__, " A tuple with the scheduler policy (optional) and parameters."); #define OS_POSIX_SPAWN_METHODDEF \ - {"posix_spawn", (PyCFunction)(void(*)(void))os_posix_spawn, METH_FASTCALL|METH_KEYWORDS, os_posix_spawn__doc__}, + {"posix_spawn", _PyCFunction_CAST(os_posix_spawn), METH_FASTCALL|METH_KEYWORDS, os_posix_spawn__doc__}, static PyObject * os_posix_spawn_impl(PyObject *module, path_t *path, PyObject *argv, @@ -2378,7 +2378,7 @@ PyDoc_STRVAR(os_posix_spawnp__doc__, " A tuple with the scheduler policy (optional) and parameters."); #define OS_POSIX_SPAWNP_METHODDEF \ - {"posix_spawnp", (PyCFunction)(void(*)(void))os_posix_spawnp, METH_FASTCALL|METH_KEYWORDS, os_posix_spawnp__doc__}, + {"posix_spawnp", _PyCFunction_CAST(os_posix_spawnp), METH_FASTCALL|METH_KEYWORDS, os_posix_spawnp__doc__}, static PyObject * os_posix_spawnp_impl(PyObject *module, path_t *path, PyObject *argv, @@ -2489,7 +2489,7 @@ PyDoc_STRVAR(os_spawnv__doc__, " Tuple or list of strings."); #define OS_SPAWNV_METHODDEF \ - {"spawnv", (PyCFunction)(void(*)(void))os_spawnv, METH_FASTCALL, os_spawnv__doc__}, + {"spawnv", _PyCFunction_CAST(os_spawnv), METH_FASTCALL, os_spawnv__doc__}, static PyObject * os_spawnv_impl(PyObject *module, int mode, path_t *path, PyObject *argv); @@ -2542,7 +2542,7 @@ PyDoc_STRVAR(os_spawnve__doc__, " Dictionary of strings mapping to strings."); #define OS_SPAWNVE_METHODDEF \ - {"spawnve", (PyCFunction)(void(*)(void))os_spawnve, METH_FASTCALL, os_spawnve__doc__}, + {"spawnve", _PyCFunction_CAST(os_spawnve), METH_FASTCALL, os_spawnve__doc__}, static PyObject * os_spawnve_impl(PyObject *module, int mode, path_t *path, PyObject *argv, @@ -2601,7 +2601,7 @@ PyDoc_STRVAR(os_register_at_fork__doc__, "\'after_in_child\' and \'after_in_parent\' callbacks are called in order."); #define OS_REGISTER_AT_FORK_METHODDEF \ - {"register_at_fork", (PyCFunction)(void(*)(void))os_register_at_fork, METH_FASTCALL|METH_KEYWORDS, os_register_at_fork__doc__}, + {"register_at_fork", _PyCFunction_CAST(os_register_at_fork), METH_FASTCALL|METH_KEYWORDS, os_register_at_fork__doc__}, static PyObject * os_register_at_fork_impl(PyObject *module, PyObject *before, @@ -2705,7 +2705,7 @@ PyDoc_STRVAR(os_sched_get_priority_max__doc__, "Get the maximum scheduling priority for policy."); #define OS_SCHED_GET_PRIORITY_MAX_METHODDEF \ - {"sched_get_priority_max", (PyCFunction)(void(*)(void))os_sched_get_priority_max, METH_FASTCALL|METH_KEYWORDS, os_sched_get_priority_max__doc__}, + {"sched_get_priority_max", _PyCFunction_CAST(os_sched_get_priority_max), METH_FASTCALL|METH_KEYWORDS, os_sched_get_priority_max__doc__}, static PyObject * os_sched_get_priority_max_impl(PyObject *module, int policy); @@ -2744,7 +2744,7 @@ PyDoc_STRVAR(os_sched_get_priority_min__doc__, "Get the minimum scheduling priority for policy."); #define OS_SCHED_GET_PRIORITY_MIN_METHODDEF \ - {"sched_get_priority_min", (PyCFunction)(void(*)(void))os_sched_get_priority_min, METH_FASTCALL|METH_KEYWORDS, os_sched_get_priority_min__doc__}, + {"sched_get_priority_min", _PyCFunction_CAST(os_sched_get_priority_min), METH_FASTCALL|METH_KEYWORDS, os_sched_get_priority_min__doc__}, static PyObject * os_sched_get_priority_min_impl(PyObject *module, int policy); @@ -2857,7 +2857,7 @@ PyDoc_STRVAR(os_sched_setscheduler__doc__, "param is an instance of sched_param."); #define OS_SCHED_SETSCHEDULER_METHODDEF \ - {"sched_setscheduler", (PyCFunction)(void(*)(void))os_sched_setscheduler, METH_FASTCALL, os_sched_setscheduler__doc__}, + {"sched_setscheduler", _PyCFunction_CAST(os_sched_setscheduler), METH_FASTCALL, os_sched_setscheduler__doc__}, static PyObject * os_sched_setscheduler_impl(PyObject *module, pid_t pid, int policy, @@ -2929,7 +2929,7 @@ PyDoc_STRVAR(os_sched_setparam__doc__, "param should be an instance of sched_param."); #define OS_SCHED_SETPARAM_METHODDEF \ - {"sched_setparam", (PyCFunction)(void(*)(void))os_sched_setparam, METH_FASTCALL, os_sched_setparam__doc__}, + {"sched_setparam", _PyCFunction_CAST(os_sched_setparam), METH_FASTCALL, os_sched_setparam__doc__}, static PyObject * os_sched_setparam_impl(PyObject *module, pid_t pid, PyObject *param_obj); @@ -3024,7 +3024,7 @@ PyDoc_STRVAR(os_sched_setaffinity__doc__, "mask should be an iterable of integers identifying CPUs."); #define OS_SCHED_SETAFFINITY_METHODDEF \ - {"sched_setaffinity", (PyCFunction)(void(*)(void))os_sched_setaffinity, METH_FASTCALL, os_sched_setaffinity__doc__}, + {"sched_setaffinity", _PyCFunction_CAST(os_sched_setaffinity), METH_FASTCALL, os_sched_setaffinity__doc__}, static PyObject * os_sched_setaffinity_impl(PyObject *module, pid_t pid, PyObject *mask); @@ -3235,7 +3235,7 @@ PyDoc_STRVAR(os_getgrouplist__doc__, " base group id of the user"); #define OS_GETGROUPLIST_METHODDEF \ - {"getgrouplist", (PyCFunction)(void(*)(void))os_getgrouplist, METH_FASTCALL, os_getgrouplist__doc__}, + {"getgrouplist", _PyCFunction_CAST(os_getgrouplist), METH_FASTCALL, os_getgrouplist__doc__}, static PyObject * os_getgrouplist_impl(PyObject *module, const char *user, int basegid); @@ -3289,7 +3289,7 @@ PyDoc_STRVAR(os_getgrouplist__doc__, " base group id of the user"); #define OS_GETGROUPLIST_METHODDEF \ - {"getgrouplist", (PyCFunction)(void(*)(void))os_getgrouplist, METH_FASTCALL, os_getgrouplist__doc__}, + {"getgrouplist", _PyCFunction_CAST(os_getgrouplist), METH_FASTCALL, os_getgrouplist__doc__}, static PyObject * os_getgrouplist_impl(PyObject *module, const char *user, gid_t basegid); @@ -3363,7 +3363,7 @@ PyDoc_STRVAR(os_initgroups__doc__, "group id."); #define OS_INITGROUPS_METHODDEF \ - {"initgroups", (PyCFunction)(void(*)(void))os_initgroups, METH_FASTCALL, os_initgroups__doc__}, + {"initgroups", _PyCFunction_CAST(os_initgroups), METH_FASTCALL, os_initgroups__doc__}, static PyObject * os_initgroups_impl(PyObject *module, PyObject *oname, int gid); @@ -3409,7 +3409,7 @@ PyDoc_STRVAR(os_initgroups__doc__, "group id."); #define OS_INITGROUPS_METHODDEF \ - {"initgroups", (PyCFunction)(void(*)(void))os_initgroups, METH_FASTCALL, os_initgroups__doc__}, + {"initgroups", _PyCFunction_CAST(os_initgroups), METH_FASTCALL, os_initgroups__doc__}, static PyObject * os_initgroups_impl(PyObject *module, PyObject *oname, gid_t gid); @@ -3450,7 +3450,7 @@ PyDoc_STRVAR(os_getpgid__doc__, "Call the system call getpgid(), and return the result."); #define OS_GETPGID_METHODDEF \ - {"getpgid", (PyCFunction)(void(*)(void))os_getpgid, METH_FASTCALL|METH_KEYWORDS, os_getpgid__doc__}, + {"getpgid", _PyCFunction_CAST(os_getpgid), METH_FASTCALL|METH_KEYWORDS, os_getpgid__doc__}, static PyObject * os_getpgid_impl(PyObject *module, pid_t pid); @@ -3597,7 +3597,7 @@ PyDoc_STRVAR(os_kill__doc__, "Kill a process with a signal."); #define OS_KILL_METHODDEF \ - {"kill", (PyCFunction)(void(*)(void))os_kill, METH_FASTCALL, os_kill__doc__}, + {"kill", _PyCFunction_CAST(os_kill), METH_FASTCALL, os_kill__doc__}, static PyObject * os_kill_impl(PyObject *module, pid_t pid, Py_ssize_t signal); @@ -3630,7 +3630,7 @@ PyDoc_STRVAR(os_killpg__doc__, "Kill a process group with a signal."); #define OS_KILLPG_METHODDEF \ - {"killpg", (PyCFunction)(void(*)(void))os_killpg, METH_FASTCALL, os_killpg__doc__}, + {"killpg", _PyCFunction_CAST(os_killpg), METH_FASTCALL, os_killpg__doc__}, static PyObject * os_killpg_impl(PyObject *module, pid_t pgid, int signal); @@ -3788,7 +3788,7 @@ PyDoc_STRVAR(os_setreuid__doc__, "Set the current process\'s real and effective user ids."); #define OS_SETREUID_METHODDEF \ - {"setreuid", (PyCFunction)(void(*)(void))os_setreuid, METH_FASTCALL, os_setreuid__doc__}, + {"setreuid", _PyCFunction_CAST(os_setreuid), METH_FASTCALL, os_setreuid__doc__}, static PyObject * os_setreuid_impl(PyObject *module, uid_t ruid, uid_t euid); @@ -3826,7 +3826,7 @@ PyDoc_STRVAR(os_setregid__doc__, "Set the current process\'s real and effective group ids."); #define OS_SETREGID_METHODDEF \ - {"setregid", (PyCFunction)(void(*)(void))os_setregid, METH_FASTCALL, os_setregid__doc__}, + {"setregid", _PyCFunction_CAST(os_setregid), METH_FASTCALL, os_setregid__doc__}, static PyObject * os_setregid_impl(PyObject *module, gid_t rgid, gid_t egid); @@ -3911,7 +3911,7 @@ PyDoc_STRVAR(os_wait3__doc__, " (pid, status, rusage)"); #define OS_WAIT3_METHODDEF \ - {"wait3", (PyCFunction)(void(*)(void))os_wait3, METH_FASTCALL|METH_KEYWORDS, os_wait3__doc__}, + {"wait3", _PyCFunction_CAST(os_wait3), METH_FASTCALL|METH_KEYWORDS, os_wait3__doc__}, static PyObject * os_wait3_impl(PyObject *module, int options); @@ -3953,7 +3953,7 @@ PyDoc_STRVAR(os_wait4__doc__, " (pid, status, rusage)"); #define OS_WAIT4_METHODDEF \ - {"wait4", (PyCFunction)(void(*)(void))os_wait4, METH_FASTCALL|METH_KEYWORDS, os_wait4__doc__}, + {"wait4", _PyCFunction_CAST(os_wait4), METH_FASTCALL|METH_KEYWORDS, os_wait4__doc__}, static PyObject * os_wait4_impl(PyObject *module, pid_t pid, int options); @@ -3999,7 +3999,7 @@ PyDoc_STRVAR(os_waitid__doc__, "no children in a waitable state."); #define OS_WAITID_METHODDEF \ - {"waitid", (PyCFunction)(void(*)(void))os_waitid, METH_FASTCALL, os_waitid__doc__}, + {"waitid", _PyCFunction_CAST(os_waitid), METH_FASTCALL, os_waitid__doc__}, static PyObject * os_waitid_impl(PyObject *module, idtype_t idtype, id_t id, int options); @@ -4038,7 +4038,7 @@ PyDoc_STRVAR(os_waitpid__doc__, "The options argument is ignored on Windows."); #define OS_WAITPID_METHODDEF \ - {"waitpid", (PyCFunction)(void(*)(void))os_waitpid, METH_FASTCALL, os_waitpid__doc__}, + {"waitpid", _PyCFunction_CAST(os_waitpid), METH_FASTCALL, os_waitpid__doc__}, static PyObject * os_waitpid_impl(PyObject *module, pid_t pid, int options); @@ -4076,7 +4076,7 @@ PyDoc_STRVAR(os_waitpid__doc__, "The options argument is ignored on Windows."); #define OS_WAITPID_METHODDEF \ - {"waitpid", (PyCFunction)(void(*)(void))os_waitpid, METH_FASTCALL, os_waitpid__doc__}, + {"waitpid", _PyCFunction_CAST(os_waitpid), METH_FASTCALL, os_waitpid__doc__}, static PyObject * os_waitpid_impl(PyObject *module, intptr_t pid, int options); @@ -4137,7 +4137,7 @@ PyDoc_STRVAR(os_pidfd_open__doc__, "signals."); #define OS_PIDFD_OPEN_METHODDEF \ - {"pidfd_open", (PyCFunction)(void(*)(void))os_pidfd_open, METH_FASTCALL|METH_KEYWORDS, os_pidfd_open__doc__}, + {"pidfd_open", _PyCFunction_CAST(os_pidfd_open), METH_FASTCALL|METH_KEYWORDS, os_pidfd_open__doc__}, static PyObject * os_pidfd_open_impl(PyObject *module, pid_t pid, unsigned int flags); @@ -4178,7 +4178,7 @@ PyDoc_STRVAR(os_readlink__doc__, "using it will raise a NotImplementedError."); #define OS_READLINK_METHODDEF \ - {"readlink", (PyCFunction)(void(*)(void))os_readlink, METH_FASTCALL|METH_KEYWORDS, os_readlink__doc__}, + {"readlink", _PyCFunction_CAST(os_readlink), METH_FASTCALL|METH_KEYWORDS, os_readlink__doc__}, static PyObject * os_readlink_impl(PyObject *module, path_t *path, int dir_fd); @@ -4238,7 +4238,7 @@ PyDoc_STRVAR(os_symlink__doc__, " If it is unavailable, using it will raise a NotImplementedError."); #define OS_SYMLINK_METHODDEF \ - {"symlink", (PyCFunction)(void(*)(void))os_symlink, METH_FASTCALL|METH_KEYWORDS, os_symlink__doc__}, + {"symlink", _PyCFunction_CAST(os_symlink), METH_FASTCALL|METH_KEYWORDS, os_symlink__doc__}, static PyObject * os_symlink_impl(PyObject *module, path_t *src, path_t *dst, @@ -4388,7 +4388,7 @@ PyDoc_STRVAR(os_setpgid__doc__, "Call the system call setpgid(pid, pgrp)."); #define OS_SETPGID_METHODDEF \ - {"setpgid", (PyCFunction)(void(*)(void))os_setpgid, METH_FASTCALL, os_setpgid__doc__}, + {"setpgid", _PyCFunction_CAST(os_setpgid), METH_FASTCALL, os_setpgid__doc__}, static PyObject * os_setpgid_impl(PyObject *module, pid_t pid, pid_t pgrp); @@ -4453,7 +4453,7 @@ PyDoc_STRVAR(os_tcsetpgrp__doc__, "Set the process group associated with the terminal specified by fd."); #define OS_TCSETPGRP_METHODDEF \ - {"tcsetpgrp", (PyCFunction)(void(*)(void))os_tcsetpgrp, METH_FASTCALL, os_tcsetpgrp__doc__}, + {"tcsetpgrp", _PyCFunction_CAST(os_tcsetpgrp), METH_FASTCALL, os_tcsetpgrp__doc__}, static PyObject * os_tcsetpgrp_impl(PyObject *module, int fd, pid_t pgid); @@ -4489,7 +4489,7 @@ PyDoc_STRVAR(os_open__doc__, " If it is unavailable, using it will raise a NotImplementedError."); #define OS_OPEN_METHODDEF \ - {"open", (PyCFunction)(void(*)(void))os_open, METH_FASTCALL|METH_KEYWORDS, os_open__doc__}, + {"open", _PyCFunction_CAST(os_open), METH_FASTCALL|METH_KEYWORDS, os_open__doc__}, static int os_open_impl(PyObject *module, path_t *path, int flags, int mode, int dir_fd); @@ -4559,7 +4559,7 @@ PyDoc_STRVAR(os_close__doc__, "Close a file descriptor."); #define OS_CLOSE_METHODDEF \ - {"close", (PyCFunction)(void(*)(void))os_close, METH_FASTCALL|METH_KEYWORDS, os_close__doc__}, + {"close", _PyCFunction_CAST(os_close), METH_FASTCALL|METH_KEYWORDS, os_close__doc__}, static PyObject * os_close_impl(PyObject *module, int fd); @@ -4594,7 +4594,7 @@ PyDoc_STRVAR(os_closerange__doc__, "Closes all file descriptors in [fd_low, fd_high), ignoring errors."); #define OS_CLOSERANGE_METHODDEF \ - {"closerange", (PyCFunction)(void(*)(void))os_closerange, METH_FASTCALL, os_closerange__doc__}, + {"closerange", _PyCFunction_CAST(os_closerange), METH_FASTCALL, os_closerange__doc__}, static PyObject * os_closerange_impl(PyObject *module, int fd_low, int fd_high); @@ -4663,7 +4663,7 @@ PyDoc_STRVAR(os_dup2__doc__, "Duplicate file descriptor."); #define OS_DUP2_METHODDEF \ - {"dup2", (PyCFunction)(void(*)(void))os_dup2, METH_FASTCALL|METH_KEYWORDS, os_dup2__doc__}, + {"dup2", _PyCFunction_CAST(os_dup2), METH_FASTCALL|METH_KEYWORDS, os_dup2__doc__}, static int os_dup2_impl(PyObject *module, int fd, int fd2, int inheritable); @@ -4727,7 +4727,7 @@ PyDoc_STRVAR(os_lockf__doc__, " The number of bytes to lock, starting at the current position."); #define OS_LOCKF_METHODDEF \ - {"lockf", (PyCFunction)(void(*)(void))os_lockf, METH_FASTCALL, os_lockf__doc__}, + {"lockf", _PyCFunction_CAST(os_lockf), METH_FASTCALL, os_lockf__doc__}, static PyObject * os_lockf_impl(PyObject *module, int fd, int command, Py_off_t length); @@ -4772,7 +4772,7 @@ PyDoc_STRVAR(os_lseek__doc__, "relative to the beginning of the file."); #define OS_LSEEK_METHODDEF \ - {"lseek", (PyCFunction)(void(*)(void))os_lseek, METH_FASTCALL, os_lseek__doc__}, + {"lseek", _PyCFunction_CAST(os_lseek), METH_FASTCALL, os_lseek__doc__}, static Py_off_t os_lseek_impl(PyObject *module, int fd, Py_off_t position, int how); @@ -4817,7 +4817,7 @@ PyDoc_STRVAR(os_read__doc__, "Read from a file descriptor. Returns a bytes object."); #define OS_READ_METHODDEF \ - {"read", (PyCFunction)(void(*)(void))os_read, METH_FASTCALL, os_read__doc__}, + {"read", _PyCFunction_CAST(os_read), METH_FASTCALL, os_read__doc__}, static PyObject * os_read_impl(PyObject *module, int fd, Py_ssize_t length); @@ -4871,7 +4871,7 @@ PyDoc_STRVAR(os_readv__doc__, "which may be less than the total capacity of all the buffers."); #define OS_READV_METHODDEF \ - {"readv", (PyCFunction)(void(*)(void))os_readv, METH_FASTCALL, os_readv__doc__}, + {"readv", _PyCFunction_CAST(os_readv), METH_FASTCALL, os_readv__doc__}, static Py_ssize_t os_readv_impl(PyObject *module, int fd, PyObject *buffers); @@ -4916,7 +4916,7 @@ PyDoc_STRVAR(os_pread__doc__, "the beginning of the file. The file offset remains unchanged."); #define OS_PREAD_METHODDEF \ - {"pread", (PyCFunction)(void(*)(void))os_pread, METH_FASTCALL, os_pread__doc__}, + {"pread", _PyCFunction_CAST(os_pread), METH_FASTCALL, os_pread__doc__}, static PyObject * os_pread_impl(PyObject *module, int fd, Py_ssize_t length, Py_off_t offset); @@ -4982,7 +4982,7 @@ PyDoc_STRVAR(os_preadv__doc__, "Using non-zero flags requires Linux 4.6 or newer."); #define OS_PREADV_METHODDEF \ - {"preadv", (PyCFunction)(void(*)(void))os_preadv, METH_FASTCALL, os_preadv__doc__}, + {"preadv", _PyCFunction_CAST(os_preadv), METH_FASTCALL, os_preadv__doc__}, static Py_ssize_t os_preadv_impl(PyObject *module, int fd, PyObject *buffers, Py_off_t offset, @@ -5036,7 +5036,7 @@ PyDoc_STRVAR(os_write__doc__, "Write a bytes object to a file descriptor."); #define OS_WRITE_METHODDEF \ - {"write", (PyCFunction)(void(*)(void))os_write, METH_FASTCALL, os_write__doc__}, + {"write", _PyCFunction_CAST(os_write), METH_FASTCALL, os_write__doc__}, static Py_ssize_t os_write_impl(PyObject *module, int fd, Py_buffer *data); @@ -5088,7 +5088,7 @@ PyDoc_STRVAR(os_sendfile__doc__, "Copy count bytes from file descriptor in_fd to file descriptor out_fd."); #define OS_SENDFILE_METHODDEF \ - {"sendfile", (PyCFunction)(void(*)(void))os_sendfile, METH_FASTCALL|METH_KEYWORDS, os_sendfile__doc__}, + {"sendfile", _PyCFunction_CAST(os_sendfile), METH_FASTCALL|METH_KEYWORDS, os_sendfile__doc__}, static PyObject * os_sendfile_impl(PyObject *module, int out_fd, int in_fd, Py_off_t offset, @@ -5167,7 +5167,7 @@ PyDoc_STRVAR(os_sendfile__doc__, "Copy count bytes from file descriptor in_fd to file descriptor out_fd."); #define OS_SENDFILE_METHODDEF \ - {"sendfile", (PyCFunction)(void(*)(void))os_sendfile, METH_FASTCALL|METH_KEYWORDS, os_sendfile__doc__}, + {"sendfile", _PyCFunction_CAST(os_sendfile), METH_FASTCALL|METH_KEYWORDS, os_sendfile__doc__}, static PyObject * os_sendfile_impl(PyObject *module, int out_fd, int in_fd, Py_off_t offset, @@ -5254,7 +5254,7 @@ PyDoc_STRVAR(os_sendfile__doc__, "Copy count bytes from file descriptor in_fd to file descriptor out_fd."); #define OS_SENDFILE_METHODDEF \ - {"sendfile", (PyCFunction)(void(*)(void))os_sendfile, METH_FASTCALL|METH_KEYWORDS, os_sendfile__doc__}, + {"sendfile", _PyCFunction_CAST(os_sendfile), METH_FASTCALL|METH_KEYWORDS, os_sendfile__doc__}, static PyObject * os_sendfile_impl(PyObject *module, int out_fd, int in_fd, PyObject *offobj, @@ -5314,7 +5314,7 @@ PyDoc_STRVAR(os__fcopyfile__doc__, "Efficiently copy content or metadata of 2 regular file descriptors (macOS)."); #define OS__FCOPYFILE_METHODDEF \ - {"_fcopyfile", (PyCFunction)(void(*)(void))os__fcopyfile, METH_FASTCALL, os__fcopyfile__doc__}, + {"_fcopyfile", _PyCFunction_CAST(os__fcopyfile), METH_FASTCALL, os__fcopyfile__doc__}, static PyObject * os__fcopyfile_impl(PyObject *module, int in_fd, int out_fd, int flags); @@ -5360,7 +5360,7 @@ PyDoc_STRVAR(os_fstat__doc__, "Equivalent to os.stat(fd)."); #define OS_FSTAT_METHODDEF \ - {"fstat", (PyCFunction)(void(*)(void))os_fstat, METH_FASTCALL|METH_KEYWORDS, os_fstat__doc__}, + {"fstat", _PyCFunction_CAST(os_fstat), METH_FASTCALL|METH_KEYWORDS, os_fstat__doc__}, static PyObject * os_fstat_impl(PyObject *module, int fd); @@ -5499,7 +5499,7 @@ PyDoc_STRVAR(os_writev__doc__, "buffers must be a sequence of bytes-like objects."); #define OS_WRITEV_METHODDEF \ - {"writev", (PyCFunction)(void(*)(void))os_writev, METH_FASTCALL, os_writev__doc__}, + {"writev", _PyCFunction_CAST(os_writev), METH_FASTCALL, os_writev__doc__}, static Py_ssize_t os_writev_impl(PyObject *module, int fd, PyObject *buffers); @@ -5545,7 +5545,7 @@ PyDoc_STRVAR(os_pwrite__doc__, "current file offset."); #define OS_PWRITE_METHODDEF \ - {"pwrite", (PyCFunction)(void(*)(void))os_pwrite, METH_FASTCALL, os_pwrite__doc__}, + {"pwrite", _PyCFunction_CAST(os_pwrite), METH_FASTCALL, os_pwrite__doc__}, static Py_ssize_t os_pwrite_impl(PyObject *module, int fd, Py_buffer *buffer, Py_off_t offset); @@ -5617,7 +5617,7 @@ PyDoc_STRVAR(os_pwritev__doc__, "Using non-zero flags requires Linux 4.7 or newer."); #define OS_PWRITEV_METHODDEF \ - {"pwritev", (PyCFunction)(void(*)(void))os_pwritev, METH_FASTCALL, os_pwritev__doc__}, + {"pwritev", _PyCFunction_CAST(os_pwritev), METH_FASTCALL, os_pwritev__doc__}, static Py_ssize_t os_pwritev_impl(PyObject *module, int fd, PyObject *buffers, Py_off_t offset, @@ -5688,7 +5688,7 @@ PyDoc_STRVAR(os_copy_file_range__doc__, "respectively for offset_dst."); #define OS_COPY_FILE_RANGE_METHODDEF \ - {"copy_file_range", (PyCFunction)(void(*)(void))os_copy_file_range, METH_FASTCALL|METH_KEYWORDS, os_copy_file_range__doc__}, + {"copy_file_range", _PyCFunction_CAST(os_copy_file_range), METH_FASTCALL|METH_KEYWORDS, os_copy_file_range__doc__}, static PyObject * os_copy_file_range_impl(PyObject *module, int src, int dst, Py_ssize_t count, @@ -5778,7 +5778,7 @@ PyDoc_STRVAR(os_splice__doc__, "descriptor that refers to a pipe must be None."); #define OS_SPLICE_METHODDEF \ - {"splice", (PyCFunction)(void(*)(void))os_splice, METH_FASTCALL|METH_KEYWORDS, os_splice__doc__}, + {"splice", _PyCFunction_CAST(os_splice), METH_FASTCALL|METH_KEYWORDS, os_splice__doc__}, static PyObject * os_splice_impl(PyObject *module, int src, int dst, Py_ssize_t count, @@ -5865,7 +5865,7 @@ PyDoc_STRVAR(os_mkfifo__doc__, " If it is unavailable, using it will raise a NotImplementedError."); #define OS_MKFIFO_METHODDEF \ - {"mkfifo", (PyCFunction)(void(*)(void))os_mkfifo, METH_FASTCALL|METH_KEYWORDS, os_mkfifo__doc__}, + {"mkfifo", _PyCFunction_CAST(os_mkfifo), METH_FASTCALL|METH_KEYWORDS, os_mkfifo__doc__}, static PyObject * os_mkfifo_impl(PyObject *module, path_t *path, int mode, int dir_fd); @@ -5941,7 +5941,7 @@ PyDoc_STRVAR(os_mknod__doc__, " If it is unavailable, using it will raise a NotImplementedError."); #define OS_MKNOD_METHODDEF \ - {"mknod", (PyCFunction)(void(*)(void))os_mknod, METH_FASTCALL|METH_KEYWORDS, os_mknod__doc__}, + {"mknod", _PyCFunction_CAST(os_mknod), METH_FASTCALL|METH_KEYWORDS, os_mknod__doc__}, static PyObject * os_mknod_impl(PyObject *module, path_t *path, int mode, dev_t device, @@ -6087,7 +6087,7 @@ PyDoc_STRVAR(os_makedev__doc__, "Composes a raw device number from the major and minor device numbers."); #define OS_MAKEDEV_METHODDEF \ - {"makedev", (PyCFunction)(void(*)(void))os_makedev, METH_FASTCALL, os_makedev__doc__}, + {"makedev", _PyCFunction_CAST(os_makedev), METH_FASTCALL, os_makedev__doc__}, static dev_t os_makedev_impl(PyObject *module, int major, int minor); @@ -6132,7 +6132,7 @@ PyDoc_STRVAR(os_ftruncate__doc__, "Truncate a file, specified by file descriptor, to a specific length."); #define OS_FTRUNCATE_METHODDEF \ - {"ftruncate", (PyCFunction)(void(*)(void))os_ftruncate, METH_FASTCALL, os_ftruncate__doc__}, + {"ftruncate", _PyCFunction_CAST(os_ftruncate), METH_FASTCALL, os_ftruncate__doc__}, static PyObject * os_ftruncate_impl(PyObject *module, int fd, Py_off_t length); @@ -6174,7 +6174,7 @@ PyDoc_STRVAR(os_truncate__doc__, " If this functionality is unavailable, using it raises an exception."); #define OS_TRUNCATE_METHODDEF \ - {"truncate", (PyCFunction)(void(*)(void))os_truncate, METH_FASTCALL|METH_KEYWORDS, os_truncate__doc__}, + {"truncate", _PyCFunction_CAST(os_truncate), METH_FASTCALL|METH_KEYWORDS, os_truncate__doc__}, static PyObject * os_truncate_impl(PyObject *module, path_t *path, Py_off_t length); @@ -6222,7 +6222,7 @@ PyDoc_STRVAR(os_posix_fallocate__doc__, "starting at offset bytes from the beginning and continuing for length bytes."); #define OS_POSIX_FALLOCATE_METHODDEF \ - {"posix_fallocate", (PyCFunction)(void(*)(void))os_posix_fallocate, METH_FASTCALL, os_posix_fallocate__doc__}, + {"posix_fallocate", _PyCFunction_CAST(os_posix_fallocate), METH_FASTCALL, os_posix_fallocate__doc__}, static PyObject * os_posix_fallocate_impl(PyObject *module, int fd, Py_off_t offset, @@ -6274,7 +6274,7 @@ PyDoc_STRVAR(os_posix_fadvise__doc__, "POSIX_FADV_DONTNEED."); #define OS_POSIX_FADVISE_METHODDEF \ - {"posix_fadvise", (PyCFunction)(void(*)(void))os_posix_fadvise, METH_FASTCALL, os_posix_fadvise__doc__}, + {"posix_fadvise", _PyCFunction_CAST(os_posix_fadvise), METH_FASTCALL, os_posix_fadvise__doc__}, static PyObject * os_posix_fadvise_impl(PyObject *module, int fd, Py_off_t offset, @@ -6323,7 +6323,7 @@ PyDoc_STRVAR(os_putenv__doc__, "Change or add an environment variable."); #define OS_PUTENV_METHODDEF \ - {"putenv", (PyCFunction)(void(*)(void))os_putenv, METH_FASTCALL, os_putenv__doc__}, + {"putenv", _PyCFunction_CAST(os_putenv), METH_FASTCALL, os_putenv__doc__}, static PyObject * os_putenv_impl(PyObject *module, PyObject *name, PyObject *value); @@ -6371,7 +6371,7 @@ PyDoc_STRVAR(os_putenv__doc__, "Change or add an environment variable."); #define OS_PUTENV_METHODDEF \ - {"putenv", (PyCFunction)(void(*)(void))os_putenv, METH_FASTCALL, os_putenv__doc__}, + {"putenv", _PyCFunction_CAST(os_putenv), METH_FASTCALL, os_putenv__doc__}, static PyObject * os_putenv_impl(PyObject *module, PyObject *name, PyObject *value); @@ -6552,7 +6552,7 @@ PyDoc_STRVAR(os_WIFCONTINUED__doc__, "job control stop."); #define OS_WIFCONTINUED_METHODDEF \ - {"WIFCONTINUED", (PyCFunction)(void(*)(void))os_WIFCONTINUED, METH_FASTCALL|METH_KEYWORDS, os_WIFCONTINUED__doc__}, + {"WIFCONTINUED", _PyCFunction_CAST(os_WIFCONTINUED), METH_FASTCALL|METH_KEYWORDS, os_WIFCONTINUED__doc__}, static int os_WIFCONTINUED_impl(PyObject *module, int status); @@ -6596,7 +6596,7 @@ PyDoc_STRVAR(os_WIFSTOPPED__doc__, "Return True if the process returning status was stopped."); #define OS_WIFSTOPPED_METHODDEF \ - {"WIFSTOPPED", (PyCFunction)(void(*)(void))os_WIFSTOPPED, METH_FASTCALL|METH_KEYWORDS, os_WIFSTOPPED__doc__}, + {"WIFSTOPPED", _PyCFunction_CAST(os_WIFSTOPPED), METH_FASTCALL|METH_KEYWORDS, os_WIFSTOPPED__doc__}, static int os_WIFSTOPPED_impl(PyObject *module, int status); @@ -6640,7 +6640,7 @@ PyDoc_STRVAR(os_WIFSIGNALED__doc__, "Return True if the process returning status was terminated by a signal."); #define OS_WIFSIGNALED_METHODDEF \ - {"WIFSIGNALED", (PyCFunction)(void(*)(void))os_WIFSIGNALED, METH_FASTCALL|METH_KEYWORDS, os_WIFSIGNALED__doc__}, + {"WIFSIGNALED", _PyCFunction_CAST(os_WIFSIGNALED), METH_FASTCALL|METH_KEYWORDS, os_WIFSIGNALED__doc__}, static int os_WIFSIGNALED_impl(PyObject *module, int status); @@ -6684,7 +6684,7 @@ PyDoc_STRVAR(os_WIFEXITED__doc__, "Return True if the process returning status exited via the exit() system call."); #define OS_WIFEXITED_METHODDEF \ - {"WIFEXITED", (PyCFunction)(void(*)(void))os_WIFEXITED, METH_FASTCALL|METH_KEYWORDS, os_WIFEXITED__doc__}, + {"WIFEXITED", _PyCFunction_CAST(os_WIFEXITED), METH_FASTCALL|METH_KEYWORDS, os_WIFEXITED__doc__}, static int os_WIFEXITED_impl(PyObject *module, int status); @@ -6728,7 +6728,7 @@ PyDoc_STRVAR(os_WEXITSTATUS__doc__, "Return the process return code from status."); #define OS_WEXITSTATUS_METHODDEF \ - {"WEXITSTATUS", (PyCFunction)(void(*)(void))os_WEXITSTATUS, METH_FASTCALL|METH_KEYWORDS, os_WEXITSTATUS__doc__}, + {"WEXITSTATUS", _PyCFunction_CAST(os_WEXITSTATUS), METH_FASTCALL|METH_KEYWORDS, os_WEXITSTATUS__doc__}, static int os_WEXITSTATUS_impl(PyObject *module, int status); @@ -6772,7 +6772,7 @@ PyDoc_STRVAR(os_WTERMSIG__doc__, "Return the signal that terminated the process that provided the status value."); #define OS_WTERMSIG_METHODDEF \ - {"WTERMSIG", (PyCFunction)(void(*)(void))os_WTERMSIG, METH_FASTCALL|METH_KEYWORDS, os_WTERMSIG__doc__}, + {"WTERMSIG", _PyCFunction_CAST(os_WTERMSIG), METH_FASTCALL|METH_KEYWORDS, os_WTERMSIG__doc__}, static int os_WTERMSIG_impl(PyObject *module, int status); @@ -6816,7 +6816,7 @@ PyDoc_STRVAR(os_WSTOPSIG__doc__, "Return the signal that stopped the process that provided the status value."); #define OS_WSTOPSIG_METHODDEF \ - {"WSTOPSIG", (PyCFunction)(void(*)(void))os_WSTOPSIG, METH_FASTCALL|METH_KEYWORDS, os_WSTOPSIG__doc__}, + {"WSTOPSIG", _PyCFunction_CAST(os_WSTOPSIG), METH_FASTCALL|METH_KEYWORDS, os_WSTOPSIG__doc__}, static int os_WSTOPSIG_impl(PyObject *module, int status); @@ -6898,7 +6898,7 @@ PyDoc_STRVAR(os_statvfs__doc__, " If this functionality is unavailable, using it raises an exception."); #define OS_STATVFS_METHODDEF \ - {"statvfs", (PyCFunction)(void(*)(void))os_statvfs, METH_FASTCALL|METH_KEYWORDS, os_statvfs__doc__}, + {"statvfs", _PyCFunction_CAST(os_statvfs), METH_FASTCALL|METH_KEYWORDS, os_statvfs__doc__}, static PyObject * os_statvfs_impl(PyObject *module, path_t *path); @@ -6939,7 +6939,7 @@ PyDoc_STRVAR(os__getdiskusage__doc__, "Return disk usage statistics about the given path as a (total, free) tuple."); #define OS__GETDISKUSAGE_METHODDEF \ - {"_getdiskusage", (PyCFunction)(void(*)(void))os__getdiskusage, METH_FASTCALL|METH_KEYWORDS, os__getdiskusage__doc__}, + {"_getdiskusage", _PyCFunction_CAST(os__getdiskusage), METH_FASTCALL|METH_KEYWORDS, os__getdiskusage__doc__}, static PyObject * os__getdiskusage_impl(PyObject *module, path_t *path); @@ -6982,7 +6982,7 @@ PyDoc_STRVAR(os_fpathconf__doc__, "If there is no limit, return -1."); #define OS_FPATHCONF_METHODDEF \ - {"fpathconf", (PyCFunction)(void(*)(void))os_fpathconf, METH_FASTCALL, os_fpathconf__doc__}, + {"fpathconf", _PyCFunction_CAST(os_fpathconf), METH_FASTCALL, os_fpathconf__doc__}, static long os_fpathconf_impl(PyObject *module, int fd, int name); @@ -7029,7 +7029,7 @@ PyDoc_STRVAR(os_pathconf__doc__, " If this functionality is unavailable, using it raises an exception."); #define OS_PATHCONF_METHODDEF \ - {"pathconf", (PyCFunction)(void(*)(void))os_pathconf, METH_FASTCALL|METH_KEYWORDS, os_pathconf__doc__}, + {"pathconf", _PyCFunction_CAST(os_pathconf), METH_FASTCALL|METH_KEYWORDS, os_pathconf__doc__}, static long os_pathconf_impl(PyObject *module, path_t *path, int name); @@ -7193,7 +7193,7 @@ PyDoc_STRVAR(os_startfile__doc__, "the underlying Win32 ShellExecute function doesn\'t work if it is."); #define OS_STARTFILE_METHODDEF \ - {"startfile", (PyCFunction)(void(*)(void))os_startfile, METH_FASTCALL|METH_KEYWORDS, os_startfile__doc__}, + {"startfile", _PyCFunction_CAST(os_startfile), METH_FASTCALL|METH_KEYWORDS, os_startfile__doc__}, static PyObject * os_startfile_impl(PyObject *module, path_t *filepath, @@ -7328,7 +7328,7 @@ PyDoc_STRVAR(os_device_encoding__doc__, "If the device is not a terminal, return None."); #define OS_DEVICE_ENCODING_METHODDEF \ - {"device_encoding", (PyCFunction)(void(*)(void))os_device_encoding, METH_FASTCALL|METH_KEYWORDS, os_device_encoding__doc__}, + {"device_encoding", _PyCFunction_CAST(os_device_encoding), METH_FASTCALL|METH_KEYWORDS, os_device_encoding__doc__}, static PyObject * os_device_encoding_impl(PyObject *module, int fd); @@ -7365,7 +7365,7 @@ PyDoc_STRVAR(os_setresuid__doc__, "Set the current process\'s real, effective, and saved user ids."); #define OS_SETRESUID_METHODDEF \ - {"setresuid", (PyCFunction)(void(*)(void))os_setresuid, METH_FASTCALL, os_setresuid__doc__}, + {"setresuid", _PyCFunction_CAST(os_setresuid), METH_FASTCALL, os_setresuid__doc__}, static PyObject * os_setresuid_impl(PyObject *module, uid_t ruid, uid_t euid, uid_t suid); @@ -7407,7 +7407,7 @@ PyDoc_STRVAR(os_setresgid__doc__, "Set the current process\'s real, effective, and saved group ids."); #define OS_SETRESGID_METHODDEF \ - {"setresgid", (PyCFunction)(void(*)(void))os_setresgid, METH_FASTCALL, os_setresgid__doc__}, + {"setresgid", _PyCFunction_CAST(os_setresgid), METH_FASTCALL, os_setresgid__doc__}, static PyObject * os_setresgid_impl(PyObject *module, gid_t rgid, gid_t egid, gid_t sgid); @@ -7498,7 +7498,7 @@ PyDoc_STRVAR(os_getxattr__doc__, " the link points to."); #define OS_GETXATTR_METHODDEF \ - {"getxattr", (PyCFunction)(void(*)(void))os_getxattr, METH_FASTCALL|METH_KEYWORDS, os_getxattr__doc__}, + {"getxattr", _PyCFunction_CAST(os_getxattr), METH_FASTCALL|METH_KEYWORDS, os_getxattr__doc__}, static PyObject * os_getxattr_impl(PyObject *module, path_t *path, path_t *attribute, @@ -7562,7 +7562,7 @@ PyDoc_STRVAR(os_setxattr__doc__, " the link points to."); #define OS_SETXATTR_METHODDEF \ - {"setxattr", (PyCFunction)(void(*)(void))os_setxattr, METH_FASTCALL|METH_KEYWORDS, os_setxattr__doc__}, + {"setxattr", _PyCFunction_CAST(os_setxattr), METH_FASTCALL|METH_KEYWORDS, os_setxattr__doc__}, static PyObject * os_setxattr_impl(PyObject *module, path_t *path, path_t *attribute, @@ -7651,7 +7651,7 @@ PyDoc_STRVAR(os_removexattr__doc__, " the link points to."); #define OS_REMOVEXATTR_METHODDEF \ - {"removexattr", (PyCFunction)(void(*)(void))os_removexattr, METH_FASTCALL|METH_KEYWORDS, os_removexattr__doc__}, + {"removexattr", _PyCFunction_CAST(os_removexattr), METH_FASTCALL|METH_KEYWORDS, os_removexattr__doc__}, static PyObject * os_removexattr_impl(PyObject *module, path_t *path, path_t *attribute, @@ -7715,7 +7715,7 @@ PyDoc_STRVAR(os_listxattr__doc__, " the link points to."); #define OS_LISTXATTR_METHODDEF \ - {"listxattr", (PyCFunction)(void(*)(void))os_listxattr, METH_FASTCALL|METH_KEYWORDS, os_listxattr__doc__}, + {"listxattr", _PyCFunction_CAST(os_listxattr), METH_FASTCALL|METH_KEYWORDS, os_listxattr__doc__}, static PyObject * os_listxattr_impl(PyObject *module, path_t *path, int follow_symlinks); @@ -7810,7 +7810,7 @@ PyDoc_STRVAR(os_memfd_create__doc__, "\n"); #define OS_MEMFD_CREATE_METHODDEF \ - {"memfd_create", (PyCFunction)(void(*)(void))os_memfd_create, METH_FASTCALL|METH_KEYWORDS, os_memfd_create__doc__}, + {"memfd_create", _PyCFunction_CAST(os_memfd_create), METH_FASTCALL|METH_KEYWORDS, os_memfd_create__doc__}, static PyObject * os_memfd_create_impl(PyObject *module, PyObject *name, unsigned int flags); @@ -7861,7 +7861,7 @@ PyDoc_STRVAR(os_eventfd__doc__, "Creates and returns an event notification file descriptor."); #define OS_EVENTFD_METHODDEF \ - {"eventfd", (PyCFunction)(void(*)(void))os_eventfd, METH_FASTCALL|METH_KEYWORDS, os_eventfd__doc__}, + {"eventfd", _PyCFunction_CAST(os_eventfd), METH_FASTCALL|METH_KEYWORDS, os_eventfd__doc__}, static PyObject * os_eventfd_impl(PyObject *module, unsigned int initval, int flags); @@ -7909,7 +7909,7 @@ PyDoc_STRVAR(os_eventfd_read__doc__, "Read eventfd value"); #define OS_EVENTFD_READ_METHODDEF \ - {"eventfd_read", (PyCFunction)(void(*)(void))os_eventfd_read, METH_FASTCALL|METH_KEYWORDS, os_eventfd_read__doc__}, + {"eventfd_read", _PyCFunction_CAST(os_eventfd_read), METH_FASTCALL|METH_KEYWORDS, os_eventfd_read__doc__}, static PyObject * os_eventfd_read_impl(PyObject *module, int fd); @@ -7947,7 +7947,7 @@ PyDoc_STRVAR(os_eventfd_write__doc__, "Write eventfd value."); #define OS_EVENTFD_WRITE_METHODDEF \ - {"eventfd_write", (PyCFunction)(void(*)(void))os_eventfd_write, METH_FASTCALL|METH_KEYWORDS, os_eventfd_write__doc__}, + {"eventfd_write", _PyCFunction_CAST(os_eventfd_write), METH_FASTCALL|METH_KEYWORDS, os_eventfd_write__doc__}, static PyObject * os_eventfd_write_impl(PyObject *module, int fd, unsigned long long value); @@ -8001,7 +8001,7 @@ PyDoc_STRVAR(os_get_terminal_size__doc__, "normally be used, os.get_terminal_size is the low-level implementation."); #define OS_GET_TERMINAL_SIZE_METHODDEF \ - {"get_terminal_size", (PyCFunction)(void(*)(void))os_get_terminal_size, METH_FASTCALL, os_get_terminal_size__doc__}, + {"get_terminal_size", _PyCFunction_CAST(os_get_terminal_size), METH_FASTCALL, os_get_terminal_size__doc__}, static PyObject * os_get_terminal_size_impl(PyObject *module, int fd); @@ -8093,7 +8093,7 @@ PyDoc_STRVAR(os_set_inheritable__doc__, "Set the inheritable flag of the specified file descriptor."); #define OS_SET_INHERITABLE_METHODDEF \ - {"set_inheritable", (PyCFunction)(void(*)(void))os_set_inheritable, METH_FASTCALL, os_set_inheritable__doc__}, + {"set_inheritable", _PyCFunction_CAST(os_set_inheritable), METH_FASTCALL, os_set_inheritable__doc__}, static PyObject * os_set_inheritable_impl(PyObject *module, int fd, int inheritable); @@ -8167,7 +8167,7 @@ PyDoc_STRVAR(os_set_handle_inheritable__doc__, "Set the inheritable flag of the specified handle."); #define OS_SET_HANDLE_INHERITABLE_METHODDEF \ - {"set_handle_inheritable", (PyCFunction)(void(*)(void))os_set_handle_inheritable, METH_FASTCALL, os_set_handle_inheritable__doc__}, + {"set_handle_inheritable", _PyCFunction_CAST(os_set_handle_inheritable), METH_FASTCALL, os_set_handle_inheritable__doc__}, static PyObject * os_set_handle_inheritable_impl(PyObject *module, intptr_t handle, @@ -8243,7 +8243,7 @@ PyDoc_STRVAR(os_set_blocking__doc__, "clear the O_NONBLOCK flag otherwise."); #define OS_SET_BLOCKING_METHODDEF \ - {"set_blocking", (PyCFunction)(void(*)(void))os_set_blocking, METH_FASTCALL, os_set_blocking__doc__}, + {"set_blocking", _PyCFunction_CAST(os_set_blocking), METH_FASTCALL, os_set_blocking__doc__}, static PyObject * os_set_blocking_impl(PyObject *module, int fd, int blocking); @@ -8281,7 +8281,7 @@ PyDoc_STRVAR(os_DirEntry_is_symlink__doc__, "Return True if the entry is a symbolic link; cached per entry."); #define OS_DIRENTRY_IS_SYMLINK_METHODDEF \ - {"is_symlink", (PyCFunction)(void(*)(void))os_DirEntry_is_symlink, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, os_DirEntry_is_symlink__doc__}, + {"is_symlink", _PyCFunction_CAST(os_DirEntry_is_symlink), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, os_DirEntry_is_symlink__doc__}, static int os_DirEntry_is_symlink_impl(DirEntry *self, PyTypeObject *defining_class); @@ -8313,7 +8313,7 @@ PyDoc_STRVAR(os_DirEntry_stat__doc__, "Return stat_result object for the entry; cached per entry."); #define OS_DIRENTRY_STAT_METHODDEF \ - {"stat", (PyCFunction)(void(*)(void))os_DirEntry_stat, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, os_DirEntry_stat__doc__}, + {"stat", _PyCFunction_CAST(os_DirEntry_stat), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, os_DirEntry_stat__doc__}, static PyObject * os_DirEntry_stat_impl(DirEntry *self, PyTypeObject *defining_class, @@ -8354,7 +8354,7 @@ PyDoc_STRVAR(os_DirEntry_is_dir__doc__, "Return True if the entry is a directory; cached per entry."); #define OS_DIRENTRY_IS_DIR_METHODDEF \ - {"is_dir", (PyCFunction)(void(*)(void))os_DirEntry_is_dir, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, os_DirEntry_is_dir__doc__}, + {"is_dir", _PyCFunction_CAST(os_DirEntry_is_dir), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, os_DirEntry_is_dir__doc__}, static int os_DirEntry_is_dir_impl(DirEntry *self, PyTypeObject *defining_class, @@ -8400,7 +8400,7 @@ PyDoc_STRVAR(os_DirEntry_is_file__doc__, "Return True if the entry is a file; cached per entry."); #define OS_DIRENTRY_IS_FILE_METHODDEF \ - {"is_file", (PyCFunction)(void(*)(void))os_DirEntry_is_file, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, os_DirEntry_is_file__doc__}, + {"is_file", _PyCFunction_CAST(os_DirEntry_is_file), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, os_DirEntry_is_file__doc__}, static int os_DirEntry_is_file_impl(DirEntry *self, PyTypeObject *defining_class, @@ -8488,7 +8488,7 @@ PyDoc_STRVAR(os_scandir__doc__, "If path is None, uses the path=\'.\'."); #define OS_SCANDIR_METHODDEF \ - {"scandir", (PyCFunction)(void(*)(void))os_scandir, METH_FASTCALL|METH_KEYWORDS, os_scandir__doc__}, + {"scandir", _PyCFunction_CAST(os_scandir), METH_FASTCALL|METH_KEYWORDS, os_scandir__doc__}, static PyObject * os_scandir_impl(PyObject *module, path_t *path); @@ -8534,7 +8534,7 @@ PyDoc_STRVAR(os_fspath__doc__, "types raise a TypeError."); #define OS_FSPATH_METHODDEF \ - {"fspath", (PyCFunction)(void(*)(void))os_fspath, METH_FASTCALL|METH_KEYWORDS, os_fspath__doc__}, + {"fspath", _PyCFunction_CAST(os_fspath), METH_FASTCALL|METH_KEYWORDS, os_fspath__doc__}, static PyObject * os_fspath_impl(PyObject *module, PyObject *path); @@ -8568,7 +8568,7 @@ PyDoc_STRVAR(os_getrandom__doc__, "Obtain a series of random bytes."); #define OS_GETRANDOM_METHODDEF \ - {"getrandom", (PyCFunction)(void(*)(void))os_getrandom, METH_FASTCALL|METH_KEYWORDS, os_getrandom__doc__}, + {"getrandom", _PyCFunction_CAST(os_getrandom), METH_FASTCALL|METH_KEYWORDS, os_getrandom__doc__}, static PyObject * os_getrandom_impl(PyObject *module, Py_ssize_t size, int flags); @@ -8632,7 +8632,7 @@ PyDoc_STRVAR(os__add_dll_directory__doc__, "to remove this directory from the search path."); #define OS__ADD_DLL_DIRECTORY_METHODDEF \ - {"_add_dll_directory", (PyCFunction)(void(*)(void))os__add_dll_directory, METH_FASTCALL|METH_KEYWORDS, os__add_dll_directory__doc__}, + {"_add_dll_directory", _PyCFunction_CAST(os__add_dll_directory), METH_FASTCALL|METH_KEYWORDS, os__add_dll_directory__doc__}, static PyObject * os__add_dll_directory_impl(PyObject *module, path_t *path); @@ -8677,7 +8677,7 @@ PyDoc_STRVAR(os__remove_dll_directory__doc__, "yourself."); #define OS__REMOVE_DLL_DIRECTORY_METHODDEF \ - {"_remove_dll_directory", (PyCFunction)(void(*)(void))os__remove_dll_directory, METH_FASTCALL|METH_KEYWORDS, os__remove_dll_directory__doc__}, + {"_remove_dll_directory", _PyCFunction_CAST(os__remove_dll_directory), METH_FASTCALL|METH_KEYWORDS, os__remove_dll_directory__doc__}, static PyObject * os__remove_dll_directory_impl(PyObject *module, PyObject *cookie); @@ -8725,7 +8725,7 @@ PyDoc_STRVAR(os_waitstatus_to_exitcode__doc__, "This function must not be called if WIFSTOPPED(status) is true."); #define OS_WAITSTATUS_TO_EXITCODE_METHODDEF \ - {"waitstatus_to_exitcode", (PyCFunction)(void(*)(void))os_waitstatus_to_exitcode, METH_FASTCALL|METH_KEYWORDS, os_waitstatus_to_exitcode__doc__}, + {"waitstatus_to_exitcode", _PyCFunction_CAST(os_waitstatus_to_exitcode), METH_FASTCALL|METH_KEYWORDS, os_waitstatus_to_exitcode__doc__}, static PyObject * os_waitstatus_to_exitcode_impl(PyObject *module, PyObject *status_obj); @@ -9331,4 +9331,4 @@ os_waitstatus_to_exitcode(PyObject *module, PyObject *const *args, Py_ssize_t na #ifndef OS_WAITSTATUS_TO_EXITCODE_METHODDEF #define OS_WAITSTATUS_TO_EXITCODE_METHODDEF #endif /* !defined(OS_WAITSTATUS_TO_EXITCODE_METHODDEF) */ -/*[clinic end generated code: output=c8c5b148b96068b4 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=3b5a56add047ee1d input=a9049054013a1b77]*/ diff --git a/Modules/clinic/pyexpat.c.h b/Modules/clinic/pyexpat.c.h index bee2ee66950a5..b2648320aad78 100644 --- a/Modules/clinic/pyexpat.c.h +++ b/Modules/clinic/pyexpat.c.h @@ -11,7 +11,7 @@ PyDoc_STRVAR(pyexpat_xmlparser_Parse__doc__, "`isfinal\' should be true at end of input."); #define PYEXPAT_XMLPARSER_PARSE_METHODDEF \ - {"Parse", (PyCFunction)(void(*)(void))pyexpat_xmlparser_Parse, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pyexpat_xmlparser_Parse__doc__}, + {"Parse", _PyCFunction_CAST(pyexpat_xmlparser_Parse), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pyexpat_xmlparser_Parse__doc__}, static PyObject * pyexpat_xmlparser_Parse_impl(xmlparseobject *self, PyTypeObject *cls, @@ -53,7 +53,7 @@ PyDoc_STRVAR(pyexpat_xmlparser_ParseFile__doc__, "Parse XML data from file-like object."); #define PYEXPAT_XMLPARSER_PARSEFILE_METHODDEF \ - {"ParseFile", (PyCFunction)(void(*)(void))pyexpat_xmlparser_ParseFile, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pyexpat_xmlparser_ParseFile__doc__}, + {"ParseFile", _PyCFunction_CAST(pyexpat_xmlparser_ParseFile), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pyexpat_xmlparser_ParseFile__doc__}, static PyObject * pyexpat_xmlparser_ParseFile_impl(xmlparseobject *self, PyTypeObject *cls, @@ -163,7 +163,7 @@ PyDoc_STRVAR(pyexpat_xmlparser_ExternalEntityParserCreate__doc__, "Create a parser for parsing an external entity based on the information passed to the ExternalEntityRefHandler."); #define PYEXPAT_XMLPARSER_EXTERNALENTITYPARSERCREATE_METHODDEF \ - {"ExternalEntityParserCreate", (PyCFunction)(void(*)(void))pyexpat_xmlparser_ExternalEntityParserCreate, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pyexpat_xmlparser_ExternalEntityParserCreate__doc__}, + {"ExternalEntityParserCreate", _PyCFunction_CAST(pyexpat_xmlparser_ExternalEntityParserCreate), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pyexpat_xmlparser_ExternalEntityParserCreate__doc__}, static PyObject * pyexpat_xmlparser_ExternalEntityParserCreate_impl(xmlparseobject *self, @@ -272,7 +272,7 @@ PyDoc_STRVAR(pyexpat_xmlparser_UseForeignDTD__doc__, "information to the parser. \'flag\' defaults to True if not provided."); #define PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF \ - {"UseForeignDTD", (PyCFunction)(void(*)(void))pyexpat_xmlparser_UseForeignDTD, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pyexpat_xmlparser_UseForeignDTD__doc__}, + {"UseForeignDTD", _PyCFunction_CAST(pyexpat_xmlparser_UseForeignDTD), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pyexpat_xmlparser_UseForeignDTD__doc__}, static PyObject * pyexpat_xmlparser_UseForeignDTD_impl(xmlparseobject *self, PyTypeObject *cls, @@ -315,7 +315,7 @@ PyDoc_STRVAR(pyexpat_ParserCreate__doc__, "Return a new XML parser object."); #define PYEXPAT_PARSERCREATE_METHODDEF \ - {"ParserCreate", (PyCFunction)(void(*)(void))pyexpat_ParserCreate, METH_FASTCALL|METH_KEYWORDS, pyexpat_ParserCreate__doc__}, + {"ParserCreate", _PyCFunction_CAST(pyexpat_ParserCreate), METH_FASTCALL|METH_KEYWORDS, pyexpat_ParserCreate__doc__}, static PyObject * pyexpat_ParserCreate_impl(PyObject *module, const char *encoding, @@ -425,4 +425,4 @@ pyexpat_ErrorString(PyObject *module, PyObject *arg) #ifndef PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF #define PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF #endif /* !defined(PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF) */ -/*[clinic end generated code: output=5d60049d385d5d56 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=3e333b89da3aa58c input=a9049054013a1b77]*/ diff --git a/Modules/clinic/readline.c.h b/Modules/clinic/readline.c.h index d1ee8089f73f0..c64a84ed81ddf 100644 --- a/Modules/clinic/readline.c.h +++ b/Modules/clinic/readline.c.h @@ -20,7 +20,7 @@ PyDoc_STRVAR(readline_read_init_file__doc__, "The default filename is the last filename used."); #define READLINE_READ_INIT_FILE_METHODDEF \ - {"read_init_file", (PyCFunction)(void(*)(void))readline_read_init_file, METH_FASTCALL, readline_read_init_file__doc__}, + {"read_init_file", _PyCFunction_CAST(readline_read_init_file), METH_FASTCALL, readline_read_init_file__doc__}, static PyObject * readline_read_init_file_impl(PyObject *module, PyObject *filename_obj); @@ -54,7 +54,7 @@ PyDoc_STRVAR(readline_read_history_file__doc__, "The default filename is ~/.history."); #define READLINE_READ_HISTORY_FILE_METHODDEF \ - {"read_history_file", (PyCFunction)(void(*)(void))readline_read_history_file, METH_FASTCALL, readline_read_history_file__doc__}, + {"read_history_file", _PyCFunction_CAST(readline_read_history_file), METH_FASTCALL, readline_read_history_file__doc__}, static PyObject * readline_read_history_file_impl(PyObject *module, PyObject *filename_obj); @@ -88,7 +88,7 @@ PyDoc_STRVAR(readline_write_history_file__doc__, "The default filename is ~/.history."); #define READLINE_WRITE_HISTORY_FILE_METHODDEF \ - {"write_history_file", (PyCFunction)(void(*)(void))readline_write_history_file, METH_FASTCALL, readline_write_history_file__doc__}, + {"write_history_file", _PyCFunction_CAST(readline_write_history_file), METH_FASTCALL, readline_write_history_file__doc__}, static PyObject * readline_write_history_file_impl(PyObject *module, PyObject *filename_obj); @@ -124,7 +124,7 @@ PyDoc_STRVAR(readline_append_history_file__doc__, "The default filename is ~/.history."); #define READLINE_APPEND_HISTORY_FILE_METHODDEF \ - {"append_history_file", (PyCFunction)(void(*)(void))readline_append_history_file, METH_FASTCALL, readline_append_history_file__doc__}, + {"append_history_file", _PyCFunction_CAST(readline_append_history_file), METH_FASTCALL, readline_append_history_file__doc__}, static PyObject * readline_append_history_file_impl(PyObject *module, int nelements, @@ -216,7 +216,7 @@ PyDoc_STRVAR(readline_set_completion_display_matches_hook__doc__, "once each time matches need to be displayed."); #define READLINE_SET_COMPLETION_DISPLAY_MATCHES_HOOK_METHODDEF \ - {"set_completion_display_matches_hook", (PyCFunction)(void(*)(void))readline_set_completion_display_matches_hook, METH_FASTCALL, readline_set_completion_display_matches_hook__doc__}, + {"set_completion_display_matches_hook", _PyCFunction_CAST(readline_set_completion_display_matches_hook), METH_FASTCALL, readline_set_completion_display_matches_hook__doc__}, static PyObject * readline_set_completion_display_matches_hook_impl(PyObject *module, @@ -252,7 +252,7 @@ PyDoc_STRVAR(readline_set_startup_hook__doc__, "before readline prints the first prompt."); #define READLINE_SET_STARTUP_HOOK_METHODDEF \ - {"set_startup_hook", (PyCFunction)(void(*)(void))readline_set_startup_hook, METH_FASTCALL, readline_set_startup_hook__doc__}, + {"set_startup_hook", _PyCFunction_CAST(readline_set_startup_hook), METH_FASTCALL, readline_set_startup_hook__doc__}, static PyObject * readline_set_startup_hook_impl(PyObject *module, PyObject *function); @@ -290,7 +290,7 @@ PyDoc_STRVAR(readline_set_pre_input_hook__doc__, "characters."); #define READLINE_SET_PRE_INPUT_HOOK_METHODDEF \ - {"set_pre_input_hook", (PyCFunction)(void(*)(void))readline_set_pre_input_hook, METH_FASTCALL, readline_set_pre_input_hook__doc__}, + {"set_pre_input_hook", _PyCFunction_CAST(readline_set_pre_input_hook), METH_FASTCALL, readline_set_pre_input_hook__doc__}, static PyObject * readline_set_pre_input_hook_impl(PyObject *module, PyObject *function); @@ -417,7 +417,7 @@ PyDoc_STRVAR(readline_replace_history_item__doc__, "pos is zero-based."); #define READLINE_REPLACE_HISTORY_ITEM_METHODDEF \ - {"replace_history_item", (PyCFunction)(void(*)(void))readline_replace_history_item, METH_FASTCALL, readline_replace_history_item__doc__}, + {"replace_history_item", _PyCFunction_CAST(readline_replace_history_item), METH_FASTCALL, readline_replace_history_item__doc__}, static PyObject * readline_replace_history_item_impl(PyObject *module, int entry_number, @@ -518,7 +518,7 @@ PyDoc_STRVAR(readline_set_completer__doc__, "It should return the next possible completion starting with \'text\'."); #define READLINE_SET_COMPLETER_METHODDEF \ - {"set_completer", (PyCFunction)(void(*)(void))readline_set_completer, METH_FASTCALL, readline_set_completer__doc__}, + {"set_completer", _PyCFunction_CAST(readline_set_completer), METH_FASTCALL, readline_set_completer__doc__}, static PyObject * readline_set_completer_impl(PyObject *module, PyObject *function); @@ -685,4 +685,4 @@ readline_redisplay(PyObject *module, PyObject *Py_UNUSED(ignored)) #ifndef READLINE_CLEAR_HISTORY_METHODDEF #define READLINE_CLEAR_HISTORY_METHODDEF #endif /* !defined(READLINE_CLEAR_HISTORY_METHODDEF) */ -/*[clinic end generated code: output=f7d390113b27989f input=a9049054013a1b77]*/ +/*[clinic end generated code: output=1fd4c04c2e7ba475 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/resource.c.h b/Modules/clinic/resource.c.h index f31f7e8265e79..c591823ed7170 100644 --- a/Modules/clinic/resource.c.h +++ b/Modules/clinic/resource.c.h @@ -66,7 +66,7 @@ PyDoc_STRVAR(resource_setrlimit__doc__, "\n"); #define RESOURCE_SETRLIMIT_METHODDEF \ - {"setrlimit", (PyCFunction)(void(*)(void))resource_setrlimit, METH_FASTCALL, resource_setrlimit__doc__}, + {"setrlimit", _PyCFunction_CAST(resource_setrlimit), METH_FASTCALL, resource_setrlimit__doc__}, static PyObject * resource_setrlimit_impl(PyObject *module, int resource, PyObject *limits); @@ -171,4 +171,4 @@ resource_getpagesize(PyObject *module, PyObject *Py_UNUSED(ignored)) #ifndef RESOURCE_PRLIMIT_METHODDEF #define RESOURCE_PRLIMIT_METHODDEF #endif /* !defined(RESOURCE_PRLIMIT_METHODDEF) */ -/*[clinic end generated code: output=9ce1886c129eb2f3 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=7c57d4f3688d3f07 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/selectmodule.c.h b/Modules/clinic/selectmodule.c.h index ca06dae32964f..daa75427319a1 100644 --- a/Modules/clinic/selectmodule.c.h +++ b/Modules/clinic/selectmodule.c.h @@ -30,7 +30,7 @@ PyDoc_STRVAR(select_select__doc__, "descriptors can be used."); #define SELECT_SELECT_METHODDEF \ - {"select", (PyCFunction)(void(*)(void))select_select, METH_FASTCALL, select_select__doc__}, + {"select", _PyCFunction_CAST(select_select), METH_FASTCALL, select_select__doc__}, static PyObject * select_select_impl(PyObject *module, PyObject *rlist, PyObject *wlist, @@ -77,7 +77,7 @@ PyDoc_STRVAR(select_poll_register__doc__, " an optional bitmask describing the type of events to check for"); #define SELECT_POLL_REGISTER_METHODDEF \ - {"register", (PyCFunction)(void(*)(void))select_poll_register, METH_FASTCALL, select_poll_register__doc__}, + {"register", _PyCFunction_CAST(select_poll_register), METH_FASTCALL, select_poll_register__doc__}, static PyObject * select_poll_register_impl(pollObject *self, int fd, unsigned short eventmask); @@ -125,7 +125,7 @@ PyDoc_STRVAR(select_poll_modify__doc__, " a bitmask describing the type of events to check for"); #define SELECT_POLL_MODIFY_METHODDEF \ - {"modify", (PyCFunction)(void(*)(void))select_poll_modify, METH_FASTCALL, select_poll_modify__doc__}, + {"modify", _PyCFunction_CAST(select_poll_modify), METH_FASTCALL, select_poll_modify__doc__}, static PyObject * select_poll_modify_impl(pollObject *self, int fd, unsigned short eventmask); @@ -201,7 +201,7 @@ PyDoc_STRVAR(select_poll_poll__doc__, "report, as a list of (fd, event) 2-tuples."); #define SELECT_POLL_POLL_METHODDEF \ - {"poll", (PyCFunction)(void(*)(void))select_poll_poll, METH_FASTCALL, select_poll_poll__doc__}, + {"poll", _PyCFunction_CAST(select_poll_poll), METH_FASTCALL, select_poll_poll__doc__}, static PyObject * select_poll_poll_impl(pollObject *self, PyObject *timeout_obj); @@ -244,7 +244,7 @@ PyDoc_STRVAR(select_devpoll_register__doc__, " an optional bitmask describing the type of events to check for"); #define SELECT_DEVPOLL_REGISTER_METHODDEF \ - {"register", (PyCFunction)(void(*)(void))select_devpoll_register, METH_FASTCALL, select_devpoll_register__doc__}, + {"register", _PyCFunction_CAST(select_devpoll_register), METH_FASTCALL, select_devpoll_register__doc__}, static PyObject * select_devpoll_register_impl(devpollObject *self, int fd, @@ -294,7 +294,7 @@ PyDoc_STRVAR(select_devpoll_modify__doc__, " an optional bitmask describing the type of events to check for"); #define SELECT_DEVPOLL_MODIFY_METHODDEF \ - {"modify", (PyCFunction)(void(*)(void))select_devpoll_modify, METH_FASTCALL, select_devpoll_modify__doc__}, + {"modify", _PyCFunction_CAST(select_devpoll_modify), METH_FASTCALL, select_devpoll_modify__doc__}, static PyObject * select_devpoll_modify_impl(devpollObject *self, int fd, @@ -375,7 +375,7 @@ PyDoc_STRVAR(select_devpoll_poll__doc__, "report, as a list of (fd, event) 2-tuples."); #define SELECT_DEVPOLL_POLL_METHODDEF \ - {"poll", (PyCFunction)(void(*)(void))select_devpoll_poll, METH_FASTCALL, select_devpoll_poll__doc__}, + {"poll", _PyCFunction_CAST(select_devpoll_poll), METH_FASTCALL, select_devpoll_poll__doc__}, static PyObject * select_devpoll_poll_impl(devpollObject *self, PyObject *timeout_obj); @@ -655,7 +655,7 @@ PyDoc_STRVAR(select_epoll_register__doc__, "The epoll interface supports all file descriptors that support poll."); #define SELECT_EPOLL_REGISTER_METHODDEF \ - {"register", (PyCFunction)(void(*)(void))select_epoll_register, METH_FASTCALL|METH_KEYWORDS, select_epoll_register__doc__}, + {"register", _PyCFunction_CAST(select_epoll_register), METH_FASTCALL|METH_KEYWORDS, select_epoll_register__doc__}, static PyObject * select_epoll_register_impl(pyEpoll_Object *self, int fd, @@ -709,7 +709,7 @@ PyDoc_STRVAR(select_epoll_modify__doc__, " a bit set composed of the various EPOLL constants"); #define SELECT_EPOLL_MODIFY_METHODDEF \ - {"modify", (PyCFunction)(void(*)(void))select_epoll_modify, METH_FASTCALL|METH_KEYWORDS, select_epoll_modify__doc__}, + {"modify", _PyCFunction_CAST(select_epoll_modify), METH_FASTCALL|METH_KEYWORDS, select_epoll_modify__doc__}, static PyObject * select_epoll_modify_impl(pyEpoll_Object *self, int fd, @@ -756,7 +756,7 @@ PyDoc_STRVAR(select_epoll_unregister__doc__, " the target file descriptor of the operation"); #define SELECT_EPOLL_UNREGISTER_METHODDEF \ - {"unregister", (PyCFunction)(void(*)(void))select_epoll_unregister, METH_FASTCALL|METH_KEYWORDS, select_epoll_unregister__doc__}, + {"unregister", _PyCFunction_CAST(select_epoll_unregister), METH_FASTCALL|METH_KEYWORDS, select_epoll_unregister__doc__}, static PyObject * select_epoll_unregister_impl(pyEpoll_Object *self, int fd); @@ -803,7 +803,7 @@ PyDoc_STRVAR(select_epoll_poll__doc__, "as a list of (fd, events) 2-tuples."); #define SELECT_EPOLL_POLL_METHODDEF \ - {"poll", (PyCFunction)(void(*)(void))select_epoll_poll, METH_FASTCALL|METH_KEYWORDS, select_epoll_poll__doc__}, + {"poll", _PyCFunction_CAST(select_epoll_poll), METH_FASTCALL|METH_KEYWORDS, select_epoll_poll__doc__}, static PyObject * select_epoll_poll_impl(pyEpoll_Object *self, PyObject *timeout_obj, @@ -875,7 +875,7 @@ PyDoc_STRVAR(select_epoll___exit____doc__, "\n"); #define SELECT_EPOLL___EXIT___METHODDEF \ - {"__exit__", (PyCFunction)(void(*)(void))select_epoll___exit__, METH_FASTCALL, select_epoll___exit____doc__}, + {"__exit__", _PyCFunction_CAST(select_epoll___exit__), METH_FASTCALL, select_epoll___exit____doc__}, static PyObject * select_epoll___exit___impl(pyEpoll_Object *self, PyObject *exc_type, @@ -1055,7 +1055,7 @@ PyDoc_STRVAR(select_kqueue_control__doc__, " This accepts floats for smaller timeouts, too."); #define SELECT_KQUEUE_CONTROL_METHODDEF \ - {"control", (PyCFunction)(void(*)(void))select_kqueue_control, METH_FASTCALL, select_kqueue_control__doc__}, + {"control", _PyCFunction_CAST(select_kqueue_control), METH_FASTCALL, select_kqueue_control__doc__}, static PyObject * select_kqueue_control_impl(kqueue_queue_Object *self, PyObject *changelist, @@ -1189,4 +1189,4 @@ select_kqueue_control(kqueue_queue_Object *self, PyObject *const *args, Py_ssize #ifndef SELECT_KQUEUE_CONTROL_METHODDEF #define SELECT_KQUEUE_CONTROL_METHODDEF #endif /* !defined(SELECT_KQUEUE_CONTROL_METHODDEF) */ -/*[clinic end generated code: output=09ff9484c1b092fb input=a9049054013a1b77]*/ +/*[clinic end generated code: output=e77cc5c8a6c77860 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/sha1module.c.h b/Modules/clinic/sha1module.c.h index d9a2e150f6d41..e2338e4a1280a 100644 --- a/Modules/clinic/sha1module.c.h +++ b/Modules/clinic/sha1module.c.h @@ -9,7 +9,7 @@ PyDoc_STRVAR(SHA1Type_copy__doc__, "Return a copy of the hash object."); #define SHA1TYPE_COPY_METHODDEF \ - {"copy", (PyCFunction)(void(*)(void))SHA1Type_copy, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, SHA1Type_copy__doc__}, + {"copy", _PyCFunction_CAST(SHA1Type_copy), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, SHA1Type_copy__doc__}, static PyObject * SHA1Type_copy_impl(SHA1object *self, PyTypeObject *cls); @@ -76,7 +76,7 @@ PyDoc_STRVAR(_sha1_sha1__doc__, "Return a new SHA1 hash object; optionally initialized with a string."); #define _SHA1_SHA1_METHODDEF \ - {"sha1", (PyCFunction)(void(*)(void))_sha1_sha1, METH_FASTCALL|METH_KEYWORDS, _sha1_sha1__doc__}, + {"sha1", _PyCFunction_CAST(_sha1_sha1), METH_FASTCALL|METH_KEYWORDS, _sha1_sha1__doc__}, static PyObject * _sha1_sha1_impl(PyObject *module, PyObject *string, int usedforsecurity); @@ -119,4 +119,4 @@ _sha1_sha1(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject * exit: return return_value; } -/*[clinic end generated code: output=93ced3c8f8fa4f21 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=322d77ba0a4282fc input=a9049054013a1b77]*/ diff --git a/Modules/clinic/sha256module.c.h b/Modules/clinic/sha256module.c.h index 619fab1a6fe2f..b94c1c548a394 100644 --- a/Modules/clinic/sha256module.c.h +++ b/Modules/clinic/sha256module.c.h @@ -9,7 +9,7 @@ PyDoc_STRVAR(SHA256Type_copy__doc__, "Return a copy of the hash object."); #define SHA256TYPE_COPY_METHODDEF \ - {"copy", (PyCFunction)(void(*)(void))SHA256Type_copy, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, SHA256Type_copy__doc__}, + {"copy", _PyCFunction_CAST(SHA256Type_copy), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, SHA256Type_copy__doc__}, static PyObject * SHA256Type_copy_impl(SHAobject *self, PyTypeObject *cls); @@ -76,7 +76,7 @@ PyDoc_STRVAR(_sha256_sha256__doc__, "Return a new SHA-256 hash object; optionally initialized with a string."); #define _SHA256_SHA256_METHODDEF \ - {"sha256", (PyCFunction)(void(*)(void))_sha256_sha256, METH_FASTCALL|METH_KEYWORDS, _sha256_sha256__doc__}, + {"sha256", _PyCFunction_CAST(_sha256_sha256), METH_FASTCALL|METH_KEYWORDS, _sha256_sha256__doc__}, static PyObject * _sha256_sha256_impl(PyObject *module, PyObject *string, int usedforsecurity); @@ -127,7 +127,7 @@ PyDoc_STRVAR(_sha256_sha224__doc__, "Return a new SHA-224 hash object; optionally initialized with a string."); #define _SHA256_SHA224_METHODDEF \ - {"sha224", (PyCFunction)(void(*)(void))_sha256_sha224, METH_FASTCALL|METH_KEYWORDS, _sha256_sha224__doc__}, + {"sha224", _PyCFunction_CAST(_sha256_sha224), METH_FASTCALL|METH_KEYWORDS, _sha256_sha224__doc__}, static PyObject * _sha256_sha224_impl(PyObject *module, PyObject *string, int usedforsecurity); @@ -170,4 +170,4 @@ _sha256_sha224(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObje exit: return return_value; } -/*[clinic end generated code: output=4f9fe3ca546b0c58 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=58b48051890d3fde input=a9049054013a1b77]*/ diff --git a/Modules/clinic/sha512module.c.h b/Modules/clinic/sha512module.c.h index fada35eff2261..b7227480c342a 100644 --- a/Modules/clinic/sha512module.c.h +++ b/Modules/clinic/sha512module.c.h @@ -9,7 +9,7 @@ PyDoc_STRVAR(SHA512Type_copy__doc__, "Return a copy of the hash object."); #define SHA512TYPE_COPY_METHODDEF \ - {"copy", (PyCFunction)(void(*)(void))SHA512Type_copy, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, SHA512Type_copy__doc__}, + {"copy", _PyCFunction_CAST(SHA512Type_copy), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, SHA512Type_copy__doc__}, static PyObject * SHA512Type_copy_impl(SHAobject *self, PyTypeObject *cls); @@ -76,7 +76,7 @@ PyDoc_STRVAR(_sha512_sha512__doc__, "Return a new SHA-512 hash object; optionally initialized with a string."); #define _SHA512_SHA512_METHODDEF \ - {"sha512", (PyCFunction)(void(*)(void))_sha512_sha512, METH_FASTCALL|METH_KEYWORDS, _sha512_sha512__doc__}, + {"sha512", _PyCFunction_CAST(_sha512_sha512), METH_FASTCALL|METH_KEYWORDS, _sha512_sha512__doc__}, static PyObject * _sha512_sha512_impl(PyObject *module, PyObject *string, int usedforsecurity); @@ -127,7 +127,7 @@ PyDoc_STRVAR(_sha512_sha384__doc__, "Return a new SHA-384 hash object; optionally initialized with a string."); #define _SHA512_SHA384_METHODDEF \ - {"sha384", (PyCFunction)(void(*)(void))_sha512_sha384, METH_FASTCALL|METH_KEYWORDS, _sha512_sha384__doc__}, + {"sha384", _PyCFunction_CAST(_sha512_sha384), METH_FASTCALL|METH_KEYWORDS, _sha512_sha384__doc__}, static PyObject * _sha512_sha384_impl(PyObject *module, PyObject *string, int usedforsecurity); @@ -170,4 +170,4 @@ _sha512_sha384(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObje exit: return return_value; } -/*[clinic end generated code: output=26d2fe27b9673ac2 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=60a0a1a28c07f391 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/signalmodule.c.h b/Modules/clinic/signalmodule.c.h index 4c27314a80c86..9e4a8eb0b998a 100644 --- a/Modules/clinic/signalmodule.c.h +++ b/Modules/clinic/signalmodule.c.h @@ -11,7 +11,7 @@ PyDoc_STRVAR(signal_default_int_handler__doc__, "It raises KeyboardInterrupt."); #define SIGNAL_DEFAULT_INT_HANDLER_METHODDEF \ - {"default_int_handler", (PyCFunction)(void(*)(void))signal_default_int_handler, METH_FASTCALL, signal_default_int_handler__doc__}, + {"default_int_handler", _PyCFunction_CAST(signal_default_int_handler), METH_FASTCALL, signal_default_int_handler__doc__}, static PyObject * signal_default_int_handler_impl(PyObject *module, int signalnum, @@ -139,7 +139,7 @@ PyDoc_STRVAR(signal_signal__doc__, "the first is the signal number, the second is the interrupted stack frame."); #define SIGNAL_SIGNAL_METHODDEF \ - {"signal", (PyCFunction)(void(*)(void))signal_signal, METH_FASTCALL, signal_signal__doc__}, + {"signal", _PyCFunction_CAST(signal_signal), METH_FASTCALL, signal_signal__doc__}, static PyObject * signal_signal_impl(PyObject *module, int signalnum, PyObject *handler); @@ -242,7 +242,7 @@ PyDoc_STRVAR(signal_siginterrupt__doc__, "signal sig, else system calls will be interrupted."); #define SIGNAL_SIGINTERRUPT_METHODDEF \ - {"siginterrupt", (PyCFunction)(void(*)(void))signal_siginterrupt, METH_FASTCALL, signal_siginterrupt__doc__}, + {"siginterrupt", _PyCFunction_CAST(signal_siginterrupt), METH_FASTCALL, signal_siginterrupt__doc__}, static PyObject * signal_siginterrupt_impl(PyObject *module, int signalnum, int flag); @@ -287,7 +287,7 @@ PyDoc_STRVAR(signal_setitimer__doc__, "Returns old values as a tuple: (delay, interval)."); #define SIGNAL_SETITIMER_METHODDEF \ - {"setitimer", (PyCFunction)(void(*)(void))signal_setitimer, METH_FASTCALL, signal_setitimer__doc__}, + {"setitimer", _PyCFunction_CAST(signal_setitimer), METH_FASTCALL, signal_setitimer__doc__}, static PyObject * signal_setitimer_impl(PyObject *module, int which, PyObject *seconds, @@ -363,7 +363,7 @@ PyDoc_STRVAR(signal_pthread_sigmask__doc__, "Fetch and/or change the signal mask of the calling thread."); #define SIGNAL_PTHREAD_SIGMASK_METHODDEF \ - {"pthread_sigmask", (PyCFunction)(void(*)(void))signal_pthread_sigmask, METH_FASTCALL, signal_pthread_sigmask__doc__}, + {"pthread_sigmask", _PyCFunction_CAST(signal_pthread_sigmask), METH_FASTCALL, signal_pthread_sigmask__doc__}, static PyObject * signal_pthread_sigmask_impl(PyObject *module, int how, sigset_t mask); @@ -522,7 +522,7 @@ PyDoc_STRVAR(signal_sigtimedwait__doc__, "The timeout is specified in seconds, with floating point numbers allowed."); #define SIGNAL_SIGTIMEDWAIT_METHODDEF \ - {"sigtimedwait", (PyCFunction)(void(*)(void))signal_sigtimedwait, METH_FASTCALL, signal_sigtimedwait__doc__}, + {"sigtimedwait", _PyCFunction_CAST(signal_sigtimedwait), METH_FASTCALL, signal_sigtimedwait__doc__}, static PyObject * signal_sigtimedwait_impl(PyObject *module, sigset_t sigset, @@ -559,7 +559,7 @@ PyDoc_STRVAR(signal_pthread_kill__doc__, "Send a signal to a thread."); #define SIGNAL_PTHREAD_KILL_METHODDEF \ - {"pthread_kill", (PyCFunction)(void(*)(void))signal_pthread_kill, METH_FASTCALL, signal_pthread_kill__doc__}, + {"pthread_kill", _PyCFunction_CAST(signal_pthread_kill), METH_FASTCALL, signal_pthread_kill__doc__}, static PyObject * signal_pthread_kill_impl(PyObject *module, unsigned long thread_id, @@ -601,7 +601,7 @@ PyDoc_STRVAR(signal_pidfd_send_signal__doc__, "Send a signal to a process referred to by a pid file descriptor."); #define SIGNAL_PIDFD_SEND_SIGNAL_METHODDEF \ - {"pidfd_send_signal", (PyCFunction)(void(*)(void))signal_pidfd_send_signal, METH_FASTCALL, signal_pidfd_send_signal__doc__}, + {"pidfd_send_signal", _PyCFunction_CAST(signal_pidfd_send_signal), METH_FASTCALL, signal_pidfd_send_signal__doc__}, static PyObject * signal_pidfd_send_signal_impl(PyObject *module, int pidfd, int signalnum, @@ -698,4 +698,4 @@ signal_pidfd_send_signal(PyObject *module, PyObject *const *args, Py_ssize_t nar #ifndef SIGNAL_PIDFD_SEND_SIGNAL_METHODDEF #define SIGNAL_PIDFD_SEND_SIGNAL_METHODDEF #endif /* !defined(SIGNAL_PIDFD_SEND_SIGNAL_METHODDEF) */ -/*[clinic end generated code: output=c353e686367bc384 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=6ca1b70310eecdba input=a9049054013a1b77]*/ diff --git a/Modules/clinic/symtablemodule.c.h b/Modules/clinic/symtablemodule.c.h index 4a17f130ac97b..2cd08f8178200 100644 --- a/Modules/clinic/symtablemodule.c.h +++ b/Modules/clinic/symtablemodule.c.h @@ -9,7 +9,7 @@ PyDoc_STRVAR(_symtable_symtable__doc__, "Return symbol and scope dictionaries used internally by compiler."); #define _SYMTABLE_SYMTABLE_METHODDEF \ - {"symtable", (PyCFunction)(void(*)(void))_symtable_symtable, METH_FASTCALL, _symtable_symtable__doc__}, + {"symtable", _PyCFunction_CAST(_symtable_symtable), METH_FASTCALL, _symtable_symtable__doc__}, static PyObject * _symtable_symtable_impl(PyObject *module, PyObject *source, @@ -48,4 +48,4 @@ _symtable_symtable(PyObject *module, PyObject *const *args, Py_ssize_t nargs) exit: return return_value; } -/*[clinic end generated code: output=a12f75cdbdf4e52a input=a9049054013a1b77]*/ +/*[clinic end generated code: output=3f7ccf535d750238 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/termios.c.h b/Modules/clinic/termios.c.h index b4d179abbe490..29858fe8d05ea 100644 --- a/Modules/clinic/termios.c.h +++ b/Modules/clinic/termios.c.h @@ -50,7 +50,7 @@ PyDoc_STRVAR(termios_tcsetattr__doc__, "queued output and discarding all queued input."); #define TERMIOS_TCSETATTR_METHODDEF \ - {"tcsetattr", (PyCFunction)(void(*)(void))termios_tcsetattr, METH_FASTCALL, termios_tcsetattr__doc__}, + {"tcsetattr", _PyCFunction_CAST(termios_tcsetattr), METH_FASTCALL, termios_tcsetattr__doc__}, static PyObject * termios_tcsetattr_impl(PyObject *module, int fd, int when, PyObject *term); @@ -90,7 +90,7 @@ PyDoc_STRVAR(termios_tcsendbreak__doc__, "has a system dependent meaning."); #define TERMIOS_TCSENDBREAK_METHODDEF \ - {"tcsendbreak", (PyCFunction)(void(*)(void))termios_tcsendbreak, METH_FASTCALL, termios_tcsendbreak__doc__}, + {"tcsendbreak", _PyCFunction_CAST(termios_tcsendbreak), METH_FASTCALL, termios_tcsendbreak__doc__}, static PyObject * termios_tcsendbreak_impl(PyObject *module, int fd, int duration); @@ -156,7 +156,7 @@ PyDoc_STRVAR(termios_tcflush__doc__, "both queues."); #define TERMIOS_TCFLUSH_METHODDEF \ - {"tcflush", (PyCFunction)(void(*)(void))termios_tcflush, METH_FASTCALL, termios_tcflush__doc__}, + {"tcflush", _PyCFunction_CAST(termios_tcflush), METH_FASTCALL, termios_tcflush__doc__}, static PyObject * termios_tcflush_impl(PyObject *module, int fd, int queue); @@ -195,7 +195,7 @@ PyDoc_STRVAR(termios_tcflow__doc__, "or termios.TCION to restart input."); #define TERMIOS_TCFLOW_METHODDEF \ - {"tcflow", (PyCFunction)(void(*)(void))termios_tcflow, METH_FASTCALL, termios_tcflow__doc__}, + {"tcflow", _PyCFunction_CAST(termios_tcflow), METH_FASTCALL, termios_tcflow__doc__}, static PyObject * termios_tcflow_impl(PyObject *module, int fd, int action); @@ -262,7 +262,7 @@ PyDoc_STRVAR(termios_tcsetwinsize__doc__, "is a two-item tuple (ws_row, ws_col) like the one returned by tcgetwinsize()."); #define TERMIOS_TCSETWINSIZE_METHODDEF \ - {"tcsetwinsize", (PyCFunction)(void(*)(void))termios_tcsetwinsize, METH_FASTCALL, termios_tcsetwinsize__doc__}, + {"tcsetwinsize", _PyCFunction_CAST(termios_tcsetwinsize), METH_FASTCALL, termios_tcsetwinsize__doc__}, static PyObject * termios_tcsetwinsize_impl(PyObject *module, int fd, PyObject *winsz); @@ -286,4 +286,4 @@ termios_tcsetwinsize(PyObject *module, PyObject *const *args, Py_ssize_t nargs) exit: return return_value; } -/*[clinic end generated code: output=db808d31296f6643 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=ef9ab888876fac17 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/unicodedata.c.h b/Modules/clinic/unicodedata.c.h index 17f2e009701f1..835a776fe172f 100644 --- a/Modules/clinic/unicodedata.c.h +++ b/Modules/clinic/unicodedata.c.h @@ -13,7 +13,7 @@ PyDoc_STRVAR(unicodedata_UCD_decimal__doc__, "ValueError is raised."); #define UNICODEDATA_UCD_DECIMAL_METHODDEF \ - {"decimal", (PyCFunction)(void(*)(void))unicodedata_UCD_decimal, METH_FASTCALL, unicodedata_UCD_decimal__doc__}, + {"decimal", _PyCFunction_CAST(unicodedata_UCD_decimal), METH_FASTCALL, unicodedata_UCD_decimal__doc__}, static PyObject * unicodedata_UCD_decimal_impl(PyObject *self, int chr, @@ -63,7 +63,7 @@ PyDoc_STRVAR(unicodedata_UCD_digit__doc__, "ValueError is raised."); #define UNICODEDATA_UCD_DIGIT_METHODDEF \ - {"digit", (PyCFunction)(void(*)(void))unicodedata_UCD_digit, METH_FASTCALL, unicodedata_UCD_digit__doc__}, + {"digit", _PyCFunction_CAST(unicodedata_UCD_digit), METH_FASTCALL, unicodedata_UCD_digit__doc__}, static PyObject * unicodedata_UCD_digit_impl(PyObject *self, int chr, PyObject *default_value); @@ -112,7 +112,7 @@ PyDoc_STRVAR(unicodedata_UCD_numeric__doc__, "ValueError is raised."); #define UNICODEDATA_UCD_NUMERIC_METHODDEF \ - {"numeric", (PyCFunction)(void(*)(void))unicodedata_UCD_numeric, METH_FASTCALL, unicodedata_UCD_numeric__doc__}, + {"numeric", _PyCFunction_CAST(unicodedata_UCD_numeric), METH_FASTCALL, unicodedata_UCD_numeric__doc__}, static PyObject * unicodedata_UCD_numeric_impl(PyObject *self, int chr, @@ -395,7 +395,7 @@ PyDoc_STRVAR(unicodedata_UCD_is_normalized__doc__, "Valid values for form are \'NFC\', \'NFKC\', \'NFD\', and \'NFKD\'."); #define UNICODEDATA_UCD_IS_NORMALIZED_METHODDEF \ - {"is_normalized", (PyCFunction)(void(*)(void))unicodedata_UCD_is_normalized, METH_FASTCALL, unicodedata_UCD_is_normalized__doc__}, + {"is_normalized", _PyCFunction_CAST(unicodedata_UCD_is_normalized), METH_FASTCALL, unicodedata_UCD_is_normalized__doc__}, static PyObject * unicodedata_UCD_is_normalized_impl(PyObject *self, PyObject *form, @@ -442,7 +442,7 @@ PyDoc_STRVAR(unicodedata_UCD_normalize__doc__, "Valid values for form are \'NFC\', \'NFKC\', \'NFD\', and \'NFKD\'."); #define UNICODEDATA_UCD_NORMALIZE_METHODDEF \ - {"normalize", (PyCFunction)(void(*)(void))unicodedata_UCD_normalize, METH_FASTCALL, unicodedata_UCD_normalize__doc__}, + {"normalize", _PyCFunction_CAST(unicodedata_UCD_normalize), METH_FASTCALL, unicodedata_UCD_normalize__doc__}, static PyObject * unicodedata_UCD_normalize_impl(PyObject *self, PyObject *form, @@ -490,7 +490,7 @@ PyDoc_STRVAR(unicodedata_UCD_name__doc__, "ValueError is raised."); #define UNICODEDATA_UCD_NAME_METHODDEF \ - {"name", (PyCFunction)(void(*)(void))unicodedata_UCD_name, METH_FASTCALL, unicodedata_UCD_name__doc__}, + {"name", _PyCFunction_CAST(unicodedata_UCD_name), METH_FASTCALL, unicodedata_UCD_name__doc__}, static PyObject * unicodedata_UCD_name_impl(PyObject *self, int chr, PyObject *default_value); @@ -559,4 +559,4 @@ unicodedata_UCD_lookup(PyObject *self, PyObject *arg) exit: return return_value; } -/*[clinic end generated code: output=a3c0eb84eda47b2d input=a9049054013a1b77]*/ +/*[clinic end generated code: output=78d7a7ae57014502 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/zlibmodule.c.h b/Modules/clinic/zlibmodule.c.h index deadf872d0cf7..ad6a7d470c5e5 100644 --- a/Modules/clinic/zlibmodule.c.h +++ b/Modules/clinic/zlibmodule.c.h @@ -16,7 +16,7 @@ PyDoc_STRVAR(zlib_compress__doc__, " The window buffer size and container format."); #define ZLIB_COMPRESS_METHODDEF \ - {"compress", (PyCFunction)(void(*)(void))zlib_compress, METH_FASTCALL|METH_KEYWORDS, zlib_compress__doc__}, + {"compress", _PyCFunction_CAST(zlib_compress), METH_FASTCALL|METH_KEYWORDS, zlib_compress__doc__}, static PyObject * zlib_compress_impl(PyObject *module, Py_buffer *data, int level, int wbits); @@ -86,7 +86,7 @@ PyDoc_STRVAR(zlib_decompress__doc__, " The initial output buffer size."); #define ZLIB_DECOMPRESS_METHODDEF \ - {"decompress", (PyCFunction)(void(*)(void))zlib_decompress, METH_FASTCALL|METH_KEYWORDS, zlib_decompress__doc__}, + {"decompress", _PyCFunction_CAST(zlib_decompress), METH_FASTCALL|METH_KEYWORDS, zlib_decompress__doc__}, static PyObject * zlib_decompress_impl(PyObject *module, Py_buffer *data, int wbits, @@ -182,7 +182,7 @@ PyDoc_STRVAR(zlib_compressobj__doc__, " containing subsequences that are likely to occur in the input data."); #define ZLIB_COMPRESSOBJ_METHODDEF \ - {"compressobj", (PyCFunction)(void(*)(void))zlib_compressobj, METH_FASTCALL|METH_KEYWORDS, zlib_compressobj__doc__}, + {"compressobj", _PyCFunction_CAST(zlib_compressobj), METH_FASTCALL|METH_KEYWORDS, zlib_compressobj__doc__}, static PyObject * zlib_compressobj_impl(PyObject *module, int level, int method, int wbits, @@ -287,7 +287,7 @@ PyDoc_STRVAR(zlib_decompressobj__doc__, " dictionary as used by the compressor that produced the input data."); #define ZLIB_DECOMPRESSOBJ_METHODDEF \ - {"decompressobj", (PyCFunction)(void(*)(void))zlib_decompressobj, METH_FASTCALL|METH_KEYWORDS, zlib_decompressobj__doc__}, + {"decompressobj", _PyCFunction_CAST(zlib_decompressobj), METH_FASTCALL|METH_KEYWORDS, zlib_decompressobj__doc__}, static PyObject * zlib_decompressobj_impl(PyObject *module, int wbits, PyObject *zdict); @@ -341,7 +341,7 @@ PyDoc_STRVAR(zlib_Compress_compress__doc__, "Call the flush() method to clear these buffers."); #define ZLIB_COMPRESS_COMPRESS_METHODDEF \ - {"compress", (PyCFunction)(void(*)(void))zlib_Compress_compress, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, zlib_Compress_compress__doc__}, + {"compress", _PyCFunction_CAST(zlib_Compress_compress), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, zlib_Compress_compress__doc__}, static PyObject * zlib_Compress_compress_impl(compobject *self, PyTypeObject *cls, @@ -396,7 +396,7 @@ PyDoc_STRVAR(zlib_Decompress_decompress__doc__, "Call the flush() method to clear these buffers."); #define ZLIB_DECOMPRESS_DECOMPRESS_METHODDEF \ - {"decompress", (PyCFunction)(void(*)(void))zlib_Decompress_decompress, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, zlib_Decompress_decompress__doc__}, + {"decompress", _PyCFunction_CAST(zlib_Decompress_decompress), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, zlib_Decompress_decompress__doc__}, static PyObject * zlib_Decompress_decompress_impl(compobject *self, PyTypeObject *cls, @@ -464,7 +464,7 @@ PyDoc_STRVAR(zlib_Compress_flush__doc__, " can still be compressed."); #define ZLIB_COMPRESS_FLUSH_METHODDEF \ - {"flush", (PyCFunction)(void(*)(void))zlib_Compress_flush, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, zlib_Compress_flush__doc__}, + {"flush", _PyCFunction_CAST(zlib_Compress_flush), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, zlib_Compress_flush__doc__}, static PyObject * zlib_Compress_flush_impl(compobject *self, PyTypeObject *cls, int mode); @@ -505,7 +505,7 @@ PyDoc_STRVAR(zlib_Compress_copy__doc__, "Return a copy of the compression object."); #define ZLIB_COMPRESS_COPY_METHODDEF \ - {"copy", (PyCFunction)(void(*)(void))zlib_Compress_copy, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, zlib_Compress_copy__doc__}, + {"copy", _PyCFunction_CAST(zlib_Compress_copy), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, zlib_Compress_copy__doc__}, static PyObject * zlib_Compress_copy_impl(compobject *self, PyTypeObject *cls); @@ -530,7 +530,7 @@ PyDoc_STRVAR(zlib_Compress___copy____doc__, "\n"); #define ZLIB_COMPRESS___COPY___METHODDEF \ - {"__copy__", (PyCFunction)(void(*)(void))zlib_Compress___copy__, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, zlib_Compress___copy____doc__}, + {"__copy__", _PyCFunction_CAST(zlib_Compress___copy__), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, zlib_Compress___copy____doc__}, static PyObject * zlib_Compress___copy___impl(compobject *self, PyTypeObject *cls); @@ -555,7 +555,7 @@ PyDoc_STRVAR(zlib_Compress___deepcopy____doc__, "\n"); #define ZLIB_COMPRESS___DEEPCOPY___METHODDEF \ - {"__deepcopy__", (PyCFunction)(void(*)(void))zlib_Compress___deepcopy__, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, zlib_Compress___deepcopy____doc__}, + {"__deepcopy__", _PyCFunction_CAST(zlib_Compress___deepcopy__), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, zlib_Compress___deepcopy____doc__}, static PyObject * zlib_Compress___deepcopy___impl(compobject *self, PyTypeObject *cls, @@ -592,7 +592,7 @@ PyDoc_STRVAR(zlib_Decompress_copy__doc__, "Return a copy of the decompression object."); #define ZLIB_DECOMPRESS_COPY_METHODDEF \ - {"copy", (PyCFunction)(void(*)(void))zlib_Decompress_copy, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, zlib_Decompress_copy__doc__}, + {"copy", _PyCFunction_CAST(zlib_Decompress_copy), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, zlib_Decompress_copy__doc__}, static PyObject * zlib_Decompress_copy_impl(compobject *self, PyTypeObject *cls); @@ -617,7 +617,7 @@ PyDoc_STRVAR(zlib_Decompress___copy____doc__, "\n"); #define ZLIB_DECOMPRESS___COPY___METHODDEF \ - {"__copy__", (PyCFunction)(void(*)(void))zlib_Decompress___copy__, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, zlib_Decompress___copy____doc__}, + {"__copy__", _PyCFunction_CAST(zlib_Decompress___copy__), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, zlib_Decompress___copy____doc__}, static PyObject * zlib_Decompress___copy___impl(compobject *self, PyTypeObject *cls); @@ -642,7 +642,7 @@ PyDoc_STRVAR(zlib_Decompress___deepcopy____doc__, "\n"); #define ZLIB_DECOMPRESS___DEEPCOPY___METHODDEF \ - {"__deepcopy__", (PyCFunction)(void(*)(void))zlib_Decompress___deepcopy__, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, zlib_Decompress___deepcopy____doc__}, + {"__deepcopy__", _PyCFunction_CAST(zlib_Decompress___deepcopy__), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, zlib_Decompress___deepcopy____doc__}, static PyObject * zlib_Decompress___deepcopy___impl(compobject *self, PyTypeObject *cls, @@ -680,7 +680,7 @@ PyDoc_STRVAR(zlib_Decompress_flush__doc__, " the initial size of the output buffer."); #define ZLIB_DECOMPRESS_FLUSH_METHODDEF \ - {"flush", (PyCFunction)(void(*)(void))zlib_Decompress_flush, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, zlib_Decompress_flush__doc__}, + {"flush", _PyCFunction_CAST(zlib_Decompress_flush), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, zlib_Decompress_flush__doc__}, static PyObject * zlib_Decompress_flush_impl(compobject *self, PyTypeObject *cls, @@ -733,7 +733,7 @@ PyDoc_STRVAR(zlib_adler32__doc__, "The returned checksum is an integer."); #define ZLIB_ADLER32_METHODDEF \ - {"adler32", (PyCFunction)(void(*)(void))zlib_adler32, METH_FASTCALL, zlib_adler32__doc__}, + {"adler32", _PyCFunction_CAST(zlib_adler32), METH_FASTCALL, zlib_adler32__doc__}, static PyObject * zlib_adler32_impl(PyObject *module, Py_buffer *data, unsigned int value); @@ -786,7 +786,7 @@ PyDoc_STRVAR(zlib_crc32__doc__, "The returned checksum is an integer."); #define ZLIB_CRC32_METHODDEF \ - {"crc32", (PyCFunction)(void(*)(void))zlib_crc32, METH_FASTCALL, zlib_crc32__doc__}, + {"crc32", _PyCFunction_CAST(zlib_crc32), METH_FASTCALL, zlib_crc32__doc__}, static unsigned int zlib_crc32_impl(PyObject *module, Py_buffer *data, unsigned int value); @@ -855,4 +855,4 @@ zlib_crc32(PyObject *module, PyObject *const *args, Py_ssize_t nargs) #ifndef ZLIB_DECOMPRESS___DEEPCOPY___METHODDEF #define ZLIB_DECOMPRESS___DEEPCOPY___METHODDEF #endif /* !defined(ZLIB_DECOMPRESS___DEEPCOPY___METHODDEF) */ -/*[clinic end generated code: output=bb1e27d8b2198a86 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=757804b3ad33454f input=a9049054013a1b77]*/ diff --git a/Objects/clinic/bytearrayobject.c.h b/Objects/clinic/bytearrayobject.c.h index 1e3f197561523..0b5c01a83dbe1 100644 --- a/Objects/clinic/bytearrayobject.c.h +++ b/Objects/clinic/bytearrayobject.c.h @@ -200,7 +200,7 @@ PyDoc_STRVAR(bytearray_translate__doc__, "The remaining characters are mapped through the given translation table."); #define BYTEARRAY_TRANSLATE_METHODDEF \ - {"translate", (PyCFunction)(void(*)(void))bytearray_translate, METH_FASTCALL|METH_KEYWORDS, bytearray_translate__doc__}, + {"translate", _PyCFunction_CAST(bytearray_translate), METH_FASTCALL|METH_KEYWORDS, bytearray_translate__doc__}, static PyObject * bytearray_translate_impl(PyByteArrayObject *self, PyObject *table, @@ -245,7 +245,7 @@ PyDoc_STRVAR(bytearray_maketrans__doc__, "The bytes objects frm and to must be of the same length."); #define BYTEARRAY_MAKETRANS_METHODDEF \ - {"maketrans", (PyCFunction)(void(*)(void))bytearray_maketrans, METH_FASTCALL|METH_STATIC, bytearray_maketrans__doc__}, + {"maketrans", _PyCFunction_CAST(bytearray_maketrans), METH_FASTCALL|METH_STATIC, bytearray_maketrans__doc__}, static PyObject * bytearray_maketrans_impl(Py_buffer *frm, Py_buffer *to); @@ -303,7 +303,7 @@ PyDoc_STRVAR(bytearray_replace__doc__, "replaced."); #define BYTEARRAY_REPLACE_METHODDEF \ - {"replace", (PyCFunction)(void(*)(void))bytearray_replace, METH_FASTCALL, bytearray_replace__doc__}, + {"replace", _PyCFunction_CAST(bytearray_replace), METH_FASTCALL, bytearray_replace__doc__}, static PyObject * bytearray_replace_impl(PyByteArrayObject *self, Py_buffer *old, @@ -380,7 +380,7 @@ PyDoc_STRVAR(bytearray_split__doc__, " -1 (the default value) means no limit."); #define BYTEARRAY_SPLIT_METHODDEF \ - {"split", (PyCFunction)(void(*)(void))bytearray_split, METH_FASTCALL|METH_KEYWORDS, bytearray_split__doc__}, + {"split", _PyCFunction_CAST(bytearray_split), METH_FASTCALL|METH_KEYWORDS, bytearray_split__doc__}, static PyObject * bytearray_split_impl(PyByteArrayObject *self, PyObject *sep, @@ -479,7 +479,7 @@ PyDoc_STRVAR(bytearray_rsplit__doc__, "Splitting is done starting at the end of the bytearray and working to the front."); #define BYTEARRAY_RSPLIT_METHODDEF \ - {"rsplit", (PyCFunction)(void(*)(void))bytearray_rsplit, METH_FASTCALL|METH_KEYWORDS, bytearray_rsplit__doc__}, + {"rsplit", _PyCFunction_CAST(bytearray_rsplit), METH_FASTCALL|METH_KEYWORDS, bytearray_rsplit__doc__}, static PyObject * bytearray_rsplit_impl(PyByteArrayObject *self, PyObject *sep, @@ -558,7 +558,7 @@ PyDoc_STRVAR(bytearray_insert__doc__, " The item to be inserted."); #define BYTEARRAY_INSERT_METHODDEF \ - {"insert", (PyCFunction)(void(*)(void))bytearray_insert, METH_FASTCALL, bytearray_insert__doc__}, + {"insert", _PyCFunction_CAST(bytearray_insert), METH_FASTCALL, bytearray_insert__doc__}, static PyObject * bytearray_insert_impl(PyByteArrayObject *self, Py_ssize_t index, int item); @@ -649,7 +649,7 @@ PyDoc_STRVAR(bytearray_pop__doc__, "If no index argument is given, will pop the last item."); #define BYTEARRAY_POP_METHODDEF \ - {"pop", (PyCFunction)(void(*)(void))bytearray_pop, METH_FASTCALL, bytearray_pop__doc__}, + {"pop", _PyCFunction_CAST(bytearray_pop), METH_FASTCALL, bytearray_pop__doc__}, static PyObject * bytearray_pop_impl(PyByteArrayObject *self, Py_ssize_t index); @@ -724,7 +724,7 @@ PyDoc_STRVAR(bytearray_strip__doc__, "If the argument is omitted or None, strip leading and trailing ASCII whitespace."); #define BYTEARRAY_STRIP_METHODDEF \ - {"strip", (PyCFunction)(void(*)(void))bytearray_strip, METH_FASTCALL, bytearray_strip__doc__}, + {"strip", _PyCFunction_CAST(bytearray_strip), METH_FASTCALL, bytearray_strip__doc__}, static PyObject * bytearray_strip_impl(PyByteArrayObject *self, PyObject *bytes); @@ -758,7 +758,7 @@ PyDoc_STRVAR(bytearray_lstrip__doc__, "If the argument is omitted or None, strip leading ASCII whitespace."); #define BYTEARRAY_LSTRIP_METHODDEF \ - {"lstrip", (PyCFunction)(void(*)(void))bytearray_lstrip, METH_FASTCALL, bytearray_lstrip__doc__}, + {"lstrip", _PyCFunction_CAST(bytearray_lstrip), METH_FASTCALL, bytearray_lstrip__doc__}, static PyObject * bytearray_lstrip_impl(PyByteArrayObject *self, PyObject *bytes); @@ -792,7 +792,7 @@ PyDoc_STRVAR(bytearray_rstrip__doc__, "If the argument is omitted or None, strip trailing ASCII whitespace."); #define BYTEARRAY_RSTRIP_METHODDEF \ - {"rstrip", (PyCFunction)(void(*)(void))bytearray_rstrip, METH_FASTCALL, bytearray_rstrip__doc__}, + {"rstrip", _PyCFunction_CAST(bytearray_rstrip), METH_FASTCALL, bytearray_rstrip__doc__}, static PyObject * bytearray_rstrip_impl(PyByteArrayObject *self, PyObject *bytes); @@ -833,7 +833,7 @@ PyDoc_STRVAR(bytearray_decode__doc__, " can handle UnicodeDecodeErrors."); #define BYTEARRAY_DECODE_METHODDEF \ - {"decode", (PyCFunction)(void(*)(void))bytearray_decode, METH_FASTCALL|METH_KEYWORDS, bytearray_decode__doc__}, + {"decode", _PyCFunction_CAST(bytearray_decode), METH_FASTCALL|METH_KEYWORDS, bytearray_decode__doc__}, static PyObject * bytearray_decode_impl(PyByteArrayObject *self, const char *encoding, @@ -918,7 +918,7 @@ PyDoc_STRVAR(bytearray_splitlines__doc__, "true."); #define BYTEARRAY_SPLITLINES_METHODDEF \ - {"splitlines", (PyCFunction)(void(*)(void))bytearray_splitlines, METH_FASTCALL|METH_KEYWORDS, bytearray_splitlines__doc__}, + {"splitlines", _PyCFunction_CAST(bytearray_splitlines), METH_FASTCALL|METH_KEYWORDS, bytearray_splitlines__doc__}, static PyObject * bytearray_splitlines_impl(PyByteArrayObject *self, int keepends); @@ -1010,7 +1010,7 @@ PyDoc_STRVAR(bytearray_hex__doc__, "\'b901:ef\'"); #define BYTEARRAY_HEX_METHODDEF \ - {"hex", (PyCFunction)(void(*)(void))bytearray_hex, METH_FASTCALL|METH_KEYWORDS, bytearray_hex__doc__}, + {"hex", _PyCFunction_CAST(bytearray_hex), METH_FASTCALL|METH_KEYWORDS, bytearray_hex__doc__}, static PyObject * bytearray_hex_impl(PyByteArrayObject *self, PyObject *sep, int bytes_per_sep); @@ -1075,7 +1075,7 @@ PyDoc_STRVAR(bytearray_reduce_ex__doc__, "Return state information for pickling."); #define BYTEARRAY_REDUCE_EX_METHODDEF \ - {"__reduce_ex__", (PyCFunction)(void(*)(void))bytearray_reduce_ex, METH_FASTCALL, bytearray_reduce_ex__doc__}, + {"__reduce_ex__", _PyCFunction_CAST(bytearray_reduce_ex), METH_FASTCALL, bytearray_reduce_ex__doc__}, static PyObject * bytearray_reduce_ex_impl(PyByteArrayObject *self, int proto); @@ -1120,4 +1120,4 @@ bytearray_sizeof(PyByteArrayObject *self, PyObject *Py_UNUSED(ignored)) { return bytearray_sizeof_impl(self); } -/*[clinic end generated code: output=a82659f581e55629 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=033e9eb5f2bb0139 input=a9049054013a1b77]*/ diff --git a/Objects/clinic/bytesobject.c.h b/Objects/clinic/bytesobject.c.h index 103a364281321..7e85720341751 100644 --- a/Objects/clinic/bytesobject.c.h +++ b/Objects/clinic/bytesobject.c.h @@ -35,7 +35,7 @@ PyDoc_STRVAR(bytes_split__doc__, " -1 (the default value) means no limit."); #define BYTES_SPLIT_METHODDEF \ - {"split", (PyCFunction)(void(*)(void))bytes_split, METH_FASTCALL|METH_KEYWORDS, bytes_split__doc__}, + {"split", _PyCFunction_CAST(bytes_split), METH_FASTCALL|METH_KEYWORDS, bytes_split__doc__}, static PyObject * bytes_split_impl(PyBytesObject *self, PyObject *sep, Py_ssize_t maxsplit); @@ -186,7 +186,7 @@ PyDoc_STRVAR(bytes_rsplit__doc__, "Splitting is done starting at the end of the bytes and working to the front."); #define BYTES_RSPLIT_METHODDEF \ - {"rsplit", (PyCFunction)(void(*)(void))bytes_rsplit, METH_FASTCALL|METH_KEYWORDS, bytes_rsplit__doc__}, + {"rsplit", _PyCFunction_CAST(bytes_rsplit), METH_FASTCALL|METH_KEYWORDS, bytes_rsplit__doc__}, static PyObject * bytes_rsplit_impl(PyBytesObject *self, PyObject *sep, Py_ssize_t maxsplit); @@ -258,7 +258,7 @@ PyDoc_STRVAR(bytes_strip__doc__, "If the argument is omitted or None, strip leading and trailing ASCII whitespace."); #define BYTES_STRIP_METHODDEF \ - {"strip", (PyCFunction)(void(*)(void))bytes_strip, METH_FASTCALL, bytes_strip__doc__}, + {"strip", _PyCFunction_CAST(bytes_strip), METH_FASTCALL, bytes_strip__doc__}, static PyObject * bytes_strip_impl(PyBytesObject *self, PyObject *bytes); @@ -292,7 +292,7 @@ PyDoc_STRVAR(bytes_lstrip__doc__, "If the argument is omitted or None, strip leading ASCII whitespace."); #define BYTES_LSTRIP_METHODDEF \ - {"lstrip", (PyCFunction)(void(*)(void))bytes_lstrip, METH_FASTCALL, bytes_lstrip__doc__}, + {"lstrip", _PyCFunction_CAST(bytes_lstrip), METH_FASTCALL, bytes_lstrip__doc__}, static PyObject * bytes_lstrip_impl(PyBytesObject *self, PyObject *bytes); @@ -326,7 +326,7 @@ PyDoc_STRVAR(bytes_rstrip__doc__, "If the argument is omitted or None, strip trailing ASCII whitespace."); #define BYTES_RSTRIP_METHODDEF \ - {"rstrip", (PyCFunction)(void(*)(void))bytes_rstrip, METH_FASTCALL, bytes_rstrip__doc__}, + {"rstrip", _PyCFunction_CAST(bytes_rstrip), METH_FASTCALL, bytes_rstrip__doc__}, static PyObject * bytes_rstrip_impl(PyBytesObject *self, PyObject *bytes); @@ -364,7 +364,7 @@ PyDoc_STRVAR(bytes_translate__doc__, "The remaining characters are mapped through the given translation table."); #define BYTES_TRANSLATE_METHODDEF \ - {"translate", (PyCFunction)(void(*)(void))bytes_translate, METH_FASTCALL|METH_KEYWORDS, bytes_translate__doc__}, + {"translate", _PyCFunction_CAST(bytes_translate), METH_FASTCALL|METH_KEYWORDS, bytes_translate__doc__}, static PyObject * bytes_translate_impl(PyBytesObject *self, PyObject *table, @@ -409,7 +409,7 @@ PyDoc_STRVAR(bytes_maketrans__doc__, "The bytes objects frm and to must be of the same length."); #define BYTES_MAKETRANS_METHODDEF \ - {"maketrans", (PyCFunction)(void(*)(void))bytes_maketrans, METH_FASTCALL|METH_STATIC, bytes_maketrans__doc__}, + {"maketrans", _PyCFunction_CAST(bytes_maketrans), METH_FASTCALL|METH_STATIC, bytes_maketrans__doc__}, static PyObject * bytes_maketrans_impl(Py_buffer *frm, Py_buffer *to); @@ -467,7 +467,7 @@ PyDoc_STRVAR(bytes_replace__doc__, "replaced."); #define BYTES_REPLACE_METHODDEF \ - {"replace", (PyCFunction)(void(*)(void))bytes_replace, METH_FASTCALL, bytes_replace__doc__}, + {"replace", _PyCFunction_CAST(bytes_replace), METH_FASTCALL, bytes_replace__doc__}, static PyObject * bytes_replace_impl(PyBytesObject *self, Py_buffer *old, Py_buffer *new, @@ -624,7 +624,7 @@ PyDoc_STRVAR(bytes_decode__doc__, " can handle UnicodeDecodeErrors."); #define BYTES_DECODE_METHODDEF \ - {"decode", (PyCFunction)(void(*)(void))bytes_decode, METH_FASTCALL|METH_KEYWORDS, bytes_decode__doc__}, + {"decode", _PyCFunction_CAST(bytes_decode), METH_FASTCALL|METH_KEYWORDS, bytes_decode__doc__}, static PyObject * bytes_decode_impl(PyBytesObject *self, const char *encoding, @@ -696,7 +696,7 @@ PyDoc_STRVAR(bytes_splitlines__doc__, "true."); #define BYTES_SPLITLINES_METHODDEF \ - {"splitlines", (PyCFunction)(void(*)(void))bytes_splitlines, METH_FASTCALL|METH_KEYWORDS, bytes_splitlines__doc__}, + {"splitlines", _PyCFunction_CAST(bytes_splitlines), METH_FASTCALL|METH_KEYWORDS, bytes_splitlines__doc__}, static PyObject * bytes_splitlines_impl(PyBytesObject *self, int keepends); @@ -788,7 +788,7 @@ PyDoc_STRVAR(bytes_hex__doc__, "\'b901:ef\'"); #define BYTES_HEX_METHODDEF \ - {"hex", (PyCFunction)(void(*)(void))bytes_hex, METH_FASTCALL|METH_KEYWORDS, bytes_hex__doc__}, + {"hex", _PyCFunction_CAST(bytes_hex), METH_FASTCALL|METH_KEYWORDS, bytes_hex__doc__}, static PyObject * bytes_hex_impl(PyBytesObject *self, PyObject *sep, int bytes_per_sep); @@ -896,4 +896,4 @@ bytes_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) exit: return return_value; } -/*[clinic end generated code: output=d706344859f40122 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=5727702e63a0a8b7 input=a9049054013a1b77]*/ diff --git a/Objects/clinic/codeobject.c.h b/Objects/clinic/codeobject.c.h index 41c5c2e1170f8..df82524a86afe 100644 --- a/Objects/clinic/codeobject.c.h +++ b/Objects/clinic/codeobject.c.h @@ -168,7 +168,7 @@ PyDoc_STRVAR(code_replace__doc__, "Return a copy of the code object with new values for the specified fields."); #define CODE_REPLACE_METHODDEF \ - {"replace", (PyCFunction)(void(*)(void))code_replace, METH_FASTCALL|METH_KEYWORDS, code_replace__doc__}, + {"replace", _PyCFunction_CAST(code_replace), METH_FASTCALL|METH_KEYWORDS, code_replace__doc__}, static PyObject * code_replace_impl(PyCodeObject *self, int co_argcount, @@ -409,7 +409,7 @@ PyDoc_STRVAR(code__varname_from_oparg__doc__, "WARNING: this method is for internal use only and may change or go away."); #define CODE__VARNAME_FROM_OPARG_METHODDEF \ - {"_varname_from_oparg", (PyCFunction)(void(*)(void))code__varname_from_oparg, METH_FASTCALL|METH_KEYWORDS, code__varname_from_oparg__doc__}, + {"_varname_from_oparg", _PyCFunction_CAST(code__varname_from_oparg), METH_FASTCALL|METH_KEYWORDS, code__varname_from_oparg__doc__}, static PyObject * code__varname_from_oparg_impl(PyCodeObject *self, int oparg); @@ -436,4 +436,4 @@ code__varname_from_oparg(PyCodeObject *self, PyObject *const *args, Py_ssize_t n exit: return return_value; } -/*[clinic end generated code: output=ebfeec29d2cff674 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=9c521b6c79f90ff7 input=a9049054013a1b77]*/ diff --git a/Objects/clinic/dictobject.c.h b/Objects/clinic/dictobject.c.h index beb3f360f8634..eda86c31fcc57 100644 --- a/Objects/clinic/dictobject.c.h +++ b/Objects/clinic/dictobject.c.h @@ -9,7 +9,7 @@ PyDoc_STRVAR(dict_fromkeys__doc__, "Create a new dictionary with keys from iterable and values set to value."); #define DICT_FROMKEYS_METHODDEF \ - {"fromkeys", (PyCFunction)(void(*)(void))dict_fromkeys, METH_FASTCALL|METH_CLASS, dict_fromkeys__doc__}, + {"fromkeys", _PyCFunction_CAST(dict_fromkeys), METH_FASTCALL|METH_CLASS, dict_fromkeys__doc__}, static PyObject * dict_fromkeys_impl(PyTypeObject *type, PyObject *iterable, PyObject *value); @@ -52,7 +52,7 @@ PyDoc_STRVAR(dict_get__doc__, "Return the value for key if key is in the dictionary, else default."); #define DICT_GET_METHODDEF \ - {"get", (PyCFunction)(void(*)(void))dict_get, METH_FASTCALL, dict_get__doc__}, + {"get", _PyCFunction_CAST(dict_get), METH_FASTCALL, dict_get__doc__}, static PyObject * dict_get_impl(PyDictObject *self, PyObject *key, PyObject *default_value); @@ -88,7 +88,7 @@ PyDoc_STRVAR(dict_setdefault__doc__, "Return the value for key if key is in the dictionary, else default."); #define DICT_SETDEFAULT_METHODDEF \ - {"setdefault", (PyCFunction)(void(*)(void))dict_setdefault, METH_FASTCALL, dict_setdefault__doc__}, + {"setdefault", _PyCFunction_CAST(dict_setdefault), METH_FASTCALL, dict_setdefault__doc__}, static PyObject * dict_setdefault_impl(PyDictObject *self, PyObject *key, @@ -126,7 +126,7 @@ PyDoc_STRVAR(dict_pop__doc__, "raise a KeyError."); #define DICT_POP_METHODDEF \ - {"pop", (PyCFunction)(void(*)(void))dict_pop, METH_FASTCALL, dict_pop__doc__}, + {"pop", _PyCFunction_CAST(dict_pop), METH_FASTCALL, dict_pop__doc__}, static PyObject * dict_pop_impl(PyDictObject *self, PyObject *key, PyObject *default_value); @@ -191,4 +191,4 @@ dict___reversed__(PyDictObject *self, PyObject *Py_UNUSED(ignored)) { return dict___reversed___impl(self); } -/*[clinic end generated code: output=7b77c16e43d6735a input=a9049054013a1b77]*/ +/*[clinic end generated code: output=582766ac0154c8bf input=a9049054013a1b77]*/ diff --git a/Objects/clinic/floatobject.c.h b/Objects/clinic/floatobject.c.h index f53018c08e045..bf0748f3b3d12 100644 --- a/Objects/clinic/floatobject.c.h +++ b/Objects/clinic/floatobject.c.h @@ -83,7 +83,7 @@ PyDoc_STRVAR(float___round____doc__, "When an argument is passed, work like built-in round(x, ndigits)."); #define FLOAT___ROUND___METHODDEF \ - {"__round__", (PyCFunction)(void(*)(void))float___round__, METH_FASTCALL, float___round____doc__}, + {"__round__", _PyCFunction_CAST(float___round__), METH_FASTCALL, float___round____doc__}, static PyObject * float___round___impl(PyObject *self, PyObject *o_ndigits); @@ -321,4 +321,4 @@ float___format__(PyObject *self, PyObject *arg) exit: return return_value; } -/*[clinic end generated code: output=604cb27bf751ea16 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=a6e6467624a92a43 input=a9049054013a1b77]*/ diff --git a/Objects/clinic/listobject.c.h b/Objects/clinic/listobject.c.h index 75ed9f9df8599..2499383cc26c5 100644 --- a/Objects/clinic/listobject.c.h +++ b/Objects/clinic/listobject.c.h @@ -9,7 +9,7 @@ PyDoc_STRVAR(list_insert__doc__, "Insert object before index."); #define LIST_INSERT_METHODDEF \ - {"insert", (PyCFunction)(void(*)(void))list_insert, METH_FASTCALL, list_insert__doc__}, + {"insert", _PyCFunction_CAST(list_insert), METH_FASTCALL, list_insert__doc__}, static PyObject * list_insert_impl(PyListObject *self, Py_ssize_t index, PyObject *object); @@ -106,7 +106,7 @@ PyDoc_STRVAR(list_pop__doc__, "Raises IndexError if list is empty or index is out of range."); #define LIST_POP_METHODDEF \ - {"pop", (PyCFunction)(void(*)(void))list_pop, METH_FASTCALL, list_pop__doc__}, + {"pop", _PyCFunction_CAST(list_pop), METH_FASTCALL, list_pop__doc__}, static PyObject * list_pop_impl(PyListObject *self, Py_ssize_t index); @@ -157,7 +157,7 @@ PyDoc_STRVAR(list_sort__doc__, "The reverse flag can be set to sort in descending order."); #define LIST_SORT_METHODDEF \ - {"sort", (PyCFunction)(void(*)(void))list_sort, METH_FASTCALL|METH_KEYWORDS, list_sort__doc__}, + {"sort", _PyCFunction_CAST(list_sort), METH_FASTCALL|METH_KEYWORDS, list_sort__doc__}, static PyObject * list_sort_impl(PyListObject *self, PyObject *keyfunc, int reverse); @@ -224,7 +224,7 @@ PyDoc_STRVAR(list_index__doc__, "Raises ValueError if the value is not present."); #define LIST_INDEX_METHODDEF \ - {"index", (PyCFunction)(void(*)(void))list_index, METH_FASTCALL, list_index__doc__}, + {"index", _PyCFunction_CAST(list_index), METH_FASTCALL, list_index__doc__}, static PyObject * list_index_impl(PyListObject *self, PyObject *value, Py_ssize_t start, @@ -353,4 +353,4 @@ list___reversed__(PyListObject *self, PyObject *Py_UNUSED(ignored)) { return list___reversed___impl(self); } -/*[clinic end generated code: output=acb2f87736311930 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=eab97a76b1568a03 input=a9049054013a1b77]*/ diff --git a/Objects/clinic/longobject.c.h b/Objects/clinic/longobject.c.h index d50c4af8096fa..59b79636bee10 100644 --- a/Objects/clinic/longobject.c.h +++ b/Objects/clinic/longobject.c.h @@ -96,7 +96,7 @@ PyDoc_STRVAR(int___round____doc__, "Rounding with an ndigits argument also returns an integer."); #define INT___ROUND___METHODDEF \ - {"__round__", (PyCFunction)(void(*)(void))int___round__, METH_FASTCALL, int___round____doc__}, + {"__round__", _PyCFunction_CAST(int___round__), METH_FASTCALL, int___round____doc__}, static PyObject * int___round___impl(PyObject *self, PyObject *o_ndigits); @@ -247,7 +247,7 @@ PyDoc_STRVAR(int_to_bytes__doc__, " is raised."); #define INT_TO_BYTES_METHODDEF \ - {"to_bytes", (PyCFunction)(void(*)(void))int_to_bytes, METH_FASTCALL|METH_KEYWORDS, int_to_bytes__doc__}, + {"to_bytes", _PyCFunction_CAST(int_to_bytes), METH_FASTCALL|METH_KEYWORDS, int_to_bytes__doc__}, static PyObject * int_to_bytes_impl(PyObject *self, Py_ssize_t length, PyObject *byteorder, @@ -338,7 +338,7 @@ PyDoc_STRVAR(int_from_bytes__doc__, " Indicates whether two\'s complement is used to represent the integer."); #define INT_FROM_BYTES_METHODDEF \ - {"from_bytes", (PyCFunction)(void(*)(void))int_from_bytes, METH_FASTCALL|METH_KEYWORDS|METH_CLASS, int_from_bytes__doc__}, + {"from_bytes", _PyCFunction_CAST(int_from_bytes), METH_FASTCALL|METH_KEYWORDS|METH_CLASS, int_from_bytes__doc__}, static PyObject * int_from_bytes_impl(PyTypeObject *type, PyObject *bytes_obj, @@ -391,4 +391,4 @@ int_from_bytes(PyTypeObject *type, PyObject *const *args, Py_ssize_t nargs, PyOb exit: return return_value; } -/*[clinic end generated code: output=16a375d93769b227 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=899e57c41861a8e9 input=a9049054013a1b77]*/ diff --git a/Objects/clinic/memoryobject.c.h b/Objects/clinic/memoryobject.c.h index 4a682f69d6573..73ef8d143b50b 100644 --- a/Objects/clinic/memoryobject.c.h +++ b/Objects/clinic/memoryobject.c.h @@ -58,7 +58,7 @@ PyDoc_STRVAR(memoryview_cast__doc__, "Cast a memoryview to a new format or shape."); #define MEMORYVIEW_CAST_METHODDEF \ - {"cast", (PyCFunction)(void(*)(void))memoryview_cast, METH_FASTCALL|METH_KEYWORDS, memoryview_cast__doc__}, + {"cast", _PyCFunction_CAST(memoryview_cast), METH_FASTCALL|METH_KEYWORDS, memoryview_cast__doc__}, static PyObject * memoryview_cast_impl(PyMemoryViewObject *self, PyObject *format, @@ -147,7 +147,7 @@ PyDoc_STRVAR(memoryview_tobytes__doc__, "to C first. order=None is the same as order=\'C\'."); #define MEMORYVIEW_TOBYTES_METHODDEF \ - {"tobytes", (PyCFunction)(void(*)(void))memoryview_tobytes, METH_FASTCALL|METH_KEYWORDS, memoryview_tobytes__doc__}, + {"tobytes", _PyCFunction_CAST(memoryview_tobytes), METH_FASTCALL|METH_KEYWORDS, memoryview_tobytes__doc__}, static PyObject * memoryview_tobytes_impl(PyMemoryViewObject *self, const char *order); @@ -218,7 +218,7 @@ PyDoc_STRVAR(memoryview_hex__doc__, "\'b901:ef\'"); #define MEMORYVIEW_HEX_METHODDEF \ - {"hex", (PyCFunction)(void(*)(void))memoryview_hex, METH_FASTCALL|METH_KEYWORDS, memoryview_hex__doc__}, + {"hex", _PyCFunction_CAST(memoryview_hex), METH_FASTCALL|METH_KEYWORDS, memoryview_hex__doc__}, static PyObject * memoryview_hex_impl(PyMemoryViewObject *self, PyObject *sep, @@ -258,4 +258,4 @@ memoryview_hex(PyMemoryViewObject *self, PyObject *const *args, Py_ssize_t nargs exit: return return_value; } -/*[clinic end generated code: output=1b879bb934d18c66 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=48be570b5e6038e3 input=a9049054013a1b77]*/ diff --git a/Objects/clinic/odictobject.c.h b/Objects/clinic/odictobject.c.h index a3ab9ea507f44..5bb9952caa273 100644 --- a/Objects/clinic/odictobject.c.h +++ b/Objects/clinic/odictobject.c.h @@ -9,7 +9,7 @@ PyDoc_STRVAR(OrderedDict_fromkeys__doc__, "Create a new ordered dictionary with keys from iterable and values set to value."); #define ORDEREDDICT_FROMKEYS_METHODDEF \ - {"fromkeys", (PyCFunction)(void(*)(void))OrderedDict_fromkeys, METH_FASTCALL|METH_KEYWORDS|METH_CLASS, OrderedDict_fromkeys__doc__}, + {"fromkeys", _PyCFunction_CAST(OrderedDict_fromkeys), METH_FASTCALL|METH_KEYWORDS|METH_CLASS, OrderedDict_fromkeys__doc__}, static PyObject * OrderedDict_fromkeys_impl(PyTypeObject *type, PyObject *seq, PyObject *value); @@ -50,7 +50,7 @@ PyDoc_STRVAR(OrderedDict_setdefault__doc__, "Return the value for key if key is in the dictionary, else default."); #define ORDEREDDICT_SETDEFAULT_METHODDEF \ - {"setdefault", (PyCFunction)(void(*)(void))OrderedDict_setdefault, METH_FASTCALL|METH_KEYWORDS, OrderedDict_setdefault__doc__}, + {"setdefault", _PyCFunction_CAST(OrderedDict_setdefault), METH_FASTCALL|METH_KEYWORDS, OrderedDict_setdefault__doc__}, static PyObject * OrderedDict_setdefault_impl(PyODictObject *self, PyObject *key, @@ -93,7 +93,7 @@ PyDoc_STRVAR(OrderedDict_pop__doc__, "raise a KeyError."); #define ORDEREDDICT_POP_METHODDEF \ - {"pop", (PyCFunction)(void(*)(void))OrderedDict_pop, METH_FASTCALL|METH_KEYWORDS, OrderedDict_pop__doc__}, + {"pop", _PyCFunction_CAST(OrderedDict_pop), METH_FASTCALL|METH_KEYWORDS, OrderedDict_pop__doc__}, static PyObject * OrderedDict_pop_impl(PyODictObject *self, PyObject *key, @@ -135,7 +135,7 @@ PyDoc_STRVAR(OrderedDict_popitem__doc__, "Pairs are returned in LIFO order if last is true or FIFO order if false."); #define ORDEREDDICT_POPITEM_METHODDEF \ - {"popitem", (PyCFunction)(void(*)(void))OrderedDict_popitem, METH_FASTCALL|METH_KEYWORDS, OrderedDict_popitem__doc__}, + {"popitem", _PyCFunction_CAST(OrderedDict_popitem), METH_FASTCALL|METH_KEYWORDS, OrderedDict_popitem__doc__}, static PyObject * OrderedDict_popitem_impl(PyODictObject *self, int last); @@ -177,7 +177,7 @@ PyDoc_STRVAR(OrderedDict_move_to_end__doc__, "Raise KeyError if the element does not exist."); #define ORDEREDDICT_MOVE_TO_END_METHODDEF \ - {"move_to_end", (PyCFunction)(void(*)(void))OrderedDict_move_to_end, METH_FASTCALL|METH_KEYWORDS, OrderedDict_move_to_end__doc__}, + {"move_to_end", _PyCFunction_CAST(OrderedDict_move_to_end), METH_FASTCALL|METH_KEYWORDS, OrderedDict_move_to_end__doc__}, static PyObject * OrderedDict_move_to_end_impl(PyODictObject *self, PyObject *key, int last); @@ -211,4 +211,4 @@ OrderedDict_move_to_end(PyODictObject *self, PyObject *const *args, Py_ssize_t n exit: return return_value; } -/*[clinic end generated code: output=e0afaad5b4bb47fe input=a9049054013a1b77]*/ +/*[clinic end generated code: output=4182a5dab66963d0 input=a9049054013a1b77]*/ diff --git a/Objects/clinic/tupleobject.c.h b/Objects/clinic/tupleobject.c.h index f65e5fa14ebd7..224fc0c374f01 100644 --- a/Objects/clinic/tupleobject.c.h +++ b/Objects/clinic/tupleobject.c.h @@ -11,7 +11,7 @@ PyDoc_STRVAR(tuple_index__doc__, "Raises ValueError if the value is not present."); #define TUPLE_INDEX_METHODDEF \ - {"index", (PyCFunction)(void(*)(void))tuple_index, METH_FASTCALL, tuple_index__doc__}, + {"index", _PyCFunction_CAST(tuple_index), METH_FASTCALL, tuple_index__doc__}, static PyObject * tuple_index_impl(PyTupleObject *self, PyObject *value, Py_ssize_t start, @@ -112,4 +112,4 @@ tuple___getnewargs__(PyTupleObject *self, PyObject *Py_UNUSED(ignored)) { return tuple___getnewargs___impl(self); } -/*[clinic end generated code: output=72cc0bc4f7358116 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=044496dc917f8a97 input=a9049054013a1b77]*/ diff --git a/Objects/clinic/unicodeobject.c.h b/Objects/clinic/unicodeobject.c.h index b9892403a2036..07877693c26e3 100644 --- a/Objects/clinic/unicodeobject.c.h +++ b/Objects/clinic/unicodeobject.c.h @@ -89,7 +89,7 @@ PyDoc_STRVAR(unicode_center__doc__, "Padding is done using the specified fill character (default is a space)."); #define UNICODE_CENTER_METHODDEF \ - {"center", (PyCFunction)(void(*)(void))unicode_center, METH_FASTCALL, unicode_center__doc__}, + {"center", _PyCFunction_CAST(unicode_center), METH_FASTCALL, unicode_center__doc__}, static PyObject * unicode_center_impl(PyObject *self, Py_ssize_t width, Py_UCS4 fillchar); @@ -145,7 +145,7 @@ PyDoc_STRVAR(unicode_encode__doc__, " codecs.register_error that can handle UnicodeEncodeErrors."); #define UNICODE_ENCODE_METHODDEF \ - {"encode", (PyCFunction)(void(*)(void))unicode_encode, METH_FASTCALL|METH_KEYWORDS, unicode_encode__doc__}, + {"encode", _PyCFunction_CAST(unicode_encode), METH_FASTCALL|METH_KEYWORDS, unicode_encode__doc__}, static PyObject * unicode_encode_impl(PyObject *self, const char *encoding, const char *errors); @@ -215,7 +215,7 @@ PyDoc_STRVAR(unicode_expandtabs__doc__, "If tabsize is not given, a tab size of 8 characters is assumed."); #define UNICODE_EXPANDTABS_METHODDEF \ - {"expandtabs", (PyCFunction)(void(*)(void))unicode_expandtabs, METH_FASTCALL|METH_KEYWORDS, unicode_expandtabs__doc__}, + {"expandtabs", _PyCFunction_CAST(unicode_expandtabs), METH_FASTCALL|METH_KEYWORDS, unicode_expandtabs__doc__}, static PyObject * unicode_expandtabs_impl(PyObject *self, int tabsize); @@ -523,7 +523,7 @@ PyDoc_STRVAR(unicode_ljust__doc__, "Padding is done using the specified fill character (default is a space)."); #define UNICODE_LJUST_METHODDEF \ - {"ljust", (PyCFunction)(void(*)(void))unicode_ljust, METH_FASTCALL, unicode_ljust__doc__}, + {"ljust", _PyCFunction_CAST(unicode_ljust), METH_FASTCALL, unicode_ljust__doc__}, static PyObject * unicode_ljust_impl(PyObject *self, Py_ssize_t width, Py_UCS4 fillchar); @@ -590,7 +590,7 @@ PyDoc_STRVAR(unicode_strip__doc__, "If chars is given and not None, remove characters in chars instead."); #define UNICODE_STRIP_METHODDEF \ - {"strip", (PyCFunction)(void(*)(void))unicode_strip, METH_FASTCALL, unicode_strip__doc__}, + {"strip", _PyCFunction_CAST(unicode_strip), METH_FASTCALL, unicode_strip__doc__}, static PyObject * unicode_strip_impl(PyObject *self, PyObject *chars); @@ -624,7 +624,7 @@ PyDoc_STRVAR(unicode_lstrip__doc__, "If chars is given and not None, remove characters in chars instead."); #define UNICODE_LSTRIP_METHODDEF \ - {"lstrip", (PyCFunction)(void(*)(void))unicode_lstrip, METH_FASTCALL, unicode_lstrip__doc__}, + {"lstrip", _PyCFunction_CAST(unicode_lstrip), METH_FASTCALL, unicode_lstrip__doc__}, static PyObject * unicode_lstrip_impl(PyObject *self, PyObject *chars); @@ -658,7 +658,7 @@ PyDoc_STRVAR(unicode_rstrip__doc__, "If chars is given and not None, remove characters in chars instead."); #define UNICODE_RSTRIP_METHODDEF \ - {"rstrip", (PyCFunction)(void(*)(void))unicode_rstrip, METH_FASTCALL, unicode_rstrip__doc__}, + {"rstrip", _PyCFunction_CAST(unicode_rstrip), METH_FASTCALL, unicode_rstrip__doc__}, static PyObject * unicode_rstrip_impl(PyObject *self, PyObject *chars); @@ -697,7 +697,7 @@ PyDoc_STRVAR(unicode_replace__doc__, "replaced."); #define UNICODE_REPLACE_METHODDEF \ - {"replace", (PyCFunction)(void(*)(void))unicode_replace, METH_FASTCALL, unicode_replace__doc__}, + {"replace", _PyCFunction_CAST(unicode_replace), METH_FASTCALL, unicode_replace__doc__}, static PyObject * unicode_replace_impl(PyObject *self, PyObject *old, PyObject *new, @@ -832,7 +832,7 @@ PyDoc_STRVAR(unicode_rjust__doc__, "Padding is done using the specified fill character (default is a space)."); #define UNICODE_RJUST_METHODDEF \ - {"rjust", (PyCFunction)(void(*)(void))unicode_rjust, METH_FASTCALL, unicode_rjust__doc__}, + {"rjust", _PyCFunction_CAST(unicode_rjust), METH_FASTCALL, unicode_rjust__doc__}, static PyObject * unicode_rjust_impl(PyObject *self, Py_ssize_t width, Py_UCS4 fillchar); @@ -893,7 +893,7 @@ PyDoc_STRVAR(unicode_split__doc__, "the regular expression module."); #define UNICODE_SPLIT_METHODDEF \ - {"split", (PyCFunction)(void(*)(void))unicode_split, METH_FASTCALL|METH_KEYWORDS, unicode_split__doc__}, + {"split", _PyCFunction_CAST(unicode_split), METH_FASTCALL|METH_KEYWORDS, unicode_split__doc__}, static PyObject * unicode_split_impl(PyObject *self, PyObject *sep, Py_ssize_t maxsplit); @@ -992,7 +992,7 @@ PyDoc_STRVAR(unicode_rsplit__doc__, "Splitting starts at the end of the string and works to the front."); #define UNICODE_RSPLIT_METHODDEF \ - {"rsplit", (PyCFunction)(void(*)(void))unicode_rsplit, METH_FASTCALL|METH_KEYWORDS, unicode_rsplit__doc__}, + {"rsplit", _PyCFunction_CAST(unicode_rsplit), METH_FASTCALL|METH_KEYWORDS, unicode_rsplit__doc__}, static PyObject * unicode_rsplit_impl(PyObject *self, PyObject *sep, Py_ssize_t maxsplit); @@ -1050,7 +1050,7 @@ PyDoc_STRVAR(unicode_splitlines__doc__, "true."); #define UNICODE_SPLITLINES_METHODDEF \ - {"splitlines", (PyCFunction)(void(*)(void))unicode_splitlines, METH_FASTCALL|METH_KEYWORDS, unicode_splitlines__doc__}, + {"splitlines", _PyCFunction_CAST(unicode_splitlines), METH_FASTCALL|METH_KEYWORDS, unicode_splitlines__doc__}, static PyObject * unicode_splitlines_impl(PyObject *self, int keepends); @@ -1116,7 +1116,7 @@ PyDoc_STRVAR(unicode_maketrans__doc__, "must be a string, whose characters will be mapped to None in the result."); #define UNICODE_MAKETRANS_METHODDEF \ - {"maketrans", (PyCFunction)(void(*)(void))unicode_maketrans, METH_FASTCALL|METH_STATIC, unicode_maketrans__doc__}, + {"maketrans", _PyCFunction_CAST(unicode_maketrans), METH_FASTCALL|METH_STATIC, unicode_maketrans__doc__}, static PyObject * unicode_maketrans_impl(PyObject *x, PyObject *y, PyObject *z); @@ -1353,4 +1353,4 @@ unicode_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) exit: return return_value; } -/*[clinic end generated code: output=e8566b060f558f72 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=b5dd7cefead9a8e7 input=a9049054013a1b77]*/ diff --git a/Objects/stringlib/clinic/transmogrify.h.h b/Objects/stringlib/clinic/transmogrify.h.h index a5135a0cba0f2..b88517bd3649a 100644 --- a/Objects/stringlib/clinic/transmogrify.h.h +++ b/Objects/stringlib/clinic/transmogrify.h.h @@ -11,7 +11,7 @@ PyDoc_STRVAR(stringlib_expandtabs__doc__, "If tabsize is not given, a tab size of 8 characters is assumed."); #define STRINGLIB_EXPANDTABS_METHODDEF \ - {"expandtabs", (PyCFunction)(void(*)(void))stringlib_expandtabs, METH_FASTCALL|METH_KEYWORDS, stringlib_expandtabs__doc__}, + {"expandtabs", _PyCFunction_CAST(stringlib_expandtabs), METH_FASTCALL|METH_KEYWORDS, stringlib_expandtabs__doc__}, static PyObject * stringlib_expandtabs_impl(PyObject *self, int tabsize); @@ -53,7 +53,7 @@ PyDoc_STRVAR(stringlib_ljust__doc__, "Padding is done using the specified fill character."); #define STRINGLIB_LJUST_METHODDEF \ - {"ljust", (PyCFunction)(void(*)(void))stringlib_ljust, METH_FASTCALL, stringlib_ljust__doc__}, + {"ljust", _PyCFunction_CAST(stringlib_ljust), METH_FASTCALL, stringlib_ljust__doc__}, static PyObject * stringlib_ljust_impl(PyObject *self, Py_ssize_t width, char fillchar); @@ -109,7 +109,7 @@ PyDoc_STRVAR(stringlib_rjust__doc__, "Padding is done using the specified fill character."); #define STRINGLIB_RJUST_METHODDEF \ - {"rjust", (PyCFunction)(void(*)(void))stringlib_rjust, METH_FASTCALL, stringlib_rjust__doc__}, + {"rjust", _PyCFunction_CAST(stringlib_rjust), METH_FASTCALL, stringlib_rjust__doc__}, static PyObject * stringlib_rjust_impl(PyObject *self, Py_ssize_t width, char fillchar); @@ -165,7 +165,7 @@ PyDoc_STRVAR(stringlib_center__doc__, "Padding is done using the specified fill character."); #define STRINGLIB_CENTER_METHODDEF \ - {"center", (PyCFunction)(void(*)(void))stringlib_center, METH_FASTCALL, stringlib_center__doc__}, + {"center", _PyCFunction_CAST(stringlib_center), METH_FASTCALL, stringlib_center__doc__}, static PyObject * stringlib_center_impl(PyObject *self, Py_ssize_t width, char fillchar); @@ -249,4 +249,4 @@ stringlib_zfill(PyObject *self, PyObject *arg) exit: return return_value; } -/*[clinic end generated code: output=2d9abc7b1cffeca6 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=46d058103bffedf7 input=a9049054013a1b77]*/ diff --git a/PC/clinic/_msi.c.h b/PC/clinic/_msi.c.h index 85c4d226ee408..fd21142158312 100644 --- a/PC/clinic/_msi.c.h +++ b/PC/clinic/_msi.c.h @@ -33,7 +33,7 @@ PyDoc_STRVAR(_msi_FCICreate__doc__, " and the name of the file inside the CAB file"); #define _MSI_FCICREATE_METHODDEF \ - {"FCICreate", (PyCFunction)(void(*)(void))_msi_FCICreate, METH_FASTCALL, _msi_FCICreate__doc__}, + {"FCICreate", _PyCFunction_CAST(_msi_FCICreate), METH_FASTCALL, _msi_FCICreate__doc__}, static PyObject * _msi_FCICreate_impl(PyObject *module, const char *cabname, PyObject *files); @@ -185,7 +185,7 @@ PyDoc_STRVAR(_msi_Record_SetString__doc__, "Set field to a string value."); #define _MSI_RECORD_SETSTRING_METHODDEF \ - {"SetString", (PyCFunction)(void(*)(void))_msi_Record_SetString, METH_FASTCALL, _msi_Record_SetString__doc__}, + {"SetString", _PyCFunction_CAST(_msi_Record_SetString), METH_FASTCALL, _msi_Record_SetString__doc__}, static PyObject * _msi_Record_SetString_impl(msiobj *self, int field, const Py_UNICODE *value); @@ -234,7 +234,7 @@ PyDoc_STRVAR(_msi_Record_SetStream__doc__, "Set field to the contents of the file named value."); #define _MSI_RECORD_SETSTREAM_METHODDEF \ - {"SetStream", (PyCFunction)(void(*)(void))_msi_Record_SetStream, METH_FASTCALL, _msi_Record_SetStream__doc__}, + {"SetStream", _PyCFunction_CAST(_msi_Record_SetStream), METH_FASTCALL, _msi_Record_SetStream__doc__}, static PyObject * _msi_Record_SetStream_impl(msiobj *self, int field, const Py_UNICODE *value); @@ -283,7 +283,7 @@ PyDoc_STRVAR(_msi_Record_SetInteger__doc__, "Set field to an integer value."); #define _MSI_RECORD_SETINTEGER_METHODDEF \ - {"SetInteger", (PyCFunction)(void(*)(void))_msi_Record_SetInteger, METH_FASTCALL, _msi_Record_SetInteger__doc__}, + {"SetInteger", _PyCFunction_CAST(_msi_Record_SetInteger), METH_FASTCALL, _msi_Record_SetInteger__doc__}, static PyObject * _msi_Record_SetInteger_impl(msiobj *self, int field, int value); @@ -373,7 +373,7 @@ PyDoc_STRVAR(_msi_SummaryInformation_SetProperty__doc__, " the new value of the property (integer or string)"); #define _MSI_SUMMARYINFORMATION_SETPROPERTY_METHODDEF \ - {"SetProperty", (PyCFunction)(void(*)(void))_msi_SummaryInformation_SetProperty, METH_FASTCALL, _msi_SummaryInformation_SetProperty__doc__}, + {"SetProperty", _PyCFunction_CAST(_msi_SummaryInformation_SetProperty), METH_FASTCALL, _msi_SummaryInformation_SetProperty__doc__}, static PyObject * _msi_SummaryInformation_SetProperty_impl(msiobj *self, int field, @@ -492,7 +492,7 @@ PyDoc_STRVAR(_msi_View_Modify__doc__, " a record describing the new data"); #define _MSI_VIEW_MODIFY_METHODDEF \ - {"Modify", (PyCFunction)(void(*)(void))_msi_View_Modify, METH_FASTCALL, _msi_View_Modify__doc__}, + {"Modify", _PyCFunction_CAST(_msi_View_Modify), METH_FASTCALL, _msi_View_Modify__doc__}, static PyObject * _msi_View_Modify_impl(msiobj *self, int kind, PyObject *data); @@ -641,7 +641,7 @@ PyDoc_STRVAR(_msi_OpenDatabase__doc__, " the persistence mode"); #define _MSI_OPENDATABASE_METHODDEF \ - {"OpenDatabase", (PyCFunction)(void(*)(void))_msi_OpenDatabase, METH_FASTCALL, _msi_OpenDatabase__doc__}, + {"OpenDatabase", _PyCFunction_CAST(_msi_OpenDatabase), METH_FASTCALL, _msi_OpenDatabase__doc__}, static PyObject * _msi_OpenDatabase_impl(PyObject *module, const Py_UNICODE *path, int persist); @@ -713,4 +713,4 @@ _msi_CreateRecord(PyObject *module, PyObject *arg) exit: return return_value; } -/*[clinic end generated code: output=49debf733ee5cab2 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=d7eb07e6bfcdc13f input=a9049054013a1b77]*/ diff --git a/PC/clinic/_testconsole.c.h b/PC/clinic/_testconsole.c.h index cf5e4ee09063a..b2fd515e77a12 100644 --- a/PC/clinic/_testconsole.c.h +++ b/PC/clinic/_testconsole.c.h @@ -11,7 +11,7 @@ PyDoc_STRVAR(_testconsole_write_input__doc__, "Writes UTF-16-LE encoded bytes to the console as if typed by a user."); #define _TESTCONSOLE_WRITE_INPUT_METHODDEF \ - {"write_input", (PyCFunction)(void(*)(void))_testconsole_write_input, METH_FASTCALL|METH_KEYWORDS, _testconsole_write_input__doc__}, + {"write_input", _PyCFunction_CAST(_testconsole_write_input), METH_FASTCALL|METH_KEYWORDS, _testconsole_write_input__doc__}, static PyObject * _testconsole_write_input_impl(PyObject *module, PyObject *file, @@ -54,7 +54,7 @@ PyDoc_STRVAR(_testconsole_read_output__doc__, "Reads a str from the console as written to stdout."); #define _TESTCONSOLE_READ_OUTPUT_METHODDEF \ - {"read_output", (PyCFunction)(void(*)(void))_testconsole_read_output, METH_FASTCALL|METH_KEYWORDS, _testconsole_read_output__doc__}, + {"read_output", _PyCFunction_CAST(_testconsole_read_output), METH_FASTCALL|METH_KEYWORDS, _testconsole_read_output__doc__}, static PyObject * _testconsole_read_output_impl(PyObject *module, PyObject *file); @@ -88,4 +88,4 @@ _testconsole_read_output(PyObject *module, PyObject *const *args, Py_ssize_t nar #ifndef _TESTCONSOLE_READ_OUTPUT_METHODDEF #define _TESTCONSOLE_READ_OUTPUT_METHODDEF #endif /* !defined(_TESTCONSOLE_READ_OUTPUT_METHODDEF) */ -/*[clinic end generated code: output=dd8b093a91b62753 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=6e9f8b0766eb5a0e input=a9049054013a1b77]*/ diff --git a/PC/clinic/msvcrtmodule.c.h b/PC/clinic/msvcrtmodule.c.h index 1ac82cb965b64..ea95897590fe4 100644 --- a/PC/clinic/msvcrtmodule.c.h +++ b/PC/clinic/msvcrtmodule.c.h @@ -37,7 +37,7 @@ PyDoc_STRVAR(msvcrt_locking__doc__, "individually."); #define MSVCRT_LOCKING_METHODDEF \ - {"locking", (PyCFunction)(void(*)(void))msvcrt_locking, METH_FASTCALL, msvcrt_locking__doc__}, + {"locking", _PyCFunction_CAST(msvcrt_locking), METH_FASTCALL, msvcrt_locking__doc__}, static PyObject * msvcrt_locking_impl(PyObject *module, int fd, int mode, long nbytes); @@ -83,7 +83,7 @@ PyDoc_STRVAR(msvcrt_setmode__doc__, "Return value is the previous mode."); #define MSVCRT_SETMODE_METHODDEF \ - {"setmode", (PyCFunction)(void(*)(void))msvcrt_setmode, METH_FASTCALL, msvcrt_setmode__doc__}, + {"setmode", _PyCFunction_CAST(msvcrt_setmode), METH_FASTCALL, msvcrt_setmode__doc__}, static long msvcrt_setmode_impl(PyObject *module, int fd, int flags); @@ -128,7 +128,7 @@ PyDoc_STRVAR(msvcrt_open_osfhandle__doc__, "to os.fdopen() to create a file object."); #define MSVCRT_OPEN_OSFHANDLE_METHODDEF \ - {"open_osfhandle", (PyCFunction)(void(*)(void))msvcrt_open_osfhandle, METH_FASTCALL, msvcrt_open_osfhandle__doc__}, + {"open_osfhandle", _PyCFunction_CAST(msvcrt_open_osfhandle), METH_FASTCALL, msvcrt_open_osfhandle__doc__}, static long msvcrt_open_osfhandle_impl(PyObject *module, void *handle, int flags); @@ -475,7 +475,7 @@ PyDoc_STRVAR(msvcrt_CrtSetReportFile__doc__, "Only available on Debug builds."); #define MSVCRT_CRTSETREPORTFILE_METHODDEF \ - {"CrtSetReportFile", (PyCFunction)(void(*)(void))msvcrt_CrtSetReportFile, METH_FASTCALL, msvcrt_CrtSetReportFile__doc__}, + {"CrtSetReportFile", _PyCFunction_CAST(msvcrt_CrtSetReportFile), METH_FASTCALL, msvcrt_CrtSetReportFile__doc__}, static void * msvcrt_CrtSetReportFile_impl(PyObject *module, int type, void *file); @@ -515,7 +515,7 @@ PyDoc_STRVAR(msvcrt_CrtSetReportMode__doc__, "Only available on Debug builds."); #define MSVCRT_CRTSETREPORTMODE_METHODDEF \ - {"CrtSetReportMode", (PyCFunction)(void(*)(void))msvcrt_CrtSetReportMode, METH_FASTCALL, msvcrt_CrtSetReportMode__doc__}, + {"CrtSetReportMode", _PyCFunction_CAST(msvcrt_CrtSetReportMode), METH_FASTCALL, msvcrt_CrtSetReportMode__doc__}, static long msvcrt_CrtSetReportMode_impl(PyObject *module, int type, int mode); @@ -647,4 +647,4 @@ msvcrt_SetErrorMode(PyObject *module, PyObject *arg) #ifndef MSVCRT_SET_ERROR_MODE_METHODDEF #define MSVCRT_SET_ERROR_MODE_METHODDEF #endif /* !defined(MSVCRT_SET_ERROR_MODE_METHODDEF) */ -/*[clinic end generated code: output=20dfbc768edce7c0 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=b543933cad520f2b input=a9049054013a1b77]*/ diff --git a/PC/clinic/winreg.c.h b/PC/clinic/winreg.c.h index 183301f061866..8bcb290ecd3b5 100644 --- a/PC/clinic/winreg.c.h +++ b/PC/clinic/winreg.c.h @@ -77,7 +77,7 @@ PyDoc_STRVAR(winreg_HKEYType___exit____doc__, "\n"); #define WINREG_HKEYTYPE___EXIT___METHODDEF \ - {"__exit__", (PyCFunction)(void(*)(void))winreg_HKEYType___exit__, METH_FASTCALL|METH_KEYWORDS, winreg_HKEYType___exit____doc__}, + {"__exit__", _PyCFunction_CAST(winreg_HKEYType___exit__), METH_FASTCALL|METH_KEYWORDS, winreg_HKEYType___exit____doc__}, static PyObject * winreg_HKEYType___exit___impl(PyHKEYObject *self, PyObject *exc_type, @@ -138,7 +138,7 @@ PyDoc_STRVAR(winreg_ConnectRegistry__doc__, "If the function fails, an OSError exception is raised."); #define WINREG_CONNECTREGISTRY_METHODDEF \ - {"ConnectRegistry", (PyCFunction)(void(*)(void))winreg_ConnectRegistry, METH_FASTCALL, winreg_ConnectRegistry__doc__}, + {"ConnectRegistry", _PyCFunction_CAST(winreg_ConnectRegistry), METH_FASTCALL, winreg_ConnectRegistry__doc__}, static HKEY winreg_ConnectRegistry_impl(PyObject *module, @@ -210,7 +210,7 @@ PyDoc_STRVAR(winreg_CreateKey__doc__, "If the function fails, an OSError exception is raised."); #define WINREG_CREATEKEY_METHODDEF \ - {"CreateKey", (PyCFunction)(void(*)(void))winreg_CreateKey, METH_FASTCALL, winreg_CreateKey__doc__}, + {"CreateKey", _PyCFunction_CAST(winreg_CreateKey), METH_FASTCALL, winreg_CreateKey__doc__}, static HKEY winreg_CreateKey_impl(PyObject *module, HKEY key, const Py_UNICODE *sub_key); @@ -287,7 +287,7 @@ PyDoc_STRVAR(winreg_CreateKeyEx__doc__, "If the function fails, an OSError exception is raised."); #define WINREG_CREATEKEYEX_METHODDEF \ - {"CreateKeyEx", (PyCFunction)(void(*)(void))winreg_CreateKeyEx, METH_FASTCALL|METH_KEYWORDS, winreg_CreateKeyEx__doc__}, + {"CreateKeyEx", _PyCFunction_CAST(winreg_CreateKeyEx), METH_FASTCALL|METH_KEYWORDS, winreg_CreateKeyEx__doc__}, static HKEY winreg_CreateKeyEx_impl(PyObject *module, HKEY key, @@ -344,7 +344,7 @@ PyDoc_STRVAR(winreg_DeleteKey__doc__, "is removed. If the function fails, an OSError exception is raised."); #define WINREG_DELETEKEY_METHODDEF \ - {"DeleteKey", (PyCFunction)(void(*)(void))winreg_DeleteKey, METH_FASTCALL, winreg_DeleteKey__doc__}, + {"DeleteKey", _PyCFunction_CAST(winreg_DeleteKey), METH_FASTCALL, winreg_DeleteKey__doc__}, static PyObject * winreg_DeleteKey_impl(PyObject *module, HKEY key, const Py_UNICODE *sub_key); @@ -411,7 +411,7 @@ PyDoc_STRVAR(winreg_DeleteKeyEx__doc__, "On unsupported Windows versions, NotImplementedError is raised."); #define WINREG_DELETEKEYEX_METHODDEF \ - {"DeleteKeyEx", (PyCFunction)(void(*)(void))winreg_DeleteKeyEx, METH_FASTCALL|METH_KEYWORDS, winreg_DeleteKeyEx__doc__}, + {"DeleteKeyEx", _PyCFunction_CAST(winreg_DeleteKeyEx), METH_FASTCALL|METH_KEYWORDS, winreg_DeleteKeyEx__doc__}, static PyObject * winreg_DeleteKeyEx_impl(PyObject *module, HKEY key, @@ -456,7 +456,7 @@ PyDoc_STRVAR(winreg_DeleteValue__doc__, " A string that identifies the value to remove."); #define WINREG_DELETEVALUE_METHODDEF \ - {"DeleteValue", (PyCFunction)(void(*)(void))winreg_DeleteValue, METH_FASTCALL, winreg_DeleteValue__doc__}, + {"DeleteValue", _PyCFunction_CAST(winreg_DeleteValue), METH_FASTCALL, winreg_DeleteValue__doc__}, static PyObject * winreg_DeleteValue_impl(PyObject *module, HKEY key, const Py_UNICODE *value); @@ -518,7 +518,7 @@ PyDoc_STRVAR(winreg_EnumKey__doc__, "raised, indicating no more values are available."); #define WINREG_ENUMKEY_METHODDEF \ - {"EnumKey", (PyCFunction)(void(*)(void))winreg_EnumKey, METH_FASTCALL, winreg_EnumKey__doc__}, + {"EnumKey", _PyCFunction_CAST(winreg_EnumKey), METH_FASTCALL, winreg_EnumKey__doc__}, static PyObject * winreg_EnumKey_impl(PyObject *module, HKEY key, int index); @@ -571,7 +571,7 @@ PyDoc_STRVAR(winreg_EnumValue__doc__, " An integer that identifies the type of the value data."); #define WINREG_ENUMVALUE_METHODDEF \ - {"EnumValue", (PyCFunction)(void(*)(void))winreg_EnumValue, METH_FASTCALL, winreg_EnumValue__doc__}, + {"EnumValue", _PyCFunction_CAST(winreg_EnumValue), METH_FASTCALL, winreg_EnumValue__doc__}, static PyObject * winreg_EnumValue_impl(PyObject *module, HKEY key, int index); @@ -710,7 +710,7 @@ PyDoc_STRVAR(winreg_LoadKey__doc__, "tree."); #define WINREG_LOADKEY_METHODDEF \ - {"LoadKey", (PyCFunction)(void(*)(void))winreg_LoadKey, METH_FASTCALL, winreg_LoadKey__doc__}, + {"LoadKey", _PyCFunction_CAST(winreg_LoadKey), METH_FASTCALL, winreg_LoadKey__doc__}, static PyObject * winreg_LoadKey_impl(PyObject *module, HKEY key, const Py_UNICODE *sub_key, @@ -789,7 +789,7 @@ PyDoc_STRVAR(winreg_OpenKey__doc__, "If the function fails, an OSError exception is raised."); #define WINREG_OPENKEY_METHODDEF \ - {"OpenKey", (PyCFunction)(void(*)(void))winreg_OpenKey, METH_FASTCALL|METH_KEYWORDS, winreg_OpenKey__doc__}, + {"OpenKey", _PyCFunction_CAST(winreg_OpenKey), METH_FASTCALL|METH_KEYWORDS, winreg_OpenKey__doc__}, static HKEY winreg_OpenKey_impl(PyObject *module, HKEY key, const Py_UNICODE *sub_key, @@ -846,7 +846,7 @@ PyDoc_STRVAR(winreg_OpenKeyEx__doc__, "If the function fails, an OSError exception is raised."); #define WINREG_OPENKEYEX_METHODDEF \ - {"OpenKeyEx", (PyCFunction)(void(*)(void))winreg_OpenKeyEx, METH_FASTCALL|METH_KEYWORDS, winreg_OpenKeyEx__doc__}, + {"OpenKeyEx", _PyCFunction_CAST(winreg_OpenKeyEx), METH_FASTCALL|METH_KEYWORDS, winreg_OpenKeyEx__doc__}, static HKEY winreg_OpenKeyEx_impl(PyObject *module, HKEY key, const Py_UNICODE *sub_key, @@ -940,7 +940,7 @@ PyDoc_STRVAR(winreg_QueryValue__doc__, "completeness."); #define WINREG_QUERYVALUE_METHODDEF \ - {"QueryValue", (PyCFunction)(void(*)(void))winreg_QueryValue, METH_FASTCALL, winreg_QueryValue__doc__}, + {"QueryValue", _PyCFunction_CAST(winreg_QueryValue), METH_FASTCALL, winreg_QueryValue__doc__}, static PyObject * winreg_QueryValue_impl(PyObject *module, HKEY key, const Py_UNICODE *sub_key); @@ -1003,7 +1003,7 @@ PyDoc_STRVAR(winreg_QueryValueEx__doc__, "The return value is a tuple of the value and the type_id."); #define WINREG_QUERYVALUEEX_METHODDEF \ - {"QueryValueEx", (PyCFunction)(void(*)(void))winreg_QueryValueEx, METH_FASTCALL, winreg_QueryValueEx__doc__}, + {"QueryValueEx", _PyCFunction_CAST(winreg_QueryValueEx), METH_FASTCALL, winreg_QueryValueEx__doc__}, static PyObject * winreg_QueryValueEx_impl(PyObject *module, HKEY key, const Py_UNICODE *name); @@ -1071,7 +1071,7 @@ PyDoc_STRVAR(winreg_SaveKey__doc__, "to the API."); #define WINREG_SAVEKEY_METHODDEF \ - {"SaveKey", (PyCFunction)(void(*)(void))winreg_SaveKey, METH_FASTCALL, winreg_SaveKey__doc__}, + {"SaveKey", _PyCFunction_CAST(winreg_SaveKey), METH_FASTCALL, winreg_SaveKey__doc__}, static PyObject * winreg_SaveKey_impl(PyObject *module, HKEY key, const Py_UNICODE *file_name); @@ -1139,7 +1139,7 @@ PyDoc_STRVAR(winreg_SetValue__doc__, "KEY_SET_VALUE access."); #define WINREG_SETVALUE_METHODDEF \ - {"SetValue", (PyCFunction)(void(*)(void))winreg_SetValue, METH_FASTCALL, winreg_SetValue__doc__}, + {"SetValue", _PyCFunction_CAST(winreg_SetValue), METH_FASTCALL, winreg_SetValue__doc__}, static PyObject * winreg_SetValue_impl(PyObject *module, HKEY key, const Py_UNICODE *sub_key, @@ -1213,7 +1213,7 @@ PyDoc_STRVAR(winreg_SetValueEx__doc__, "the configuration registry to help the registry perform efficiently."); #define WINREG_SETVALUEEX_METHODDEF \ - {"SetValueEx", (PyCFunction)(void(*)(void))winreg_SetValueEx, METH_FASTCALL, winreg_SetValueEx__doc__}, + {"SetValueEx", _PyCFunction_CAST(winreg_SetValueEx), METH_FASTCALL, winreg_SetValueEx__doc__}, static PyObject * winreg_SetValueEx_impl(PyObject *module, HKEY key, @@ -1346,4 +1346,4 @@ winreg_QueryReflectionKey(PyObject *module, PyObject *arg) exit: return return_value; } -/*[clinic end generated code: output=497a2e804821d5c9 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=c3454803528f6e97 input=a9049054013a1b77]*/ diff --git a/PC/clinic/winsound.c.h b/PC/clinic/winsound.c.h index c5458990baa7f..9f99b8e400261 100644 --- a/PC/clinic/winsound.c.h +++ b/PC/clinic/winsound.c.h @@ -14,7 +14,7 @@ PyDoc_STRVAR(winsound_PlaySound__doc__, " Flag values, ored together. See module documentation."); #define WINSOUND_PLAYSOUND_METHODDEF \ - {"PlaySound", (PyCFunction)(void(*)(void))winsound_PlaySound, METH_FASTCALL|METH_KEYWORDS, winsound_PlaySound__doc__}, + {"PlaySound", _PyCFunction_CAST(winsound_PlaySound), METH_FASTCALL|METH_KEYWORDS, winsound_PlaySound__doc__}, static PyObject * winsound_PlaySound_impl(PyObject *module, PyObject *sound, int flags); @@ -57,7 +57,7 @@ PyDoc_STRVAR(winsound_Beep__doc__, " How long the sound should play, in milliseconds."); #define WINSOUND_BEEP_METHODDEF \ - {"Beep", (PyCFunction)(void(*)(void))winsound_Beep, METH_FASTCALL|METH_KEYWORDS, winsound_Beep__doc__}, + {"Beep", _PyCFunction_CAST(winsound_Beep), METH_FASTCALL|METH_KEYWORDS, winsound_Beep__doc__}, static PyObject * winsound_Beep_impl(PyObject *module, int frequency, int duration); @@ -99,7 +99,7 @@ PyDoc_STRVAR(winsound_MessageBeep__doc__, "x defaults to MB_OK."); #define WINSOUND_MESSAGEBEEP_METHODDEF \ - {"MessageBeep", (PyCFunction)(void(*)(void))winsound_MessageBeep, METH_FASTCALL|METH_KEYWORDS, winsound_MessageBeep__doc__}, + {"MessageBeep", _PyCFunction_CAST(winsound_MessageBeep), METH_FASTCALL|METH_KEYWORDS, winsound_MessageBeep__doc__}, static PyObject * winsound_MessageBeep_impl(PyObject *module, int type); @@ -131,4 +131,4 @@ winsound_MessageBeep(PyObject *module, PyObject *const *args, Py_ssize_t nargs, exit: return return_value; } -/*[clinic end generated code: output=16b3c1a96861cd3a input=a9049054013a1b77]*/ +/*[clinic end generated code: output=b7e53fab4f26aeaf input=a9049054013a1b77]*/ diff --git a/Python/clinic/_warnings.c.h b/Python/clinic/_warnings.c.h index ad6b9a8e2428c..aa85c2a0d4d92 100644 --- a/Python/clinic/_warnings.c.h +++ b/Python/clinic/_warnings.c.h @@ -9,7 +9,7 @@ PyDoc_STRVAR(warnings_warn__doc__, "Issue a warning, or maybe ignore it or raise an exception."); #define WARNINGS_WARN_METHODDEF \ - {"warn", (PyCFunction)(void(*)(void))warnings_warn, METH_FASTCALL|METH_KEYWORDS, warnings_warn__doc__}, + {"warn", _PyCFunction_CAST(warnings_warn), METH_FASTCALL|METH_KEYWORDS, warnings_warn__doc__}, static PyObject * warnings_warn_impl(PyObject *module, PyObject *message, PyObject *category, @@ -66,4 +66,4 @@ warnings_warn(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObjec exit: return return_value; } -/*[clinic end generated code: output=eb9997fa998fdbad input=a9049054013a1b77]*/ +/*[clinic end generated code: output=0435c68611fa2fe9 input=a9049054013a1b77]*/ diff --git a/Python/clinic/bltinmodule.c.h b/Python/clinic/bltinmodule.c.h index 4053f5a341e1f..f69b0069ec0f5 100644 --- a/Python/clinic/bltinmodule.c.h +++ b/Python/clinic/bltinmodule.c.h @@ -24,7 +24,7 @@ PyDoc_STRVAR(builtin___import____doc__, "is the number of parent directories to search relative to the current module."); #define BUILTIN___IMPORT___METHODDEF \ - {"__import__", (PyCFunction)(void(*)(void))builtin___import__, METH_FASTCALL|METH_KEYWORDS, builtin___import____doc__}, + {"__import__", _PyCFunction_CAST(builtin___import__), METH_FASTCALL|METH_KEYWORDS, builtin___import____doc__}, static PyObject * builtin___import___impl(PyObject *module, PyObject *name, PyObject *globals, @@ -161,7 +161,7 @@ PyDoc_STRVAR(builtin_format__doc__, "details."); #define BUILTIN_FORMAT_METHODDEF \ - {"format", (PyCFunction)(void(*)(void))builtin_format, METH_FASTCALL, builtin_format__doc__}, + {"format", _PyCFunction_CAST(builtin_format), METH_FASTCALL, builtin_format__doc__}, static PyObject * builtin_format_impl(PyObject *module, PyObject *value, PyObject *format_spec); @@ -242,7 +242,7 @@ PyDoc_STRVAR(builtin_compile__doc__, "in addition to any features explicitly specified."); #define BUILTIN_COMPILE_METHODDEF \ - {"compile", (PyCFunction)(void(*)(void))builtin_compile, METH_FASTCALL|METH_KEYWORDS, builtin_compile__doc__}, + {"compile", _PyCFunction_CAST(builtin_compile), METH_FASTCALL|METH_KEYWORDS, builtin_compile__doc__}, static PyObject * builtin_compile_impl(PyObject *module, PyObject *source, PyObject *filename, @@ -338,7 +338,7 @@ PyDoc_STRVAR(builtin_divmod__doc__, "Return the tuple (x//y, x%y). Invariant: div*y + mod == x."); #define BUILTIN_DIVMOD_METHODDEF \ - {"divmod", (PyCFunction)(void(*)(void))builtin_divmod, METH_FASTCALL, builtin_divmod__doc__}, + {"divmod", _PyCFunction_CAST(builtin_divmod), METH_FASTCALL, builtin_divmod__doc__}, static PyObject * builtin_divmod_impl(PyObject *module, PyObject *x, PyObject *y); @@ -374,7 +374,7 @@ PyDoc_STRVAR(builtin_eval__doc__, "If only globals is given, locals defaults to it."); #define BUILTIN_EVAL_METHODDEF \ - {"eval", (PyCFunction)(void(*)(void))builtin_eval, METH_FASTCALL, builtin_eval__doc__}, + {"eval", _PyCFunction_CAST(builtin_eval), METH_FASTCALL, builtin_eval__doc__}, static PyObject * builtin_eval_impl(PyObject *module, PyObject *source, PyObject *globals, @@ -420,7 +420,7 @@ PyDoc_STRVAR(builtin_exec__doc__, "If only globals is given, locals defaults to it."); #define BUILTIN_EXEC_METHODDEF \ - {"exec", (PyCFunction)(void(*)(void))builtin_exec, METH_FASTCALL, builtin_exec__doc__}, + {"exec", _PyCFunction_CAST(builtin_exec), METH_FASTCALL, builtin_exec__doc__}, static PyObject * builtin_exec_impl(PyObject *module, PyObject *source, PyObject *globals, @@ -483,7 +483,7 @@ PyDoc_STRVAR(builtin_hasattr__doc__, "This is done by calling getattr(obj, name) and catching AttributeError."); #define BUILTIN_HASATTR_METHODDEF \ - {"hasattr", (PyCFunction)(void(*)(void))builtin_hasattr, METH_FASTCALL, builtin_hasattr__doc__}, + {"hasattr", _PyCFunction_CAST(builtin_hasattr), METH_FASTCALL, builtin_hasattr__doc__}, static PyObject * builtin_hasattr_impl(PyObject *module, PyObject *obj, PyObject *name); @@ -527,7 +527,7 @@ PyDoc_STRVAR(builtin_setattr__doc__, "setattr(x, \'y\', v) is equivalent to ``x.y = v\'\'"); #define BUILTIN_SETATTR_METHODDEF \ - {"setattr", (PyCFunction)(void(*)(void))builtin_setattr, METH_FASTCALL, builtin_setattr__doc__}, + {"setattr", _PyCFunction_CAST(builtin_setattr), METH_FASTCALL, builtin_setattr__doc__}, static PyObject * builtin_setattr_impl(PyObject *module, PyObject *obj, PyObject *name, @@ -562,7 +562,7 @@ PyDoc_STRVAR(builtin_delattr__doc__, "delattr(x, \'y\') is equivalent to ``del x.y\'\'"); #define BUILTIN_DELATTR_METHODDEF \ - {"delattr", (PyCFunction)(void(*)(void))builtin_delattr, METH_FASTCALL, builtin_delattr__doc__}, + {"delattr", _PyCFunction_CAST(builtin_delattr), METH_FASTCALL, builtin_delattr__doc__}, static PyObject * builtin_delattr_impl(PyObject *module, PyObject *obj, PyObject *name); @@ -628,7 +628,7 @@ PyDoc_STRVAR(builtin_anext__doc__, "iterator is exhausted, it is returned instead of raising StopAsyncIteration."); #define BUILTIN_ANEXT_METHODDEF \ - {"anext", (PyCFunction)(void(*)(void))builtin_anext, METH_FASTCALL, builtin_anext__doc__}, + {"anext", _PyCFunction_CAST(builtin_anext), METH_FASTCALL, builtin_anext__doc__}, static PyObject * builtin_anext_impl(PyObject *module, PyObject *aiterator, @@ -718,7 +718,7 @@ PyDoc_STRVAR(builtin_pow__doc__, "invoked using the three argument form."); #define BUILTIN_POW_METHODDEF \ - {"pow", (PyCFunction)(void(*)(void))builtin_pow, METH_FASTCALL|METH_KEYWORDS, builtin_pow__doc__}, + {"pow", _PyCFunction_CAST(builtin_pow), METH_FASTCALL|METH_KEYWORDS, builtin_pow__doc__}, static PyObject * builtin_pow_impl(PyObject *module, PyObject *base, PyObject *exp, @@ -769,7 +769,7 @@ PyDoc_STRVAR(builtin_print__doc__, " whether to forcibly flush the stream."); #define BUILTIN_PRINT_METHODDEF \ - {"print", (PyCFunction)(void(*)(void))builtin_print, METH_FASTCALL|METH_KEYWORDS, builtin_print__doc__}, + {"print", _PyCFunction_CAST(builtin_print), METH_FASTCALL|METH_KEYWORDS, builtin_print__doc__}, static PyObject * builtin_print_impl(PyObject *module, PyObject *args, PyObject *sep, @@ -840,7 +840,7 @@ PyDoc_STRVAR(builtin_input__doc__, "On *nix systems, readline is used if available."); #define BUILTIN_INPUT_METHODDEF \ - {"input", (PyCFunction)(void(*)(void))builtin_input, METH_FASTCALL, builtin_input__doc__}, + {"input", _PyCFunction_CAST(builtin_input), METH_FASTCALL, builtin_input__doc__}, static PyObject * builtin_input_impl(PyObject *module, PyObject *prompt); @@ -886,7 +886,7 @@ PyDoc_STRVAR(builtin_round__doc__, "the return value has the same type as the number. ndigits may be negative."); #define BUILTIN_ROUND_METHODDEF \ - {"round", (PyCFunction)(void(*)(void))builtin_round, METH_FASTCALL|METH_KEYWORDS, builtin_round__doc__}, + {"round", _PyCFunction_CAST(builtin_round), METH_FASTCALL|METH_KEYWORDS, builtin_round__doc__}, static PyObject * builtin_round_impl(PyObject *module, PyObject *number, PyObject *ndigits); @@ -929,7 +929,7 @@ PyDoc_STRVAR(builtin_sum__doc__, "reject non-numeric types."); #define BUILTIN_SUM_METHODDEF \ - {"sum", (PyCFunction)(void(*)(void))builtin_sum, METH_FASTCALL|METH_KEYWORDS, builtin_sum__doc__}, + {"sum", _PyCFunction_CAST(builtin_sum), METH_FASTCALL|METH_KEYWORDS, builtin_sum__doc__}, static PyObject * builtin_sum_impl(PyObject *module, PyObject *iterable, PyObject *start); @@ -972,7 +972,7 @@ PyDoc_STRVAR(builtin_isinstance__doc__, "or ...`` etc."); #define BUILTIN_ISINSTANCE_METHODDEF \ - {"isinstance", (PyCFunction)(void(*)(void))builtin_isinstance, METH_FASTCALL, builtin_isinstance__doc__}, + {"isinstance", _PyCFunction_CAST(builtin_isinstance), METH_FASTCALL, builtin_isinstance__doc__}, static PyObject * builtin_isinstance_impl(PyObject *module, PyObject *obj, @@ -1007,7 +1007,7 @@ PyDoc_STRVAR(builtin_issubclass__doc__, "or ...``."); #define BUILTIN_ISSUBCLASS_METHODDEF \ - {"issubclass", (PyCFunction)(void(*)(void))builtin_issubclass, METH_FASTCALL, builtin_issubclass__doc__}, + {"issubclass", _PyCFunction_CAST(builtin_issubclass), METH_FASTCALL, builtin_issubclass__doc__}, static PyObject * builtin_issubclass_impl(PyObject *module, PyObject *cls, @@ -1030,4 +1030,4 @@ builtin_issubclass(PyObject *module, PyObject *const *args, Py_ssize_t nargs) exit: return return_value; } -/*[clinic end generated code: output=d341fa7525f30070 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=6a2b78ef82bc5155 input=a9049054013a1b77]*/ diff --git a/Python/clinic/context.c.h b/Python/clinic/context.c.h index 2ac8bf7c0b8ca..292d3f7f4ff49 100644 --- a/Python/clinic/context.c.h +++ b/Python/clinic/context.c.h @@ -12,7 +12,7 @@ PyDoc_STRVAR(_contextvars_Context_get__doc__, "return None."); #define _CONTEXTVARS_CONTEXT_GET_METHODDEF \ - {"get", (PyCFunction)(void(*)(void))_contextvars_Context_get, METH_FASTCALL, _contextvars_Context_get__doc__}, + {"get", _PyCFunction_CAST(_contextvars_Context_get), METH_FASTCALL, _contextvars_Context_get__doc__}, static PyObject * _contextvars_Context_get_impl(PyContext *self, PyObject *key, @@ -127,7 +127,7 @@ PyDoc_STRVAR(_contextvars_ContextVar_get__doc__, " * raise a LookupError."); #define _CONTEXTVARS_CONTEXTVAR_GET_METHODDEF \ - {"get", (PyCFunction)(void(*)(void))_contextvars_ContextVar_get, METH_FASTCALL, _contextvars_ContextVar_get__doc__}, + {"get", _PyCFunction_CAST(_contextvars_ContextVar_get), METH_FASTCALL, _contextvars_ContextVar_get__doc__}, static PyObject * _contextvars_ContextVar_get_impl(PyContextVar *self, PyObject *default_value); @@ -177,4 +177,4 @@ PyDoc_STRVAR(_contextvars_ContextVar_reset__doc__, #define _CONTEXTVARS_CONTEXTVAR_RESET_METHODDEF \ {"reset", (PyCFunction)_contextvars_ContextVar_reset, METH_O, _contextvars_ContextVar_reset__doc__}, -/*[clinic end generated code: output=f2e42f34e358e179 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=2436b16a92452869 input=a9049054013a1b77]*/ diff --git a/Python/clinic/import.c.h b/Python/clinic/import.c.h index 6052316cdd8e3..0451d97a720dd 100644 --- a/Python/clinic/import.c.h +++ b/Python/clinic/import.c.h @@ -75,7 +75,7 @@ PyDoc_STRVAR(_imp__fix_co_filename__doc__, " File path to use."); #define _IMP__FIX_CO_FILENAME_METHODDEF \ - {"_fix_co_filename", (PyCFunction)(void(*)(void))_imp__fix_co_filename, METH_FASTCALL, _imp__fix_co_filename__doc__}, + {"_fix_co_filename", _PyCFunction_CAST(_imp__fix_co_filename), METH_FASTCALL, _imp__fix_co_filename__doc__}, static PyObject * _imp__fix_co_filename_impl(PyObject *module, PyCodeObject *code, @@ -184,7 +184,7 @@ PyDoc_STRVAR(_imp_find_frozen__doc__, " the module\'s current name)"); #define _IMP_FIND_FROZEN_METHODDEF \ - {"find_frozen", (PyCFunction)(void(*)(void))_imp_find_frozen, METH_FASTCALL|METH_KEYWORDS, _imp_find_frozen__doc__}, + {"find_frozen", _PyCFunction_CAST(_imp_find_frozen), METH_FASTCALL|METH_KEYWORDS, _imp_find_frozen__doc__}, static PyObject * _imp_find_frozen_impl(PyObject *module, PyObject *name, int withdata); @@ -233,7 +233,7 @@ PyDoc_STRVAR(_imp_get_frozen_object__doc__, "Create a code object for a frozen module."); #define _IMP_GET_FROZEN_OBJECT_METHODDEF \ - {"get_frozen_object", (PyCFunction)(void(*)(void))_imp_get_frozen_object, METH_FASTCALL, _imp_get_frozen_object__doc__}, + {"get_frozen_object", _PyCFunction_CAST(_imp_get_frozen_object), METH_FASTCALL, _imp_get_frozen_object__doc__}, static PyObject * _imp_get_frozen_object_impl(PyObject *module, PyObject *name, @@ -422,7 +422,7 @@ PyDoc_STRVAR(_imp_create_dynamic__doc__, "Create an extension module."); #define _IMP_CREATE_DYNAMIC_METHODDEF \ - {"create_dynamic", (PyCFunction)(void(*)(void))_imp_create_dynamic, METH_FASTCALL, _imp_create_dynamic__doc__}, + {"create_dynamic", _PyCFunction_CAST(_imp_create_dynamic), METH_FASTCALL, _imp_create_dynamic__doc__}, static PyObject * _imp_create_dynamic_impl(PyObject *module, PyObject *spec, PyObject *file); @@ -517,7 +517,7 @@ PyDoc_STRVAR(_imp_source_hash__doc__, "\n"); #define _IMP_SOURCE_HASH_METHODDEF \ - {"source_hash", (PyCFunction)(void(*)(void))_imp_source_hash, METH_FASTCALL|METH_KEYWORDS, _imp_source_hash__doc__}, + {"source_hash", _PyCFunction_CAST(_imp_source_hash), METH_FASTCALL|METH_KEYWORDS, _imp_source_hash__doc__}, static PyObject * _imp_source_hash_impl(PyObject *module, long key, Py_buffer *source); @@ -565,4 +565,4 @@ _imp_source_hash(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyOb #ifndef _IMP_EXEC_DYNAMIC_METHODDEF #define _IMP_EXEC_DYNAMIC_METHODDEF #endif /* !defined(_IMP_EXEC_DYNAMIC_METHODDEF) */ -/*[clinic end generated code: output=adcf787969a11353 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=8d0f4305b1d0714b input=a9049054013a1b77]*/ diff --git a/Python/clinic/marshal.c.h b/Python/clinic/marshal.c.h index f80d5ef31f29c..36f2afd5241b7 100644 --- a/Python/clinic/marshal.c.h +++ b/Python/clinic/marshal.c.h @@ -20,7 +20,7 @@ PyDoc_STRVAR(marshal_dump__doc__, "to the file. The object will not be properly read back by load()."); #define MARSHAL_DUMP_METHODDEF \ - {"dump", (PyCFunction)(void(*)(void))marshal_dump, METH_FASTCALL, marshal_dump__doc__}, + {"dump", _PyCFunction_CAST(marshal_dump), METH_FASTCALL, marshal_dump__doc__}, static PyObject * marshal_dump_impl(PyObject *module, PyObject *value, PyObject *file, @@ -87,7 +87,7 @@ PyDoc_STRVAR(marshal_dumps__doc__, "unsupported type."); #define MARSHAL_DUMPS_METHODDEF \ - {"dumps", (PyCFunction)(void(*)(void))marshal_dumps, METH_FASTCALL, marshal_dumps__doc__}, + {"dumps", _PyCFunction_CAST(marshal_dumps), METH_FASTCALL, marshal_dumps__doc__}, static PyObject * marshal_dumps_impl(PyObject *module, PyObject *value, int version); @@ -155,4 +155,4 @@ marshal_loads(PyObject *module, PyObject *arg) return return_value; } -/*[clinic end generated code: output=68b78f38bfe0c06d input=a9049054013a1b77]*/ +/*[clinic end generated code: output=b9e838edee43fe87 input=a9049054013a1b77]*/ diff --git a/Python/clinic/sysmodule.c.h b/Python/clinic/sysmodule.c.h index ce5390c8a1e58..6ee3bb2a849aa 100644 --- a/Python/clinic/sysmodule.c.h +++ b/Python/clinic/sysmodule.c.h @@ -9,7 +9,7 @@ PyDoc_STRVAR(sys_addaudithook__doc__, "Adds a new audit hook callback."); #define SYS_ADDAUDITHOOK_METHODDEF \ - {"addaudithook", (PyCFunction)(void(*)(void))sys_addaudithook, METH_FASTCALL|METH_KEYWORDS, sys_addaudithook__doc__}, + {"addaudithook", _PyCFunction_CAST(sys_addaudithook), METH_FASTCALL|METH_KEYWORDS, sys_addaudithook__doc__}, static PyObject * sys_addaudithook_impl(PyObject *module, PyObject *hook); @@ -50,7 +50,7 @@ PyDoc_STRVAR(sys_excepthook__doc__, "Handle an exception by displaying it with a traceback on sys.stderr."); #define SYS_EXCEPTHOOK_METHODDEF \ - {"excepthook", (PyCFunction)(void(*)(void))sys_excepthook, METH_FASTCALL, sys_excepthook__doc__}, + {"excepthook", _PyCFunction_CAST(sys_excepthook), METH_FASTCALL, sys_excepthook__doc__}, static PyObject * sys_excepthook_impl(PyObject *module, PyObject *exctype, PyObject *value, @@ -148,7 +148,7 @@ PyDoc_STRVAR(sys_exit__doc__, "exit status will be one (i.e., failure)."); #define SYS_EXIT_METHODDEF \ - {"exit", (PyCFunction)(void(*)(void))sys_exit, METH_FASTCALL, sys_exit__doc__}, + {"exit", _PyCFunction_CAST(sys_exit), METH_FASTCALL, sys_exit__doc__}, static PyObject * sys_exit_impl(PyObject *module, PyObject *status); @@ -416,7 +416,7 @@ PyDoc_STRVAR(sys_set_coroutine_origin_tracking_depth__doc__, "Set a depth of 0 to disable."); #define SYS_SET_COROUTINE_ORIGIN_TRACKING_DEPTH_METHODDEF \ - {"set_coroutine_origin_tracking_depth", (PyCFunction)(void(*)(void))sys_set_coroutine_origin_tracking_depth, METH_FASTCALL|METH_KEYWORDS, sys_set_coroutine_origin_tracking_depth__doc__}, + {"set_coroutine_origin_tracking_depth", _PyCFunction_CAST(sys_set_coroutine_origin_tracking_depth), METH_FASTCALL|METH_KEYWORDS, sys_set_coroutine_origin_tracking_depth__doc__}, static PyObject * sys_set_coroutine_origin_tracking_depth_impl(PyObject *module, int depth); @@ -802,7 +802,7 @@ PyDoc_STRVAR(sys__getframe__doc__, "only."); #define SYS__GETFRAME_METHODDEF \ - {"_getframe", (PyCFunction)(void(*)(void))sys__getframe, METH_FASTCALL, sys__getframe__doc__}, + {"_getframe", _PyCFunction_CAST(sys__getframe), METH_FASTCALL, sys__getframe__doc__}, static PyObject * sys__getframe_impl(PyObject *module, int depth); @@ -881,7 +881,7 @@ PyDoc_STRVAR(sys_call_tracing__doc__, "some other code."); #define SYS_CALL_TRACING_METHODDEF \ - {"call_tracing", (PyCFunction)(void(*)(void))sys_call_tracing, METH_FASTCALL, sys_call_tracing__doc__}, + {"call_tracing", _PyCFunction_CAST(sys_call_tracing), METH_FASTCALL, sys_call_tracing__doc__}, static PyObject * sys_call_tracing_impl(PyObject *module, PyObject *func, PyObject *funcargs); @@ -1014,4 +1014,4 @@ sys_getandroidapilevel(PyObject *module, PyObject *Py_UNUSED(ignored)) #ifndef SYS_GETANDROIDAPILEVEL_METHODDEF #define SYS_GETANDROIDAPILEVEL_METHODDEF #endif /* !defined(SYS_GETANDROIDAPILEVEL_METHODDEF) */ -/*[clinic end generated code: output=60756bc6f683e0c8 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=98efd34fd9b9b6ab input=a9049054013a1b77]*/ diff --git a/Tools/clinic/clinic.py b/Tools/clinic/clinic.py index f660474da94a0..bf0fe5bed5a76 100755 --- a/Tools/clinic/clinic.py +++ b/Tools/clinic/clinic.py @@ -694,7 +694,7 @@ def output_templates(self, f): methoddef_define = normalize_snippet(""" #define {methoddef_name} \\ - {{"{name}", {methoddef_cast}{c_basename}, {methoddef_flags}, {c_basename}__doc__}}, + {{"{name}", {methoddef_cast}{c_basename}{methoddef_cast_end}, {methoddef_flags}, {c_basename}__doc__}}, """) if new_or_init and not f.docstring: docstring_prototype = docstring_definition = '' @@ -1131,14 +1131,17 @@ def parser_body(prototype, *fields, declarations=''): if flags in ('METH_NOARGS', 'METH_O', 'METH_VARARGS'): methoddef_cast = "(PyCFunction)" + methoddef_cast_end = "" else: - methoddef_cast = "(PyCFunction)(void(*)(void))" + methoddef_cast = "_PyCFunction_CAST(" + methoddef_cast_end = ")" if f.methoddef_flags: flags += '|' + f.methoddef_flags methoddef_define = methoddef_define.replace('{methoddef_flags}', flags) methoddef_define = methoddef_define.replace('{methoddef_cast}', methoddef_cast) + methoddef_define = methoddef_define.replace('{methoddef_cast_end}', methoddef_cast_end) methoddef_ifndef = '' conditional = self.cpp.condition() From webhook-mailer at python.org Tue May 3 14:47:33 2022 From: webhook-mailer at python.org (vstinner) Date: Tue, 03 May 2022 18:47:33 -0000 Subject: [Python-checkins] gh-91320: Fix more old-style cast warnings in C++ (#92247) Message-ID: https://github.com/python/cpython/commit/ff3e9cdf334737aeedbbec2e5a219084d27db9cd commit: ff3e9cdf334737aeedbbec2e5a219084d27db9cd branch: main author: Victor Stinner committer: vstinner date: 2022-05-03T20:47:29+02:00 summary: gh-91320: Fix more old-style cast warnings in C++ (#92247) Use _Py_CAST(), _Py_STATIC_CAST() and _PyASCIIObject_CAST() in static inline functions to fix C++ compiler warnings: "use of old-style cast" (clang -Wold-style-cast). test_cppext now builds the C++ test extension with -Wold-style-cast. files: M Include/cpython/unicodeobject.h M Include/cpython/weakrefobject.h M Lib/test/test_cppext.py diff --git a/Include/cpython/unicodeobject.h b/Include/cpython/unicodeobject.h index 47194ac7829fd..96bfaaf4d2bad 100644 --- a/Include/cpython/unicodeobject.h +++ b/Include/cpython/unicodeobject.h @@ -314,16 +314,15 @@ enum PyUnicode_Kind { /* Return one of the PyUnicode_*_KIND values defined above. */ #define PyUnicode_KIND(op) \ - (assert(PyUnicode_Check(op)), \ - assert(PyUnicode_IS_READY(op)), \ - ((PyASCIIObject *)(op))->state.kind) + (assert(PyUnicode_IS_READY(op)), \ + _PyASCIIObject_CAST(op)->state.kind) /* Return a void pointer to the raw unicode buffer. */ static inline void* _PyUnicode_COMPACT_DATA(PyObject *op) { if (PyUnicode_IS_ASCII(op)) { - return (void*)(_PyASCIIObject_CAST(op) + 1); + return _Py_STATIC_CAST(void*, (_PyASCIIObject_CAST(op) + 1)); } - return (void*)(_PyCompactUnicodeObject_CAST(op) + 1); + return _Py_STATIC_CAST(void*, (_PyCompactUnicodeObject_CAST(op) + 1)); } static inline void* _PyUnicode_NONCOMPACT_DATA(PyObject *op) { @@ -348,9 +347,9 @@ static inline void* PyUnicode_DATA(PyObject *op) { No checks are performed, use PyUnicode_KIND() before to ensure these will work correctly. */ -#define PyUnicode_1BYTE_DATA(op) ((Py_UCS1*)PyUnicode_DATA(op)) -#define PyUnicode_2BYTE_DATA(op) ((Py_UCS2*)PyUnicode_DATA(op)) -#define PyUnicode_4BYTE_DATA(op) ((Py_UCS4*)PyUnicode_DATA(op)) +#define PyUnicode_1BYTE_DATA(op) _Py_STATIC_CAST(Py_UCS1*, PyUnicode_DATA(op)) +#define PyUnicode_2BYTE_DATA(op) _Py_STATIC_CAST(Py_UCS2*, PyUnicode_DATA(op)) +#define PyUnicode_4BYTE_DATA(op) _Py_STATIC_CAST(Py_UCS4*, PyUnicode_DATA(op)) /* Returns the length of the unicode string. The caller has to make sure that the string has it's canonical representation set before calling @@ -373,16 +372,16 @@ static inline void PyUnicode_WRITE(unsigned int kind, void *data, { if (kind == PyUnicode_1BYTE_KIND) { assert(value <= 0xffU); - ((Py_UCS1 *)data)[index] = (Py_UCS1)value; + _Py_STATIC_CAST(Py_UCS1*, data)[index] = _Py_STATIC_CAST(Py_UCS1, value); } else if (kind == PyUnicode_2BYTE_KIND) { assert(value <= 0xffffU); - ((Py_UCS2 *)data)[index] = (Py_UCS2)value; + _Py_STATIC_CAST(Py_UCS2*, data)[index] = _Py_STATIC_CAST(Py_UCS2, value); } else { assert(kind == PyUnicode_4BYTE_KIND); assert(value <= 0x10ffffU); - ((Py_UCS4 *)data)[index] = value; + _Py_STATIC_CAST(Py_UCS4*, data)[index] = value; } } #define PyUnicode_WRITE(kind, data, index, value) \ @@ -394,13 +393,13 @@ static inline Py_UCS4 PyUnicode_READ(unsigned int kind, const void *data, Py_ssize_t index) { if (kind == PyUnicode_1BYTE_KIND) { - return ((const Py_UCS1 *)data)[index]; + return _Py_STATIC_CAST(const Py_UCS1*, data)[index]; } if (kind == PyUnicode_2BYTE_KIND) { - return ((const Py_UCS2 *)data)[index]; + return _Py_STATIC_CAST(const Py_UCS2*, data)[index]; } assert(kind == PyUnicode_4BYTE_KIND); - return ((const Py_UCS4 *)data)[index]; + return _Py_STATIC_CAST(const Py_UCS4*, data)[index]; } #define PyUnicode_READ(kind, data, index) \ PyUnicode_READ((unsigned int)(kind), (const void*)(data), (index)) @@ -693,7 +692,9 @@ static inline const char* PyUnicode_AS_DATA(PyObject *op) { _Py_COMP_DIAG_PUSH _Py_COMP_DIAG_IGNORE_DEPR_DECLS - return (const char *)PyUnicode_AS_UNICODE(op); + Py_UNICODE *data = PyUnicode_AS_UNICODE(op); + // In C++, casting directly PyUnicode* to const char* is not valid + return _Py_STATIC_CAST(const char*, _Py_STATIC_CAST(const void*, data)); _Py_COMP_DIAG_POP } #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 diff --git a/Include/cpython/weakrefobject.h b/Include/cpython/weakrefobject.h index 1078fffc2e0a5..bec69ba90d6b9 100644 --- a/Include/cpython/weakrefobject.h +++ b/Include/cpython/weakrefobject.h @@ -38,7 +38,7 @@ PyAPI_FUNC(void) _PyWeakref_ClearRef(PyWeakReference *self); static inline PyObject* PyWeakref_GET_OBJECT(PyObject *ref_obj) { assert(PyWeakref_Check(ref_obj)); - PyWeakReference *ref = (PyWeakReference *)ref_obj; + PyWeakReference *ref = _Py_CAST(PyWeakReference*, ref_obj); PyObject *obj = ref->wr_object; // Explanation for the Py_REFCNT() check: when a weakref's target is part // of a long chain of deallocations which triggers the trashcan mechanism, diff --git a/Lib/test/test_cppext.py b/Lib/test/test_cppext.py index 99f6062d79d47..fbb79bb8ac3ed 100644 --- a/Lib/test/test_cppext.py +++ b/Lib/test/test_cppext.py @@ -27,6 +27,8 @@ # a C++ extension using the Python C API does not emit C++ compiler # warnings '-Werror', + # Warn on old-style cast (C cast) like: (PyObject*)op + '-Wold-style-cast', ] else: # Don't pass any compiler flag to MSVC From webhook-mailer at python.org Tue May 3 15:17:55 2022 From: webhook-mailer at python.org (JelleZijlstra) Date: Tue, 03 May 2022 19:17:55 -0000 Subject: [Python-checkins] gh-90172: add test for functools.singledispatch on Union types with None type (#92174) Message-ID: https://github.com/python/cpython/commit/f03d3dd9afd5a2df8ffb6db80c0bb45f2d8909f5 commit: f03d3dd9afd5a2df8ffb6db80c0bb45f2d8909f5 branch: main author: Thaddeus1499 <104600742+Thaddeus1499 at users.noreply.github.com> committer: JelleZijlstra date: 2022-05-03T13:17:43-06:00 summary: gh-90172: add test for functools.singledispatch on Union types with None type (#92174) Signed-off-by: prwatson Co-authored-by: Jelle Zijlstra files: M Lib/test/test_functools.py diff --git a/Lib/test/test_functools.py b/Lib/test/test_functools.py index e3c065615778f..382e7dbffddf9 100644 --- a/Lib/test/test_functools.py +++ b/Lib/test/test_functools.py @@ -2792,6 +2792,49 @@ def _(arg: int | float): self.assertEqual(f(1), "types.UnionType") self.assertEqual(f(1.0), "types.UnionType") + def test_union_conflict(self): + @functools.singledispatch + def f(arg): + return "default" + + @f.register + def _(arg: typing.Union[str, bytes]): + return "typing.Union" + + @f.register + def _(arg: int | str): + return "types.UnionType" + + self.assertEqual(f([]), "default") + self.assertEqual(f(""), "types.UnionType") # last one wins + self.assertEqual(f(b""), "typing.Union") + self.assertEqual(f(1), "types.UnionType") + + def test_union_None(self): + @functools.singledispatch + def typing_union(arg): + return "default" + + @typing_union.register + def _(arg: typing.Union[str, None]): + return "typing.Union" + + self.assertEqual(typing_union(1), "default") + self.assertEqual(typing_union(""), "typing.Union") + self.assertEqual(typing_union(None), "typing.Union") + + @functools.singledispatch + def types_union(arg): + return "default" + + @types_union.register + def _(arg: int | None): + return "types.UnionType" + + self.assertEqual(types_union(""), "default") + self.assertEqual(types_union(1), "types.UnionType") + self.assertEqual(types_union(None), "types.UnionType") + def test_register_genericalias(self): @functools.singledispatch def f(arg): From webhook-mailer at python.org Tue May 3 15:18:39 2022 From: webhook-mailer at python.org (ericsnowcurrently) Date: Tue, 03 May 2022 19:18:39 -0000 Subject: [Python-checkins] gh-81057: Get the c-analyzer tool working again. (gh-92246) Message-ID: https://github.com/python/cpython/commit/456cd513e360ccd17e51ae3711ec48976b1be0c0 commit: 456cd513e360ccd17e51ae3711ec48976b1be0c0 branch: main author: Eric Snow committer: ericsnowcurrently date: 2022-05-03T13:18:27-06:00 summary: gh-81057: Get the c-analyzer tool working again. (gh-92246) files: M Tools/c-analyzer/c_parser/info.py M Tools/c-analyzer/c_parser/parser/_compound_decl_body.py M Tools/c-analyzer/c_parser/parser/_regexes.py M Tools/c-analyzer/cpython/_parser.py diff --git a/Tools/c-analyzer/c_parser/info.py b/Tools/c-analyzer/c_parser/info.py index 697b1f26dc215..bbfbff7e62d02 100644 --- a/Tools/c-analyzer/c_parser/info.py +++ b/Tools/c-analyzer/c_parser/info.py @@ -1161,7 +1161,9 @@ def from_data(cls, raw, index): vartype = dict(raw.data) del vartype['storage'] if 'size' in vartype: - size = int(vartype.pop('size')) + size = vartype.pop('size') + if isinstance(size, str) and size.isdigit(): + size = int(size) vartype = VarType(**vartype) return cls(name, vartype, size) diff --git a/Tools/c-analyzer/c_parser/parser/_compound_decl_body.py b/Tools/c-analyzer/c_parser/parser/_compound_decl_body.py index eb5bc67607bb1..67528d2279896 100644 --- a/Tools/c-analyzer/c_parser/parser/_compound_decl_body.py +++ b/Tools/c-analyzer/c_parser/parser/_compound_decl_body.py @@ -99,7 +99,7 @@ def parse_body(source): name = anon_name('struct-field-') if size: # data = (data, size) - data['size'] = int(size) + data['size'] = int(size) if size.isdigit() else size else: # This shouldn't happen (we expect each field to have a name). raise NotImplementedError diff --git a/Tools/c-analyzer/c_parser/parser/_regexes.py b/Tools/c-analyzer/c_parser/parser/_regexes.py index cb85a59aaa16c..b7f22b186f496 100644 --- a/Tools/c-analyzer/c_parser/parser/_regexes.py +++ b/Tools/c-analyzer/c_parser/parser/_regexes.py @@ -176,6 +176,7 @@ def _ind(text, level=1, edges='both'): (?: # {STRICT_IDENTIFIER} ) + # Inside the brackets is actually a "constant expression". (?: \s* \[ (?: \s* [^\]]+ \s* )? [\]] )* # arrays ) | @@ -184,6 +185,7 @@ def _ind(text, level=1, edges='both'): (?: # {STRICT_IDENTIFIER} ) + # Inside the brackets is actually a "constant expression". (?: \s* \[ (?: \s* [^\]]+ \s* )? [\]] )* # arrays \s* [)] ) @@ -194,6 +196,7 @@ def _ind(text, level=1, edges='both'): (?: # {STRICT_IDENTIFIER} ) + # Inside the brackets is actually a "constant expression". (?: \s* \[ (?: \s* [^\]]+ \s* )? [\]] )* # arrays \s* [)] # We allow for a single level of paren nesting in parameters. @@ -322,7 +325,10 @@ def _ind(text, level=1, edges='both'): (?: \s* [:] \s* (?: # + # This is actually a "constant expression". \d+ + | + [^'",}}]+ ) )? \s* @@ -357,6 +363,7 @@ def _ind(text, level=1, edges='both'): (?: \s* = \s* (?: # + # This is actually a "constant expression". {_ind(STRING_LITERAL, 4)} | [^'",}}]+ diff --git a/Tools/c-analyzer/cpython/_parser.py b/Tools/c-analyzer/cpython/_parser.py index 19000096fc9c3..eaad7278ed79e 100644 --- a/Tools/c-analyzer/cpython/_parser.py +++ b/Tools/c-analyzer/cpython/_parser.py @@ -46,6 +46,7 @@ def clean_lines(text): @end=sh@ ''' +# XXX Handle these. EXCLUDED = clean_lines(''' # @begin=conf@ @@ -69,6 +70,7 @@ def clean_lines(text): Python/dynload_dl.c # dl.h Python/dynload_hpux.c # dl.h Python/thread_pthread.h +Python/emscripten_signal.c # only huge constants (safe but parsing is slow) Modules/_blake2/impl/blake2-kat.h @@ -202,6 +204,7 @@ def clean_lines(text): Include/cpython/traceback.h Py_CPYTHON_TRACEBACK_H 1 Include/cpython/tupleobject.h Py_CPYTHON_TUPLEOBJECT_H 1 Include/cpython/unicodeobject.h Py_CPYTHON_UNICODEOBJECT_H 1 +Include/internal/pycore_code.h SIZEOF_VOID_P 8 # implied include of pyport.h Include/**/*.h PyAPI_DATA(RTYPE) extern RTYPE @@ -297,8 +300,8 @@ def clean_lines(text): _abs('Objects/stringlib/unicode_format.h'): (10_000, 400), _abs('Objects/typeobject.c'): (20_000, 200), _abs('Python/compile.c'): (20_000, 500), - _abs('Python/pylifecycle.c'): (200_000, 5000), - _abs('Python/pystate.c'): (200_000, 5000), + _abs('Python/pylifecycle.c'): (500_000, 5000), + _abs('Python/pystate.c'): (500_000, 5000), } From webhook-mailer at python.org Tue May 3 15:38:41 2022 From: webhook-mailer at python.org (vstinner) Date: Tue, 03 May 2022 19:38:41 -0000 Subject: [Python-checkins] gh-91321: Add _Py_NULL macro (#92253) Message-ID: https://github.com/python/cpython/commit/551d02b3e697098236bb3a6e0a855b2ad8dc0424 commit: 551d02b3e697098236bb3a6e0a855b2ad8dc0424 branch: main author: Victor Stinner committer: vstinner date: 2022-05-03T21:38:37+02:00 summary: gh-91321: Add _Py_NULL macro (#92253) Fix C++ compiler warnings: "zero as null pointer constant" (clang -Wzero-as-null-pointer-constant). * Add the _Py_NULL macro used by static inline functions to use nullptr in C++. * Replace NULL with nullptr in _testcppext.cpp. files: M Include/cpython/abstract.h M Include/cpython/unicodeobject.h M Include/object.h M Include/pyport.h M Lib/test/_testcppext.cpp M Lib/test/test_cppext.py diff --git a/Include/cpython/abstract.h b/Include/cpython/abstract.h index 77e2cfa02ed07..161e2cb30fde3 100644 --- a/Include/cpython/abstract.h +++ b/Include/cpython/abstract.h @@ -103,8 +103,8 @@ PyAPI_FUNC(PyObject *) PyObject_VectorcallMethod( static inline PyObject * PyObject_CallMethodNoArgs(PyObject *self, PyObject *name) { - return PyObject_VectorcallMethod(name, &self, - 1 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL); + size_t nargsf = 1 | PY_VECTORCALL_ARGUMENTS_OFFSET; + return PyObject_VectorcallMethod(name, &self, nargsf, _Py_NULL); } static inline PyObject * @@ -113,8 +113,8 @@ PyObject_CallMethodOneArg(PyObject *self, PyObject *name, PyObject *arg) PyObject *args[2] = {self, arg}; assert(arg != NULL); - return PyObject_VectorcallMethod(name, args, - 2 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL); + size_t nargsf = 2 | PY_VECTORCALL_ARGUMENTS_OFFSET; + return PyObject_VectorcallMethod(name, args, nargsf, _Py_NULL); } PyAPI_FUNC(PyObject *) _PyObject_CallMethod(PyObject *obj, @@ -144,7 +144,7 @@ _PyObject_VectorcallMethodId( { PyObject *oname = _PyUnicode_FromId(name); /* borrowed */ if (!oname) { - return NULL; + return _Py_NULL; } return PyObject_VectorcallMethod(oname, args, nargsf, kwnames); } @@ -152,8 +152,8 @@ _PyObject_VectorcallMethodId( static inline PyObject * _PyObject_CallMethodIdNoArgs(PyObject *self, _Py_Identifier *name) { - return _PyObject_VectorcallMethodId(name, &self, - 1 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL); + size_t nargsf = 1 | PY_VECTORCALL_ARGUMENTS_OFFSET; + return _PyObject_VectorcallMethodId(name, &self, nargsf, _Py_NULL); } static inline PyObject * @@ -162,8 +162,8 @@ _PyObject_CallMethodIdOneArg(PyObject *self, _Py_Identifier *name, PyObject *arg PyObject *args[2] = {self, arg}; assert(arg != NULL); - return _PyObject_VectorcallMethodId(name, args, - 2 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL); + size_t nargsf = 2 | PY_VECTORCALL_ARGUMENTS_OFFSET; + return _PyObject_VectorcallMethodId(name, args, nargsf, _Py_NULL); } PyAPI_FUNC(int) _PyObject_HasLen(PyObject *o); diff --git a/Include/cpython/unicodeobject.h b/Include/cpython/unicodeobject.h index 96bfaaf4d2bad..8e182d0fbf799 100644 --- a/Include/cpython/unicodeobject.h +++ b/Include/cpython/unicodeobject.h @@ -642,9 +642,9 @@ static inline Py_ssize_t PyUnicode_GET_SIZE(PyObject *op) { _Py_COMP_DIAG_PUSH _Py_COMP_DIAG_IGNORE_DEPR_DECLS - if (_PyASCIIObject_CAST(op)->wstr == NULL) { + if (_PyASCIIObject_CAST(op)->wstr == _Py_NULL) { (void)PyUnicode_AsUnicode(op); - assert(_PyASCIIObject_CAST(op)->wstr != NULL); + assert(_PyASCIIObject_CAST(op)->wstr != _Py_NULL); } return PyUnicode_WSTR_LENGTH(op); _Py_COMP_DIAG_POP @@ -674,7 +674,7 @@ Py_DEPRECATED(3.3) static inline Py_UNICODE* PyUnicode_AS_UNICODE(PyObject *op) { wchar_t *wstr = _PyASCIIObject_CAST(op)->wstr; - if (wstr != NULL) { + if (wstr != _Py_NULL) { return wstr; } diff --git a/Include/object.h b/Include/object.h index f93ecce13b409..a0dba697569c4 100644 --- a/Include/object.h +++ b/Include/object.h @@ -587,7 +587,7 @@ static inline void Py_DECREF(PyObject *op) /* Function to use in case the object pointer can be NULL: */ static inline void Py_XINCREF(PyObject *op) { - if (op != NULL) { + if (op != _Py_NULL) { Py_INCREF(op); } } @@ -597,7 +597,7 @@ static inline void Py_XINCREF(PyObject *op) static inline void Py_XDECREF(PyObject *op) { - if (op != NULL) { + if (op != _Py_NULL) { Py_DECREF(op); } } diff --git a/Include/pyport.h b/Include/pyport.h index f6270be0ce5c0..614a2789fb078 100644 --- a/Include/pyport.h +++ b/Include/pyport.h @@ -33,6 +33,14 @@ # define _Py_CAST(type, expr) ((type)(expr)) #endif +// Static inline functions should use _Py_NULL rather than using directly NULL +// to prevent C++ compiler warnings. In C++, _Py_NULL uses nullptr. +#ifdef __cplusplus +# define _Py_NULL nullptr +#else +# define _Py_NULL NULL +#endif + /* Defines to build Python and its standard library: * diff --git a/Lib/test/_testcppext.cpp b/Lib/test/_testcppext.cpp index 257843bfc7726..dc40f0ee9eb1c 100644 --- a/Lib/test/_testcppext.cpp +++ b/Lib/test/_testcppext.cpp @@ -52,7 +52,7 @@ test_api_casts(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args)) static PyMethodDef _testcppext_methods[] = { {"add", _testcppext_add, METH_VARARGS, _testcppext_add_doc}, - {"test_api_casts", test_api_casts, METH_NOARGS, NULL}, + {"test_api_casts", test_api_casts, METH_NOARGS, nullptr}, {nullptr, nullptr, 0, nullptr} /* sentinel */ }; @@ -68,7 +68,7 @@ _testcppext_exec(PyObject *module) static PyModuleDef_Slot _testcppext_slots[] = { {Py_mod_exec, reinterpret_cast(_testcppext_exec)}, - {0, NULL} + {0, nullptr} }; @@ -81,8 +81,8 @@ static struct PyModuleDef _testcppext_module = { 0, // m_size _testcppext_methods, // m_methods _testcppext_slots, // m_slots - NULL, // m_traverse - NULL, // m_clear + nullptr, // m_traverse + nullptr, // m_clear nullptr, // m_free }; diff --git a/Lib/test/test_cppext.py b/Lib/test/test_cppext.py index fbb79bb8ac3ed..e056410456630 100644 --- a/Lib/test/test_cppext.py +++ b/Lib/test/test_cppext.py @@ -29,6 +29,8 @@ '-Werror', # Warn on old-style cast (C cast) like: (PyObject*)op '-Wold-style-cast', + # Warn when using NULL rather than _Py_NULL in static inline functions + '-Wzero-as-null-pointer-constant', ] else: # Don't pass any compiler flag to MSVC From webhook-mailer at python.org Tue May 3 15:42:20 2022 From: webhook-mailer at python.org (vstinner) Date: Tue, 03 May 2022 19:42:20 -0000 Subject: [Python-checkins] gh-91320: Use _PyCFunction_CAST() (#92251) Message-ID: https://github.com/python/cpython/commit/804f2529d8e545a8d59eaf260ee032d014e681ba commit: 804f2529d8e545a8d59eaf260ee032d014e681ba branch: main author: Victor Stinner committer: vstinner date: 2022-05-03T21:42:14+02:00 summary: gh-91320: Use _PyCFunction_CAST() (#92251) Replace "(PyCFunction)(void(*)(void))func" cast with _PyCFunction_CAST(func). Change generated by the command: sed -i -e \ 's!(PyCFunction)(void(\*)(void)) *\([A-Za-z0-9_]\+\)!_PyCFunction_CAST(\1)!g' \ $(find -name "*.c") files: M Modules/_asynciomodule.c M Modules/_collectionsmodule.c M Modules/_csv.c M Modules/_datetimemodule.c M Modules/_decimal/_decimal.c M Modules/_elementtree.c M Modules/_functoolsmodule.c M Modules/_lsprof.c M Modules/_operator.c M Modules/_struct.c M Modules/_testbuffer.c M Modules/_testcapimodule.c M Modules/_testmultiphase.c M Modules/_threadmodule.c M Modules/_xxsubinterpretersmodule.c M Modules/atexitmodule.c M Modules/faulthandler.c M Modules/mathmodule.c M Modules/nismodule.c M Modules/signalmodule.c M Modules/socketmodule.c M Modules/syslogmodule.c M Modules/xxlimited.c M Modules/xxsubtype.c M Objects/descrobject.c M Objects/dictobject.c M Objects/genobject.c M Objects/odictobject.c M Objects/typeobject.c M Objects/unicodeobject.c M Tools/peg_generator/peg_extension/peg_extension.c diff --git a/Modules/_asynciomodule.c b/Modules/_asynciomodule.c index d8d3da91cdd8e..5fa722305757d 100644 --- a/Modules/_asynciomodule.c +++ b/Modules/_asynciomodule.c @@ -1724,7 +1724,7 @@ FutureIter_traverse(futureiterobject *it, visitproc visit, void *arg) static PyMethodDef FutureIter_methods[] = { {"send", (PyCFunction)FutureIter_send, METH_O, NULL}, - {"throw", (PyCFunction)(void(*)(void))FutureIter_throw, METH_FASTCALL, NULL}, + {"throw", _PyCFunction_CAST(FutureIter_throw), METH_FASTCALL, NULL}, {"close", (PyCFunction)FutureIter_close, METH_NOARGS, NULL}, {NULL, NULL} /* Sentinel */ }; diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c index 18c762b21754b..741cfbe9dc614 100644 --- a/Modules/_collectionsmodule.c +++ b/Modules/_collectionsmodule.c @@ -1588,9 +1588,9 @@ static PyMethodDef deque_methods[] = { METH_O, extend_doc}, {"extendleft", (PyCFunction)deque_extendleft, METH_O, extendleft_doc}, - {"index", (PyCFunction)(void(*)(void))deque_index, + {"index", _PyCFunction_CAST(deque_index), METH_FASTCALL, index_doc}, - {"insert", (PyCFunction)(void(*)(void))deque_insert, + {"insert", _PyCFunction_CAST(deque_insert), METH_FASTCALL, insert_doc}, {"pop", (PyCFunction)deque_pop, METH_NOARGS, pop_doc}, @@ -1604,7 +1604,7 @@ static PyMethodDef deque_methods[] = { METH_NOARGS, reversed_doc}, {"reverse", (PyCFunction)deque_reverse, METH_NOARGS, reverse_doc}, - {"rotate", (PyCFunction)(void(*)(void))deque_rotate, + {"rotate", _PyCFunction_CAST(deque_rotate), METH_FASTCALL, rotate_doc}, {"__sizeof__", (PyCFunction)deque_sizeof, METH_NOARGS, sizeof_doc}, diff --git a/Modules/_csv.c b/Modules/_csv.c index 4d68df54a0cb0..cbf4c5de51968 100644 --- a/Modules/_csv.c +++ b/Modules/_csv.c @@ -1704,11 +1704,11 @@ PyDoc_STRVAR(csv_register_dialect_doc, " dialect = csv.register_dialect(name[, dialect[, **fmtparams]])"); static struct PyMethodDef csv_methods[] = { - { "reader", (PyCFunction)(void(*)(void))csv_reader, + { "reader", _PyCFunction_CAST(csv_reader), METH_VARARGS | METH_KEYWORDS, csv_reader_doc}, - { "writer", (PyCFunction)(void(*)(void))csv_writer, + { "writer", _PyCFunction_CAST(csv_writer), METH_VARARGS | METH_KEYWORDS, csv_writer_doc}, - { "register_dialect", (PyCFunction)(void(*)(void))csv_register_dialect, + { "register_dialect", _PyCFunction_CAST(csv_register_dialect), METH_VARARGS | METH_KEYWORDS, csv_register_dialect_doc}, _CSV_LIST_DIALECTS_METHODDEF _CSV_UNREGISTER_DIALECT_METHODDEF diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c index a35c72395ec95..24c2198893a37 100644 --- a/Modules/_datetimemodule.c +++ b/Modules/_datetimemodule.c @@ -3491,7 +3491,7 @@ static PyMethodDef date_methods[] = { METH_CLASS, PyDoc_STR("str -> Construct a date from the output of date.isoformat()")}, - {"fromisocalendar", (PyCFunction)(void(*)(void))date_fromisocalendar, + {"fromisocalendar", _PyCFunction_CAST(date_fromisocalendar), METH_VARARGS | METH_KEYWORDS | METH_CLASS, PyDoc_STR("int, int, int -> Construct a date from the ISO year, week " "number and weekday.\n\n" @@ -3506,7 +3506,7 @@ static PyMethodDef date_methods[] = { {"ctime", (PyCFunction)date_ctime, METH_NOARGS, PyDoc_STR("Return ctime() style string.")}, - {"strftime", (PyCFunction)(void(*)(void))date_strftime, METH_VARARGS | METH_KEYWORDS, + {"strftime", _PyCFunction_CAST(date_strftime), METH_VARARGS | METH_KEYWORDS, PyDoc_STR("format -> strftime() style string.")}, {"__format__", (PyCFunction)date_format, METH_VARARGS, @@ -3534,7 +3534,7 @@ static PyMethodDef date_methods[] = { PyDoc_STR("Return the day of the week represented by the date.\n" "Monday == 0 ... Sunday == 6")}, - {"replace", (PyCFunction)(void(*)(void))date_replace, METH_VARARGS | METH_KEYWORDS, + {"replace", _PyCFunction_CAST(date_replace), METH_VARARGS | METH_KEYWORDS, PyDoc_STR("Return date with new specified fields.")}, {"__reduce__", (PyCFunction)date_reduce, METH_NOARGS, @@ -4644,7 +4644,7 @@ time_reduce(PyDateTime_Time *self, PyObject *arg) static PyMethodDef time_methods[] = { - {"isoformat", (PyCFunction)(void(*)(void))time_isoformat, METH_VARARGS | METH_KEYWORDS, + {"isoformat", _PyCFunction_CAST(time_isoformat), METH_VARARGS | METH_KEYWORDS, PyDoc_STR("Return string in ISO 8601 format, [HH[:MM[:SS[.mmm[uuu]]]]]" "[+HH:MM].\n\n" "The optional argument timespec specifies the number " @@ -4652,7 +4652,7 @@ static PyMethodDef time_methods[] = { "options are 'auto', 'hours', 'minutes',\n'seconds', " "'milliseconds' and 'microseconds'.\n")}, - {"strftime", (PyCFunction)(void(*)(void))time_strftime, METH_VARARGS | METH_KEYWORDS, + {"strftime", _PyCFunction_CAST(time_strftime), METH_VARARGS | METH_KEYWORDS, PyDoc_STR("format -> strftime() style string.")}, {"__format__", (PyCFunction)date_format, METH_VARARGS, @@ -4667,7 +4667,7 @@ static PyMethodDef time_methods[] = { {"dst", (PyCFunction)time_dst, METH_NOARGS, PyDoc_STR("Return self.tzinfo.dst(self).")}, - {"replace", (PyCFunction)(void(*)(void))time_replace, METH_VARARGS | METH_KEYWORDS, + {"replace", _PyCFunction_CAST(time_replace), METH_VARARGS | METH_KEYWORDS, PyDoc_STR("Return time with new specified fields.")}, {"fromisoformat", (PyCFunction)time_fromisoformat, METH_O | METH_CLASS, @@ -6308,7 +6308,7 @@ static PyMethodDef datetime_methods[] = { METH_NOARGS | METH_CLASS, PyDoc_STR("Return a new datetime representing UTC day and time.")}, - {"fromtimestamp", (PyCFunction)(void(*)(void))datetime_fromtimestamp, + {"fromtimestamp", _PyCFunction_CAST(datetime_fromtimestamp), METH_VARARGS | METH_KEYWORDS | METH_CLASS, PyDoc_STR("timestamp[, tz] -> tz's local time from POSIX timestamp.")}, @@ -6321,7 +6321,7 @@ static PyMethodDef datetime_methods[] = { PyDoc_STR("string, format -> new datetime parsed from a string " "(like time.strptime()).")}, - {"combine", (PyCFunction)(void(*)(void))datetime_combine, + {"combine", _PyCFunction_CAST(datetime_combine), METH_VARARGS | METH_KEYWORDS | METH_CLASS, PyDoc_STR("date, time -> datetime with same date and time fields")}, @@ -6352,7 +6352,7 @@ static PyMethodDef datetime_methods[] = { {"utctimetuple", (PyCFunction)datetime_utctimetuple, METH_NOARGS, PyDoc_STR("Return UTC time tuple, compatible with time.localtime().")}, - {"isoformat", (PyCFunction)(void(*)(void))datetime_isoformat, METH_VARARGS | METH_KEYWORDS, + {"isoformat", _PyCFunction_CAST(datetime_isoformat), METH_VARARGS | METH_KEYWORDS, PyDoc_STR("[sep] -> string in ISO 8601 format, " "YYYY-MM-DDT[HH[:MM[:SS[.mmm[uuu]]]]][+HH:MM].\n" "sep is used to separate the year from the time, and " @@ -6371,10 +6371,10 @@ static PyMethodDef datetime_methods[] = { {"dst", (PyCFunction)datetime_dst, METH_NOARGS, PyDoc_STR("Return self.tzinfo.dst(self).")}, - {"replace", (PyCFunction)(void(*)(void))datetime_replace, METH_VARARGS | METH_KEYWORDS, + {"replace", _PyCFunction_CAST(datetime_replace), METH_VARARGS | METH_KEYWORDS, PyDoc_STR("Return datetime with new specified fields.")}, - {"astimezone", (PyCFunction)(void(*)(void))datetime_astimezone, METH_VARARGS | METH_KEYWORDS, + {"astimezone", _PyCFunction_CAST(datetime_astimezone), METH_VARARGS | METH_KEYWORDS, PyDoc_STR("tz -> convert to local time in new timezone tz\n")}, {"__reduce_ex__", (PyCFunction)datetime_reduce_ex, METH_VARARGS, diff --git a/Modules/_decimal/_decimal.c b/Modules/_decimal/_decimal.c index 8c08847328bc0..65885965ff046 100644 --- a/Modules/_decimal/_decimal.c +++ b/Modules/_decimal/_decimal.c @@ -4904,30 +4904,30 @@ static PyNumberMethods dec_number_methods = static PyMethodDef dec_methods [] = { /* Unary arithmetic functions, optional context arg */ - { "exp", (PyCFunction)(void(*)(void))dec_mpd_qexp, METH_VARARGS|METH_KEYWORDS, doc_exp }, - { "ln", (PyCFunction)(void(*)(void))dec_mpd_qln, METH_VARARGS|METH_KEYWORDS, doc_ln }, - { "log10", (PyCFunction)(void(*)(void))dec_mpd_qlog10, METH_VARARGS|METH_KEYWORDS, doc_log10 }, - { "next_minus", (PyCFunction)(void(*)(void))dec_mpd_qnext_minus, METH_VARARGS|METH_KEYWORDS, doc_next_minus }, - { "next_plus", (PyCFunction)(void(*)(void))dec_mpd_qnext_plus, METH_VARARGS|METH_KEYWORDS, doc_next_plus }, - { "normalize", (PyCFunction)(void(*)(void))dec_mpd_qreduce, METH_VARARGS|METH_KEYWORDS, doc_normalize }, - { "to_integral", (PyCFunction)(void(*)(void))PyDec_ToIntegralValue, METH_VARARGS|METH_KEYWORDS, doc_to_integral }, - { "to_integral_exact", (PyCFunction)(void(*)(void))PyDec_ToIntegralExact, METH_VARARGS|METH_KEYWORDS, doc_to_integral_exact }, - { "to_integral_value", (PyCFunction)(void(*)(void))PyDec_ToIntegralValue, METH_VARARGS|METH_KEYWORDS, doc_to_integral_value }, - { "sqrt", (PyCFunction)(void(*)(void))dec_mpd_qsqrt, METH_VARARGS|METH_KEYWORDS, doc_sqrt }, + { "exp", _PyCFunction_CAST(dec_mpd_qexp), METH_VARARGS|METH_KEYWORDS, doc_exp }, + { "ln", _PyCFunction_CAST(dec_mpd_qln), METH_VARARGS|METH_KEYWORDS, doc_ln }, + { "log10", _PyCFunction_CAST(dec_mpd_qlog10), METH_VARARGS|METH_KEYWORDS, doc_log10 }, + { "next_minus", _PyCFunction_CAST(dec_mpd_qnext_minus), METH_VARARGS|METH_KEYWORDS, doc_next_minus }, + { "next_plus", _PyCFunction_CAST(dec_mpd_qnext_plus), METH_VARARGS|METH_KEYWORDS, doc_next_plus }, + { "normalize", _PyCFunction_CAST(dec_mpd_qreduce), METH_VARARGS|METH_KEYWORDS, doc_normalize }, + { "to_integral", _PyCFunction_CAST(PyDec_ToIntegralValue), METH_VARARGS|METH_KEYWORDS, doc_to_integral }, + { "to_integral_exact", _PyCFunction_CAST(PyDec_ToIntegralExact), METH_VARARGS|METH_KEYWORDS, doc_to_integral_exact }, + { "to_integral_value", _PyCFunction_CAST(PyDec_ToIntegralValue), METH_VARARGS|METH_KEYWORDS, doc_to_integral_value }, + { "sqrt", _PyCFunction_CAST(dec_mpd_qsqrt), METH_VARARGS|METH_KEYWORDS, doc_sqrt }, /* Binary arithmetic functions, optional context arg */ - { "compare", (PyCFunction)(void(*)(void))dec_mpd_qcompare, METH_VARARGS|METH_KEYWORDS, doc_compare }, - { "compare_signal", (PyCFunction)(void(*)(void))dec_mpd_qcompare_signal, METH_VARARGS|METH_KEYWORDS, doc_compare_signal }, - { "max", (PyCFunction)(void(*)(void))dec_mpd_qmax, METH_VARARGS|METH_KEYWORDS, doc_max }, - { "max_mag", (PyCFunction)(void(*)(void))dec_mpd_qmax_mag, METH_VARARGS|METH_KEYWORDS, doc_max_mag }, - { "min", (PyCFunction)(void(*)(void))dec_mpd_qmin, METH_VARARGS|METH_KEYWORDS, doc_min }, - { "min_mag", (PyCFunction)(void(*)(void))dec_mpd_qmin_mag, METH_VARARGS|METH_KEYWORDS, doc_min_mag }, - { "next_toward", (PyCFunction)(void(*)(void))dec_mpd_qnext_toward, METH_VARARGS|METH_KEYWORDS, doc_next_toward }, - { "quantize", (PyCFunction)(void(*)(void))dec_mpd_qquantize, METH_VARARGS|METH_KEYWORDS, doc_quantize }, - { "remainder_near", (PyCFunction)(void(*)(void))dec_mpd_qrem_near, METH_VARARGS|METH_KEYWORDS, doc_remainder_near }, + { "compare", _PyCFunction_CAST(dec_mpd_qcompare), METH_VARARGS|METH_KEYWORDS, doc_compare }, + { "compare_signal", _PyCFunction_CAST(dec_mpd_qcompare_signal), METH_VARARGS|METH_KEYWORDS, doc_compare_signal }, + { "max", _PyCFunction_CAST(dec_mpd_qmax), METH_VARARGS|METH_KEYWORDS, doc_max }, + { "max_mag", _PyCFunction_CAST(dec_mpd_qmax_mag), METH_VARARGS|METH_KEYWORDS, doc_max_mag }, + { "min", _PyCFunction_CAST(dec_mpd_qmin), METH_VARARGS|METH_KEYWORDS, doc_min }, + { "min_mag", _PyCFunction_CAST(dec_mpd_qmin_mag), METH_VARARGS|METH_KEYWORDS, doc_min_mag }, + { "next_toward", _PyCFunction_CAST(dec_mpd_qnext_toward), METH_VARARGS|METH_KEYWORDS, doc_next_toward }, + { "quantize", _PyCFunction_CAST(dec_mpd_qquantize), METH_VARARGS|METH_KEYWORDS, doc_quantize }, + { "remainder_near", _PyCFunction_CAST(dec_mpd_qrem_near), METH_VARARGS|METH_KEYWORDS, doc_remainder_near }, /* Ternary arithmetic functions, optional context arg */ - { "fma", (PyCFunction)(void(*)(void))dec_mpd_qfma, METH_VARARGS|METH_KEYWORDS, doc_fma }, + { "fma", _PyCFunction_CAST(dec_mpd_qfma), METH_VARARGS|METH_KEYWORDS, doc_fma }, /* Boolean functions, no context arg */ { "is_canonical", dec_mpd_iscanonical, METH_NOARGS, doc_is_canonical }, @@ -4940,8 +4940,8 @@ static PyMethodDef dec_methods [] = { "is_zero", dec_mpd_iszero, METH_NOARGS, doc_is_zero }, /* Boolean functions, optional context arg */ - { "is_normal", (PyCFunction)(void(*)(void))dec_mpd_isnormal, METH_VARARGS|METH_KEYWORDS, doc_is_normal }, - { "is_subnormal", (PyCFunction)(void(*)(void))dec_mpd_issubnormal, METH_VARARGS|METH_KEYWORDS, doc_is_subnormal }, + { "is_normal", _PyCFunction_CAST(dec_mpd_isnormal), METH_VARARGS|METH_KEYWORDS, doc_is_normal }, + { "is_subnormal", _PyCFunction_CAST(dec_mpd_issubnormal), METH_VARARGS|METH_KEYWORDS, doc_is_subnormal }, /* Unary functions, no context arg */ { "adjusted", dec_mpd_adjexp, METH_NOARGS, doc_adjusted }, @@ -4954,24 +4954,24 @@ static PyMethodDef dec_methods [] = { "copy_negate", dec_mpd_qcopy_negate, METH_NOARGS, doc_copy_negate }, /* Unary functions, optional context arg */ - { "logb", (PyCFunction)(void(*)(void))dec_mpd_qlogb, METH_VARARGS|METH_KEYWORDS, doc_logb }, - { "logical_invert", (PyCFunction)(void(*)(void))dec_mpd_qinvert, METH_VARARGS|METH_KEYWORDS, doc_logical_invert }, - { "number_class", (PyCFunction)(void(*)(void))dec_mpd_class, METH_VARARGS|METH_KEYWORDS, doc_number_class }, - { "to_eng_string", (PyCFunction)(void(*)(void))dec_mpd_to_eng, METH_VARARGS|METH_KEYWORDS, doc_to_eng_string }, + { "logb", _PyCFunction_CAST(dec_mpd_qlogb), METH_VARARGS|METH_KEYWORDS, doc_logb }, + { "logical_invert", _PyCFunction_CAST(dec_mpd_qinvert), METH_VARARGS|METH_KEYWORDS, doc_logical_invert }, + { "number_class", _PyCFunction_CAST(dec_mpd_class), METH_VARARGS|METH_KEYWORDS, doc_number_class }, + { "to_eng_string", _PyCFunction_CAST(dec_mpd_to_eng), METH_VARARGS|METH_KEYWORDS, doc_to_eng_string }, /* Binary functions, optional context arg for conversion errors */ - { "compare_total", (PyCFunction)(void(*)(void))dec_mpd_compare_total, METH_VARARGS|METH_KEYWORDS, doc_compare_total }, - { "compare_total_mag", (PyCFunction)(void(*)(void))dec_mpd_compare_total_mag, METH_VARARGS|METH_KEYWORDS, doc_compare_total_mag }, - { "copy_sign", (PyCFunction)(void(*)(void))dec_mpd_qcopy_sign, METH_VARARGS|METH_KEYWORDS, doc_copy_sign }, - { "same_quantum", (PyCFunction)(void(*)(void))dec_mpd_same_quantum, METH_VARARGS|METH_KEYWORDS, doc_same_quantum }, + { "compare_total", _PyCFunction_CAST(dec_mpd_compare_total), METH_VARARGS|METH_KEYWORDS, doc_compare_total }, + { "compare_total_mag", _PyCFunction_CAST(dec_mpd_compare_total_mag), METH_VARARGS|METH_KEYWORDS, doc_compare_total_mag }, + { "copy_sign", _PyCFunction_CAST(dec_mpd_qcopy_sign), METH_VARARGS|METH_KEYWORDS, doc_copy_sign }, + { "same_quantum", _PyCFunction_CAST(dec_mpd_same_quantum), METH_VARARGS|METH_KEYWORDS, doc_same_quantum }, /* Binary functions, optional context arg */ - { "logical_and", (PyCFunction)(void(*)(void))dec_mpd_qand, METH_VARARGS|METH_KEYWORDS, doc_logical_and }, - { "logical_or", (PyCFunction)(void(*)(void))dec_mpd_qor, METH_VARARGS|METH_KEYWORDS, doc_logical_or }, - { "logical_xor", (PyCFunction)(void(*)(void))dec_mpd_qxor, METH_VARARGS|METH_KEYWORDS, doc_logical_xor }, - { "rotate", (PyCFunction)(void(*)(void))dec_mpd_qrotate, METH_VARARGS|METH_KEYWORDS, doc_rotate }, - { "scaleb", (PyCFunction)(void(*)(void))dec_mpd_qscaleb, METH_VARARGS|METH_KEYWORDS, doc_scaleb }, - { "shift", (PyCFunction)(void(*)(void))dec_mpd_qshift, METH_VARARGS|METH_KEYWORDS, doc_shift }, + { "logical_and", _PyCFunction_CAST(dec_mpd_qand), METH_VARARGS|METH_KEYWORDS, doc_logical_and }, + { "logical_or", _PyCFunction_CAST(dec_mpd_qor), METH_VARARGS|METH_KEYWORDS, doc_logical_or }, + { "logical_xor", _PyCFunction_CAST(dec_mpd_qxor), METH_VARARGS|METH_KEYWORDS, doc_logical_xor }, + { "rotate", _PyCFunction_CAST(dec_mpd_qrotate), METH_VARARGS|METH_KEYWORDS, doc_rotate }, + { "scaleb", _PyCFunction_CAST(dec_mpd_qscaleb), METH_VARARGS|METH_KEYWORDS, doc_scaleb }, + { "shift", _PyCFunction_CAST(dec_mpd_qshift), METH_VARARGS|METH_KEYWORDS, doc_shift }, /* Miscellaneous */ { "from_float", dec_from_float, METH_O|METH_CLASS, doc_from_float }, @@ -5609,7 +5609,7 @@ static PyMethodDef context_methods [] = { "subtract", ctx_mpd_qsub, METH_VARARGS, doc_ctx_subtract }, /* Binary or ternary arithmetic functions */ - { "power", (PyCFunction)(void(*)(void))ctx_mpd_qpow, METH_VARARGS|METH_KEYWORDS, doc_ctx_power }, + { "power", _PyCFunction_CAST(ctx_mpd_qpow), METH_VARARGS|METH_KEYWORDS, doc_ctx_power }, /* Ternary arithmetic functions */ { "fma", ctx_mpd_qfma, METH_VARARGS, doc_ctx_fma }, @@ -5727,7 +5727,7 @@ static PyMethodDef _decimal_methods [] = { { "getcontext", (PyCFunction)PyDec_GetCurrentContext, METH_NOARGS, doc_getcontext}, { "setcontext", (PyCFunction)PyDec_SetCurrentContext, METH_O, doc_setcontext}, - { "localcontext", (PyCFunction)(void(*)(void))ctxmanager_new, METH_VARARGS|METH_KEYWORDS, doc_localcontext}, + { "localcontext", _PyCFunction_CAST(ctxmanager_new), METH_VARARGS|METH_KEYWORDS, doc_localcontext}, #ifdef EXTRA_FUNCTIONALITY { "IEEEContext", (PyCFunction)ieee_context, METH_O, doc_ieee_context}, #endif diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c index 1794124aa45ad..89f877f6e1279 100644 --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -4349,7 +4349,7 @@ static PyTypeObject XMLParser_Type = { /* python module interface */ static PyMethodDef _functions[] = { - {"SubElement", (PyCFunction)(void(*)(void)) subelement, METH_VARARGS | METH_KEYWORDS}, + {"SubElement", _PyCFunction_CAST(subelement), METH_VARARGS | METH_KEYWORDS}, _ELEMENTTREE__SET_FACTORIES_METHODDEF {NULL, NULL} }; diff --git a/Modules/_functoolsmodule.c b/Modules/_functoolsmodule.c index 0974fc704ffbd..c6d6ca934e9c4 100644 --- a/Modules/_functoolsmodule.c +++ b/Modules/_functoolsmodule.c @@ -1432,7 +1432,7 @@ PyDoc_STRVAR(_functools_doc, static PyMethodDef _functools_methods[] = { {"reduce", functools_reduce, METH_VARARGS, functools_reduce_doc}, - {"cmp_to_key", (PyCFunction)(void(*)(void))functools_cmp_to_key, + {"cmp_to_key", _PyCFunction_CAST(functools_cmp_to_key), METH_VARARGS | METH_KEYWORDS, functools_cmp_to_key_doc}, {NULL, NULL} /* sentinel */ }; diff --git a/Modules/_lsprof.c b/Modules/_lsprof.c index ff499aacbab37..9ba45e69ef4e2 100644 --- a/Modules/_lsprof.c +++ b/Modules/_lsprof.c @@ -787,7 +787,7 @@ profiler_init(ProfilerObject *pObj, PyObject *args, PyObject *kw) static PyMethodDef profiler_methods[] = { _LSPROF_PROFILER_GETSTATS_METHODDEF - {"enable", (PyCFunction)(void(*)(void))profiler_enable, + {"enable", _PyCFunction_CAST(profiler_enable), METH_VARARGS | METH_KEYWORDS, enable_doc}, {"disable", (PyCFunction)profiler_disable, METH_NOARGS, disable_doc}, diff --git a/Modules/_operator.c b/Modules/_operator.c index fdc3176c8395f..739ae5b229e1e 100644 --- a/Modules/_operator.c +++ b/Modules/_operator.c @@ -893,7 +893,7 @@ PyDoc_STRVAR(_operator_call__doc__, "Same as obj(*args, **kwargs)."); #define _OPERATOR_CALL_METHODDEF \ - {"call", (PyCFunction)(void(*)(void))_operator_call, METH_FASTCALL | METH_KEYWORDS, _operator_call__doc__}, + {"call", _PyCFunction_CAST(_operator_call), METH_FASTCALL | METH_KEYWORDS, _operator_call__doc__}, static PyObject * _operator_call(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) diff --git a/Modules/_struct.c b/Modules/_struct.c index 7cd0ef8d87b36..4daf9529d882c 100644 --- a/Modules/_struct.c +++ b/Modules/_struct.c @@ -2049,8 +2049,8 @@ s_sizeof(PyStructObject *self, void *unused) static struct PyMethodDef s_methods[] = { STRUCT_ITER_UNPACK_METHODDEF - {"pack", (PyCFunction)(void(*)(void))s_pack, METH_FASTCALL, s_pack__doc__}, - {"pack_into", (PyCFunction)(void(*)(void))s_pack_into, METH_FASTCALL, s_pack_into__doc__}, + {"pack", _PyCFunction_CAST(s_pack), METH_FASTCALL, s_pack__doc__}, + {"pack_into", _PyCFunction_CAST(s_pack_into), METH_FASTCALL, s_pack_into__doc__}, STRUCT_UNPACK_METHODDEF STRUCT_UNPACK_FROM_METHODDEF {"__sizeof__", (PyCFunction)s_sizeof, METH_NOARGS, s_sizeof__doc__}, @@ -2298,8 +2298,8 @@ static struct PyMethodDef module_functions[] = { _CLEARCACHE_METHODDEF CALCSIZE_METHODDEF ITER_UNPACK_METHODDEF - {"pack", (PyCFunction)(void(*)(void))pack, METH_FASTCALL, pack_doc}, - {"pack_into", (PyCFunction)(void(*)(void))pack_into, METH_FASTCALL, pack_into_doc}, + {"pack", _PyCFunction_CAST(pack), METH_FASTCALL, pack_doc}, + {"pack_into", _PyCFunction_CAST(pack_into), METH_FASTCALL, pack_into_doc}, UNPACK_METHODDEF UNPACK_FROM_METHODDEF {NULL, NULL} /* sentinel */ diff --git a/Modules/_testbuffer.c b/Modules/_testbuffer.c index 1b4fb09fb8fbc..eea9d217557e2 100644 --- a/Modules/_testbuffer.c +++ b/Modules/_testbuffer.c @@ -2633,7 +2633,7 @@ static PyMethodDef ndarray_methods [] =