[Tutor] trouble understanding the python environment in OSX

danielle davout danielle.davout at gmail.com
Wed Mar 7 10:38:29 CET 2007


probably it is not the same issue but ...
I've got a problem with BeautifulSoup that I've never encounter before
( I've got a new computer and a brand new installation Python 2.5
(r25:51908, Sep, 09:52:17) [MSC v.1310 32 bit (Intel)] on win32 )

When I run BeautifulSoupTests.py ( If I am not mistaken, the
BeautifulSoup installer also run this test and it's why I think that
Clay's Unicode problem is somehow related ..)

I obtain the following message :
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright Microsoft Corp.

C:\programmes\python25\Lib\site-packages>BeautifulSoupTests.py
.................................C:\programmes\python25\Lib\site-packages\Beauti
fulSoup.py:1654: UnicodeWarning: Unicode equal comparison failed to convert both
 arguments to Unicode - interpreting them as being unequal
 elif data[:3] == '\xef\xbb\xbf':
C:\programmes\python25\Lib\site-packages\BeautifulSoup.py:1657: UnicodeWarning:
Unicode equal comparison failed to convert both arguments to Unicode - interpret
ing them as being unequal
 elif data[:4] == '\x00\x00\xfe\xff':
C:\programmes\python25\Lib\site-packages\BeautifulSoup.py:1660: UnicodeWarning:
Unicode equal comparison failed to convert both arguments to Unicode - interpret
ing them as being unequal
 elif data[:4] == '\xff\xfe\x00\x00':
.......F...........
======================================================================
FAIL: testQuotedAttributeValues (__main__.QuoteMeOnThat)
----------------------------------------------------------------------
Traceback (most recent call last):
 File "C:\programmes\python25\Lib\site-packages\BeautifulSoupTests.py", line 38
2, in testQuotedAttributeValues
   '<this is="r&#101;ally messed up &amp; stuff"></this>')
 File "C:\programmes\python25\Lib\site-packages\BeautifulSoupTests.py", line 19
, in assertSoupEquals
   self.assertEqual(str(c(toParse, convertEntities=convertEntities)), rep)
 File "C:\programmes\python25\Lib\site-packages\unittest.py", line 273, in fail
UnlessEqual
   raise self.failureException, (msg or '%s != %s' % (first, second))
AssertionError: <this is="really messed up &amp; stuff"></this> != <this is="r&#
101;ally messed up &amp; stuff"></this>
----------------------------------------------------------------------
Ran 52 tests in 0.300s

FAILED (failures=1)

but I am not sure that this failure come  from a Python installation problem
as a matter of fact when I installed Emule, I did receive a strange warning
emule has detected that your current code page "1252 (ANSI-Latin I )"
is not the same as your system's code page "1252 (ANSI-Latin I )". For
converting non-Unicode data to Unicode, you need to specify which code
page to use

emule's code contains
(http://www.koders.com/cpp/fid558EFC295DED6419B3F3DEA41F94A2BAFE2470DE.aspx)
#ifdef _UNICODE
	if (theApp.GetProfileInt(_T("eMule"), _T("SetLanguageACP"), 0) != 0)
		return true;
	int iSetSysACP = theApp.GetProfileInt(_T("eMule"), _T("SetSystemACP"), -1);
	if (iSetSysACP != -1)
		return true;
	iSetSysACP = 0;

	LCID lcidSystem = GetSystemDefaultLCID();	// Installation, or altered
by user in control panel (WinXP)
	LCID lcidUser = GetUserDefaultLCID();		// Installation, or altered by
user in control panel (WinXP)

	// get the ANSI codepage which is to be used for all non-Unicode conversions.
	LANGID lidSystem = LANGIDFROMLCID(lcidSystem);

	// get user's sorting preferences
	//UINT uSortIdUser = SORTIDFROMLCID(lcidUser);
	//UINT uSortVerUser = SORTVERSIONFROMLCID(lcidUser);
	// we can't use the same sorting paramters for 2 different Languages..
	UINT uSortIdUser = SORT_DEFAULT;
	UINT uSortVerUser = 0;

	// create a thread locale which gives full backward compability for
users which had run ANSI emule on
	// a system where the system's code page did not match the user's language..
	LCID lcid = MAKESORTLCID(lidSystem, uSortIdUser, uSortVerUser);
	LCID lcidThread = GetThreadLocale();
	if (lcidThread != lcid)
	{
		CString str =
			_T("eMule has detected that your system's codepage is not the same
as eMule's current codepage. Do you want eMule to use your system's
codepage for converting non-Unicode data to Unicode?\r\n")
			_T("\r\n")
			_T("If you want eMule to use your system's codepage for converting
non-Unicode data, click 'Yes'. (This will give you more backward
compatibility when reading older *.met files created with non-Unicode
eMule versions.)\r\n")
			_T("\r\n")
			_T("If you want eMule to use the current codepage for converting
non-Unicode data, click 'No'. (If you are using eMule the first time
or if you don't care about this issue at all, chose this option. This
is recommended.)\r\n")
			_T("\r\n")
			_T("If you want to cancel and create backup of all your config
files or visit our forum to learn more about this issue, click
'Cancel'.\r\n");
		int iAnswer = AfxMessageBox(str, MB_ICONSTOP | MB_YESNOCANCEL |
MB_DEFBUTTON2);
		if (iAnswer == IDCANCEL)
			return false;
		if (iAnswer == IDYES)
			iSetSysACP = 1;
	}
	theApp.WriteProfileInt(_T("eMule"), _T("SetSystemACP"), iSetSysACP);
#endif

My regional settings is French
But in the "Regional and Languages Options" panel (advanced tab), I could read

Language for non-Unicode programs
this system setting enables non-Unicode programs to display menus and
dialogs in their native language. It does not affect Unicode programs,
but it does apply to all users of this computer
Select a language to match the language version of the non-Unicode
programs you want to use: ...

it was fixed by default to English(United States)
I changed to French(France) and after the necessary reboot, I've no
more warning from Emule but the problem with BeautifulSoup remains
my active code page have changed from 437 to 850 Multilingual (Latin
I) (as told by DOS command line chcp)
I try :
import locale
loc = locale.getlocale(locale.LC_ALL)
I get  (None, None) !
I run the test code: (Localization - set to default on Windows:
http://www.mail-archive.com/python-list@python.org/msg118811.html)

import locale
# Get default
print locale.getdefaultlocale('LANG')
# Get actual
print locale.getlocale(locale.LC_ALL)
# Get default to "loc"
loc, enc = locale.getdefaultlocale('LANG')
try:
    # Try to set
    locale.setlocale(locale.LC_ALL, loc)
except Exception, msg:
    # An error
    print msg
# Get actual
print locale.getlocale(locale.LC_ALL)
# Set manually
locale.setlocale(locale.LC_ALL, "HU")
# Get the actual locale
print locale.getlocale(locale.LC_ALL)
print locale.getdefaultlocale('LANG')

and get
>>> ('fr_FR', 'cp1252')
(None, None)
unsupported locale setting
(None, None)
('fr_FR', 'cp1252')
('fr_FR', 'cp1252')
==================
>>> sys.getfilesystemencoding()
'mbcs'
>>> sys.getdefaultencoding()
'ascii'
==================
I run autotest.py : I've got one test failure reported (test_uuid with a
    WARNING: uuid.getnode is unreliable on many platforms.)
but a "failure" was not reported at the end of the execution :
test_unicode_file
C:\programmes\python25\lib\test\test_unicode_file.py:103:
UnicodeWarning: Unicode equal comparison failed to convert both
arguments to Unicode - interpreting them as being unequal
  filename1==filename2
C:\programmes\python25\lib\shutil.py:36: UnicodeWarning: Unicode equal
comparison failed to convert both arguments to Unicode - interpreting
them as being unequal
  os.path.normcase(os.path.abspath(dst)))

one thing that's clear in all this is that I badly need help !
thanks






>>> ('fr_FR', 'cp1252')
(None, None)
unsupported locale setting
(None, None)
('fr_FR', 'cp1252')
('fr_FR', 'cp1252')
2007/3/3, Kent Johnson <kent37 at tds.net>:
- Afficher le texte des messages précédents -
> Clay Wiedemann wrote:
>
> > I am running the latest OSX (10.4.8) and know a little about moving
> > about in the terminal. But the world of paths, etc. has me a little
> > confused. And now it is getting in my way. I was wondering if I could
> > get a little help with some things.
> >
> > - Can anyone point me to a well-regarded and pithy tutorial regarding
> > the UNIX underpinnings of OSX, especially anything that would help
> > with Python. (e.g., I can navigate to Python.framework and versions
> > but see 2.5 and Current, which confuses me since 2.5 is the current
> > version.) I would love to know what the structure of the Python
> > installation means.
>
> Current is an alias for 2.5, which is the current install.
> >
> > - I am having trouble installing the BeautifulSoup package. The
> > installer stumbles on a unicode issue (that the Soup developer says is
> > a problem with my Python installation) -- so what is the best way to
> > manually install this? And does the 2.5 / Current divide matter?
>
> What is the error you get in the installer?
>
> The installer is not really needed in this case. You should be able to
> just download the single file and put it in
> .../Current/lib/python2.5/site-packages
>
> Kent
> >
> >
> >
> > Thanks in advance for any help with these basic issues.
> >
> > Good morning from Brooklyn,
> > Clay
> >
> >
> > * Any experience with coding webpages is not helping here
> >
> >
> >
> > - - - - - - -
> >
> > Clay S. Wiedemann
> >
> > aim: khlav
> > wii:
> > twitter: seastokes
> > _______________________________________________
> > Tutor maillist  -  Tutor at python.org
> > http://mail.python.org/mailman/listinfo/tutor
> >
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>


2007/3/3, Clay Wiedemann <clay.wiedemann at gmail.com>:
> Hi,
>
> I am not only new to Python, but new to programming in an environment
> like this, where knowing a little of how the underpinning work is
> essential.*
>
> I am running the latest OSX (10.4.8) and know a little about moving
> about in the terminal. But the world of paths, etc. has me a little
> confused. And now it is getting in my way. I was wondering if I could
> get a little help with some things.
>
> - Can anyone point me to a well-regarded and pithy tutorial regarding
> the UNIX underpinnings of OSX, especially anything that would help
> with Python. (e.g., I can navigate to Python.framework and versions
> but see 2.5 and Current, which confuses me since 2.5 is the current
> version.) I would love to know what the structure of the Python
> installation means.
>
> - I am having trouble installing the BeautifulSoup package. The
> installer stumbles on a unicode issue (that the Soup developer says is
> a problem with my Python installation) -- so what is the best way to
> manually install this? And does the 2.5 / Current divide matter?
>
>
>
> Thanks in advance for any help with these basic issues.
>
> Good morning from Brooklyn,
> Clay
>
>
> * Any experience with coding webpages is not helping here
>
>
>
> - - - - - - -
>
> Clay S. Wiedemann
>
> aim: khlav
> wii:
> twitter: seastokes
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>


More information about the Tutor mailing list