8000 C API tests: use special markers to test that output parameters were set by serhiy-storchaka · Pull Request #109014 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

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

New issue

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

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

Already on GitHub? Sign in to your account

Merged

Conversation

serhiy-storchaka
Copy link
Member

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

Copy link
Member
@vstinner vstinner left a comment

Choose a reason for hiding this comment

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

LGTM. I 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.

Co-authored-by: Victor Stinner <vstinner@python.org>
@serhiy-storchaka serhiy-storchaka merged commit bf414b7 into python:main Sep 6, 2023
@miss-islington
Copy link
Contributor

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

@serhiy-storchaka serhiy-storchaka deleted the testcapi-uninitialized-markers branch September 6, 2023 19:02
@miss-islington
Copy link
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>
@bedevere-bot
Copy link

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

@bedevere-bot 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 serhiy-storchaka removed their assignment Sep 8, 2023
@vstinner
Copy link
Member
vstinner commented Sep 12, 2023

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

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
0