sys.path and unicode folder names

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Nir Aides

    sys.path and unicode folder names

    Hello,

    Is there a solution or a work around for the sys.path problem with
    unicode folder names on Windows XP?

    I need to be able to import modules from a folder with a non-ascii name.

    Thanks,
    Nir
  • Martin v. Löwis

    #2
    Re: sys.path and unicode folder names

    Nir Aides wrote:[color=blue]
    > Is there a solution or a work around for the sys.path problem with
    > unicode folder names on Windows XP?
    >
    > I need to be able to import modules from a folder with a non-ascii name.[/color]

    If the name is restricted to the CP_ACP code page (i.e. more than ASCII,
    less then full Unicode), using the "mbcs" encoding should work fine.

    Regards,
    Martin

    Comment

    • Nir Aides

      #3
      Re: sys.path and unicode folder names

      I can not restrict the name to CP_ACP.
      I am interested in the general case of Unicode.
      Windows XP is a native Unicode OS.


      Martin v. Löwis wrote:[color=blue]
      > Nir Aides wrote:[color=green]
      >> Is there a solution or a work around for the sys.path problem with
      >> unicode folder names on Windows XP?
      >>
      >> I need to be able to import modules from a folder with a non-ascii name.[/color]
      >
      > If the name is restricted to the CP_ACP code page (i.e. more than ASCII,
      > less then full Unicode), using the "mbcs" encoding should work fine.
      >
      > Regards,
      > Martin[/color]

      Comment

      • Thomas Heller

        #4
        Re: sys.path and unicode folder names

        [color=blue][color=green]
        >> Nir Aides wrote:[color=darkred]
        >>> Is there a solution or a work around for the sys.path problem with
        >>> unicode folder names on Windows XP?
        >>>
        >>> I need to be able to import modules from a folder with a non-ascii name.[/color][/color][/color]
        [color=blue]
        > Martin v. Löwis wrote:[/color]
        [color=blue][color=green]
        >> If the name is restricted to the CP_ACP code page (i.e. more than
        >> ASCII, less then full Unicode), using the "mbcs" encoding should work
        >> fine. Regards, Martin[/color][/color]

        Nir Aides:[color=blue]
        > I can not restrict the name to CP_ACP.
        > I am interested in the general case of Unicode.
        > Windows XP is a native Unicode OS.[/color]

        Python internally converts unicode entries on sys.path to strings before
        using them. Changing that would require a large rewrite of the import
        machinery. I once started to work on a patch, but got ZERO feedback, so
        I gave up.

        Thomas


        Comment

        • Martin v. Löwis

          #5
          Re: sys.path and unicode folder names

          Nir Aides wrote:[color=blue]
          > I can not restrict the name to CP_ACP.
          > I am interested in the general case of Unicode.[/color]

          So you should implement a patch, and contribute this
          to sf.net/projects/python.

          Regards,
          Martin

          Comment

          • Tim Churches

            #6
            Python and the health of the public

            The use of Python in a public health surveillance system is described
            here (see references 15 and 26):


            Some more papers describing Python's starring role in some other public
            health projects should appear in the next several months.

            Tim C



            Comment

            • Nir Aides

              #7
              Re: sys.path and unicode folder names

              Actually, I already managed to make a Patch for this problem.
              I will post it soon on my website and in this group.

              But I find it strange that this problem even exists, and that I could
              not find any workarounds on the Internet.

              Nir


              Martin v. Löwis wrote:[color=blue]
              > Nir Aides wrote:[color=green]
              >> I can not restrict the name to CP_ACP.
              >> I am interested in the general case of Unicode.[/color]
              >
              > So you should implement a patch, and contribute this
              > to sf.net/projects/python.
              >
              > Regards,
              > Martin[/color]

              Comment

              • Martin v. Löwis

                #8
                Re: sys.path and unicode folder names

                Nir Aides wrote:[color=blue]
                > Actually, I already managed to make a Patch for this problem.
                > I will post it soon on my website and in this group.
                >
                > But I find it strange that this problem even exists, and that I could
                > not find any workarounds on the Internet.[/color]

                Very few people use file names not in their respective CP_ACP (why
                do you need such filenames?), and virtually nobody wants to put such
                a file name on Python's sys.path (why do you want to? - just rename
                the directory and be done).

                Regards,
                Martin

                Comment

                • Nir Aides

                  #9
                  Re: sys.path and unicode folder names

                  If few people use file names not in their respective CP_ACP as you say,
                  why did Microsoft bother to make Windows XP a unicode OS?
                  It does not make any sense.

                  The existence of such bugs is the source of the problem itself.

                  It is because of this situation that people in non-English speaking
                  countries prefer to install English Windows XP. After all why should
                  they get all messed up with incompatible software?

                  And from my experience a considerable percent of these
                  stay-on-the-safe-side users have their CP_ACP pages setup incorrectly.

                  My software installs per-user Python modules in a sub-folder of the
                  User's Application-Data folder. The software itself resides under
                  Program-Files. The User's Application-Data folder will contain unicode
                  characters if the User's account name contains unicode characters.

                  You can argue that the design is good or wrong or can be altered to work
                  around the problem, but the fact remains:

                  Python is Broken.



                  Martin v. Löwis wrote:[color=blue]
                  > Nir Aides wrote:[color=green]
                  >> Actually, I already managed to make a Patch for this problem.
                  >> I will post it soon on my website and in this group.
                  >>
                  >> But I find it strange that this problem even exists, and that I could
                  >> not find any workarounds on the Internet.[/color]
                  >
                  > Very few people use file names not in their respective CP_ACP (why
                  > do you need such filenames?), and virtually nobody wants to put such
                  > a file name on Python's sys.path (why do you want to? - just rename
                  > the directory and be done).
                  >
                  > Regards,
                  > Martin[/color]

                  Comment

                  • Magnus Lycka

                    #10
                    Re: Python and the health of the public

                    Tim Churches wrote:[color=blue]
                    > The use of Python in a public health surveillance system is described
                    > here (see references 15 and 26):
                    > http://www.biomedcentral.com/1471-2458/5/141
                    >
                    > Some more papers describing Python's starring role in some other public
                    > health projects should appear in the next several months.[/color]

                    Might there be something for www.pythonology.com in the future?

                    Comment

                    • Martin v. Löwis

                      #11
                      Re: sys.path and unicode folder names

                      Nir Aides wrote:[color=blue]
                      > If few people use file names not in their respective CP_ACP as you say,
                      > why did Microsoft bother to make Windows XP a unicode OS?[/color]

                      Because it simplifies their implementation, in the long run.
                      [color=blue]
                      > It is because of this situation that people in non-English speaking
                      > countries prefer to install English Windows XP. After all why should
                      > they get all messed up with incompatible software?[/color]

                      I see. Why do these people then refuse to change the code page of
                      their system (which *is* possible, even in English XP)?
                      [color=blue]
                      > Python is Broken.[/color]

                      I agree. Please contribute a patch.

                      Regards,
                      Martin

                      Comment

                      • Nir Aides

                        #12
                        Re: sys.path and unicode folder names

                        Martin v. Löwis wrote:[color=blue]
                        > Nir Aides wrote:[color=green]
                        >> If few people use file names not in their respective CP_ACP as you say,
                        >> why did Microsoft bother to make Windows XP a unicode OS?[/color]
                        >
                        > Because it simplifies their implementation, in the long run.
                        >[color=green]
                        >> It is because of this situation that people in non-English speaking
                        >> countries prefer to install English Windows XP. After all why should
                        >> they get all messed up with incompatible software?[/color]
                        >
                        > I see. Why do these people then refuse to change the code page of
                        > their system (which *is* possible, even in English XP)?
                        >[/color]

                        They don't refuse. You assume they actually know about its existence. I
                        think that in most cases they are not aware of that thing. Sometimes
                        they call their 10 year old neighbors to fix their computer if they are
                        tired of seeing garbage on their screen instead of readable characters,
                        but their computer usually crashes under the heavy load of dozens of
                        viruses and spy-ware long before that kid neighbor gets a chance to look
                        at it anyway.
                        [color=blue][color=green]
                        >> Python is Broken.[/color]
                        >
                        > I agree. Please contribute a patch.
                        >[/color]

                        I will do my best.
                        [color=blue]
                        > Regards,
                        > Martin[/color]

                        Comment

                        Working...