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

Fix compilation warnings #52

Closed
thomasst opened this issue Jun 4, 2018 · 1 comment
Closed

Fix compilation warnings #52

thomasst opened this issue Jun 4, 2018 · 1 comment
Assignees

Comments

@thomasst
Copy link
Member

thomasst commented Jun 4, 2018

Variable declaration should be wrapped in #ifdef for Python versions where it's not needed (I believe >= 3.2).

module.c: In function ‘PyInit_ciso8601’:
module.c:414:15: warning: unused variable ‘pytz’ [-Wunused-variable]
     PyObject *pytz;

Also, should we trigger errors on compile warnings to catch these?

@movermeyer
Copy link
Collaborator

movermeyer commented Jun 4, 2018

There are several compilation warnings right now, depending on the Python version:

Python 2.7

module.c: In function ‘_parse’:
module.c:126:13: warning: format ‘%d’ expects argument of type ‘int’, but argument 5 has type ‘long unsigned int’ [-Wformat=]
             PARSE_SEPARATOR(IS_CALENDAR_DATE_SEPARATOR, "date separator ('-')")
             ^
module.c:205:9: warning: format ‘%d’ expects argument of type ‘int’, but argument 5 has type ‘long unsigned int’ [-Wformat=]
         PARSE_SEPARATOR(IS_DATE_AND_TIME_SEPARATOR,
         ^
module.c:223:21: warning: format ‘%d’ expects argument of type ‘int’, but argument 5 has type ‘long unsigned int’ [-Wformat=]
                     PARSE_SEPARATOR(IS_TIME_SEPARATOR, "time separator (':')")
                     ^
module.c: In function ‘initciso8601’:
module.c:415:15: warning: unused variable ‘datetime’ [-Wunused-variable]
     PyObject *datetime;

Python 3.7

env37/bin/python setup.py bdist
...
module.c: In function ‘PyInit_ciso8601’:
module.c:415:15: warning: unused variable ‘datetime’ [-Wunused-variable]
     PyObject *datetime;
               ^
module.c:414:15: warning: unused variable ‘pytz’ [-Wunused-variable]
     PyObject *pytz;
               ^
module.c: At top level:
module.c:4:18: warning: ‘fixed_offset’ defined but not used [-Wunused-variable]
 static PyObject *fixed_offset;
                  ^

Python 3.6 on Windows:

module.c
module.c(107): error C2220: warning treated as error - no 'object' file generated
module.c(107): warning C4267: 'function': conversion from 'size_t' to 'int', possible loss of data
module.c(127): warning C4267: 'function': conversion from 'size_t' to 'int', possible loss of data
module.c(133): warning C4267: 'function': conversion from 'size_t' to 'int', possible loss of data
module.c(141): warning C4267: 'function': conversion from 'size_t' to 'int', possible loss of data
module.c(145): warning C4267: 'function': conversion from 'size_t' to 'int', possible loss of data
module.c(213): warning C4267: 'function': conversion from 'size_t' to 'int', possible loss of data
module.c(223): warning C4267: 'function': conversion from 'size_t' to 'int', possible loss of data
module.c(230): warning C4267: 'function': conversion from 'size_t' to 'int', possible loss of data
module.c(235): warning C4267: 'function': conversion from 'size_t' to 'int', possible loss of data
module.c(241): warning C4267: 'function': conversion from 'size_t' to 'int', possible loss of data
module.c(245): warning C4267: 'function': conversion from 'size_t' to 'int', possible loss of data
module.c(250): warning C4267: 'function': conversion from 'size_t' to 'int', possible loss of data
module.c(295): warning C4267: 'function': conversion from 'size_t' to 'int', possible loss of data
module.c(300): warning C4267: 'function': conversion from 'size_t' to 'int', possible loss of data
module.c(303): warning C4267: 'function': conversion from 'size_t' to 'int', possible loss of data

There are also 2 warnings from Python about missing metadata in setup.py:

warning: check: missing required meta-data: url

warning: check: missing meta-data: either (author and author_email) or (maintainer and maintainer_email) must be supplied

I'll create a PR to fix all these. The code doesn't get any cleaner, but it might be nice to be able to fail the CI on new warnings.

@movermeyer movermeyer changed the title pytz compile warning Fix compilation warnings Jun 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants