Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 282318 - non-existent/poor handling of NoneType objects in python-2.6 os.path.join()
Summary: non-existent/poor handling of NoneType objects in python-2.6 os.path.join()
Status: RESOLVED UPSTREAM
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: AMD64 Linux
: High normal (vote)
Assignee: Python Gentoo Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-08-22 16:12 UTC by Brian Dolbec
Modified: 2009-08-22 18:24 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
os.path.join() fix (python-2.6-posixpath.patch,355 bytes, patch)
2009-08-22 16:33 UTC, Brian Dolbec (RETIRED)
Details | Diff
os.path.join() patch (python-2.6-posixpath-2.patch,558 bytes, patch)
2009-08-22 16:41 UTC, Brian Dolbec (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Brian Dolbec (RETIRED) gentoo-dev 2009-08-22 16:12:41 UTC
python-2.6 os.path.join() does not do any object verification before trying to do it's join method.  It should do input parameter checking and return an appropriate result if the inputs requirements are not met.


Reproducible: Always

Steps to Reproduce:
1.start alacarte
2.
3.

Actual Results:  
brian@big_daddy ~ $ alacarte
Traceback (most recent call last):
  File "/usr/bin/alacarte", line 36, in <module>
    main()
  File "/usr/bin/alacarte", line 32, in main
    app = MainWindow(datadir, version, sys.argv)
  File "/usr/lib64/python2.6/site-packages/Alacarte/MainWindow.py", line 48, in __init__
    self.editor = MenuEditor()
  File "/usr/lib64/python2.6/site-packages/Alacarte/MenuEditor.py", line 36, in __init__
    self.__loadMenus()
  File "/usr/lib64/python2.6/site-packages/Alacarte/MenuEditor.py", line 42, in __loadMenus
    self.applications.path = os.path.join(util.getUserMenuPath(), self.applications.tree.get_menu_file())
  File "/usr/lib64/python2.6/posixpath.py", line 65, in join
    if b.startswith('/'):
AttributeError: 'NoneType' object has no attribute 'startswith'


Expected Results:  
the application to run or fail due to it's errors alone.

I am searching/filing a bug for alacarte.  This bug is for python's poor handling of bad data input.
Comment 1 Brian Dolbec (RETIRED) gentoo-dev 2009-08-22 16:33:15 UTC
Created attachment 201940 [details, diff]
os.path.join() fix

This change allows the join function to ignore NoneType objects in the *p parameters.
Comment 2 Brian Dolbec (RETIRED) gentoo-dev 2009-08-22 16:41:43 UTC
Created attachment 201941 [details, diff]
os.path.join() patch

This patch also takes care of a primary parameter being a NoneType object.  But Im not sure if that would be correct for os.path.

final result of the patch:

>>> os.path.join('this','is','a','test',None,'of','python')
'this/is/a/test/of/python'
>>> os.path.join(None,'this','is','a','test',None,'of','python')
'this/is/a/test/of/python'
>>>
Comment 3 Jeremy Olexa (darkside) (RETIRED) archtester gentoo-dev Security 2009-08-22 18:20:01 UTC
assigning to python maintainers
Comment 4 Arfrever Frehtes Taifersar Arahesis (RETIRED) gentoo-dev 2009-08-22 18:24:42 UTC
Please report it to Python upstream.
http://bugs.python.org/