Opened 13 years ago

Closed 10 years ago

#270 closed defect (worksforme)

apt unicode error

Reported by: alexbruy Owned by: maphew
Priority: major Component: Package
Version: Keywords: apt unicode
Cc:

Description

Just installed apt via OSGeo4W installer under Windows XP. When I try to run it from OSGeo4W Shell I get error

Traceback (most recent call last):
  File "<string>", line 991, in <module>
UnicodeEncodeError: 'ascii' codec can't encode characters in position 36-42: ordinal not in range(128)

My system is Windows XP Pro SP3, all packages downloaded with OSGeo4W installer and stored in D:\install\gis\osgeo4w\offline\. Working installation is C:\OSGeo4W

Attachments (1)

apt.diff (5.0 KB ) - added by jef 13 years ago.
the attached patch fixes the problem for me

Download all attachments as: .zip

Change History (8)

comment:1 by jef, 13 years ago

Does your account name have non-ascii characters in it?

comment:2 by alexbruy, 13 years ago

No, only ASCII.

comment:3 by maphew, 13 years ago

Owner: changed from osgeo4w-dev@… to maphew
Status: newassigned
Summary: apt don't work under Windows XPapt unicode error on Windows XP

Apt doesn't know anything about unicode yet.

What is your Start Menu path?

Line 991 of apt.py attempts to create the environment variable OSGEO4W_STARTMENU, which in turn is derived from the system ALLUSERSPROGRAMS special folder -- this is C:\ProgramData\Microsoft\Windows\Start Menu on a us-english win7 computer and C:\Documents and Settings\All Users\Start Menu\Programs on us-english winXP.

comment:4 by alexbruy, 13 years ago

Seems this is root of the problem. In non-english (in my case Russian/Ukrainian) Windows XP Start Menu path contains non-ASCII characters C:\Documents and Settings\All Users\Главное меню\Программы

comment:5 by maphew, 13 years ago

Keywords: unicode added
Summary: apt unicode error on Windows XPapt unicode error

I did some research on how to handle unicode in python and everything I found is way over my head. I'm afraid apt will have to classified as working on ansi systems only for the time being. (patches to change this gratefully accepted).

A workaround would be to edit bin\apt-dev.py and change:

## insert at line 2:
# coding: utf-8
## line 991 from:
OSGEO4W_STARTMENU = get_special_folder(ALLUSERSPROGRAMS) + "\\" + start_menu_name
# to:
OSGEO4W_STARTMENU = r'C:\Documents and Settings\All Users\Главное меню\Программы'
# or to skip menu links altogether:
OSGEO4W_STARTMENU = os.getenv('TEMP')

(and then run apt-dev instead of apt of course.)

by jef, 13 years ago

Attachment: apt.diff added

the attached patch fixes the problem for me

comment:6 by maphew, 10 years ago

I'm so embarrassed. I can't believe I let this patch sit here for THREE YEARS without incorporating it! Sorry Jürgen!

Changing that this week. There's been too much code drift to apply it straight up, but it doesn't look to hard to reconstitute for the current order.

comment:7 by maphew, 10 years ago

Resolution: worksforme
Status: assignedclosed

committed in https://github.com/maphew/apt/commit/26e0fba11aa09367113968e1584f14e563d3e2ea

works on my system, but I'm just using standard north american cp1252 encoding, so that's not automatically a clean bill of health. Resolving as works for me, please reopen if it's not fixed.

Note: See TracTickets for help on using tickets.