Commit 21dba4e7 authored by Francis Herne's avatar Francis Herne
Browse files

Set parser feature version correctly for Python 3.8+

Otherwise the user gets errors for some new syntax.

e.g. `f'{expr=}'` ->
 "f-string: self documenting expressions are only supported
  in Python 3.8 and greater"
parent 2098cffa
......@@ -1319,6 +1319,7 @@ void PyDUChainTest::testTypes_data()
"def foo(a, b, /, c, d):\n"
" return a, b, c, d\n"
"checkme = foo(10, 'x', 2.3, d='y')\n" << "tuple of (int, str, float, str)";
QTest::newRow("fstring_self_documenting") << "checkme = f'{expr=}'" << "str";
#endif
}
......
......@@ -20,9 +20,15 @@
#ifndef KDEVPYTHON_VERSION_H
#define KDEVPYTHON_VERSION_H
#define PYTHON_VERSION_MINOR @PYTHON_VERSION_MINOR@
#define PYTHON_VERSION_MINOR_STR "@PYTHON_VERSION_MINOR@"
#define PYTHON_VERSION_MAJOR @PYTHON_VERSION_MAJOR@
#define PYTHON_VERSION_MAJOR_STR "@PYTHON_VERSION_MAJOR@"
#define PYTHON_VERSION QT_VERSION_CHECK(@PYTHON_VERSION_MAJOR@, @PYTHON_VERSION_MINOR@, @PYTHON_VERSION_PATCH@)
#define PYTHON_VERSION_STR "@PYTHON_VERSION_MAJOR@.@PYTHON_VERSION_MINOR@"
#define PYTHON_EXECUTABLE "@PYTHON_EXECUTABLE@"
#endif
......@@ -104,7 +104,7 @@ CodeAst::Ptr AstBuilder::parse(const QUrl& filename, QString &contents)
#if PYTHON_VERSION >= QT_VERSION_CHECK(3, 8, 0)
PyCompilerFlags flags;
flags.cf_flags = PyCF_SOURCE_IS_UTF8 | PyCF_IGNORE_COOKIE | PyCF_ONLY_AST;
flags.cf_feature_version = 7;
flags.cf_feature_version = PYTHON_VERSION_MINOR;
#else
PyCompilerFlags flags = {PyCF_SOURCE_IS_UTF8 | PyCF_IGNORE_COOKIE};
#endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment