python-hypothesis/hypothesis-Add-support-for-positional-only-arguments.patch
2020-06-24 17:28:32 +08:00

29 lines
1.1 KiB
Diff

From 8f47297fa2e19c426a42b06bb5f8bf1406b8f0f3 Mon Sep 17 00:00:00 2001
From: Paul Ganssle <paul@ganssle.io>
Date: Mon, 29 Apr 2019 15:12:28 -0400
Subject: [PATCH] Add support for positional only arguments
PEP 570 adds "positional only" arguments to Python, which changes the
code object constructor. This adds support for Python 3.8.
Fixes GH #1943: https://github.com/HypothesisWorks/hypothesis/issues/1943
---
hypothesis-python/src/hypothesis/internal/compat.py | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/hypothesis-python/src/hypothesis/internal/compat.py b/hypothesis-python/src/hypothesis/internal/compat.py
index 73305bacd2..58f63715ac 100644
--- a/src/hypothesis/internal/compat.py
+++ b/src/hypothesis/internal/compat.py
@@ -392,6 +392,10 @@ def get_type_hints(thing):
'co_cellvars',
]
+ if sys.version_info >= (3, 8, 0):
+ # PEP 570 added "positional only arguments"
+ CODE_FIELD_ORDER.insert(1, "co_posonlyargcount")
+
def update_code_location(code, newfile, newlineno):
"""Take a code object and lie shamelessly about where it comes from.