Issue22942
Created on 2014-11-25 19:52 by jordan, last changed 2016-12-24 10:09 by martin.panter.
Messages (4) | |||
---|---|---|---|
msg231680 - (view) | Author: Jordan (jordan) | Date: 2014-11-25 19:52 | |
# I would like to report three bugs in the # Language Reference Python 3.4.2 ################################# # bug 1: Typo in parameter_list # ################################# # In 8.6 the rule for parameter_list should be corrected: The first "|" should be "(" # parameter_list ::= (defparameter ",")* # | "*" [parameter] ("," defparameter)* ["," "**" parameter] # | "**" parameter # | defparameter [","] ) # This rule was correct in 3.3 but has been changed with issue #21439, I guess. ############################################################################### # bug 2: print(*(1,2),) is allowed according to the syntax - but not accepted # ############################################################################### # In 6.3.4: # call ::= primary "(" [argument_list [","] | comprehension] ")" # argument_list ::= positional_arguments ["," keyword_arguments] # ["," "*" expression] ["," keyword_arguments] # ["," "**" expression] # | keyword_arguments ["," "*" expression] # ["," keyword_arguments] ["," "**" expression] # | "*" expression ["," keyword_arguments] ["," "**" expression] # | "**" expression # Why is this wrong? print(1,2,) # is allowed print(*(1,2)) # is allowed #print(*(1,2),) # is allowed according to the syntax - but not accepted # I guess the trailing comma is only allowed when there is no *-argument # as it is in the rule for parameter_list ########################################################### # bug 3: decorator rule allows (aditional) trailing comma # ########################################################### # In 8.6: # decorator ::= "@" dotted_name ["(" [parameter_list [","]] ")"] NEWLINE # parameter_list ::= (defparameter ",")* # ( "*" [parameter] ("," defparameter)* ["," "**" parameter] # | "**" parameter # | defparameter [","] ) # Why is this wrong? def klammer(klammer_left,klammer_right): def klammer_decorator(func): def func_wrapper(name): return klammer_left + func(name) + klammer_right return func_wrapper return klammer_decorator @klammer("<",">",) # is allowed #@klammer("<",">",,) # is allowed according to the syntax - but is not accepted def get_text(name): return "Hallo " + name print(get_text("Uli")) @klammer(*("<",">")) # is allowed #@klammer(*("<",">"),) # is allowed according to the syntax - but is not accepted def get_text(name): return "Hallo " + name print(get_text("Uli")) # I guess the decorator rule might be changed to: # decorator ::= "@" dotted_name ["(" [parameter_list ] ")"] NEWLINE # The other appearences of parameter_list have no optional comma. |
|||
msg239080 - (view) | Author: Martin Panter (martin.panter) * ![]() |
Date: 2015-03-24 00:33 | |
See also Issue 9232, about adding support for trailing commas in all cases of function calls and definitions. |
|||
msg267830 - (view) | Author: Martin Panter (martin.panter) * ![]() |
Date: 2016-06-08 10:17 | |
Bug 1 is still present in 3.5. In 3.6 it is no longer relevant because the documentation was changed for Issue 9232 (allowing trailing commas in function definitions). Bug 2 is present in 2.7, but is not relevant to 3.5+. Trailing commas are now allowed in function calls, probably thanks to PEP 448, unpacking generalizations. Bug 3 has been fixed in Issue 27042. |
|||
msg283934 - (view) | Author: Martin Panter (martin.panter) * ![]() |
Date: 2016-12-24 10:09 | |
Issue 28978 covers the parameter list syntax (Bug 1 + plus another problem). |
History | |||
---|---|---|---|
Date | User | Action | Args |
2016-12-24 10:09:27 | martin.panter | set | dependencies:
+ a redundant right parentheses in the EBNF rules of parameter_list messages: + msg283934 |
2016-06-08 10:17:14 | martin.panter | set | stage: needs patch messages: + msg267830 versions: + Python 2.7, Python 3.5, - Python 3.4 |
2015-03-24 00:33:35 | martin.panter | set | nosy:
+ martin.panter messages: + msg239080 |
2015-03-02 08:34:03 | ezio.melotti | set | nosy:
+ Joshua.Landau, NeilGirdhar |
2014-11-25 20:15:37 | ezio.melotti | set | nosy:
+ ezio.melotti |
2014-11-25 19:52:38 | jordan | create |