问题
I created a Simple Selenium Pytest automation script on Python 3.8.1. After running the script I see the below error:
Traceback (most recent call last):
.
.
.
Error messages
.
.
TypeError: required field "posonlyargs" missing from arguments
I googled and saw that this seems to be an issue with Python 3.8.1. Any suggestions on how to avoid this error? I could always go back to the previous Python version (3.8.0), but I'm keeping that as the last option.
回答1:
This error message...
TypeError: required field "posonlyargs" missing from arguments
...implies that posonlyargs
were missing from the arguments when defining function on Python 3.8
Deep dive
@carmenbianca in this merge mentioned as per the Python docs ast.arguments
was changed to also take posonlyargs
as argument. Different parsers are loaded depending on the base version of Python. The parser for Python 3.8 was required which would inherit from the v36 parser to adapt to the changes incorporated inorder to address this issue.
Solution
This issue was addressed through:
- Python 3.8.0 beta 2: bpo-37221: The new function PyCode_NewWithPosOnlyArgs() allows to create code objects like PyCode_New(), but with an extra posonlyargcount parameter for indicating the number of positonal-only arguments.
- Python 3.8.0 beta 3: bpo-37593: Swap the positions of the posonlyargs and args parameters in the constructor of ast.parameters nodes.
However, as per best practices you should upgrade to Python 3.8.1 final Release date: 2019-12-18
来源:https://stackoverflow.com/questions/59564990/typeerror-required-field-posonlyargs-missing-from-arguments-error-running-a-p