Skip to content

Commit

Permalink
Merge pull request #337 from python-greenlet/issue332
Browse files Browse the repository at this point in the history
Fix assertion error and build
  • Loading branch information
jamadden committed Jan 26, 2023
2 parents 1b58d87 + 2473e83 commit e67fd53
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 13 deletions.
11 changes: 5 additions & 6 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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"
Expand All @@ -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
Expand Down
5 changes: 4 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ def get_greenlet_version():
],
'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',
],
},
Expand Down
4 changes: 0 additions & 4 deletions src/greenlet/greenlet_thread_state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,11 +307,7 @@ class ThreadState {
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);
}
}

Expand Down
9 changes: 9 additions & 0 deletions src/greenlet/tests/test_tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ def dummy():
('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
Expand Down

0 comments on commit e67fd53

Please sign in to comment.