Subject: bug#13570: closed (24.2; (python.el) "ValueError: Attempted relative import in non-package" with relative import.)

From: [email-masked] (GNU bug Tracking System)
Date: Sun, 27 Jul 2014 06:42:03 +0000

Your bug report

#13570: 24.2; (python.el) "ValueError: Attempted relative import in non-package" with relative import.

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
13570: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=13570
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: 24.2; (python.el) "ValueError: Attempted relative import in non-package" with relative import.
From: [email-masked] (Fabián Ezequiel Gallina)
To: [email-masked]
Date: Sun, 27 Jul 2014 03:41:52 -0300
List-Id: <debbugs-submit.debbugs.gnu.org>

Fixed at revno 117584 in trunk.

The new `python-shell-package-enable' command let's you enable a package
for the current shell and use relative imports in evaled code.

Cheers,
Fabián

Subject: 24.2; (python.el) "ValueError: Attempted relative import in non-package" with relative import.
From: Oleksandr Gavenko <[email-masked]>
To: [email-masked]
Date: Mon, 28 Jan 2013 00:40:20 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

In GNU Emacs 24.2.1 (x86_64-pc-linux-gnu, GTK+ Version 3.4.2)
 of 2013-01-21 on trouble, modified by Debian

  # mkdir package
  # cd package

  # cat <<EOF >cmd.py
  from . import lib
  lib.ok()
  EOF

  # cat <<EOF >lib.py
  def ok():
      print('ok')
  EOF

When you open cmd.py and try C-c C-l (python-load-file) you get:

  >>> Traceback (most recent call last):
  Traceback (most recent call last):
    File "/home/user/devel/tmp/package/cmd.py", line 1, in <module>
      from . import lib
  ValueError: Attempted relative import in non-package

With C-c C-c (python-send-string) ever worse: it uses (make-temp-file "py") so
relative import is not possible!!

-- 
Best regards!