Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 38 additions & 33 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -641,45 +641,45 @@ jobs:
run: |
"$BUILD_DIR/cross-python/bin/python3" -m test test_sysconfig test_site test_embed

# CIFuzz job based on https://google.github.io/oss-fuzz/getting-started/continuous-integration/
cifuzz:
name: CIFuzz
runs-on: ubuntu-latest
timeout-minutes: 60
# ${{ '' } is a hack to nest jobs under the same sidebar category.
name: CIFuzz${{ '' }} # zizmor: ignore[obfuscation]
needs: build-context
if: needs.build-context.outputs.run-ci-fuzz == 'true'
if: >-
needs.build-context.outputs.run-ci-fuzz == 'true'
|| needs.build-context.outputs.run-ci-fuzz-stdlib == 'true'
permissions:
security-events: write
strategy:
fail-fast: false
matrix:
sanitizer: [address, undefined, memory]
steps:
- name: Build fuzzers (${{ matrix.sanitizer }})
id: build
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
with:
oss-fuzz-project-name: cpython3
sanitizer: ${{ matrix.sanitizer }}
- name: Run fuzzers (${{ matrix.sanitizer }})
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
with:
fuzz-seconds: 600
oss-fuzz-project-name: cpython3
output-sarif: true
sanitizer: ${{ matrix.sanitizer }}
- name: Upload crash
if: failure() && steps.build.outcome == 'success'
uses: actions/upload-artifact@v6
with:
name: ${{ matrix.sanitizer }}-artifacts
path: ./out/artifacts
- name: Upload SARIF
if: always() && steps.build.outcome == 'success'
uses: github/codeql-action/upload-sarif@v4
with:
sarif_file: cifuzz-sarif/results.sarif
checkout_path: cifuzz-sarif
sanitizer:
- address
- undefined
- memory
oss-fuzz-project-name:
- cpython3
- python3-libraries
exclude:
# Note that the 'no-exclude' sentinel below is to prevent
# an empty string value from excluding all jobs and causing
# GHA to create a 'default' matrix entry with all empty values.
- oss-fuzz-project-name: >-
${{
needs.build-context.outputs.run-ci-fuzz == 'true'
&& 'no-exclude'
|| 'cpython3'
}}
- oss-fuzz-project-name: >-
${{
needs.build-context.outputs.run-ci-fuzz-stdlib == 'true'
&& 'no-exclude'
|| 'python3-libraries'
}}
uses: ./.github/workflows/reusable-cifuzz.yml
with:
oss-fuzz-project-name: ${{ matrix.oss-fuzz-project-name }}
sanitizer: ${{ matrix.sanitizer }}

all-required-green: # This job does nothing and is only used for the branch protection
name: All required checks pass
Expand Down Expand Up @@ -734,7 +734,12 @@ jobs:
|| ''
}}
${{ !fromJSON(needs.build-context.outputs.run-windows-tests) && 'build-windows,' || '' }}
${{ !fromJSON(needs.build-context.outputs.run-ci-fuzz) && 'cifuzz,' || '' }}
${{
!fromJSON(needs.build-context.outputs.run-ci-fuzz)
&& !fromJSON(needs.build-context.outputs.run-ci-fuzz-stdlib)
&& 'cifuzz,' ||
''
}}
${{ !fromJSON(needs.build-context.outputs.run-macos) && 'build-macos,' || '' }}
${{
!fromJSON(needs.build-context.outputs.run-ubuntu)
Expand Down
46 changes: 46 additions & 0 deletions .github/workflows/reusable-cifuzz.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# CIFuzz job based on https://google.github.io/oss-fuzz/getting-started/continuous-integration/
name: Reusable CIFuzz

on:
workflow_call:
inputs:
oss-fuzz-project-name:
description: OSS-Fuzz project name
required: true
type: string
sanitizer:
description: OSS-Fuzz sanitizer
required: true
type: string

jobs:
cifuzz:
name: ${{ inputs.oss-fuzz-project-name }} (${{ inputs.sanitizer }})
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- name: Build fuzzers (${{ inputs.sanitizer }})
id: build
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
with:
oss-fuzz-project-name: ${{ inputs.oss-fuzz-project-name }}
sanitizer: ${{ inputs.sanitizer }}
- name: Run fuzzers (${{ inputs.sanitizer }})
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
with:
fuzz-seconds: 600
oss-fuzz-project-name: ${{ inputs.oss-fuzz-project-name }}
output-sarif: true
sanitizer: ${{ inputs.sanitizer }}
- name: Upload crash
if: failure() && steps.build.outcome == 'success'
uses: actions/upload-artifact@v6
with:
name: ${{ inputs.sanitizer }}-artifacts
path: ./out/artifacts
- name: Upload SARIF
if: always() && steps.build.outcome == 'success'
uses: github/codeql-action/upload-sarif@v4
with:
sarif_file: cifuzz-sarif/results.sarif
checkout_path: cifuzz-sarif
6 changes: 5 additions & 1 deletion .github/workflows/reusable-context.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ on: # yamllint disable-line rule:truthy
description: Whether to run the Android tests
value: ${{ jobs.compute-changes.outputs.run-android }} # bool
run-ci-fuzz:
description: Whether to run the CIFuzz job
description: Whether to run the CIFuzz job for 'cpython' fuzzer
value: ${{ jobs.compute-changes.outputs.run-ci-fuzz }} # bool
run-ci-fuzz-stdlib:
description: Whether to run the CIFuzz job for 'python3-libraries' fuzzer
value: ${{ jobs.compute-changes.outputs.run-ci-fuzz-stdlib }} # bool
run-docs:
description: Whether to build the docs
value: ${{ jobs.compute-changes.outputs.run-docs }} # bool
Expand Down Expand Up @@ -56,6 +59,7 @@ jobs:
outputs:
run-android: ${{ steps.changes.outputs.run-android }}
run-ci-fuzz: ${{ steps.changes.outputs.run-ci-fuzz }}
run-ci-fuzz-stdlib: ${{ steps.changes.outputs.run-ci-fuzz-stdlib }}
run-docs: ${{ steps.changes.outputs.run-docs }}
run-ios: ${{ steps.changes.outputs.run-ios }}
run-macos: ${{ steps.changes.outputs.run-macos }}
Expand Down
2 changes: 1 addition & 1 deletion Doc/c-api/object.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Object Protocol
instead of the :func:`repr`.
.. c:function:: void PyUnstable_Object_Dump(PyObject *op)
.. c:function:: void PyObject_Dump(PyObject *op)
Dump an object *op* to ``stderr``. This should only be used for debugging.
Expand Down
2 changes: 1 addition & 1 deletion Doc/whatsnew/3.15.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1261,7 +1261,7 @@ New features
* Add :c:func:`PyTuple_FromArray` to create a :class:`tuple` from an array.
(Contributed by Victor Stinner in :gh:`111489`.)

* Add :c:func:`PyUnstable_Object_Dump` to dump an object to ``stderr``.
* Add :c:func:`PyObject_Dump` to dump an object to ``stderr``.
It should only be used for debugging.
(Contributed by Victor Stinner in :gh:`141070`.)

Expand Down
6 changes: 3 additions & 3 deletions Include/cpython/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,10 @@ PyAPI_FUNC(PyObject *) PyType_GetDict(PyTypeObject *);

PyAPI_FUNC(int) PyObject_Print(PyObject *, FILE *, int);
PyAPI_FUNC(void) _Py_BreakPoint(void);
PyAPI_FUNC(void) PyUnstable_Object_Dump(PyObject *);
PyAPI_FUNC(void) PyObject_Dump(PyObject *);

// Alias for backward compatibility
#define _PyObject_Dump PyUnstable_Object_Dump
#define _PyObject_Dump PyObject_Dump

Py_DEPRECATED(3.15) PyAPI_FUNC(PyObject*) _PyObject_GetAttrId(PyObject *, _Py_Identifier *);

Expand Down Expand Up @@ -391,7 +391,7 @@ PyAPI_FUNC(PyObject *) _PyObject_FunctionStr(PyObject *);
but compile away to nothing if NDEBUG is defined.

However, before aborting, Python will also try to call
PyUnstable_Object_Dump() on the given object. This may be of use when
PyObject_Dump() on the given object. This may be of use when
investigating bugs in which a particular object is corrupt (e.g. buggy a
tp_visit method in an extension module breaking the garbage collector), to
help locate the broken objects.
Expand Down
2 changes: 1 addition & 1 deletion Include/internal/pycore_global_objects_fini_generated.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Lib/test/libregrtest/cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@
and 3.9 to test backwards compatibility. These tests
may take very long to complete.
wantobjects - Allows to run Tkinter tests with the specified value of
tkinter.wantobjects.
To enable all resources except one, use '-uall,-<resource>'. For
example, to run all the tests except for the gui tests, give the
option '-uall,-gui'.
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/libregrtest/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
# - tzdata: while needed to validate fully test_datetime, it makes
# test_datetime too slow (15-20 min on some buildbots) and so is disabled by
# default (see bpo-30822).
RESOURCE_NAMES = ALL_RESOURCES + ('extralargefile', 'tzdata', 'xpickle')
RESOURCE_NAMES = ALL_RESOURCES + ('extralargefile', 'tzdata', 'xpickle', 'wantobjects')


# Types for types hints
Expand Down
4 changes: 4 additions & 0 deletions Lib/test/test_inspect/test_inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -6266,6 +6266,10 @@ def test_stat_module_has_signatures(self):
import stat
self._test_module_has_signatures(stat)

def test_struct_module_has_signatures(self):
import struct
self._test_module_has_signatures(struct)

def test_string_module_has_signatures(self):
import string
self._test_module_has_signatures(string)
Expand Down
4 changes: 4 additions & 0 deletions Lib/test/test_tcl.py
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,10 @@ def test_huge_string_builtins2(self, size):


def setUpModule():
wantobjects = support.get_resource_value('wantobjects')
if wantobjects is not None:
unittest.enterModuleContext(
support.swap_attr(tkinter, 'wantobjects', int(wantobjects)))
if support.verbose:
tcl = Tcl()
print('patchlevel =', tcl.call('info', 'patchlevel'), flush=True)
Expand Down
6 changes: 6 additions & 0 deletions Lib/test/test_tkinter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,9 @@

def load_tests(*args):
return load_package_tests(os.path.dirname(__file__), *args)

def setUpModule():
wantobjects = support.get_resource_value('wantobjects')
if wantobjects is not None:
unittest.enterModuleContext(
support.swap_attr(tkinter, 'wantobjects', int(wantobjects)))
11 changes: 11 additions & 0 deletions Lib/test/test_tkinter/support.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
import functools
import tkinter
import unittest
from test import support


def setUpModule():
wantobjects = support.get_resource_value('wantobjects')
if wantobjects is not None:
unittest.enterModuleContext(
support.swap_attr(tkinter, 'wantobjects', int(wantobjects)))

class AbstractTkTest:

Expand All @@ -10,6 +19,8 @@ def setUpClass(cls):
tkinter.NoDefaultRoot()
cls.root = tkinter.Tk()
cls.wantobjects = cls.root.wantobjects()
if support.is_resource_enabled('wantobjects'):
assert cls.wantobjects == int(support.get_resource_value('wantobjects'))
# De-maximize main window.
# Some window managers can maximize new windows.
cls.root.wm_state('normal')
Expand Down
1 change: 1 addition & 0 deletions Lib/test/test_tkinter/test_colorchooser.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import unittest
import tkinter
from test.support import requires, swap_attr
from test.test_tkinter.support import setUpModule # noqa: F401
from test.test_tkinter.support import AbstractDefaultRootTest, AbstractTkTest
from tkinter import colorchooser
from tkinter.colorchooser import askcolor
Expand Down
1 change: 1 addition & 0 deletions Lib/test/test_tkinter/test_font.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import tkinter
from tkinter import font
from test.support import requires, gc_collect, ALWAYS_EQ
from test.test_tkinter.support import setUpModule # noqa: F401
from test.test_tkinter.support import AbstractTkTest, AbstractDefaultRootTest

requires('gui')
Expand Down
1 change: 1 addition & 0 deletions Lib/test/test_tkinter/test_geometry_managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from tkinter import TclError
from test.support import requires

from test.test_tkinter.support import setUpModule # noqa: F401
from test.test_tkinter.support import pixels_conv
from test.test_tkinter.widget_tests import AbstractWidgetTest

Expand Down
1 change: 1 addition & 0 deletions Lib/test/test_tkinter/test_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import tkinter
from test import support
from test.support import os_helper
from test.test_tkinter.support import setUpModule # noqa: F401
from test.test_tkinter.support import AbstractTkTest, AbstractDefaultRootTest, requires_tk

support.requires('gui')
Expand Down
1 change: 1 addition & 0 deletions Lib/test/test_tkinter/test_loadtk.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import unittest
import test.support as test_support
from test.support import os_helper
from test.test_tkinter.support import setUpModule # noqa: F401
from tkinter import Tcl, TclError

test_support.requires('gui')
Expand Down
1 change: 1 addition & 0 deletions Lib/test/test_tkinter/test_messagebox.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import unittest
import tkinter
from test.support import requires, swap_attr
from test.test_tkinter.support import setUpModule # noqa: F401
from test.test_tkinter.support import AbstractDefaultRootTest
from tkinter.commondialog import Dialog
from tkinter.messagebox import showinfo
Expand Down
1 change: 1 addition & 0 deletions Lib/test/test_tkinter/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from tkinter import TclError
import enum
from test import support
from test.test_tkinter.support import setUpModule # noqa: F401
from test.test_tkinter.support import (AbstractTkTest, AbstractDefaultRootTest,
requires_tk, get_tk_patchlevel)

Expand Down
1 change: 1 addition & 0 deletions Lib/test/test_tkinter/test_simpledialog.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import unittest
import tkinter
from test.support import requires, swap_attr
from test.test_tkinter.support import setUpModule # noqa: F401
from test.test_tkinter.support import AbstractDefaultRootTest
from tkinter.simpledialog import Dialog, askinteger

Expand Down
1 change: 1 addition & 0 deletions Lib/test/test_tkinter/test_text.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import unittest
import tkinter
from test.support import requires
from test.test_tkinter.support import setUpModule # noqa: F401
from test.test_tkinter.support import AbstractTkTest

requires('gui')
Expand Down
1 change: 1 addition & 0 deletions Lib/test/test_tkinter/test_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from tkinter import (Variable, StringVar, IntVar, DoubleVar, BooleanVar, Tcl,
TclError)
from test.support import ALWAYS_EQ
from test.test_tkinter.support import setUpModule # noqa: F401
from test.test_tkinter.support import AbstractDefaultRootTest, tcl_version


Expand Down
1 change: 1 addition & 0 deletions Lib/test/test_tkinter/test_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import os
from test.support import requires

from test.test_tkinter.support import setUpModule # noqa: F401
from test.test_tkinter.support import (requires_tk, tk_version,
get_tk_patchlevel, widget_eq,
AbstractDefaultRootTest)
Expand Down
4 changes: 4 additions & 0 deletions Lib/test/test_ttk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ def test_deprecated__version__(self):


def setUpModule():
wantobjects = support.get_resource_value('wantobjects')
if wantobjects is not None:
unittest.enterModuleContext(
support.swap_attr(tkinter, 'wantobjects', int(wantobjects)))
root = None
try:
root = tkinter.Tk()
Expand Down
1 change: 1 addition & 0 deletions Lib/test/test_ttk/test_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import tkinter
from tkinter import ttk
from test.support import requires, gc_collect
from test.test_tkinter.support import setUpModule # noqa: F401
from test.test_tkinter.support import AbstractTkTest, AbstractDefaultRootTest

requires('gui')
Expand Down
1 change: 1 addition & 0 deletions Lib/test/test_ttk/test_style.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from tkinter import TclError
from test import support
from test.support import requires
from test.test_tkinter.support import setUpModule # noqa: F401
from test.test_tkinter.support import AbstractTkTest, get_tk_patchlevel

requires('gui')
Expand Down
Loading
Loading