Author jordan
Recipients docs@python, jordan
Date 2014-11-25.19:52:37
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1416945158.04.0.329806790258.issue22942@psf.upfronthosting.co.za>
In-reply-to
Content
# 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.
History
Date User Action Args
2014-11-25 19:52:38jordansetrecipients: + jordan, docs@python
2014-11-25 19:52:38jordansetmessageid: <1416945158.04.0.329806790258.issue22942@psf.upfronthosting.co.za>
2014-11-25 19:52:37jordanlinkissue22942 messages
2014-11-25 19:52:37jordancreate