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

Locale error on OSX #12

Open
jerith opened this issue Feb 9, 2014 · 9 comments
Open

Locale error on OSX #12

jerith opened this issue Feb 9, 2014 · 9 comments

Comments

@jerith
Copy link

jerith commented Feb 9, 2014

(This is the same problem as #11, but it goes a bit deeper.)

OSX sets the environment variable LC_CTYPE to "UTF-8" by default, which Python objects to because it doesn't contain a language. On its own, this isn't too much of a problem because Python usually looks at LC_ALL first. (Also, if this were the problem the error would be locale.Error: unsupported locale setting at the point where locale.setlocale(locale.LC_ALL, '') is called.) Because the error is only happening later (when I open a command window, in my case) there must be something setting the locale from outside of Python.

I tracked it down to wxWidgets, which calls setlocale(LC_CTYPE, "UTF-8") in C++. (Revision 72375 added this.) Since the wxWidgets setup only happens after dabo sets the locale (if it isn't skipped based on settings), it overrides the working locale setting and the next call to dabo.getEncoding() will fail with ValueError: unknown locale: UTF-8.

A better solution would be to set the locale again (if configured to do so) after setting up the UI so that all calls to locale.getlocale() are safe again. The change in #11 avoids the symptom of the problem in dabo's code, but any calls to locale.getlocale() from application code would trigger it. It also risks an encoding mismatch if the default encoding is not UTF-8.

@jerith
Copy link
Author

jerith commented Feb 9, 2014

I'm not yet familiar enough with dabo to provide a patch for this (I've only been playing with it for a couple of hours), but I'll poke around in the UI code when I next have some free time (if this hasn't already been fixed by then) to see what I can come up with.

@stefanor
Copy link

I tracked it down to wxWidgets, which calls setlocale(LC_CTYPE, "UTF-8") in C++.

That sounds wrong. Shouldn't it be C.UTF-8 ?

@jerith
Copy link
Author

jerith commented Feb 10, 2014

That sounds wrong. Shouldn't it be C.UTF-8 ?

Probably, but OSX's default for LC_CTYPE is just UTF-8.

@ubuntuslave
Copy link

Again, I'm also experiencing locale issues on Mavericks. I realized the problem is the locale directory cannot be found. It only exists under dabo.git/dabo/locale, so you have to be in the dabo.git/dabo directory in order to run samples such as $ python ../demo/DaboDemo.py.

Maybe the locale should be able to find the dabo's locale automatically somehow.

@ubuntuslave
Copy link

I realized the last commit is the culprit for the locale folder not to be found.

The last changes in the setup.py are actually causing this issue on OS X.

I got it back to normal by manually using the previous version of setup.py

@CarlFK
Copy link
Contributor

CarlFK commented May 14, 2014

Is this the error?

juser@negk:$ virtualenv test2
New python executable in test2/bin/python
Installing setuptools, pip...done.
juser@negk:
$ pip install dabo
Downloading/unpacking dabo
Downloading Dabo-0.9.6.tar.gz (631kB): 631kB downloaded
Running setup.py (path:/tmp/pip_build_juser/dabo/setup.py) egg_info for
package dabo
Traceback (most recent call last):
File "", line 17, in
File "/tmp/pip_build_juser/dabo/setup.py", line 3, in
import ez_setup # From
http://peak.telecommunity.com/DevCenter/setuptools
ImportError: No module named ez_setup
Complete output from command python setup.py egg_info:
Traceback (most recent call last):

File "", line 17, in

File "/tmp/pip_build_juser/dabo/setup.py", line 3, in

import ez_setup # From

http://peak.telecommunity.com/DevCenter/setuptools

ImportError: No module named ez_setup


Cleaning up...
Command python setup.py egg_info failed with error code 1 in
/tmp/pip_build_juser/dabo
Storing debug log for failure in /home/juser/.pip/pip.log
juser@negk:~$

On Wed, May 14, 2014 at 9:17 AM, Carlos [email protected] wrote:

I realized the last commit is the culprit for the locale folder not to be
found.

The last changes in the setup.py are actually causing this issue on OS X.

I got it back to normal by manually using the previous version of setup.py


Reply to this email directly or view it on GitHubhttps://github.com//issues/12#issuecomment-43085863
.

Carl K

@ubuntuslave
Copy link

No, I'm pulling the code directly from git and running

$ python setup.py install

in dabo's root directory. I think it failed when I attempted to do $ pip install dabo.

I'm also curious, why is the version under pip 0.9.6? I thought the master git branch was the mainstream, but the version is here 0.9.14 instead?....minor observation.

@CarlFK
Copy link
Contributor

CarlFK commented May 14, 2014

https://pypi.python.org/pypi/Dabo

Dabo-0.9.6.tar.gz is all there is.

On Wed, May 14, 2014 at 9:39 AM, Carlos [email protected] wrote:

No, I'm pulling the code directly from git and running

$ python setup.py install

in dabo's root directory. I think it failed when I attempted to do $ pip
install dabo.

I'm also curious, why is the version under pip 0.9.6? I thought the
master git branch was the mainstream, but the version is here 0.9.14
instead?....minor observation.


Reply to this email directly or view it on GitHub.

Carl K

@EdLeafe
Copy link
Member

EdLeafe commented May 14, 2014

I tried to install from github using pip:

pip install -U git+git://github.com/dabodev/dabo.git

and when I tried to use dabo, I got:

Python 2.7.5 (default, Aug 25 2013, 00:04:04) 
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import dabo
2014-05-14 09:34:55 - ERROR - 
No translation file found for domain 'dabo'.
    Locale dir = /Users/ed/projects/locale
    Languages = ['en_US']
    Codeset = UTF-8 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/ed/.virtualenvs/dtest/lib/python2.7/site-packages/dabo/__init__.py", line 186, in <module>
    dLocalize.install("dabo")
  File "/Users/ed/.virtualenvs/dtest/lib/python2.7/site-packages/dabo/dLocalize.py", line 79, in install
    setLanguage(_defaultLanguage, _defaultEncoding)
  File "/Users/ed/.virtualenvs/dtest/lib/python2.7/site-packages/dabo/dLocalize.py", line 113, in setLanguage
    daboTranslation = gettext.translation("dabo", daboLocaleDir, languages=["en"], codeset=charset)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/gettext.py", line 469, in translation
    raise IOError(ENOENT, 'No translation file found for domain', domain)
IOError: [Errno 2] No translation file found for domain: 'dabo'

So yes, there is a problem. I'll look into it when I get a chance.

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

5 participants