[Python-Dev] Adding the 'path' module (was Re: Some RFE for review)

Neil Hodgson nyamatongwe at gmail.com
Tue Jun 28 03:19:45 CEST 2005


Andrew Durdin:

> While we'ew discussing outstanding issues: In a related discussion of
> the path module on c.l.py, Thomas Heller pointed out that the path
> module doesn't correctly handle unicode paths:
> ...

   Here is a patch that avoids failure when paths can not be
represented in a single 8 bit encoding. It adds a _cwd variable in the
initialisation and then calls this rather than os.getcwd. I sent the
patch to Jason as well.

_base = str
_cwd = os.getcwd
try:
   if os.path.supports_unicode_filenames:
       _base = unicode
       _cwd = os.getcwdu
except AttributeError:
   pass

#...

   def getcwd():
       """ Return the current working directory as a path object. """
       return path(_cwd())

   Neil


More information about the Python-Dev mailing list