| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -6015,32 +6015,30 @@ improve_missing_self_error(PyThreadState* tstate, PyCodeObject* co, Py_ssize_t n | |
| if (nargs + 1 != co->co_argcount) { | ||
| return; | ||
| } | ||
|
|
||
| PyObject *type, *val, *tb; | ||
| _PyErr_Fetch(tstate, &type, &val, &tb); | ||
|
|
||
| if (!PyUnicode_CheckExact(val)) { | ||
| goto exit; | ||
| } | ||
|
|
||
| if (co->co_argcount > 0 && co->co_varnames && PyTuple_GET_SIZE(co->co_varnames) > 0) { | ||
| PyObject* first_arg = PyTuple_GET_ITEM(co->co_varnames, 0); | ||
| int comp = PyUnicode_CompareWithASCIIString(first_arg, "self"); | ||
| if (comp == 0 || comp == -1) { | ||
| if (_PyUnicode_EqualToASCIIString(first_arg, "self")) { | ||
| PyErr_Clear(); | ||
|
Comment thread
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityIt is not needed.
Sorry, something went wrong.
All reactions
|
||
| goto exit; | ||
| } | ||
| } | ||
|
|
||
| if (PyUnicode_CheckExact(val)) { | ||
| PyObject* trailing = PyUnicode_FromString(". Did you forget 'self' in the method definition?"); | ||
| if (trailing == NULL) { | ||
| PyErr_Clear(); | ||
| goto exit; | ||
| } | ||
| PyObject* new_val = PyUnicode_Concat(val, trailing); | ||
| if (new_val == NULL) { | ||
| PyErr_Clear(); | ||
| goto exit; | ||
| } | ||
| Py_DECREF(val); | ||
| val = new_val; | ||
| PyObject* new_val = PyUnicode_FromFormat("%U. Did you forget 'self' in the method" | ||
| " definition?", val); | ||
| if (new_val == NULL) { | ||
| PyErr_Clear(); | ||
| goto exit; | ||
| } | ||
| Py_DECREF(val); | ||
| val = new_val; | ||
| exit: | ||
| PyErr_Restore(type, val, tb); | ||
| } | ||
| Back | FazBrowse Home | New Git URL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityWhat about positional-only parameters and var-positional parameter?
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityI left that for future PRs, I wanted to get the basic logic first and then improve upon. But is just mirroring the logic in too_many_positional().
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityThere is the check !(co->co_flags & CO_VARARGS) befory calling too_many_positional().
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.