diff options
author | Jason Madden <jamadden@gmail.com> | 2023-01-26 12:42:14 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-26 12:42:14 -0600 |
commit | e67fd532775e0f03af7d7b884ea820825624e84c (patch) | |
tree | a06de6515ce0c976eeb99493fd0c85368d0f37dd | |
parent | 1b58d874d0fc8772d8d5b66ad712651ca444f9bb (diff) | |
parent | 2473e836f7e0f02dd3e7576300dc34c0a10c9d8a (diff) | |
download | greenlet-e67fd532775e0f03af7d7b884ea820825624e84c.tar.gz |
Merge pull request #337 from python-greenlet/issue332
Fix assertion error and build
-rw-r--r-- | .github/workflows/tests.yml | 11 | ||||
-rw-r--r-- | CHANGES.rst | 5 | ||||
-rw-r--r-- | appveyor.yml | 1 | ||||
-rwxr-xr-x | setup.py | 3 | ||||
-rw-r--r-- | src/greenlet/greenlet_thread_state.hpp | 4 | ||||
-rw-r--r-- | src/greenlet/tests/test_tracing.py | 9 |
6 files changed, 20 insertions, 13 deletions
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 7c8f344..56d986d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -26,7 +26,10 @@ jobs: strategy: matrix: python-version: [2.7, 3.5, 3.6, 3.7, 3.8, 3.9, "3.10", "3.11"] - os: [ubuntu-latest, macos-latest] + # Jan 2023: We have pinned back from ubuntu-latest (which is + # now ubuntu 22.04) because older Python versions like + # 3.5, 3.6 and presumably 2.7 are not available in it. + os: [ubuntu-20.04, macos-latest] steps: - uses: actions/checkout@v2 - name: Set up Python @@ -44,7 +47,6 @@ jobs: run: | python -m pip install -U pip setuptools wheel python -m pip install -U twine - python -m pip install -q -U 'faulthandler; python_version == "2.7" and platform_python_implementation == "CPython"' - name: Install greenlet run: | python setup.py bdist_wheel @@ -67,7 +69,6 @@ jobs: path: dist/*whl - name: Test run: | - python -c 'import faulthandler; assert faulthandler.is_enabled()' python -c 'import greenlet._greenlet as G; assert G.GREENLET_USE_STANDARD_THREADING' python -m unittest discover -v greenlet.tests - name: Doctest @@ -88,7 +89,7 @@ jobs: strategy: matrix: python-version: [2.7, 3.5, "3.11"] - os: [ubuntu-latest, macos-latest] + os: [ubuntu-20.04, macos-latest] steps: - uses: actions/checkout@v2 - name: Set up Python @@ -106,7 +107,6 @@ jobs: run: | python -m pip install -U pip setuptools wheel python -m pip install -U twine - python -m pip install -q -U 'faulthandler; python_version == "2.7" and platform_python_implementation == "CPython"' - name: Install greenlet env: CPPFLAGS: "-DG_USE_STANDARD_THREADING=0 -UNDEBUG -Ofast" @@ -115,7 +115,6 @@ jobs: python -m pip install -U -v -e ".[test,docs]" - name: Test run: | - python -c 'import faulthandler; assert faulthandler.is_enabled()' python -c 'import greenlet._greenlet as G; assert not G.GREENLET_USE_STANDARD_THREADING' python -m unittest discover -v greenlet.tests diff --git a/CHANGES.rst b/CHANGES.rst index 8a15aac..9f31503 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,7 +5,10 @@ 2.0.2 (unreleased) ================== -- Nothing changed yet. +- Fix calling ``greenlet.settrace()`` with the same tracer object that + was currently active. See `issue 332 + <https://github.com/python-greenlet/greenlet/issues/332>`_. + 2.0.1 (2022-11-07) diff --git a/appveyor.yml b/appveyor.yml index 307cf99..9729d82 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -200,7 +200,6 @@ build_script: test_script: - - "%CMD_IN_ENV% python -c \"import faulthandler; assert faulthandler.is_enabled()\"" - if not "%GWHEEL_ONLY%"=="true" %PYEXE% -m zope.testrunner --test-path=src -vvv # XXX: Doctest disabled pending sphinx release for 3.10; see tests.yml. # - "%CMD_IN_ENV% python -m sphinx -b doctest -d docs/_build/doctrees docs docs/_build/doctest" @@ -226,7 +226,8 @@ setup( ], 'test': [ 'objgraph', - 'faulthandler; python_version == "2.7" and platform_python_implementation == "CPython"', + # Sigh, all releases of this were yanked from PyPI. + #'faulthandler; python_version == "2.7" and platform_python_implementation == "CPython"', 'psutil', ], }, diff --git a/src/greenlet/greenlet_thread_state.hpp b/src/greenlet/greenlet_thread_state.hpp index 15111c5..b740874 100644 --- a/src/greenlet/greenlet_thread_state.hpp +++ b/src/greenlet/greenlet_thread_state.hpp @@ -307,11 +307,7 @@ public: this->tracefunc.CLEAR(); } else { -#ifndef NDEBUG - Py_ssize_t old_refs = Py_REFCNT(tracefunc); -#endif this->tracefunc = tracefunc; - assert(this->tracefunc.REFCNT() == old_refs + 1); } } diff --git a/src/greenlet/tests/test_tracing.py b/src/greenlet/tests/test_tracing.py index 843e3cf..de84dbc 100644 --- a/src/greenlet/tests/test_tracing.py +++ b/src/greenlet/tests/test_tracing.py @@ -66,6 +66,15 @@ class TestGreenletTracing(TestCase): ('switch', (main, g)), ]) + def test_set_same_tracer_twice(self): + # https://github.com/python-greenlet/greenlet/issues/332 + # Our logic in asserting that the tracefunction should + # gain a reference was incorrect if the same tracefunction was set + # twice. + tracer = GreenletTracer() + with tracer: + greenlet.settrace(tracer) + class PythonTracer(object): oldtrace = None |