Thanks to visit codestin.com
Credit goes to github.com

Skip to content

bpo-32150: Expand tabs to spaces in C files. #4583

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

Merged
merged 2 commits into from
Nov 28, 2017

Conversation

serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented Nov 27, 2017

Tabs in C files add a noise in the diff if the committer uses an editor which don't preserve tabs (see for example #4390). This can hide semantic changes in tab expansion changes. It is better to expand all tabs to spaces in the single commit that doesn't do anything other.

https://bugs.python.org/issue32150

@gvanrossum
Copy link
Member

Where's the bpo issue?

@serhiy-storchaka
Copy link
Member Author

I haven't created a bpo issue. Do you think that this is necessary?

@gvanrossum
Copy link
Member

gvanrossum commented Nov 27, 2017 via email

@serhiy-storchaka serhiy-storchaka changed the title Expand tabs to spaces in C files. bpo-32150: Expand tabs to spaces in C files. Nov 27, 2017
Copy link
Member Author

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented issues in the current code fixed by this PR.


#define BIT2BYTE(ibit) ((ibit) / BITSPERBYTE)
#define BIT2SHIFT(ibit) ((ibit) % BITSPERBYTE)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here tabs make the view on GitHub uglier. See at left side.

@@ -72,8 +72,8 @@ PyAPI_FUNC(PyObject*) _PyBytes_FromHex(
int use_bytearray);
#endif
PyAPI_FUNC(PyObject *) PyBytes_DecodeEscape(const char *, Py_ssize_t,
const char *, Py_ssize_t,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong alignment due to tabs.

@@ -132,10 +132,10 @@ PyAPI_FUNC(Py_ssize_t) _PyBytes_InsertThousandsGrouping(char *buffer,

/* Flags used by string formatting */
#define F_LJUST (1<<0)
#define F_SIGN (1<<1)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mixed tabs and spaces make worser a view on GitHub.

@@ -7,8 +7,8 @@ extern "C" {
#endif

typedef struct {
PyObject_HEAD
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too larger indent.

@@ -30,13 +30,13 @@ PyAPI_FUNC(PyObject *) PyMethod_Self(PyObject *);
#define PyMethod_GET_FUNCTION(meth) \
(((PyMethodObject *)meth) -> im_func)
#define PyMethod_GET_SELF(meth) \
(((PyMethodObject *)meth) -> im_self)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mixed tabs and spaces (compare with lines above).

@@ -8,5 +8,5 @@
const char *
Py_GetPlatform(void)
{
return PLATFORM;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too large indent.

@@ -8,8 +8,8 @@
const char *
Py_GetVersion(void)
{
static char version[250];
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too large indent.

@@ -19,5 +19,5 @@ int PyFPE_counter = 0;
double
PyFPE_dummy(void *dummy)
{
return 1.0;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too large indent.

@@ -16,14 +16,14 @@ static PyObject *_Py_strhex_impl(const char* argbuf, const Py_ssize_t arglen,
if (return_bytes) {
/* If _PyBytes_FromSize() were public we could avoid malloc+copy. */
retbuf = (Py_UCS1*) PyMem_Malloc(arglen*2);
if (!retbuf)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mixed tabs and spaces.

@@ -5,10 +5,10 @@
char *
strdup(const char *str)
{
if (str != NULL) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too large indent.

@@ -17,7 +17,7 @@ Shoddy_increment(Shoddy *self, PyObject *unused)
static PyMethodDef Shoddy_methods[] = {
{"increment", (PyCFunction)Shoddy_increment, METH_NOARGS,
PyDoc_STR("increment state counter")},
{NULL, NULL},
{NULL, NULL},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is part of the documentation. Maybe use a single space? The tab doesn’t seem to align with anything.

Or even drop the second NULL. Other PyMethodDef arrays on the page have a single NULL. The other three fields get zeroed implicitly, and it looks like the first field (ml_name) is the one that is checked for NULL.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to drop the second NULL.

@serhiy-storchaka serhiy-storchaka merged commit 598ceae into python:master Nov 28, 2017
@serhiy-storchaka serhiy-storchaka deleted the expand-tabs branch November 28, 2017 15:56
#define PY_MINOR_VERSION 7
#define PY_MICRO_VERSION 0
#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_ALPHA
#define PY_RELEASE_SERIAL 2

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that the version constants are automatically generated by the release management tool, https://github.com/python/release-tools/blob/master/release.py, so that will probably need to be modified to handle spaces instead of tabs and any changes there need to be able to continue to handle patchlevel.h in older release cycles.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, my bad.

I have created a PR for the release management tool: python/release-tools#2 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants