From b23990e5f5a2d90abe3c820ab10907a232bd7153330ed3667991388fe8ef3b72 Mon Sep 17 00:00:00 2001 From: Dominique Leuenberger Date: Fri, 24 Feb 2017 23:53:26 +0000 Subject: [PATCH] Accepting request 459722 from KDE:Extra - Add build-with-py36.diff: diff from upstream 50-python36 branch to enable building with Python 3.6 OBS-URL: https://build.opensuse.org/request/show/459722 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/kdevelop5-plugin-python3?expand=0&rev=5 --- build-with-py36.diff | 604 +++++++++++++++++++++++++++++++ kdevelop5-plugin-python3.changes | 6 + kdevelop5-plugin-python3.spec | 9 +- 3 files changed, 618 insertions(+), 1 deletion(-) create mode 100644 build-with-py36.diff diff --git a/build-with-py36.diff b/build-with-py36.diff new file mode 100644 index 0000000..02c6a77 --- /dev/null +++ b/build-with-py36.diff @@ -0,0 +1,604 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index b06a6658..ec8dc3e3 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -31,10 +31,10 @@ add_definitions( -DTRANSLATION_DOMAIN=\"kdevpython\" ) + + # find the system python 3 interpreter, only used for determining search paths. + # must be called before find_package(KF5) because it searchs for python too, but finds python2 +-find_package(Python 3.5 REQUIRED) ++find_package(Python 3.6 REQUIRED) + configure_file( "${kdevpython_SOURCE_DIR}/kdevpythonversion.h.cmake" "${kdevpython_BINARY_DIR}/kdevpythonversion.h" @ONLY ) +-if ( (NOT PYTHON_LIBRARIES) OR "${PYTHON_VERSION_MINOR}" GREATER 5 ) +- message(FATAL_ERROR "Python >= 3.5.0 but < 3.6 with --enable-shared is required to build kdev-python") ++if ( (NOT PYTHON_LIBRARIES) OR "${PYTHON_VERSION_MINOR}" GREATER 6 ) ++ message(FATAL_ERROR "Python >= 3.6.0 but < 3.7 with --enable-shared is required to build kdev-python") + endif() + + find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED Widgets Test) +diff --git a/app_templates/django_project/django_project.kdevtemplate b/app_templates/django_project/django_project.kdevtemplate +index 4b2e1ed3..0a517c5c 100644 +--- a/app_templates/django_project/django_project.kdevtemplate ++++ b/app_templates/django_project/django_project.kdevtemplate +@@ -6,6 +6,7 @@ Name[ca@valencia]=Projecte nou del Django + Name[cs]=Nový projekt Django + Name[en_GB]=New Django project + Name[es]=Nuevo proyecto de Django ++Name[et]=Uus Django projekt + Name[it]=Nuovo progetto Django + Name[nl]=Nieuw Django-project + Name[pl]=Nowy projekt Django +@@ -21,6 +22,7 @@ Comment[ca@valencia]=Genera l'estructura de fitxers per a iniciar un projecte Dj + Comment[cs]=Vygenerovat strukturu souborů pro započetí projektu Django + Comment[en_GB]=Generate filestructure to start a Django project + Comment[es]=Generar la estructura de archivos para empezar un proyecto de Django ++Comment[et]=Failistruktuuri genereerimine Django projekti tarbeks + Comment[it]=Genera una struttura di file per inizializzare un progetto Django + Comment[nl]=Genereer een bestandsstructuur om een Django-project te starten + Comment[pl]=Tworzy strukturę plików do rozpoczęcia projektu Django +diff --git a/app_templates/qtdesigner_app/qtdesigner_app.kdevtemplate b/app_templates/qtdesigner_app/qtdesigner_app.kdevtemplate +index 65367cd1..5befb368 100644 +--- a/app_templates/qtdesigner_app/qtdesigner_app.kdevtemplate ++++ b/app_templates/qtdesigner_app/qtdesigner_app.kdevtemplate +@@ -6,6 +6,7 @@ Name[ca@valencia]=Aplicació senzilla amb IGU Qt que usa el Designer + Name[cs]=Jednoduchá aplikace Qt GUI pomocí Designeru + Name[en_GB]=Simple Qt GUI application using Designer + Name[es]=Sencilla aplicación con interfaz gráfica de usuario que usa Designer ++Name[et]=Lihtne Qt GUI rakendus Designeri abil + Name[it]=Semplice applicazione grafica Qt che usa Designer + Name[nl]=Eenvoudige Qt-GUI-toepassing met gebruik van Designer + Name[pl]=Prosta aplikacja z interfejsem Qt przy użyciu Designera +@@ -20,6 +21,7 @@ Comment[ca]=Un exemple d'aplicació que usa el Designer de Qt. Si editeu el «ma + Comment[ca@valencia]=Un exemple d'aplicació que usa el Designer de Qt. Si editeu el «mainwindow.ui», regenereu el «mainwindow.py» invocant el «pyuic5». + Comment[en_GB]=An example application using Qt Designer. If you edit mainwindow.ui, regenerate mainwindow.py by calling pyuic5. + Comment[es]=Un ejemplo de aplicación que usa Qt Designer. Si edita mainwindow.ui, vuelva a generar mainwindow.py llamando a pyuic5. ++Comment[et]=Näidisrakendus Qt Designeri abil. Kui redigeerid faili mainwindow.ui, regenereeri mainwindow.py, kutsudes välja pyuic5. + Comment[it]=Un'applicazione di esempio che usa Qt Designer. Se modifichi mainwindow.ui, rigenera mainwindow.py eseguendo pyuic5. + Comment[nl]=Een voorbeeld toepassing met gebruik van Qt Designer. Als u mainwindow.ui bewerkt, genereer dan opnieuw mainwindow.py door pyuic5 aan te roepen. + Comment[pl]=Przykładowa aplikacja wykorzystująca Qt Designera. Po zmianie mainwindow.ui, odśwież mainwindow.py ponownie wywołując pyuic5. +diff --git a/app_templates/simple_pythonapp/simple_pythonapp.kdevtemplate b/app_templates/simple_pythonapp/simple_pythonapp.kdevtemplate +index c0a01793..26e0c3b6 100644 +--- a/app_templates/simple_pythonapp/simple_pythonapp.kdevtemplate ++++ b/app_templates/simple_pythonapp/simple_pythonapp.kdevtemplate +@@ -6,10 +6,12 @@ Name[ca@valencia]=Una aplicació Python senzilla + Name[cs]=Jednoduchá aplikace v Pythonu + Name[en_GB]=Simple Python Application + Name[es]=Aplicación sencilla en Python ++Name[et]=Lihtne Pythoni rakendus + Name[it]=Semplice applicazione Python + Name[nl]=Eenvoudige Python-toepassing + Name[pl]=Prosta aplikacja Pythona + Name[pt]=Aplicação Simples de Python ++Name[pt_BR]=Aplicativo Python simples + Name[sk]=Jednoduchá Python aplikácia + Name[sv]=Enkelt Python-program + Name[uk]=Проста програма мовою Python +@@ -21,6 +23,7 @@ Comment[ca@valencia]=Genera l'estructura de fitxers per a iniciar una aplicació + Comment[cs]=Vygenerovat strukturu souborů pro započetí aplikace v Pythonu + Comment[en_GB]=Generate filestructure to start a Python application + Comment[es]=Generar la estructura de archivos para empezar una aplicación en Python ++Comment[et]=Failistruktuuri genereerimine Pythoni rakenduse tarbeks + Comment[it]=Genera una struttura file per avviare un'applicazione in Python + Comment[nl]=Genereer een bestandsstructuur om een Python-toepassing te starten + Comment[pl]=Tworzy strukturę plików do rozpoczęcia projektu Pythona +diff --git a/cmake/modules/FindPython.cmake b/cmake/modules/FindPython.cmake +index 37eca7e4..15bfd45e 100644 +--- a/cmake/modules/FindPython.cmake ++++ b/cmake/modules/FindPython.cmake +@@ -31,7 +31,7 @@ + include(FindPackageHandleStandardArgs) + + # TODO +-set(LOOKING_FOR_VERSION "3.5") ++set(LOOKING_FOR_VERSION "3.6") + + # allow specifying which Python installation to use + if (NOT PYTHON_EXEC) +diff --git a/codecompletion/context.cpp b/codecompletion/context.cpp +index 39db76d6..b5f95d33 100644 +--- a/codecompletion/context.cpp ++++ b/codecompletion/context.cpp +@@ -253,6 +253,9 @@ PythonCodeCompletionContext::ItemList PythonCodeCompletionContext::raiseItems() + DUChainReadLocker lock; + ItemList resultingItems; + ReferencedTopDUContext ctx = Helper::getDocumentationFileContext(); ++ if ( !ctx ) { ++ return {}; ++ } + QList< Declaration* > declarations = ctx->findDeclarations(QualifiedIdentifier("BaseException")); + if ( declarations.isEmpty() || ! declarations.first()->abstractType() ) { + qCDebug(KDEV_PYTHON_CODECOMPLETION) << "No valid exception classes found, aborting"; +diff --git a/debugger/kdevpdb.json b/debugger/kdevpdb.json +index 0fea5579..90e51917 100644 +--- a/debugger/kdevpdb.json ++++ b/debugger/kdevpdb.json +@@ -43,4 +43,4 @@ + "org.kdevelop.IExecuteScriptPlugin" + ], + "X-KDevelop-Mode": "GUI" +-} +\ No newline at end of file ++} +diff --git a/duchain/declarationbuilder.cpp b/duchain/declarationbuilder.cpp +index 43c61cf0..b08f91dc 100644 +--- a/duchain/declarationbuilder.cpp ++++ b/duchain/declarationbuilder.cpp +@@ -557,7 +557,7 @@ void DeclarationBuilder::visitComprehension(ComprehensionAst* node) + // and both other occurences are uses of that declaration. + // TODO add a special case to the usebuilder to display the second occurence as a declaration + RangeInRevision declarationRange(currentContext()->range().start, currentContext()->range().start); +- declarationRange.end.column -= 1; ++ declarationRange.end.column -= 2; + declarationRange.start.column -= 1; + + AbstractType::Ptr targetType(new IntegralType(IntegralType::TypeMixed)); +@@ -1428,6 +1428,17 @@ void DeclarationBuilder::visitAssignment(AssignmentAst* node) + } + } + ++void DeclarationBuilder::visitAnnotationAssignment(AnnotationAssignmentAst* node) { ++ ExpressionVisitor v(currentContext()); ++ v.visitNode(node->target); ++ v.visitNode(node->value); ++ auto assignType = v.lastType(); // Never mind aliasing, why annotate that? ++ v.visitNode(node->annotation); ++ assignType = Helper::mergeTypes(assignType, v.lastType()); ++ auto sourceType = SourceType{ assignType, DeclarationPointer(), false }; ++ assignToUnknown(node->target, sourceType); ++} ++ + void DeclarationBuilder::visitClassDefinition( ClassDefinitionAst* node ) + { + const CorrectionHelper::Recursion r(m_correctionHelper->enterClass(node->name->value)); +diff --git a/duchain/declarationbuilder.h b/duchain/declarationbuilder.h +index 800a5398..5b5de516 100644 +--- a/duchain/declarationbuilder.h ++++ b/duchain/declarationbuilder.h +@@ -86,6 +86,7 @@ protected: + void visitClassDefinition(ClassDefinitionAst* node) override; + void visitFunctionDefinition(FunctionDefinitionAst* node) override; + void visitAssignment(AssignmentAst* node) override; ++ void visitAnnotationAssignment(AnnotationAssignmentAst* node) override; + void visitFor(ForAst* node) override; + void visitImport(ImportAst* node) override; + void visitImportFrom(ImportFromAst* node) override; +diff --git a/duchain/tests/pyduchaintest.cpp b/duchain/tests/pyduchaintest.cpp +index 12ed85fe..903dc6ed 100644 +--- a/duchain/tests/pyduchaintest.cpp ++++ b/duchain/tests/pyduchaintest.cpp +@@ -418,6 +418,8 @@ void PyDUChainTest::testCrashes_data() { + + QTest::newRow("list_extend_missing") << "foo = []\nfoo.extend(missing)"; + QTest::newRow("list_extend_missing_arg") << "foo = []\nfoo.extend()"; ++ QTest::newRow("comprehension_in_fstring") << ++ "def crash(): return f'expr={ {x: y for x, y in [(1, 2), ]}}'"; + } + + void PyDUChainTest::testClassVariables() +@@ -797,7 +799,9 @@ void PyDUChainTest::testTypes_data() + { + QTest::addColumn("code"); + QTest::addColumn("expectedType"); +- ++ ++ QTest::newRow("annotate_decl") << "checkme: int" << "int"; ++ QTest::newRow("annotate_assign") << "checkme: int = 3.5" << "unsure (float, int)"; + QTest::newRow("listtype") << "checkme = []" << "list"; + QTest::newRow("listtype_func") << "checkme = list()" << "list"; + QTest::newRow("listtype_with_contents") << "checkme = [1, 2, 3, 4, 5]" << "list of int"; +diff --git a/kdevpythonsupport.json b/kdevpythonsupport.json +index 935fc65b..5501f4da 100644 +--- a/kdevpythonsupport.json ++++ b/kdevpythonsupport.json +@@ -67,4 +67,4 @@ + "X-KDevelop-SupportedMimeTypes": [ + "text/x-python" + ] +-} +\ No newline at end of file ++} +diff --git a/org.kde.kdev-python.appdata.xml b/org.kde.kdev-python.appdata.xml +index 92c99653..c03a3de8 100644 +--- a/org.kde.kdev-python.appdata.xml ++++ b/org.kde.kdev-python.appdata.xml +@@ -5,8 +5,11 @@ + kdev-python + kdev-python + kdev-python ++ kdev-python + kdev-python + kdev-python ++ kdev-python ++ kdev-python + kdev-python + kdev-python + kdev-python +@@ -19,6 +22,8 @@ + Implementació del llenguatge Python al KDevelop + Python language support for KDevelop + Implementación del lenguaje Python para KDevelop ++ KDevelopi Pythoni keele toetus ++ Supporto per il linguaggio Python in KDevelop + Ondersteuning voor de taal Python voor KDevelop + Obsługa języka Python dla KDevelop + Suporte para a linguagem Python no KDevelop +@@ -30,8 +35,11 @@ + Sven Brauch <mail@svenbrauch.de> + Sven Brauch <mail@svenbrauch.de> + Sven Brauch <mail@svenbrauch.de> ++ Sven Brauch <mail@svenbrauch.de> + Sven Brauch <mail@svenbrauch.de> + Sven Brauch <mail@svenbrauch.de> ++ Sven Brauch <mail@svenbrauch.de> ++ Sven Brauch <mail@svenbrauch.de> + Sven Brauch <mail@svenbrauch.de> + Sven Brauch <mail@svenbrauch.de> + Sven Brauch <mail@svenbrauch.de> +diff --git a/parser/ast.cpp b/parser/ast.cpp +index 4a011df5..41fe56ba 100644 +--- a/parser/ast.cpp ++++ b/parser/ast.cpp +@@ -64,9 +64,14 @@ AugmentedAssignmentAst::AugmentedAssignmentAst(Ast* parent): StatementAst(parent + + } + ++AnnotationAssignmentAst::AnnotationAssignmentAst(Ast* parent): StatementAst(parent, Ast::AnnotationAssignmentAstType), target(0), value(0), annotation(0) ++{ ++ ++} ++ + BinaryOperationAst::BinaryOperationAst(Ast* parent): ExpressionAst(parent, Ast::BinaryOperationAstType), lhs(0), rhs(0) + { +- ++ + } + + BooleanOperationAst::BooleanOperationAst(Ast* parent): ExpressionAst(parent, Ast::BooleanOperationAstType) +@@ -290,7 +295,17 @@ StatementAst::StatementAst(Ast* parent, AstType type): Ast(parent, type) + + StringAst::StringAst(Ast* parent): ExpressionAst(parent, Ast::StringAstType), value(""), usedAsComment(false) + { +- ++ ++} ++ ++JoinedStringAst::JoinedStringAst(Ast* parent): ExpressionAst(parent, Ast::JoinedStringAstType), values() ++{ ++ ++} ++ ++FormattedValueAst::FormattedValueAst(Ast* parent): ExpressionAst(parent, Ast::FormattedValueAstType), value(nullptr), conversion(0), formatSpec(0) ++{ ++ + } + + BytesAst::BytesAst(Ast* parent): ExpressionAst(parent, Ast::BytesAstType), value("") +diff --git a/parser/ast.h b/parser/ast.h +index 91646b6d..b69a7068 100644 +--- a/parser/ast.h ++++ b/parser/ast.h +@@ -93,6 +93,7 @@ public: + ContinueAstType, + AssertionAstType, + AugmentedAssignmentAstType, ++ AnnotationAssignmentAstType, + LastStatementType, + ExpressionAstType, // everything below is an expression + AwaitAstType, +@@ -116,6 +117,8 @@ public: + CompareAstType, + NumberAstType, + StringAstType, ++ JoinedStringAstType, ++ FormattedValueAstType, + BytesAstType, + SubscriptAstType, + StarredAstType, +@@ -325,6 +328,14 @@ public: + ExpressionAst* value; + }; + ++class KDEVPYTHONPARSER_EXPORT AnnotationAssignmentAst : public StatementAst { ++public: ++ AnnotationAssignmentAst(Ast* parent); ++ ExpressionAst* target; ++ ExpressionAst* value; ++ ExpressionAst* annotation; ++}; ++ + class KDEVPYTHONPARSER_EXPORT ForAst : public StatementAst { + public: + ForAst(Ast* parent); +@@ -594,6 +605,20 @@ public: + bool usedAsComment; + }; + ++class KDEVPYTHONPARSER_EXPORT JoinedStringAst : public ExpressionAst { ++public: ++ JoinedStringAst(Ast* parent); ++ QList values; ++}; ++ ++class KDEVPYTHONPARSER_EXPORT FormattedValueAst : public ExpressionAst { ++public: ++ FormattedValueAst(Ast* parent); ++ ExpressionAst* value; ++ int conversion; ++ ExpressionAst* formatSpec; ++}; ++ + class KDEVPYTHONPARSER_EXPORT BytesAst : public ExpressionAst { + public: + BytesAst(Ast* parent); +diff --git a/parser/astdefaultvisitor.cpp b/parser/astdefaultvisitor.cpp +index 2c20585d..9a56fb81 100644 +--- a/parser/astdefaultvisitor.cpp ++++ b/parser/astdefaultvisitor.cpp +@@ -48,6 +48,21 @@ void AstDefaultVisitor::visitString(StringAst* node) { Q_UNUSED(node); } + void AstDefaultVisitor::visitBytes(BytesAst* node) { Q_UNUSED(node); } + void AstDefaultVisitor::visitIdentifier(Identifier* node) { Q_UNUSED(node); } + ++void AstDefaultVisitor::visitJoinedString(JoinedStringAst* node) { ++//TODO: Fix range/context/??? bugs, then re-enable this. ++ Q_UNUSED(node); ++// foreach (Ast* value, node->values) { ++// visitNode(value); ++// } ++} ++ ++void AstDefaultVisitor::visitFormattedValue(FormattedValueAst* node) { ++// TODO: Fix range issues, then re-enable (if required) ++ Q_UNUSED(node); ++// visitNode(node->value); ++// visitNode(node->formatSpec); ++} ++ + void AstDefaultVisitor::visitStarred(StarredAst* node) { + visitNode(node->value); + } +@@ -326,6 +341,13 @@ void AstDefaultVisitor::visitAugmentedAssignment(AugmentedAssignmentAst* node) + visitNode(node->value); + } + ++void AstDefaultVisitor::visitAnnotationAssignment(AnnotationAssignmentAst* node) ++{ ++ visitNode(node->target); ++ visitNode(node->annotation); ++ visitNode(node->value); ++} ++ + void AstDefaultVisitor::visitBinaryOperation(BinaryOperationAst* node) + { + visitNode(node->lhs); +diff --git a/parser/astdefaultvisitor.h b/parser/astdefaultvisitor.h +index 153e219c..84229716 100644 +--- a/parser/astdefaultvisitor.h ++++ b/parser/astdefaultvisitor.h +@@ -48,6 +48,7 @@ public: + virtual void visitDelete(DeleteAst* node); + virtual void visitAssignment(AssignmentAst* node); + virtual void visitAugmentedAssignment(AugmentedAssignmentAst* node); ++ virtual void visitAnnotationAssignment(AnnotationAssignmentAst* node); + virtual void visitFor(ForAst* node); + virtual void visitWhile(WhileAst* node); + virtual void visitIf(IfAst* node); +@@ -76,6 +77,8 @@ public: + virtual void visitCompare(CompareAst* node); + virtual void visitNumber(NumberAst* node); + virtual void visitString(StringAst* node); ++ virtual void visitJoinedString(JoinedStringAst* node); ++ virtual void visitFormattedValue(FormattedValueAst* node); + virtual void visitBytes(BytesAst* node); + virtual void visitYield(YieldAst* node); + virtual void visitYieldFrom(YieldFromAst* node); +@@ -118,6 +121,7 @@ public: + virtual void visitDelete(DeleteAst* node) { AstDefaultVisitor::visitDelete(node); delete node; } + virtual void visitAssignment(AssignmentAst* node) { AstDefaultVisitor::visitAssignment(node); delete node; } + virtual void visitAugmentedAssignment(AugmentedAssignmentAst* node) { AstDefaultVisitor::visitAugmentedAssignment(node); delete node; } ++ virtual void visitAnnotationAssignment(AnnotationAssignmentAst* node) { AstDefaultVisitor::visitAnnotationAssignment(node); delete node; } + virtual void visitFor(ForAst* node) { AstDefaultVisitor::visitFor(node); delete node; } + virtual void visitWhile(WhileAst* node) { AstDefaultVisitor::visitWhile(node); delete node; } + virtual void visitIf(IfAst* node) { AstDefaultVisitor::visitIf(node); delete node; } +@@ -146,6 +150,8 @@ public: + virtual void visitCompare(CompareAst* node) { AstDefaultVisitor::visitCompare(node); delete node; } + virtual void visitNumber(NumberAst* node) { AstDefaultVisitor::visitNumber(node); delete node; } + virtual void visitString(StringAst* node) { AstDefaultVisitor::visitString(node); delete node; } ++ virtual void visitJoinedString(JoinedStringAst* node) { AstDefaultVisitor::visitJoinedString(node); delete node; } ++ virtual void visitFormattedValue(FormattedValueAst* node) { AstDefaultVisitor::visitFormattedValue(node); delete node; } + virtual void visitBytes(BytesAst* node) { AstDefaultVisitor::visitBytes(node); delete node; } + virtual void visitYield(YieldAst* node) { AstDefaultVisitor::visitYield(node); delete node; } + virtual void visitYieldFrom(YieldFromAst* node) { AstDefaultVisitor::visitYieldFrom(node); delete node; } +diff --git a/parser/astvisitor.cpp b/parser/astvisitor.cpp +index bff45662..ace7d619 100644 +--- a/parser/astvisitor.cpp ++++ b/parser/astvisitor.cpp +@@ -46,6 +46,7 @@ void AstVisitor::visitNode(Ast* node) + case Ast::DeleteAstType: this->visitDelete(static_cast(node)); break; + case Ast::AssignmentAstType: this->visitAssignment(static_cast(node)); break; + case Ast::AugmentedAssignmentAstType: this->visitAugmentedAssignment(static_cast(node)); break; ++ case Ast::AnnotationAssignmentAstType: this->visitAnnotationAssignment(static_cast(node)); break; + case Ast::ForAstType: this->visitFor(static_cast(node)); break; + case Ast::WhileAstType: this->visitWhile(static_cast(node)); break; + case Ast::IfAstType: this->visitIf(static_cast(node)); break; +@@ -74,6 +75,8 @@ void AstVisitor::visitNode(Ast* node) + case Ast::CompareAstType: this->visitCompare(static_cast(node)); break; + case Ast::NumberAstType: this->visitNumber(static_cast(node)); break; + case Ast::StringAstType: this->visitString(static_cast(node)); break; ++ case Ast::FormattedValueAstType: this->visitFormattedValue(static_cast(node)); break; ++ case Ast::JoinedStringAstType: this->visitJoinedString(static_cast(node)); break; + case Ast::BytesAstType: this->visitBytes(static_cast(node)); break; + case Ast::YieldAstType: this->visitYield(static_cast(node)); break; + case Ast::NameAstType: this->visitName(static_cast(node)); break; +diff --git a/parser/astvisitor.h b/parser/astvisitor.h +index 3e455e60..ce1a92a3 100644 +--- a/parser/astvisitor.h ++++ b/parser/astvisitor.h +@@ -53,6 +53,7 @@ public: + virtual void visitDelete(DeleteAst* node) { Q_UNUSED(node); }; + virtual void visitAssignment(AssignmentAst* node) { Q_UNUSED(node); }; + virtual void visitAugmentedAssignment(AugmentedAssignmentAst* node) { Q_UNUSED(node); }; ++ virtual void visitAnnotationAssignment(AnnotationAssignmentAst* node) { Q_UNUSED(node); }; + virtual void visitFor(ForAst* node) { Q_UNUSED(node); }; + virtual void visitWhile(WhileAst* node) { Q_UNUSED(node); }; + virtual void visitIf(IfAst* node) { Q_UNUSED(node); }; +@@ -83,6 +84,8 @@ public: + virtual void visitCompare(CompareAst* node) { Q_UNUSED(node); }; + virtual void visitNumber(NumberAst* node) { Q_UNUSED(node); }; + virtual void visitString(StringAst* node) { Q_UNUSED(node); }; ++ virtual void visitFormattedValue(FormattedValueAst* node) { Q_UNUSED(node); }; ++ virtual void visitJoinedString(JoinedStringAst* node) { Q_UNUSED(node); }; + virtual void visitBytes(BytesAst* node) { Q_UNUSED(node); }; + virtual void visitYield(YieldAst* node) { Q_UNUSED(node); }; + virtual void visitName(NameAst* node) { Q_UNUSED(node); }; +diff --git a/parser/conversionGenerator.py b/parser/conversionGenerator.py +index 385dbcb9..d44e51ee 100644 +--- a/parser/conversionGenerator.py ++++ b/parser/conversionGenerator.py +@@ -9,7 +9,7 @@ + + import sys + +-contents = open('python35.sdef').read().replace("\n", "").split(';;') ++contents = open('python36.sdef').read().replace("\n", "").split(';;') + + func_structure = ''' + Ast* visitNode(%{RULE_FOR}* node) { +@@ -19,7 +19,7 @@ func_structure = ''' + switch ( node->kind ) { + %{SWITCH_LINES} + default: +- qWarning() << "Unsupported statement AST type: " << node->kind; ++ qWarning() << "Unsupported %{RULE_FOR} AST type: " << node->kind; + Q_ASSERT(false); + } + %{APPENDIX} +diff --git a/parser/generated.h b/parser/generated.h +index bb0a1074..874ad4ec 100644 +--- a/parser/generated.h ++++ b/parser/generated.h +@@ -124,7 +124,7 @@ private: + break; + } + default: +- qWarning() << "Unsupported statement AST type: " << node->kind; ++ qWarning() << "Unsupported _excepthandler AST type: " << node->kind; + Q_ASSERT(false); + } + +@@ -284,6 +284,20 @@ private: + result = v; + break; + } ++ case JoinedStr_kind: { ++ JoinedStringAst* v = new JoinedStringAst(parent()); ++ nodeStack.push(v); v->values = visitNodeList<_expr, ExpressionAst>(node->v.JoinedStr.values); nodeStack.pop(); ++ result = v; ++ break; ++ } ++ case FormattedValue_kind: { ++ FormattedValueAst* v = new FormattedValueAst(parent()); ++ nodeStack.push(v); v->value = static_cast(visitNode(node->v.FormattedValue.value)); nodeStack.pop(); ++ v->conversion = node->v.FormattedValue.conversion; ++ nodeStack.push(v); v->formatSpec = static_cast(visitNode(node->v.FormattedValue.format_spec)); nodeStack.pop(); ++ result = v; ++ break; ++ } + case Bytes_kind: { + BytesAst* v = new BytesAst(parent()); + v->value = PyUnicodeObjectToQString(node->v.Bytes.s); +@@ -366,7 +380,7 @@ private: + break; + } + default: +- qWarning() << "Unsupported statement AST type: " << node->kind; ++ qWarning() << "Unsupported _expr AST type: " << node->kind; + Q_ASSERT(false); + } + +@@ -445,7 +459,7 @@ private: + break; + } + default: +- qWarning() << "Unsupported statement AST type: " << node->kind; ++ qWarning() << "Unsupported _slice AST type: " << node->kind; + Q_ASSERT(false); + } + +@@ -565,6 +579,14 @@ private: + result = v; + break; + } ++ case AnnAssign_kind: { ++ AnnotationAssignmentAst* v = new AnnotationAssignmentAst(parent()); ++ nodeStack.push(v); v->target = static_cast(visitNode(node->v.AnnAssign.target)); nodeStack.pop(); ++ nodeStack.push(v); v->annotation = static_cast(visitNode(node->v.AnnAssign.annotation)); nodeStack.pop(); ++ nodeStack.push(v); v->value = static_cast(visitNode(node->v.AnnAssign.value)); nodeStack.pop(); ++ result = v; ++ break; ++ } + case For_kind: { + ForAst* v = new ForAst(parent()); + nodeStack.push(v); v->target = static_cast(visitNode(node->v.For.target)); nodeStack.pop(); +@@ -690,7 +712,7 @@ private: + break; + } + default: +- qWarning() << "Unsupported statement AST type: " << node->kind; ++ qWarning() << "Unsupported _stmt AST type: " << node->kind; + Q_ASSERT(false); + } + +diff --git a/parser/python35.sdef b/parser/python36.sdef +similarity index 94% +rename from parser/python35.sdef +rename to parser/python36.sdef +index 30f12777..059bf69c 100644 +--- a/parser/python35.sdef ++++ b/parser/python36.sdef +@@ -17,6 +17,7 @@ RULE_FOR _stmt;KIND Return_kind;ACTIONS create|ReturnAst set|value->ExpressionAs + RULE_FOR _stmt;KIND Delete_kind;ACTIONS create|DeleteAst set|targets=>ExpressionAst,targets;; + RULE_FOR _stmt;KIND Assign_kind;ACTIONS create|AssignmentAst set|targets=>ExpressionAst,targets set|value->ExpressionAst,value;; + RULE_FOR _stmt;KIND AugAssign_kind;ACTIONS create|AugmentedAssignmentAst set|target->ExpressionAst,target set|op*>OperatorTypes,op set|value->ExpressionAst,value;; ++RULE_FOR _stmt;KIND AnnAssign_kind;ACTIONS create|AnnotationAssignmentAst set|target->ExpressionAst,target set|annotation->ExpressionAst,annotation set|value->ExpressionAst,value;; + RULE_FOR _stmt;KIND For_kind;ACTIONS create|ForAst set|target->ExpressionAst,target set|iterator->ExpressionAst,iter set|body=>Ast,body set|orelse=>Ast,orelse;; + RULE_FOR _stmt;KIND AsyncFor_kind;ACTIONS create|ForAst set|target->ExpressionAst,target set|iterator->ExpressionAst,iter set|body=>Ast,body set|orelse=>Ast,orelse;; + RULE_FOR _stmt;KIND While_kind;ACTIONS create|WhileAst set|condition->ExpressionAst,test set|body=>Ast,body set|orelse=>Ast,orelse;; +@@ -53,6 +54,8 @@ RULE_FOR _expr;KIND Compare_kind;ACTIONS create|CompareAst set|leftmostElement-> + RULE_FOR _expr;KIND Call_kind;ACTIONS create|CallAst set|function->ExpressionAst,func set|arguments=>ExpressionAst,args set|keywords=>KeywordAst,keywords;CODE v->function->belongsToCall = v;; + RULE_FOR _expr;KIND Num_kind;ACTIONS create|NumberAst;CODE v->isInt = PyLong_Check(node->v.Num.n); v->value = PyLong_AsLong(node->v.Num.n);; + RULE_FOR _expr;KIND Str_kind;ACTIONS create|StringAst set|value$>s;; ++RULE_FOR _expr;KIND JoinedStr_kind;ACTIONS create|JoinedStringAst set|values=>ExpressionAst,values;; ++RULE_FOR _expr;KIND FormattedValue_kind;ACTIONS create|FormattedValueAst set|value->ExpressionAst,value set|conversion:>conversion set|formatSpec->ExpressionAst,format_spec;; + RULE_FOR _expr;KIND Bytes_kind;ACTIONS create|BytesAst set|value$>s;; + RULE_FOR _expr;KIND Attribute_kind;ACTIONS create|AttributeAst set|attribute~>attr set|value->ExpressionAst,value set|context*>Context,ctx;; + RULE_FOR _expr;KIND Subscript_kind;ACTIONS create|SubscriptAst set|value->ExpressionAst,value set|slice->SliceAst,slice set|context*>Context,ctx;; +diff --git a/parser/tests/pyasttest.cpp b/parser/tests/pyasttest.cpp +index 875662aa..7995b18f 100644 +--- a/parser/tests/pyasttest.cpp ++++ b/parser/tests/pyasttest.cpp +@@ -153,6 +153,8 @@ void PyAstTest::testStatements_data() + QTest::newRow("continue") << "while True: continue"; + QTest::newRow("pass") << "pass"; + QTest::newRow("nonlocal") << "nonlocal x"; ++ QTest::newRow("varannotation1") << "primes: List[int] = []"; ++ QTest::newRow("varannotation2") << "captain: str # Note: no initial value!"; + } + + void PyAstTest::testSlices() +@@ -221,10 +223,16 @@ void PyAstTest::testExpressions_data() + QTest::newRow("None") << "None"; + QTest::newRow("False") << "False"; + QTest::newRow("True") << "True"; ++ ++ QTest::newRow("async_generator") << "async def foo(): result = [i async for i in aiter() if i % 2]"; ++ QTest::newRow("await_generator") << "async def foo(): result = [await fun() for fun in funcs]"; ++ ++ QTest::newRow("underscore_literals") << "0x_FF_FF_FF_FF"; + QTest::newRow("dstar_unpack") << "ext_map = {\n" + " **{ext: self.obj_extension for ext in self.src_extensions},\n" + " **{ext: self.res_extension for ext in self._rc_extensions + self._mc_extensions},\n" + "}"; ++ QTest::newRow("formatted_string_literal") << "f\"He said his name is {name}.\""; + } + + void PyAstTest::testCorrectedFuncRanges() diff --git a/kdevelop5-plugin-python3.changes b/kdevelop5-plugin-python3.changes index ceb1aa8..a5ecc08 100644 --- a/kdevelop5-plugin-python3.changes +++ b/kdevelop5-plugin-python3.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Wed Feb 22 15:13:52 UTC 2017 - lbeltrame@kde.org + +- Add build-with-py36.diff: diff from upstream 50-python36 branch + to enable building with Python 3.6 + ------------------------------------------------------------------- Fri Dec 2 14:55:35 UTC 2016 - wbauer@tmo.at diff --git a/kdevelop5-plugin-python3.spec b/kdevelop5-plugin-python3.spec index 2648c1b..a36941b 100644 --- a/kdevelop5-plugin-python3.spec +++ b/kdevelop5-plugin-python3.spec @@ -1,7 +1,7 @@ # # spec file for package kdevelop5-plugin-python3 # -# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -26,6 +26,10 @@ License: GPL-2.0+ Group: Development/Tools/IDE Url: http://www.kdevelop.org Source0: %{rname}-%{version}.tar.xz +%if 0%{?suse_version} > 1320 +#PATCH-FIX-UPSTREAM build-with-py36.diff - Add Python 3.6 support from the 50-python36 branch +Patch0: build-with-py36.diff +%endif BuildRequires: extra-cmake-modules BuildRequires: fdupes BuildRequires: grantlee5-devel @@ -79,6 +83,9 @@ Provides translations to the package %{name} %prep %setup -q -n %{rname}-%{version} +%if 0%{?suse_version} > 1320 +%patch0 -p1 +%endif %build %cmake_kf5 -d build