Skip to content

Commit

Permalink
Merge branch 'object_ownership'
Browse files Browse the repository at this point in the history
  • Loading branch information
jamadden committed Nov 2, 2021
2 parents 0aa442e + 2902081 commit 1865d4f
Show file tree
Hide file tree
Showing 32 changed files with 4,178 additions and 1,568 deletions.
12 changes: 3 additions & 9 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
[MASTER]
extension-pkg-whitelist=gevent.greenlet,gevent.libuv._corecffi,gevent.libev._corecffi,gevent.libev._corecffi.lib,gevent.local,gevent._ident

# Control the amount of potential inferred values when inferring a single
# object. This can help the performance when dealing with large functions or
# complex, nested conditions.
# gevent: The changes for Python 3.7 in _ssl3.py lead to infinite recursion
# in pylint 2.3.1/astroid 2.2.5 in that file unless we this this to 1
# from the default of 100.
limit-inference-results=1
extension-pkg-whitelist=greenlet._greenlet,greenlet.tests._test_extension
extension-pkg-allow-list=greenlet._greenlet,greenlet.tests._test_extension


[MESSAGES CONTROL]

Expand Down
9 changes: 9 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@
``getcurrent()`` before exiting a thread to allow its main greenlet
to be cleaned up. See `issue 252 <https://github.com/python-greenlet/greenlet/issues/251>`_.

- Fix the C API ``PyGreenlet_Throw`` to perform the same error
checking that the Python API ``greenlet.throw()`` does. Previously,
it did no error checking.

- Fix C++ exception handling on 32-bit Windows. This might have
ramifications if you embed Python in your application and also use
SEH on 32-bit windows, or if you embed Python in a C++ application.
Please contact the maintainers if you have problems in this area.

1.1.2 (2021-09-29)
==================

Expand Down
16 changes: 10 additions & 6 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ environment:

matrix:
# http://www.appveyor.com/docs/installed-software#python
- PYTHON: "C:\\Python27"
PYTHON_ARCH: "32"
PYTHON_VERSION: "2.7.x"
PYTHON_EXE: python

- PYTHON: "C:\\Python310-x64"
PYTHON_VERSION: "3.10.0"
PYTHON_ARCH: "64"
Expand All @@ -54,11 +59,6 @@ environment:
PYTHON_EXE: python
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019

- PYTHON: "C:\\Python27"
PYTHON_ARCH: "32"
PYTHON_VERSION: "2.7.x"
PYTHON_EXE: python

- PYTHON: "C:\\Python27-x64"
PYTHON_ARCH: "64"
PYTHON_VERSION: "2.7.x"
Expand Down Expand Up @@ -164,11 +164,15 @@ install:
- "%CMD_IN_ENV% pip install --upgrade -r dev-requirements.txt"

build_script:
# Show any compiler warnings.
- "%CMD_IN_ENV% python setup.py build_ext"
- "%CMD_IN_ENV% python -m pip install -U -e .[test,docs]"
- "%CMD_IN_ENV% python -m pip install -U zope.testrunner"


test_script:
- "%CMD_IN_ENV% python -m unittest discover -v greenlet.tests"
- "%CMD_IN_ENV% python -c \"import faulthandler; assert faulthandler.is_enabled()\""
- "%CMD_IN_ENV% python -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
4 changes: 2 additions & 2 deletions make-manylinux
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export PIP_NO_WARN_SCRIPT_LOCATION=1

if [ -d /greenlet -a -d /opt/python ]; then
# Running inside docker

export GREENLET_MANYLINUX=1
# Build for speed (we're going to test this anyway) and without assertions.
# Note: -Ofast includes -ffast-math which affects process-wide floating-point flags (e.g. can affect numpy).
# It may also violate standards compliance in a few ways. Rather than opt-out with -fno-fast-math,
Expand All @@ -38,7 +38,7 @@ if [ -d /greenlet -a -d /opt/python ]; then

python -mpip install -U pip
python setup.py bdist_wheel
python -mpip install -U .
python -mpip install -U .[test]
python -m unittest discover -v greenlet.tests
PATH="$OPATH" auditwheel repair dist/greenlet*.whl
cp wheelhouse/greenlet*.whl /greenlet/wheelhouse
Expand Down
67 changes: 51 additions & 16 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#! /usr/bin/env python

from __future__ import print_function
import sys
import os
import glob
Expand All @@ -16,6 +16,9 @@
# Extra compiler arguments passed to C++ extensions
cpp_compile_args = []

# Extra linker arguments passed to C++ extensions
cpp_link_args = []

# Extra compiler arguments passed to the main extension
main_compile_args = []

Expand All @@ -38,10 +41,39 @@
cpp_compile_args.append("--std=gnu++11")
elif sys.platform == 'win32':
# Older versions of MSVC (Python 2.7) don't handle C++ exceptions
# correctly by default. "/EH" == exception handling. "s" == standard C++,
# "c" == extern C doesn't throw
cpp_compile_args.append("/EHsc")

# correctly by default. While newer versions do handle exceptions by default,
# they don't do it fully correctly. So we need an argument on all versions.
#"/EH" == exception handling.
# "s" == standard C++,
# "c" == extern C functions don't throw
# OR
# "a" == standard C++, and Windows SEH; anything may throw, compiler optimizations
# around try blocks are less aggressive.
# /EHsc is suggested, as /EHa isn't supposed to be linked to other things not built
# with it.
# See https://docs.microsoft.com/en-us/cpp/build/reference/eh-exception-handling-model?view=msvc-160
handler = "/EHsc"
cpp_compile_args.append(handler)
# To disable most optimizations:
#cpp_compile_args.append('/Od')

# To enable assertions:
#cpp_compile_args.append('/UNDEBUG')

# To enable more compile-time warnings (/Wall produces a mountain of output).
#cpp_compile_args.append('/W4')

# To link with the debug C runtime...except we can't because we need
# the Python debug lib too, and they're not around by default
# cpp_compile_args.append('/MDd')

# Support fiber-safe thread-local storage: "the compiler mustn't
# cache the address of the TLS array, or optimize it as a common
# subexpression across a function call." This would probably solve
# some of the issues we had with MSVC caching the thread local
# variables on the stack, leading to having to split some
# functions up. Revisit those.
cpp_compile_args.append("/GT")

def readfile(filename):
with open(filename, 'r') as f: # pylint:disable=unspecified-encoding
Expand Down Expand Up @@ -88,6 +120,7 @@ def _find_impl_headers():
language='c++',
extra_objects=extra_objects,
extra_compile_args=global_compile_args + main_compile_args + cpp_compile_args,
extra_link_args=cpp_link_args,
depends=[
GREENLET_HEADER,
GREENLET_SRC_DIR + 'slp_platformselect.h',
Expand All @@ -107,19 +140,16 @@ def _find_impl_headers():
include_dirs=[GREENLET_HEADER_DIR],
extra_compile_args=global_compile_args,
),
Extension(
name='greenlet.tests._test_extension_cpp',
sources=[GREENLET_TEST_DIR + '_test_extension_cpp.cpp'],
language="c++",
include_dirs=[GREENLET_HEADER_DIR],
extra_compile_args=global_compile_args + cpp_compile_args,
extra_link_args=cpp_link_args,
),
]

if os.environ.get('GREENLET_TEST_CPP', 'yes').lower() not in ('0', 'no', 'false'):
ext_modules.append(
Extension(
name='greenlet.tests._test_extension_cpp',
sources=[GREENLET_TEST_DIR + '_test_extension_cpp.cpp'],
language="c++",
include_dirs=[GREENLET_HEADER_DIR],
extra_compile_args=global_compile_args + cpp_compile_args,
)
)


def get_greenlet_version():
with open('src/greenlet/__init__.py') as f: # pylint:disable=unspecified-encoding
Expand Down Expand Up @@ -177,8 +207,13 @@ def get_greenlet_version():
extras_require={
'docs': [
'Sphinx',
# 0.18b1 breaks sphinx 1.8.5 which is the latest version that runs
# on Python 2. The version pin sphinx itself contains isn't specific enough.
'docutils < 0.18; python_version < "3"',
],
'test': [
'objgraph',
'faulthandler; python_version == "2.7" and platform_python_implementation == "CPython"',
],
},
python_requires=">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*",
Expand Down

0 comments on commit 1865d4f

Please sign in to comment.