msg197914 - (view) |
Author: Alan Hourihane (alanh) |
Date: 2013-09-16 16:02 |
Patch....
--- Python/fileutils.c.old 2013-09-11 07:04:42.000000000 +0000
+++ Python/fileutils.c 2013-09-11 07:05:01.000000000 +0000
@@ -4,8 +4,8 @@
# include <windows.h>
#endif
-#ifdef HAVE_LANGINFO_H
#include <locale.h>
+#ifdef HAVE_LANGINFO_H
#include <langinfo.h>
#endif
|
msg197920 - (view) |
Author: R. David Murray (r.david.murray) *  |
Date: 2013-09-16 17:39 |
Can you provide more information about the circumstances in which this is a problem? Presumably there is a reason why the code is currently the way it is, especially since it is done this way in several of the source files, and has been that way for a *long* time.
|
msg197922 - (view) |
Author: R. David Murray (r.david.murray) *  |
Date: 2013-09-16 18:10 |
Oops, didn't mean to assign this to anyone.
|
msg197923 - (view) |
Author: Alan Hourihane (alanh) |
Date: 2013-09-16 18:24 |
Sure, Look in the function.....
check_force_ascii()
You'll see a hunk of code that is ifdef'd for ...
#if defined(HAVE_LANGINFO_H) && defined(CODESET)
Then you'll see
setlocale()
is called outside of that check, just before another hunk of code is
ifdef'd with the same....
#if defined(HAVE_LANGINFO_H) && defined(CODESET)
Basically making setlocale() outside of the check, and therefore requiring the #include <locale.h> outside of the above check as well.
In pythonrun.c the setlocale() call is already wrapped inside the #ifdef so the problem is bumped into there.
|
msg197924 - (view) |
Author: Alan Hourihane (alanh) |
Date: 2013-09-16 18:25 |
Oops, meant to say.....
In pythonrun.c the setlocale() call is already wrapped inside the #ifdef so the problem ISN'T bumped into there.
|
msg197928 - (view) |
Author: R. David Murray (r.david.murray) *  |
Date: 2013-09-16 18:41 |
So the real problem is that the setlocale call is outside the ifdef, which means Victor is the right person to look at this, since it was his patch that introduced the code in question. I'll remove MAL from nosy, since I only added him by accident.
|
msg197936 - (view) |
Author: STINNER Victor (vstinner) *  |
Date: 2013-09-16 19:35 |
It looks like a real issue, but on which platform did you get the error?
> setlocale fails due to locale.h being wrapped up in LANGINFO check.
What do you mean by "fail"? Is it an error at runtime? Or during the compilation?
--
The include was added recently:
changeset: 81257:c256764e2b3f
branch: 3.2
parent: 81253:c4a4863b85b2
user: Victor Stinner <victor.stinner@gmail.com>
date: Thu Jan 03 01:08:58 2013 +0100
files: Misc/NEWS Objects/unicodeobject.c Python/fileutils.c
description:
Issue #16455: On FreeBSD and Solaris, if the locale is C, the
ASCII/surrogateescape codec is now used, instead of the locale encoding, to
decode the command line arguments. This change fixes inconsistencies with
os.fsencode() and os.fsdecode() because these operating systems announces an
ASCII locale encoding, whereas the ISO-8859-1 encoding is used in practice.
The commit was integrated in Python 3.2.5 and Python 3.3.2 .
If I remember correctly, I copied/pasted the code from Python/pythonrun.c:
#ifdef HAVE_LANGINFO_H
#include <locale.h>
#include <langinfo.h>
#endif
Many other files use "#include <locale.h>" without #ifdef HAVE_LANGINFO_H: Modules/main.c, Modules/python.c, Modules/readline.c, Python/frozenmain.c, Python/pystrtod.c and Modules/_localemodule.c. The #include in Modules/main.c was added 5 years ago by changeset 22a74eaf6b22.
|
msg197937 - (view) |
Author: STINNER Victor (vstinner) *  |
Date: 2013-09-16 19:37 |
Oh by the way, please attach the patch as a file to the issue.
|
msg197939 - (view) |
Author: Alan Hourihane (alanh) |
Date: 2013-09-16 19:46 |
Yes, it's a "Build" issue as mentioned using the "Components" field.
But cut & pasting from other files is incorrect in this case because setlocale() is still used outside of the #ifdef.
File attached.
|
msg197940 - (view) |
Author: STINNER Victor (vstinner) *  |
Date: 2013-09-16 19:50 |
> Yes, it's a "Build" issue as mentioned using the "Components" field.
Again, what is your platform (OS name, OS version)?
What is the compiler error message?
|
msg197942 - (view) |
Author: Alan Hourihane (alanh) |
Date: 2013-09-16 20:03 |
You'll see the error on any platform that doesn't include "locale.h" when it should, i.e. a platform that doesn't have NL_LANGINFO. This is the build error.....
Python/fileutils.c: In function 'check_force_ascii':
Python/fileutils.c:101:5: warning: implicit declaration of function 'setlocale' [-Wimplicit-function-declaration]
Python/fileutils.c:101:21: error: 'LC_CTYPE' undeclared (first use in this function)
Python/fileutils.c:101:21: note: each undeclared identifier is reported only once for each function it appears in
You can simulate it on Linux, by just commenting out the #include for "locale.h" and voila.
But for completeness, it's an m68k Atari platform.
|
msg207745 - (view) |
Author: Stefan Krah (skrah) *  |
Date: 2014-01-09 16:24 |
The patch looks correct to me. locale.h is at least C99 (I don't have the earlier standards).
|
msg208543 - (view) |
Author: Roundup Robot (python-dev)  |
Date: 2014-01-20 14:36 |
New changeset f82b6ec1ae6e by Stefan Krah in branch '3.3':
Issue #19036: Including locale.h should not depend on HAVE_LANGINFO_H.
http://hg.python.org/cpython/rev/f82b6ec1ae6e
|
msg213931 - (view) |
Author: Roundup Robot (python-dev)  |
Date: 2014-03-18 01:32 |
New changeset 3589980c98de by Victor Stinner in branch 'default':
Issue #19977, #19036: Always include <locale.h> in pythonrun.c
http://hg.python.org/cpython/rev/3589980c98de
|
|
Date |
User |
Action |
Args |
2022-04-11 14:57:51 | admin | set | github: 63236 |
2014-03-18 01:32:24 | python-dev | set | messages:
+ msg213931 |
2014-01-20 14:37:56 | skrah | set | status: open -> closed type: compile error resolution: remind -> fixed stage: resolved |
2014-01-20 14:36:47 | python-dev | set | nosy:
+ python-dev messages:
+ msg208543
|
2014-01-09 16:24:39 | skrah | set | nosy:
+ skrah messages:
+ msg207745
|
2014-01-09 15:32:24 | alanh | set | resolution: remind |
2013-09-16 20:03:11 | alanh | set | messages:
+ msg197942 |
2013-09-16 19:50:40 | vstinner | set | messages:
+ msg197940 |
2013-09-16 19:46:33 | alanh | set | files:
+ python-3.3.2.patch keywords:
+ patch messages:
+ msg197939
|
2013-09-16 19:37:16 | vstinner | set | messages:
+ msg197937 |
2013-09-16 19:36:55 | vstinner | set | versions:
+ Python 3.2, Python 3.4 |
2013-09-16 19:35:35 | vstinner | set | messages:
+ msg197936 |
2013-09-16 18:41:34 | r.david.murray | set | nosy:
- lemburg
|
2013-09-16 18:41:23 | r.david.murray | set | messages:
+ msg197928 |
2013-09-16 18:25:19 | alanh | set | messages:
+ msg197924 |
2013-09-16 18:24:36 | alanh | set | messages:
+ msg197923 |
2013-09-16 18:10:28 | r.david.murray | set | assignee: lemburg ->
messages:
+ msg197922 nosy:
+ vstinner |
2013-09-16 17:39:46 | r.david.murray | set | assignee: lemburg
messages:
+ msg197920 nosy:
+ r.david.murray, lemburg |
2013-09-16 16:02:37 | alanh | create | |