[Python-3000-checkins] r54926 - in python/branches/p3yk: Lib/test/test_grammar.py Python/ast.c
nick.coghlan
python-3000-checkins at python.org
Mon Apr 23 13:05:06 CEST 2007
Author: nick.coghlan
Date: Mon Apr 23 13:05:01 2007
New Revision: 54926
Modified:
python/branches/p3yk/Lib/test/test_grammar.py
python/branches/p3yk/Python/ast.c
Log:
Allow decorators and return annotations to be used together (fixes SF#1697248)
Modified: python/branches/p3yk/Lib/test/test_grammar.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_grammar.py (original)
+++ python/branches/p3yk/Lib/test/test_grammar.py Mon Apr 23 13:05:01 2007
@@ -322,7 +322,12 @@
self.assertEquals(f.__annotations__,
{'b': 1, 'c': 2, 'e': 3, 'g': 6, 'h': 7, 'j': 9,
'k': 11, 'return': 12})
-
+ # Check for SF Bug #1697248 - mixing decorators and a return annotation
+ def null(x): return x
+ @null
+ def f(x) -> list: pass
+ self.assertEquals(f.__annotations__, {'return': list})
+
# test MAKE_CLOSURE with a variety of oparg's
closure = 1
def f(): return closure
Modified: python/branches/p3yk/Python/ast.c
==============================================================================
--- python/branches/p3yk/Python/ast.c (original)
+++ python/branches/p3yk/Python/ast.c Mon Apr 23 13:05:01 2007
@@ -983,7 +983,7 @@
REQ(n, funcdef);
- if (NCH(n) == 6) { /* decorators are present */
+ if (NCH(n) == 6 || NCH(n) == 8) { /* decorators are present */
decorator_seq = ast_for_decorators(c, CHILD(n, 0));
if (!decorator_seq)
return NULL;
More information about the Python-3000-checkins
mailing list