[issue24949] Identifier lookup in a multi-level package is flakey
Bob Hossley
report at bugs.python.org
Fri Aug 28 00:59:22 CEST 2015
New submission from Bob Hossley:
This seems like a bug to me, but it may be a recognized limitation even though I couldn't find any documentation suggesting that my tests should not work reliably. I see no reason why my tests should not work reliably.
I have reliably reproduced the flakeyness under Windows XP with Python 2.6.4 and under Xubuntu 14.04 64-bit with Python 2.7.6 and Python 3.4.0.
Ubuntu 14.04 (trusty) - XFCE desktop (Xubuntu) 64-bit
Gnome: 3.8.4
Kernel: 3.13.0-62-generic
GCC Version: 4.8 (x86_64-linux-gnu)
Xorg Version: 1.15.1 (12 February 2015 02:49:29PM)
Rebooting doesn't help.
I first encountered the flakeyness in a complicated script which I will describe in outline first. The very, very simple interactive Python sessions that follow are probably of more interest and use to you.
---
Outline of my complicated script:
import email
# The next line works around a flakeyness in Python
from email.mime.nonmultipart import MIMENonMultipart
msg = email.mime.nonmultipart.MIMENonMultipart('text', 'plain', charset='utf-8')
Without the above work around I always get Error:
AttributeError: 'module' object has no attribute 'nonmultipart'
Note "import email" is global. "from email.mime.nonmultipart import MIMENonMultipart" is local to the function containing the "msg = " line which is the line that fails whenever the workaround is absent.
---
XP Interpreter Session:
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\Admin>python
Python 2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import email
>>> print email.mime.nonmultipart.__file__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'nonmultipart'
>>> print email.mime.nonmultipart.__file__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'nonmultipart'
>>> print email.mime.nonmultipart.__file__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'nonmultipart'
>>> print email.mime.nonmultipart.__file__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'nonmultipart'
>>> print email.mime.nonmultipart.__file__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'nonmultipart'
>>> from email.mime import nonmultipart
>>> print email.mime.nonmultipart.__file__
C:\bin\Python26\lib\email\mime\nonmultipart.pyc
>>>
Xubuntu Python 2.7.6 Session
2015-08-25 14:02:46 /home/bob06
$ python
Python 2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import email
>>> print(email.mime.nonmultipart.__file__)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'nonmultipart'
>>> print(email.mime.nonmultipart.__file__)
/usr/lib/python2.7/email/mime/nonmultipart.pyc
Xubuntu Python 3.4.0 Session
2015-08-27 15:27:39 /home/bob06
$ python3
Python 3.4.0 (default, Jun 19 2015, 14:20:21)
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import email
>>> print(email.mime.nonmultipart.__file__)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'mime'
>>> print(email.mime.nonmultipart.__file__)
/usr/lib/python3.4/email/mime/nonmultipart.py
----------
components: Interpreter Core
messages: 249269
nosy: SegundoBob
priority: normal
severity: normal
status: open
title: Identifier lookup in a multi-level package is flakey
type: compile error
versions: Python 2.7, Python 3.4
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24949>
_______________________________________
More information about the Python-bugs-list
mailing list