FS#13858 - python: os.path broken

Attached to Project: Arch Linux
Opened by Vinzent Steinberg (vks) - Wednesday, 18 March 2009, 20:01 GMT
Last edited by Allan McRae (Allan) - Thursday, 19 March 2009, 14:23 GMT
Task Type Bug Report
Category Packages: Extra
Status Closed
Assigned To Allan McRae (Allan)
Architecture i686
Severity High
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 1
Private No

Details

Description:

The essential standard Python module os.path seems to be broken. Due to this, many modules/programs are broken.

Additional info:
Python 2.6.1 and Python 3.0.1


Steps to reproduce:
Install python. Optionally install python3 and python-matplotlib (community).
Run the Python interpreter interactively and try this:

$ python
Python 2.6.1 (r261:67515, Dec 7 2008, 08:27:41)
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/site-packages/matplotlib/__init__.py", line 97, in <module>
import distutils.sysconfig
File "/usr/lib/python2.6/distutils/sysconfig.py", line 22, in <module>
PREFIX = os.path.normpath(sys.prefix)
AttributeError: 'module' object has no attribute 'path'
>>> import os
>>> os.path
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'path'
>>> import os.path
>>> os.path.normpath
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'path'
>>> from os.path import *
>>> normpath
<function normpath at 0xb7b548ec>

Strangely, os.path only works when imported using the "from .. import .." syntax.
This task depends upon

Closed by  Allan McRae (Allan)
Thursday, 19 March 2009, 14:23 GMT
Reason for closing:  Not a bug
Comment by Vinzent Steinberg (vks) - Wednesday, 18 March 2009, 20:18 GMT
Please note that os.path should be equal to posixpath (on Linux), so you can "fix" os.path manually:

>>> import posixpath
>>> os.path = posixpath
>>> os.path.normpath
<function normpath at 0xb7b548ec>
Comment by Gerardo Exequiel Pozzi (djgera) - Wednesday, 18 March 2009, 22:12 GMT
Seems that your installation is broken, i can't reproduce this

[djgera@gerardo ~]$ python
Python 2.6.1 (r261:67515, Dec 7 2008, 08:27:41)
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
>>> import os
>>> os.path
<module 'posixpath' from '/usr/lib/python2.6/posixpath.pyc'>


also i tried to install the python3

[djgera@gerardo ~]$ python3
Python 3.0.1 (r301:69556, Feb 22 2009, 02:43:30)
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.path
<module 'posixpath' from '/usr/lib/python3.0/posixpath.py'>
>>>

an also works for me.

So maybe a more apropiate for this issue is a post in the forum...
Comment by Allan McRae (Allan) - Thursday, 19 March 2009, 03:44 GMT
No problems here either. This is on i686.

> python
Python 2.6.1 (r261:67515, Dec 7 2008, 08:27:41)
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
>>> import os
>>> os.path
<module 'posixpath' from '/usr/lib/python2.6/posixpath.pyc'>
>>> import os.path
>>> os.path.normpath
<function normpath at 0xb7bb8994>

Comment by Vinzent Steinberg (vks) - Thursday, 19 March 2009, 14:11 GMT
Thank you for your support!

I just found the problem in my .pythonrc. To tidy up the namespace after enabling auto-completion there was the following line:

del os.path

This should be changed to "del os", otherwise os.path will be missing, even when importing os.

I'm not sure whether this is a bug to be reported upstream. What do you think?
Comment by Allan McRae (Allan) - Thursday, 19 March 2009, 14:22 GMT
Huh? Is this you ~/.pythonrc file? It seems to be doing exactly what you tell it to do. So I don't think this is a bug anywhere...

Loading...