Skip to content

Commit

Permalink
Remove some more legacy Python 2-isms.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamadden committed Jun 21, 2023
1 parent 55e075b commit 728e2ea
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 33 deletions.
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ def get_greenlet_version():
'Programming Language :: C',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
Expand Down
11 changes: 0 additions & 11 deletions src/greenlet/greenlet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,17 +318,6 @@ class GreenletGlobals
Mutex* const thread_states_to_destroy_lock;
greenlet::cleanup_queue_t thread_states_to_destroy;

GreenletGlobals(const int UNUSED(dummy)) :
event_switch(0),
event_throw(0),
PyExc_GreenletError(0),
PyExc_GreenletExit(0),
empty_tuple(0),
empty_dict(0),
str_run(0),
thread_states_to_destroy_lock(0)
{}

GreenletGlobals() :
event_switch("switch"),
event_throw("throw"),
Expand Down
13 changes: 4 additions & 9 deletions src/greenlet/tests/test_greenlet.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,8 +578,6 @@ def initiator():
self.assertEqual(value, 42)

def test_tuple_subclass(self):
# XXX: This is failing on Python 2 with a SystemError: error return without exception set

# The point of this test is to see what happens when a custom
# tuple subclass is used as an object passed directly to the C
# function ``green_switch``; part of ``green_switch`` checks
Expand All @@ -591,13 +589,10 @@ def test_tuple_subclass(self):
# `apply` function directly passes the given args tuple object
# to the underlying function, whereas the Python 3 version
# unpacks and repacks into an actual tuple. This could still
# happen using the C API on Python 3 though.
if sys.version_info[0] > 2:
# There's no apply in Python 3.x
def _apply(func, a, k):
func(*a, **k)
else:
_apply = apply # pylint:disable=undefined-variable
# happen using the C API on Python 3 though. We should write a
# builtin version of apply() ourself.
def _apply(func, a, k):
func(*a, **k)

class mytuple(tuple):
def __len__(self):
Expand Down
7 changes: 0 additions & 7 deletions src/greenlet/tests/test_greenlet_trash.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,10 @@
"""
from __future__ import print_function, absolute_import, division

import sys
import unittest



class TestTrashCanReEnter(unittest.TestCase):

@unittest.skipUnless(
sys.version_info[0] > 2,
"Python 2 tracks this slightly differently, so our test doesn't catch a problem there. "
)
def test_it(self):
# Try several times to trigger it, because it isn't 100%
# reliable.
Expand Down
9 changes: 4 additions & 5 deletions src/greenlet/tests/test_leaks.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
from . import TestCase
from .leakcheck import fails_leakcheck
from .leakcheck import ignores_leakcheck
from .leakcheck import RUNNING_ON_GITHUB_ACTIONS
from .leakcheck import RUNNING_ON_MANYLINUX

try:
Expand Down Expand Up @@ -309,11 +308,11 @@ def _only_test_some_versions(self):
# and this set of tests is relatively fragile, depending on
# OS and memory management details. So we want to run it on 3.11+
# (obviously) but not every older 3.x version in order to reduce
# false negatives.
if sys.version_info[0] >= 3 and sys.version_info[:2] < (3, 8):
# false negatives. At the moment, those false results seem to have
# resolved, so we are actually running this on 3.8+
assert sys.version_info[0] >= 3
if sys.version_info[:2] < (3, 8):
self.skipTest('Only observed on 3.11')
if sys.version_info[0] == 2 and RUNNING_ON_GITHUB_ACTIONS:
self.skipTest('Hard to get a stable pattern here')
if RUNNING_ON_MANYLINUX:
self.skipTest("Slow and not worth repeating here")

Expand Down
1 change: 0 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
envlist =
py37,py38,py39,py310,py27-ns,py310-ns,py311,py311-ns,docs

# XXX: Is non-standard thread mode still needed? Check on that.
[testenv]
commands =
python -c 'import greenlet._greenlet as G; assert G.GREENLET_USE_STANDARD_THREADING'
Expand Down

0 comments on commit 728e2ea

Please sign in to comment.