-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
STYLE: Fix incorrect path to ujson directory #39352
New issue
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
Conversation
Thanks @gcmaciel , but now that they are not skipped, there are lots of issues to fixup in them - is that something to want to work on? |
Yeah, I'd like to work on it. |
awesome! I'll mark this as "draft" then until that's done then, ping when it's ready and we'll review |
@MarcoGorelli , so far I've fixed 35 out of 42 issues. But before I start working on the remaining 7, I have a few questions about them. 5 of the remaining issues says The other two issues has to do with a missing copyright message on two files (date_conversions.c and date_conversions.h). In the beginning, I had no clue which copyright message should be included, but after I inspected the other files on the same directory, I've noticed all of them share the same copyright message, which is this one:
Which makes me think this is the copyright that should be included. But I'm not sure about it. |
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.
Lgtm
Thanks @WillAyd - do you know if the same copyright notice (pasted in #39352 (comment)) can be used here and needs to be included in each file? |
The date_conversions files were created by pandas and not vendored from ultrajson, so they are fine without that copyright notice |
Sorry approved from my phone without seeing the checks - need to be green before really approving / merging, but conceptually this is all OK |
Unfortunately, without the copyright message, the linting test will fail. The way it is right now, when I run:
This is the output:
So I still need to fix that lack of copyright (and put something in that |
If needed for cpplint you can use the copyright here
https://github.com/pandas-dev/pandas/blob/309cf3a6c76c0671ac5710e14655257c9cbcdbf8/pandas/_libs/src/inline_helper.h#L2
Just change 2016 to whenever the file was created through present
…Sent from my iPad
On Jan 24, 2021, at 11:19 AM, Gustavo C. Maciel ***@***.***> wrote:
Unfortunately, without the copyright message, the linting test will fail.
The way it is right now, when I run:
./ci/code_checks.sh lint
This is the output:
Linting .pyx code for spacing conventions in casting
Linting .pyx code for spacing conventions in casting DONE
Linting .c and .h
pandas/_libs/src/ujson/python/date_conversions.c:0: No copyright message found. You should have a line: "Copyright [year] <Copyright Owner>" [legal/copyright] [5]
pandas/_libs/src/ujson/python/date_conversions.c:111: Missing username in TODO; it should look like "// TODO(my_username): Stuff." [readability/todo] [2]
Done processing pandas/_libs/src/ujson/python/date_conversions.c
pandas/_libs/src/ujson/python/date_conversions.h:0: No copyright message found. You should have a line: "Copyright [year] <Copyright Owner>" [legal/copyright] [5]
pandas/_libs/src/ujson/python/date_conversions.h:17: Missing username in TODO; it should look like "// TODO(my_username): Stuff." [readability/todo] [2]
Done processing pandas/_libs/src/ujson/python/date_conversions.h
pandas/_libs/src/ujson/python/objToJSON.c:1522: Missing username in TODO; it should look like "// TODO(my_username): Stuff." [readability/todo] [2]
pandas/_libs/src/ujson/python/objToJSON.c:1621: Missing username in TODO; it should look like "// TODO(my_username): Stuff." [readability/todo] [2]
Done processing pandas/_libs/src/ujson/python/objToJSON.c
pandas/_libs/src/ujson/python/ujson.c:76: Missing username in TODO; it should look like "// TODO(my_username): Stuff." [readability/todo] [2]
Done processing pandas/_libs/src/ujson/python/ujson.c
Total errors found: 7
Linting .c and .h DONE
So I still need to fix that lack of copyright (and put something in that TODO part).
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Great! Thanks @WillAyd |
I fixed all the issues raised by But one of the changes I've made led to some fails. After inspecting those logs I've identified that when I've replaced So to make it work, I reverted
|
It's all green now! @MarcoGorelli @WillAyd , this PR is ready to be reviewed |
The error messages suggest you are just mixing up passing a pointer and an integer as an argument. Can you post the code tried instead of removing the rule?
…Sent from my iPhone
On Jan 25, 2021, at 7:47 AM, Gustavo C. Maciel ***@***.***> wrote:
It's all green now! @MarcoGorelli @WillAyd , this PR is ready to be reviewed
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
@WillAyd sure, but actually I wasn't writing a new function or anything, I only replaced cLabel = PyObject_Malloc(21); // 21 chars for int64
sprintf(cLabel, "%" NPY_DATETIME_FMT,
NpyDateTimeToEpoch(nanosecVal, base));
len = strlen(cLabel); Then, I've replaced cLabel = PyObject_Malloc(21); // 21 chars for int64
snprintf(cLabel, "%" NPY_DATETIME_FMT,
NpyDateTimeToEpoch(nanosecVal, base));
len = strlen(cLabel); But this second code led to those errors. I tried to find a way to make it work without removing the rule but, in the end, I decided to revert that to |
The second argument to snprintf is an integer. I believe you can just pass 21 as the second argument (the size of the cLabel buffer)
… On Jan 25, 2021, at 9:59 AM, Gustavo C. Maciel ***@***.***> wrote:
@WillAyd <https://github.com/WillAyd> sure, but actually I wasn't writing a new function or anything, I only replaced sprintf with snprintf because it was required by cpplint. So this is the code from https://github.com/pandas-dev/pandas/blob/master/pandas/_libs/src/ujson/python/objToJSON.c#L1398 <https://github.com/pandas-dev/pandas/blob/master/pandas/_libs/src/ujson/python/objToJSON.c#L1398>, line 1398, before the replacement:
cLabel = PyObject_Malloc(21); // 21 chars for int64
sprintf(cLabel, "%" NPY_DATETIME_FMT,
NpyDateTimeToEpoch(nanosecVal, base));
len = strlen(cLabel);
Then, I've replaced sprintf with snprintf and it looked like this:
cLabel = PyObject_Malloc(21); // 21 chars for int64
snprintf(cLabel, "%" NPY_DATETIME_FMT,
NpyDateTimeToEpoch(nanosecVal, base));
len = strlen(cLabel);
But this second code led to those errors. I tried to find a way to make it work without removing the rule but, in the end, I decided to revert that to sprinft (which was working before) and add -runtime/printf to the list of filters because I've noticed there were some other rules that had been already removed and also because at least it could have a working version until this could be better discussed.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#39352 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAEU4UIYBKAA6QXMNR33OLTS3WWQLANCNFSM4WP4XR2A>.
|
Like this, right? cLabel = PyObject_Malloc(21); // 21 chars for int64
snprintf(cLabel, 21, "%" NPY_DATETIME_FMT,
NpyDateTimeToEpoch(nanosecVal, base));
len = strlen(cLabel); |
I think looks right - can you compile and test?
…Sent from my iPhone
On Jan 25, 2021, at 11:53 AM, Gustavo C. Maciel ***@***.***> wrote:
Like this, right?
cLabel = PyObject_Malloc(21); // 21 chars for int64
snprintf(cLabel, 21, "%" NPY_DATETIME_FMT,
NpyDateTimeToEpoch(nanosecVal, base));
len = strlen(cLabel);
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
It didn't work as expected because So I decided to declare The final version looks like this: cLabel = PyObject_Malloc(21); // 21 chars for int64
int size_of_cLabel = 21;
snprintf(cLabel, size_of_cLabel, "%" NPY_DATETIME_FMT,
NpyDateTimeToEpoch(nanosecVal, base));
len = strlen(cLabel); Now I'm going to remove |
Can you push the change? Would be a little cleaner if you move the variable declaration up one line and pass it as an argument to |
I pushed the changes. I'm pasting here too to make it easier: int size_of_cLabel = 21; // 21 chars for int 64
cLabel = PyObject_Malloc(size_of_cLabel);
snprintf(cLabel, size_of_cLabel, "%" NPY_DATETIME_FMT,
NpyDateTimeToEpoch(nanosecVal, base));
len = strlen(cLabel); |
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.
lgtm. @WillAyd merge when ready
Great thanks @gcmaciel |
I fixed the path to
ujson
directory socpplint
will run onpandas/_libs/src/ujson/
instead ofpandas/_libs/ujson
, which doesn't exist.But the title of the issue says
cpplint (unintentionally?) skips pandas/_libs/src/ujson/
, so I understand there's a chance thepandas/_libs/src/ujson/
is getting intentionally skipped.Assuming this was unintentional, I believe this small fix solves the issue.