Help on symbol does not work with relative imports

Bug #1020973 reported by Urs Fleisch
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-mode.el
Fix Released
Medium
Andreas Roehler

Bug Description

Reproduction:
Create two files mod1.py and mod2.py in the same directory.

--- mod1.py
def func1():
    """Help on func1."""
    print 'func1'
--- mod2.py
import mod1

if __name__ == '__main__':
    mod1.func1()
---

Point on mod1.func1, C-c C-e

Traceback (most recent call last):
  File "/tmp/mod2.py3710LMc.py", line 2, in <module>
    import mod1;pydoc.help('mod1.func1')
ImportError: No module named mod1

The python file generated to create the help text cannot import modules from the current directory.

The attached patch fixes the problem.

Related branches

Revision history for this message
Urs Fleisch (ufleisch) wrote :
Changed in python-mode:
assignee: nobody → Andreas Roehler (a-roehler)
milestone: none → 6.1.0
importance: Undecided → Medium
Revision history for this message
Andreas Roehler (a-roehler) wrote :

Hi Urs,

with example given, IMO it should print something like:

func1()
    Help on func1.

##########

which it doesn't, so exists a bug.

Beside remember some discussion related to current directory and path.
AFAIU it considered a risk having the working dir in PYTHONPATH, resp. having that done unnoticed.

Maybe I'm misreading your patch or being wrong otherwise.

Or others may comment,

thanks,

Andreas

Changed in python-mode:
status: New → Confirmed
Revision history for this message
Andreas Roehler (a-roehler) wrote : pycomplete_1531_1533_bzrsend.patch

Hi Urs,

unfortunately your mail containing

pycomplete_1531_1533_bzrsend.patch

pycomplete_doc_signature.diff

vanished from my reader.

Patch has been saved before, just can't answer that post.

It's very interesting stuff indeed.

As you asked, in cases new features are introduced, pushing an own branch at lp
probably is best.

BTW will be away from computer for some days, after next week it should go on

Thanks,

Andreas

Revision history for this message
Andreas Roehler (a-roehler) wrote :

Hi Urs,

please upload your branch here followed by a merge-request.

So we may discuss your extension, which looks promising for me,

thanks,

Andreas

Revision history for this message
Andreas Roehler (a-roehler) wrote : Re: [Bug 1020973] Re: Help on symbol does not work with relative imports

Am 07.07.2012 08:08, schrieb Andreas Roehler:
> Hi Urs,
>
> please upload your branch here followed by a merge-request.
>
> So we may discuss your extension, which looks promising for me,
>
> thanks,
>
> Andreas
>

ah, seeing your branch now. :)

Changed in python-mode:
status: Confirmed → Fix Committed
Changed in python-mode:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.