# 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.
|