This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Compiler warning for readline extension
Type: compile error Stage: resolved
Components: Build, Extension Modules Versions: Python 3.4, Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, masamoto, python-dev
Priority: normal Keywords: patch

Created on 2015-04-25 14:21 by masamoto, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
3.4-issue24058-readline-_PyOS_ReadlineTState.patch masamoto, 2015-04-25 14:23 review
Repositories containing patches
https://hg.python.org/cpython#3.4
Messages (7)
msg242013 - (view) Author: Masayuki Yamamoto (masamoto) * Date: 2015-04-25 14:21
Compiler warns case of define HAVE_DECLSPEC_DLL.
In Modules/readline.c:1065, _PyOS_ReadlineTState variable declaration is different to Include/pythonrun.h:275.
msg242014 - (view) Author: Masayuki Yamamoto (masamoto) * Date: 2015-04-25 14:23
Here is a patch modifying variable declaration to same as Include/pytonrun.h.
msg242021 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2015-04-25 18:25
What kind of compiler/system does this happen on?
msg242022 - (view) Author: Masayuki Yamamoto (masamoto) * Date: 2015-04-25 20:07
um, Compiler warned, but test passed. It seems a only warning.

build log:
$ ./configure --prefix=/opt/py34
$ make
...
building 'readline' extension
gcc -Wno-unused-result -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Werror=declaration-after-statement -I./Include -I/opt/py34/include -I. -IInclude -I/usr/local/include -I/home/masayuki/src/CPython-3.4/Include -I/home/masayuki/src/CPython-3.4 -c /cygdrive/d/cyghome/masayuki/src/CPython-3.4/Modules/readline.c -o build/temp.cygwin-1.7.35-i686-3.4/cygdrive/d/cyghome/masayuki/src/CPython-3.4/Modules/readline.o
/cygdrive/d/cyghome/masayuki/src/CPython-3.4/Modules/readline.c:1065:23: warning: '_PyOS_ReadlineTState' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
 extern PyThreadState* _PyOS_ReadlineTState;
                       ^
...

test log:
$ /opt/py34/bin/python3.4m.exe -E -Wd -mtest -v test_readline
== CPython 3.4.3+ (3.4:ce2b9f160391+, Apr 25 2015, 20:45:32) [GCC 4.9.2]
==   CYGWIN_NT-6.0-1.7.35-0.287-5-3-i686-32bit-WindowsPE little-endian
==   hash algorithm: siphash24 32bit
==   /tmp/test_python_2660
Testing with flags: sys.flags(debug=0, inspect=0, interactive=0, optimize=0, dont_write_bytecode=0, no_user_site=0, no_site=0, ignore_environment=1, verbose=0, bytes_warning=0, quiet=0, hash_randomization=1, isolated=0)
[1/1] test_readline
testHistoryUpdates (test.test_readline.TestHistoryManipulation) ... ok
test_init (test.test_readline.TestReadline) ... ok

----------------------------------------------------------------------
Ran 2 tests in 0.199s

OK
1 test OK.
msg242059 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2015-04-26 16:50
Does simply removing the "extern" work?
msg242074 - (view) Author: Masayuki Yamamoto (masamoto) * Date: 2015-04-26 19:51
I tried another two case changing variable declaration.
First case of just removing "extern", Compiler similarly warns, and test passed.
Second case of removing "_PyOS_ReadlineTState" declaration, Compiler has not warned, and test passed.

First:
$ hg diff
diff -r a50707a73d84 Modules/readline.c
--- a/Modules/readline.c	Wed Nov 05 15:11:34 2014 +0100
+++ b/Modules/readline.c	Mon Apr 27 03:09:06 2015 +0900
@@ -1062,7 +1062,7 @@
     rl_callback_handler_remove();
 }
 
-extern PyThreadState* _PyOS_ReadlineTState;
+PyThreadState* _PyOS_ReadlineTState;
 
 static char *
 readline_until_enter_or_signal(const char *prompt, int *signal)

$ ./configure --prefix=/opt/py34 && make
...
building 'readline' extension
...
/cygdrive/d/cyghome/masayuki/src/CPython-3.4/Modules/readline.c:1065:16: warning: '_PyOS_ReadlineTState' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
 PyThreadState* _PyOS_ReadlineTState;
                ^
...

$ make install
$ /opt/py34/bin/python3.4m.exe -E -Wd -mtest -v test_readline
== CPython 3.4.3+ (3.4:a50707a73d84+, Apr 27 2015, 02:59:04) [GCC 4.9.2]
==   CYGWIN_NT-6.0-1.7.35-0.287-5-3-i686-32bit-WindowsPE little-endian
==   hash algorithm: siphash24 32bit
==   /tmp/test_python_3872
Testing with flags: sys.flags(debug=0, inspect=0, interactive=0, optimize=0, dont_write_bytecode=0, no_user_site=0, no_site=0, ignore_environment=1, verbose=0, bytes_warning=0, quiet=0, hash_randomization=1, isolated=0)
[1/1] test_readline
testHistoryUpdates (test.test_readline.TestHistoryManipulation) ... ok
test_init (test.test_readline.TestReadline) ... ok

----------------------------------------------------------------------
Ran 2 tests in 0.203s

OK
1 test OK.


Second:
$ hg diff
diff -r a50707a73d84 Modules/readline.c
--- a/Modules/readline.c        Wed Nov 05 15:11:34 2014 +0100
+++ b/Modules/readline.c        Mon Apr 27 04:13:45 2015 +0900
@@ -1062,7 +1062,6 @@
     rl_callback_handler_remove();
 }

-extern PyThreadState* _PyOS_ReadlineTState;

 static char *
 readline_until_enter_or_signal(const char *prompt, int *signal)

$ ./configure --prefix=/opt/py34 && make
... building 'readline' extension has not warned.

$ make install
$ /opt/py34/bin/python3.4m.exe -E -Wd -mtest -v test_readline
== CPython 3.4.3+ (3.4:a50707a73d84+, Apr 27 2015, 04:19:36) [GCC 4.9.2]
==   CYGWIN_NT-6.0-1.7.35-0.287-5-3-i686-32bit-WindowsPE little-endian
==   hash algorithm: siphash24 32bit
==   /tmp/test_python_5936
Testing with flags: sys.flags(debug=0, inspect=0, interactive=0, optimize=0, dont_write_bytecode=0, no_user_site=0, no_site=0, ignore_environment=1, verbose=0, bytes_warning=0, quiet=0, hash_randomization=1, isolated=0)
[1/1] test_readline
testHistoryUpdates (test.test_readline.TestHistoryManipulation) ... ok
test_init (test.test_readline.TestReadline) ... ok

----------------------------------------------------------------------
Ran 2 tests in 0.160s

OK
1 test OK.
msg242075 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015-04-26 19:56
New changeset ec6ed10d611e by Benjamin Peterson in branch '3.4':
remove extern definition, since it's in a header file (closes #24058)
https://hg.python.org/cpython/rev/ec6ed10d611e

New changeset 192f9efe4a38 by Benjamin Peterson in branch '2.7':
remove extern definition, since it's in a header file (closes #24058)
https://hg.python.org/cpython/rev/192f9efe4a38

New changeset cb4334ab8453 by Benjamin Peterson in branch 'default':
merge 3.4 (#24058)
https://hg.python.org/cpython/rev/cb4334ab8453
History
Date User Action Args
2022-04-11 14:58:16adminsetgithub: 68246
2015-04-26 19:56:30python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg242075

resolution: fixed
stage: resolved
2015-04-26 19:51:46masamotosetmessages: + msg242074
2015-04-26 16:50:20benjamin.petersonsetmessages: + msg242059
2015-04-25 20:07:13masamotosetmessages: + msg242022
2015-04-25 18:25:53benjamin.petersonsetnosy: + benjamin.peterson
messages: + msg242021
2015-04-25 14:23:06masamotosetfiles: + 3.4-issue24058-readline-_PyOS_ReadlineTState.patch
keywords: + patch
messages: + msg242014
2015-04-25 14:21:10masamotocreate