Files
python-pythran/support-gast-0.6.patch
Benjamin Greiner 59750e7e5a - Update to 0.18.0 - balafenn
* no upstream changelog.
  ## git commits (a few non-relevant filtered)
  * Fix uninitialized iexpr assignment
  * Fix folding of comparison operators
  * Take augassign into account when removing nested functions
  * Fix local processing in presence of else: clause in for loop
  * Fix detection of c++ compiler
  * Traverse augassign when computing scopes
  * Reproducible ContainerOf iteration
  * Fix overload handling for NoneType
  * Fix type inference in presence of augassign
  * Improve forward substitution in presence of augassign
  * Remove dead code in tests
  * Faster (and common!) implementation of make_integer_sequence
  * Only register a node in name_to_nodes if the combiner was
    succesful
  * Reproducible aliasing ordering
  * Reproducible nested functions removal
  * Reproducible topological order
  * Verify reproducibility of c++ output
  * Reproducible (because sortable) alias order
  * Stateless PType
  * Reproducible local declaration order
  * Reproducible identifiers generation
  * Reproducible include order
  * More flexible implementation of default list
  * Fix typing issue under complex slice combination
  * Add support for nonlocal keyword
  * Fix bug in nested function remover

OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:numeric/python-pythran?expand=0&rev=56
2025-05-30 10:58:41 +00:00

77 lines
4.7 KiB
Diff

From 840a0e706ec39963aec6bcd1f118bf33177c20b4 Mon Sep 17 00:00:00 2001
From: serge-sans-paille <serge.guelton@telecom-bretagne.eu>
Date: Sat, 29 Jun 2024 19:13:02 +0200
Subject: [PATCH] Bump gast requirement to 0.6.0
This mostly helps for harmonious behavior wrt. gast.dump
---
docs/TUTORIAL.rst | 8 ++++----
pythran/utils.py | 2 +-
requirements.txt | 2 +-
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/docs/TUTORIAL.rst b/docs/TUTORIAL.rst
index 09f6902f9..7692547eb 100644
--- a/docs/TUTORIAL.rst
+++ b/docs/TUTORIAL.rst
@@ -20,7 +20,7 @@ Python ships a standard module, ``ast`` to turn Python code into an AST. For ins
>>> code = "a=1"
>>> tree = ast.parse(code) # turn the code into an AST
>>> print(ast.dump(tree)) # view it as a string
- Module(body=[Assign(targets=[Name(id='a', ctx=Store(), annotation=None, type_comment=None)], value=Constant(value=1, kind=None), type_comment=None)], type_ignores=[])
+ Module(body=[Assign(targets=[Name(id='a', ctx=Store())], value=Constant(value=1, kind=None))])
Deciphering the above line, one learns that the single assignment is parsed as
a module containing a single statement, which is an assignment to a single
@@ -33,7 +33,7 @@ Eventually, one needs to parse more complex codes, and things get a bit more cry
... return n if n< 2 else fib(n-1) + fib(n-2)"""
>>> tree = ast.parse(fib_src)
>>> print(ast.dump(tree))
- Module(body=[FunctionDef(name='fib', args=arguments(args=[Name(id='n', ctx=Param(), annotation=None, type_comment=None)], posonlyargs=[], vararg=None, kwonlyargs=[], kw_defaults=[], kwarg=None, defaults=[]), body=[Return(value=IfExp(test=Compare(left=Name(id='n', ctx=Load(), annotation=None, type_comment=None), ops=[Lt()], comparators=[Constant(value=2, kind=None)]), body=Name(id='n', ctx=Load(), annotation=None, type_comment=None), orelse=BinOp(left=Call(func=Name(id='fib', ctx=Load(), annotation=None, type_comment=None), args=[BinOp(left=Name(id='n', ctx=Load(), annotation=None, type_comment=None), op=Sub(), right=Constant(value=1, kind=None))], keywords=[]), op=Add(), right=Call(func=Name(id='fib', ctx=Load(), annotation=None, type_comment=None), args=[BinOp(left=Name(id='n', ctx=Load(), annotation=None, type_comment=None), op=Sub(), right=Constant(value=2, kind=None))], keywords=[]))))], decorator_list=[], returns=None, type_comment=None)], type_ignores=[])
+ Module(body=[FunctionDef(name='fib', args=arguments(args=[Name(id='n', ctx=Param())]), body=[Return(value=IfExp(test=Compare(left=Name(id='n', ctx=Load()), ops=[Lt()], comparators=[Constant(value=2, kind=None)]), body=Name(id='n', ctx=Load()), orelse=BinOp(left=Call(func=Name(id='fib', ctx=Load()), args=[BinOp(left=Name(id='n', ctx=Load()), op=Sub(), right=Constant(value=1, kind=None))]), op=Add(), right=Call(func=Name(id='fib', ctx=Load()), args=[BinOp(left=Name(id='n', ctx=Load()), op=Sub(), right=Constant(value=2, kind=None))]))))])])
The idea remains the same. The whole Python syntax is described in
http://docs.python.org/2/library/ast.html and is worth a glance, otherwise
@@ -199,7 +199,7 @@ constant expressions. In the previous code, there is only two constant
>>> ce = pm.gather(analyses.ConstantExpressions, tree)
>>> sorted(map(ast.dump, ce))
- ["Attribute(value=Name(id='math', ctx=Load(), annotation=None, type_comment=None), attr='cos', ctx=Load())", 'Constant(value=3, kind=None)']
+ ["Attribute(value=Name(id='math', ctx=Load()), attr='cos', ctx=Load())", 'Constant(value=3, kind=None)']
One of the most critical analyse of Pythran is the points-to analysis. There
are two flavors of this analyse, one that computes an over-set of the aliased
@@ -210,7 +210,7 @@ variable, and one that computes an under set. ``Aliases`` computes an over-set::
>>> al = pm.gather(analyses.Aliases, tree)
>>> returned = tree.body[-1].body[-1].value
>>> print(ast.dump(returned))
- Name(id='b', ctx=Load(), annotation=None, type_comment=None)
+ Name(id='b', ctx=Load())
>>> sorted(a.id for a in al[returned])
['c', 'd']
diff --git a/pythran/utils.py b/pythran/utils.py
index 2d7a67327..55a7e8ad6 100644
--- a/pythran/utils.py
+++ b/pythran/utils.py
@@ -106,7 +106,7 @@ def get_variable(assignable):
... slice=ast.Name('j', ast.Load(), None, None),
... ctx=ast.Load())
>>> ast.dump(get_variable(ref))
- "Name(id='a', ctx=Load(), annotation=None, type_comment=None)"
+ "Name(id='a', ctx=Load())"
"""
msg = "Only name and subscript can be assigned."
assert isinstance(assignable, (ast.Name, ast.Subscript)), msg
diff --git a/requirements.txt b/requirements.txt
index fd6a738e5..c7a25c52a 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,5 +1,5 @@
ply>=3.4
setuptools
-gast~=0.5.0
+gast~=0.6.0
numpy
beniget~=0.4.0