bpo-30726: Fix elementtree warnings on Windows due to expat upgrade by segevfiner · Pull Request #2319 · python/cpython (original) (raw)

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 andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation4 Commits2 Checks0 Files changed

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

segevfiner

We are getting:

Warning	C4005	'HAVE_MEMMOVE': macro redefinition	_elementtree	c:\users\segev\prj\python\cpython\modules\expat\winconfig.h	34	
Warning	C4267	'=': conversion from 'size_t' to 'unsigned char', possible loss of data	_elementtree	c:\users\segev\prj\python\cpython\modules\expat\siphash.h	316	
Warning	C4996	'getenv': This function or variable may be unsafe. Consider using _dupenv_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.	_elementtree	C:\Users\Segev\prj\python\cpython\Modules\expat\xmlparse.c	796	
Warning	C4005	'HAVE_MEMMOVE': macro redefinition	_elementtree	c:\users\segev\prj\python\cpython\modules\expat\winconfig.h	34	
Warning	C4005	'HAVE_MEMMOVE': macro redefinition	_elementtree	c:\users\segev\prj\python\cpython\modules\expat\winconfig.h	34

And in 64-bit:

c:\users\segev\prj\python\cpython\modules\expat\siphash.h(201): warning C4244: 'initializing': conversion from '__int64' to 'char', possible loss of data

I'm not sure how many Python versions this affects.

@vstinner

Can you please rewrite your PR on new master branch, just to add _CRT_SECURE_NO_WARNINGS define? Please explain in the commit message that it's to fix the warning on getenv(). I agree that the usage of getenv() is safe: thanks to the GIL, we only run one thread at the same time, and the getenv() result is not stored but used in the next instruction. So I don't see any risk of race condition here.

@segevfiner

Caused by usage of getenv which should be safe. And a few integer truncations which should also be ok.

@segevfiner

@Haypo Done. I forgot that I silenced more warnings than those fixed by #2348 when I commented on it. 😛

vstinner

@@ -62,7 +62,8 @@
..\Modules\expat;%(AdditionalIncludeDirectories)
USE_PYEXPAT_CAPI;XML_STATIC;%(PreprocessorDefinitions)
_CRT_SECURE_NO_WARNINGS;USE_PYEXPAT_CAPI;XML_STATIC;%(PreprocessorDefinitions)
4244;4267;%(DisableSpecificWarnings)

Choose a reason for hiding this comment

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

What are these warnings? Why do you want to turn them off? If they are related to integer downcast, please keep the warnings. I prefer to fix them rather than make them quiet. See my PR to libexpat. Once it's merged upstream (libexpat), I plan to cherry-pick the fix downstream (CPython).

At least, list these warnings in your commit message with their description.

@segevfiner

@Haypo They are:

Warning	C4267	'=': conversion from 'size_t' to 'unsigned char', possible loss of data	_elementtree	siphash.h	316	
siphash.h(201): warning C4244: 'initializing': conversion from '__int64' to 'char', possible loss of data

I think your libexpat/libexpat#58 does fix those. Which is obviously a better way to fix those warnings. I will remove ignoring those warnings.

@segevfiner

vstinner

@segevfiner segevfiner deleted the bpo-30726-elementtree-warnings branch

June 23, 2017 10:54

vstinner added a commit that referenced this pull request

Jun 23, 2017

@vstinner

… (#2350)

bpo-30726, bpo-29591: libexpat 2.2.1 of Modules/expat/ now uses a winconfig.h configuration file which already defines:

Remove these defines from PCbuild/_elementtree.vcxproj to prevent compiler warnings.

Co-Authored-By: Jeremy Kloth jeremy.kloth@gmail.com (cherry picked from commit c8fb58b)

Caused by usage of getenv which should be safe. And a few integer truncations which should also be ok.

(cherry picked from commit 87c6555)

vstinner added a commit that referenced this pull request

Jun 23, 2017

@vstinner

… (#2349)

bpo-30726, bpo-29591: libexpat 2.2.1 of Modules/expat/ now uses a winconfig.h configuration file which already defines:

Remove these defines from PCbuild/_elementtree.vcxproj to prevent compiler warnings.

Co-Authored-By: Jeremy Kloth jeremy.kloth@gmail.com (cherry picked from commit c8fb58b)

Caused by usage of getenv which should be safe. And a few integer truncations which should also be ok.

(cherry picked from commit 87c6555)

ned-deily pushed a commit to ned-deily/cpython that referenced this pull request

Jul 7, 2017

@vstinner @ned-deily

…on#2348) (python#2349)

bpo-30726, bpo-29591: libexpat 2.2.1 of Modules/expat/ now uses a winconfig.h configuration file which already defines:

Remove these defines from PCbuild/_elementtree.vcxproj to prevent compiler warnings.

Co-Authored-By: Jeremy Kloth jeremy.kloth@gmail.com (cherry picked from commit c8fb58b)

Caused by usage of getenv which should be safe. And a few integer truncations which should also be ok.

(cherry picked from commit 87c6555) (cherry picked from commit d32a059)

larryhastings pushed a commit that referenced this pull request

Jul 12, 2017

@vstinner @larryhastings

…2164) (#2203)

Remove the configuration (Modules/expat/*config.h) of unsupported platforms:

The XML_HAS_SET_HASH_SALT define of Modules/expat/expat.h became useless since our local expat copy was upgrade to expat 2.1 (it's now expat 2.2.0).

(cherry picked from commit 23ec4b5)

New file: Modules/expat/siphash.h. (cherry picked from commit 5ff7132)

bpo-30726, bpo-29591: libexpat 2.2.1 of Modules/expat/ now uses a winconfig.h configuration file which already defines:

Remove these defines from PCbuild/_elementtree.vcxproj to prevent compiler warnings.

Co-Authored-By: Jeremy Kloth jeremy.kloth@gmail.com (cherry picked from commit c8fb58b)

Caused by usage of getenv which should be safe. And a few integer truncations which should also be ok.

(cherry picked from commit 87c6555)

ned-deily pushed a commit that referenced this pull request

Jul 16, 2017

@vstinner @ned-deily

…2164) (#2204)

Remove the configuration (Modules/expat/*config.h) of unsupported platforms:

The XML_HAS_SET_HASH_SALT define of Modules/expat/expat.h became useless since our local expat copy was upgrade to expat 2.1 (it's now expat 2.2.0).

(cherry picked from commit 23ec4b5)

New file: Modules/expat/siphash.h. (cherry picked from commit 5ff7132)

bpo-30726, bpo-29591: libexpat 2.2.1 of Modules/expat/ now uses a winconfig.h configuration file which already defines:

Remove these defines from PCbuild/_elementtree.vcxproj to prevent compiler warnings.

Co-Authored-By: Jeremy Kloth jeremy.kloth@gmail.com (cherry picked from commit c8fb58b)

Caused by usage of getenv which should be safe. And a few integer truncations which should also be ok.

(cherry picked from commit 87c6555)