Skip to content
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

PEP 7 : don't allow MSVC extensions #758

Open
erikjanss opened this issue Aug 18, 2018 · 8 comments
Open

PEP 7 : don't allow MSVC extensions #758

erikjanss opened this issue Aug 18, 2018 · 8 comments

Comments

@erikjanss
Copy link

@erikjanss erikjanss commented Aug 18, 2018

PEP 7 has this sentence :

  • Don't use GCC extensions

I would propose to change this to :

  • Don't use GCC or MSVC extensions

Reason : using MSVC extensions in the C-code makes is harder to reuse the code or do experimental work on the code using different toolchains or make the code portable to other toolchains, which could be a long term disadvantage.

An exemption could be made for the PC/pyconfig.h file as this file is more or less MSVC specific.

@holdenweb

This comment was marked as off-topic.

@erikjanss

This comment was marked as off-topic.

@holdenweb

This comment was marked as off-topic.

@holdenweb

This comment was marked as off-topic.

@encukou
Copy link
Member

@encukou encukou commented Aug 19, 2018

@erikjanss In my interpretation, this is already implied as the PEP mentions ANSI/ISO standard C (though since the list of C99 features was added, it became a little less clear).
Do you have a specific example of a MSVC extension that should be called out? Is there non-standard code in CPython now that you'd like to get rid of?

@erikjanss
Copy link
Author

@erikjanss erikjanss commented Aug 19, 2018

@encukou Up to now I only found one (I have not yet been able to go through all files though),
since the PEP mentions GCC explicitly, it might be read as 'MSVC extension is fine in windows specific code'

Modules/socketmodule.c line 562 :

# define SUPPRESS_DEPRECATED_CALL __pragma(warning(suppress: 4996))

uses __pragma, which appears to be a MSVC extension :

https://msdn.microsoft.com/en-us/library/d9x1s805.aspx

@encukou
Copy link
Member

@encukou encukou commented Aug 20, 2018

Can you file a CPython pull request to properly conditionalize that?
I don't know much about coding for Windows, but to me this looks like an oversight rather than deliberately equating MS_WINDOWS with MSVC.

I think it will be useful to first have a PR discussion on this particular case, and then to clarify the PEP based on the PR discussion.

@brettcannon brettcannon changed the title PEP 7 : don't use GCC extensions PEP 7 : don't allow MSVC extensions Aug 24, 2018
@erikjanss
Copy link
Author

@erikjanss erikjanss commented Sep 5, 2018

I made a PR for this :

python/cpython#9067

The associated issue is 34581

https://bugs.python.org/issue34581

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

Successfully merging a pull request may close this issue.

None yet
3 participants