From a686f74d9441c53088fef6b847cd1e7404960c29 Mon Sep 17 00:00:00 2001 From: Joshua Oreman Date: Tue, 4 Jun 2019 01:35:05 -0700 Subject: [PATCH] Fix closure cell rewriting on 3.8 (#539) * Fix closure cell rewriting on 3.8 * Enable py38 * Don't use CodeType.replace() -- it was added in 3.8.0b1, but CI still uses 3.8.0a4 --- azure-pipelines.yml | 7 +++---- src/attr/_compat.py | 2 ++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 5ad92cc5..f498a90d 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -30,10 +30,9 @@ jobs: py37: python.version: '3.7' tox.env: py37 - # Our cell rewriting is currently broken on 3.8. - # py38: - # python.version: '3.8' - # tox.env: py38 + py38: + python.version: '3.8' + tox.env: py38 pypy2: python.version: 'pypy2' diff --git a/src/attr/_compat.py b/src/attr/_compat.py index efd1eb52..a0df333b 100644 --- a/src/attr/_compat.py +++ b/src/attr/_compat.py @@ -164,6 +164,8 @@ def make_set_closure_cell(): # Convert this code object to a code object that sets the # function's first _freevar_ (not cellvar) to the argument. args = [co.co_argcount] + if sys.version_info >= (3, 8): + args.append(co.co_posonlyargcount) if not PY2: args.append(co.co_kwonlyargcount) args.extend(