[IronPython] A pseudobug in standard library usage
Michael Foord
fuzzyman at voidspace.org.uk
Sun Jun 3 17:19:06 CEST 2007
Mohammad Tayseer wrote:
> The builtin module "nt" has no method called "_getfullpathname", which
> the stdlib uses to detect if the OS is Windows (that's what the
> comment says). I don't know why the library writer didn't check for
> sys.platform.
Because it uses the '_getfullpathname' if it is available.
Inside the 'abspath' function (which uses '_getfullpathname') is an
explicit check, which returns the current directory for an empty path:
if path: # Empty path must return current working directory.
try:
path = _getfullpathname(path)
except WindowsError:
pass # Bad path - return unchanged.
else:
path = os.getcwd()
I think this is *designed* to work for an empty string - but *happens*
to work for None as well.
Either way, it could be fixed if the built-in nt module supplied
'_getfullpathname'.
Thanks
Michael
http://www.voidspace.org.uk/ironpython/index.shtml
> I think that running CPython on Linux will result in an exception
>
> There are two issues here: IronPython work item & CPython stdlib bug
>
> */Dave Fugate <dfugate at microsoft.com>/* wrote:
>
> Thanks Michael! This has been filed as CodePlex Work Item #10710
> (http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=10710).
>
> -----Original Message-----
> From: users-bounces at lists.ironpython.com
> [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord
> Sent: Friday, June 01, 2007 7:13 AM
> To: Discussion of IronPython
> Subject: [IronPython] A pseudobug in standard library usage
>
> Hello all,
>
> More fun with None, this time with the standard library - specifically
> with 'os.path.abspath':
>
> CPython:
>
> >>> import os
> >>> os.path.abspath(None)
> 'C:\\Program Files\\Python24'
> >>>
>
> IronPython:
> >>> import os
> >>> os.path.abspath(None)
> Traceback (most recent call last):
> File , line 0, in ##89
> File C:\Program Files\Python24\Lib\ntpath.py, line 491, in abspath
> File C:\Program Files\Python24\Lib\ntpath.py, line 53, in isabs
> File C:\Program Files\Python24\Lib\ntpath.py, line 119, in splitdrive
> AttributeError: 'NoneType' object has no attribute '__getitem__'
> >>>
>
> Thanks
>
> Michael
>
> --
> Michael Foord
> Resolver Systems
> michael.foord at resolversystems.com
>
> Office address: 17a Clerkenwell Road, London EC1M 5RD, UK
> Registered address: 843 Finchley Road, London NW11 8NA, UK
>
> Resolver Systems Limited is registered in England and Wales as
> company number 5467329.
> VAT No. GB 893 5643 79
>
> _______________________________________________
> users mailing list
> users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
> _______________________________________________
> users mailing list
> users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
>
>
>
> Mohammad Tayseer
> http://spellcoder.com/blogs/tayseer
>
> ------------------------------------------------------------------------
> 8:00? 8:25? 8:40? Find a flick
> <http://tools.search.yahoo.com/shortcuts/?fr=oni_on_mail&#news> in no time
> with theYahoo! Search movie showtime shortcut.
> <http://tools.search.yahoo.com/shortcuts/?fr=oni_on_mail&#news>
> ------------------------------------------------------------------------
>
> _______________________________________________
> users mailing list
> users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
More information about the Ironpython-users
mailing list