FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

C API tests: use special markers to test that output parameters were set by serhiy-storchaka · Pull Request #109014 · python/cpython · GitHub

/ cpython Public

C API tests: use special markers to test that output parameters were set - #109014

Merged
serhiy-storchaka merged 2 commits into
python:mainfrom
serhiy-storchaka:testcapi-uninitialized-markers
Sep 6, 2023
Merged

C API tests: use special markers to test that output parameters were set#109014
serhiy-storchaka merged 2 commits into
python:mainfrom
serhiy-storchaka:testcapi-uninitialized-markers

Conversation

Copy link
Copy Markdown
Member

Extended extraction from #108797. It will be backported, unlike to the main part of #108797.

vstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM. I just propose a less common value for UNINITIALIZED_INT and UNINITIALIZED_SIZE.

I used random.randint(0, 2**30) to generate the two numbers that I proposed.

Comment thread Modules/_testcapi/util.h Outdated
Comment thread Modules/_testcapi/util.h
Comment thread Modules/_testcapi/util.h Outdated
Co-authored-by: Victor Stinner <vstinner@python.org>
serhiy-storchaka merged commit bf414b7 into python:main Sep 6, 2023

Copy link
Copy Markdown
Contributor

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖

serhiy-storchaka deleted the testcapi-uninitialized-markers branch September 6, 2023 19:02

Copy link
Copy Markdown
Contributor

Sorry, @serhiy-storchaka, I could not cleanly backport this to 3.12 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker bf414b7fcb7c8ba780a5e1d9f320ecef0c7f9488 3.12

serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this pull request Sep 6, 2023
…s were set (pythonGH-109014).

(cherry picked from commit bf414b7)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>

Copy link
Copy Markdown

GH-109023 is a backport of this pull request to the 3.12 branch.

bedevere-bot removed the needs backport to 3.12 only security fixes label Sep 6, 2023
Yhg1s pushed a commit that referenced this pull request Sep 8, 2023
…s were set (GH-109014) (#109023)

[3.12] C API tests: use special markers to test that output parameters were set (GH-109014).
(cherry picked from commit bf414b7)
serhiy-storchaka removed their assignment Sep 8, 2023

vstinner commented Sep 12, 2023
edited
Loading

Copy link
Copy Markdown
Member

This change introduced compiler warnings on FreeBSD (clang -O2):

../Modules/_testcapimodule.c:225:18: warning: result of comparison against a string literal is unspecified (use an explicit string comparison function instead) [-Wstring-compare]
        assert(k != UNINITIALIZED_PTR);
                 ^  ~~~~~~~~~~~~~~~~~
/usr/include/assert.h:56:21: note: expanded from macro 'assert'
#define assert(e)       ((e) ? (void)0 : __assert(__func__, __FILE__, \
                          ^
../Modules/_testcapimodule.c:226:18: warning: result of comparison against a string literal is unspecified (use an explicit string comparison function instead) [-Wstring-compare]
        assert(v != UNINITIALIZED_PTR);
                 ^  ~~~~~~~~~~~~~~~~~
/usr/include/assert.h:56:21: note: expanded from macro 'assert'
#define assert(e)       ((e) ? (void)0 : __assert(__func__, __FILE__, \
                          ^
../Modules/_testcapimodule.c:238:14: warning: result of comparison against a string literal is unspecified (use an explicit string comparison function instead) [-Wstring-compare]
    assert(k == UNINITIALIZED_PTR);
             ^  ~~~~~~~~~~~~~~~~~
/usr/include/assert.h:56:21: note: expanded from macro 'assert'
#define assert(e)       ((e) ? (void)0 : __assert(__func__, __FILE__, \
                          ^
../Modules/_testcapimodule.c:239:14: warning: result of comparison against a string literal is unspecified (use an explicit string comparison function instead) [-Wstring-compare]
    assert(v == UNINITIALIZED_PTR);
             ^  ~~~~~~~~~~~~~~~~~
/usr/include/assert.h:56:21: note: expanded from macro 'assert'
#define assert(e)       ((e) ? (void)0 : __assert(__func__, __FILE__, \
                          ^

--- Modules/_testcapi/dict.o ---
cc -pthread  -fno-strict-overflow -Wsign-compare -g -Og -Wall  -O2 -pipe  -std=c11 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -Werror=implicit-function-declaration -fvisibility=hidden  -I../Include/internal -IObjects -IInclude -IPython -I. -I../Include    -fPIC -c ../Modules/_testcapi/dict.c -o Modules/_testcapi/dict.o
../Modules/_testcapi/dict.c:289:16: warning: result of comparison against a string literal is unspecified (use an explicit string comparison function instead) [-Wstring-compare]
    assert(key == UNINITIALIZED_PTR);
               ^  ~~~~~~~~~~~~~~~~~
/usr/include/assert.h:56:21: note: expanded from macro 'assert'
#define assert(e)       ((e) ? (void)0 : __assert(__func__, __FILE__, \
                          ^
../Modules/_testcapi/dict.c:290:18: warning: result of comparison against a string literal is unspecified (use an explicit string comparison function instead) [-Wstring-compare]
    assert(value == UNINITIALIZED_PTR);
                 ^  ~~~~~~~~~~~~~~~~~
/usr/include/assert.h:56:21: note: expanded from macro 'assert'
#define assert(e)       ((e) ? (void)0 : __assert(__func__, __FILE__, \
                          ^
2 warnings generated.

--- Modules/_testcapi/exceptions.o ---
../Modules/_testcapi/exceptions.c:129:17: warning: result of comparison against a string literal is unspecified (use an explicit string comparison function instead) [-Wstring-compare]
    assert(type != UNINITIALIZED_PTR);
                ^  ~~~~~~~~~~~~~~~~~
/usr/include/assert.h:56:21: note: expanded from macro 'assert'
#define assert(e)       ((e) ? (void)0 : __assert(__func__, __FILE__, \
                          ^
../Modules/_testcapi/exceptions.c:130:18: warning: result of comparison against a string literal is unspecified (use an explicit string comparison function instead) [-Wstring-compare]
    assert(value != UNINITIALIZED_PTR);
                 ^  ~~~~~~~~~~~~~~~~~
/usr/include/assert.h:56:21: note: expanded from macro 'assert'
#define assert(e)       ((e) ? (void)0 : __assert(__func__, __FILE__, \
                          ^
../Modules/_testcapi/exceptions.c:131:15: warning: result of comparison against a string literal is unspecified (use an explicit string comparison function instead) [-Wstring-compare]
    assert(tb != UNINITIALIZED_PTR);
              ^  ~~~~~~~~~~~~~~~~~
/usr/include/assert.h:56:21: note: expanded from macro 'assert'
#define assert(e)       ((e) ? (void)0 : __assert(__func__, __FILE__, \
                          ^

I'm not sure if I copied correctly all warnings.

build: https://cirrus-ci.com/task/5026392602050560?logs=build#L79

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL