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

[3.14] gh-135906: Test more internal headers in test_cext/test_cppext by vstinner · Pull Request #144758 · python/cpython · GitHub

/ cpython Public
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .c  (1) .cpp  (1) .py  (2) All 3 file types selected
Only manifest files
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
5 changes: 4 additions & 1 deletion Lib/test/test_cext/extension.c
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,19 @@

#ifdef TEST_INTERNAL_C_API
// gh-135906: Check for compiler warnings in the internal C API.
// - Cython uses pycore_frame.h.
// - Cython uses pycore_critical_section.h, pycore_frame.h and
// pycore_template.h.
// - greenlet uses pycore_frame.h, pycore_interpframe_structs.h and
// pycore_interpframe.h.
# include "internal/pycore_critical_section.h"
# include "internal/pycore_frame.h"
# include "internal/pycore_gc.h"
# include "internal/pycore_interp.h"
# include "internal/pycore_interpframe.h"
# include "internal/pycore_interpframe_structs.h"
# include "internal/pycore_object.h"
# include "internal/pycore_pystate.h"
# include "internal/pycore_template.h"
#endif

#ifndef MODULE_NAME
Expand Down
14 changes: 11 additions & 3 deletions Lib/test/test_cppext/__init__.py
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import shlex
import shutil
import subprocess
import sys
import unittest
from test import support

Expand All @@ -27,9 +28,6 @@
class BaseTests:
TEST_INTERNAL_C_API = False

def test_build(self):
self.check_build('_testcppext')

def check_build(self, extension_name, std=None, limited=False):
venv_dir = 'env'
with support.setup_venv_with_pip_setuptools(venv_dir) as python_exe:
Expand Down Expand Up @@ -91,6 +89,9 @@ def run_cmd(operation, cmd):


class TestPublicCAPI(BaseTests, unittest.TestCase):
def test_build(self):
self.check_build('_testcppext')

@support.requires_gil_enabled('incompatible with Free Threading')
def test_build_limited_cpp03(self):
self.check_build('_test_limited_cpp03ext', std='c++03', limited=True)
Expand Down Expand Up @@ -119,6 +120,13 @@ def test_build_cpp14(self):
class TestInteralCAPI(BaseTests, unittest.TestCase):
TEST_INTERNAL_C_API = True

def test_build(self):
kwargs = {}
if sys.platform == 'darwin':
# Old Apple clang++ default C++ std is gnu++98
kwargs['std'] = 'c++11'
self.check_build('_testcppext_internal', **kwargs)


if __name__ == "__main__":
unittest.main()
16 changes: 11 additions & 5 deletions Lib/test/test_cppext/extension.cpp
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,20 @@

#ifdef TEST_INTERNAL_C_API
// gh-135906: Check for compiler warnings in the internal C API
// - Cython uses pycore_critical_section.h, pycore_frame.h and
// pycore_template.h.
// - greenlet uses pycore_frame.h, pycore_interpframe_structs.h and
// pycore_interpframe.h.
# include "internal/pycore_frame.h"
// mimalloc emits many compiler warnings when Python is built in debug
// mode (when MI_DEBUG is not zero).
// mimalloc emits compiler warnings when Python is built on Windows
// and macOS.
# if !defined(Py_DEBUG) && !defined(MS_WINDOWS) && !defined(__APPLE__)
# include "internal/pycore_interpframe_structs.h"
# include "internal/pycore_template.h"

// mimalloc emits compiler warnings on Windows.
# if !defined(MS_WINDOWS)
# include "internal/pycore_backoff.h"
# include "internal/pycore_cell.h"
# include "internal/pycore_critical_section.h"
# include "internal/pycore_interpframe.h"
# endif
#endif

Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_cppext/setup.py
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
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def main():
else:
cppflags.append(f'-std={std}')

if limited or (std != 'c++03'):
if limited or (std != 'c++03') and not internal:
# See CPPFLAGS_PEDANTIC docstring
cppflags.extend(CPPFLAGS_PEDANTIC)

Expand Down
Loading

Back | FazBrowse Home | New Git URL