In Python3.3, I thought that every loaded module has a __loader__
attribute. Apparently this is not the case for a few builtin modules:
Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:57:17) [MSC v.1600 64
bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import importlib
>>>
>>> def bug():
... for name in list(sys.modules.keys()):
... try:
... importlib.find_loader(name)
... except Exception as details:
... print(name, type(details), details)
...
>>> bug()
_frozen_importlib <class 'AttributeError'> 'module' object has no
attribute '__loader__'
builtins <class 'AttributeError'> 'module' object has no attribute
'__loader__'
signal <class 'AttributeError'> 'module' object has no attribute
'__loader__'
importlib._bootstrap <class 'AttributeError'> 'module' object has no
attribute '__loader__'
>>>
However, the importlib docs talk about a ValueError instead of the
AttributeError that I see above:
> Find the loader for a module, optionally within the specified path.
> If the module is in sys.modules, then sys.modules[name].__loader__
> is returned (unless the loader would be None, in which case
> ValueError is raised).
Is this a bug?
Thomas
Hi All,
We create our customised manager which will fork child process with baseManager. Because we registered SIGCHLD to reap the zombie for manager, we found this causes baseManager raise RemoteError when called twice.(Test script attached.)
After look at baseManager.py we found recv() in handling the request has been interrupted by comming SIGCHLD, not retry recv(), but raise to client side directly.
try:
methodname = obj = None
request = recv()<------------------this line been interrupted by SIGCHLD
ident, methodname, args, kwds = request
obj, exposed, gettypeid = id_to_obj[ident]
if methodname not in exposed:
raise AttributeError(
'method %r of %r object is not in exposed=%r' %
(methodname, type(obj), exposed)
)
function = getattr(obj, methodname)
try:
res = function(*args, **kwds)
except Exception, e:
msg = ('#ERROR', e)
else:
typeid = gettypeid and gettypeid.get(methodname, None)
if typeid:
rident, rexposed = self.create(conn, typeid, res)
token = Token(typeid, self.address, rident)
msg = ('#PROXY', (rexposed, token))
else:
msg = ('#RETURN', res)
except AttributeError:
if methodname is None:
msg = ('#TRACEBACK', format_exc())
else:
try:
fallback_func = self.fallback_mapping[methodname]
result = fallback_func(
self, conn, ident, obj, *args, **kwds
)
msg = ('#RETURN', result)
except Exception:
msg = ('#TRACEBACK', format_exc())
except EOFError:
util.debug('got EOF -- exiting thread serving %r',
threading.current_thread().name)
sys.exit(0)
except Exception:<------does not handle IOError,INTR here should retry recv()
msg = ('#TRACEBACK', format_exc())
REF: http://bugs.python.org/issue17097
On Fri, 1 Feb 2013 04:20:46 +0100 (CET)
ezio.melotti <python-checkins(a)python.org> wrote:
>
> diff --git a/Doc/glossary.rst b/Doc/glossary.rst
> --- a/Doc/glossary.rst
> +++ b/Doc/glossary.rst
> @@ -320,7 +320,8 @@
> All of Python's immutable built-in objects are hashable, while no mutable
> containers (such as lists or dictionaries) are. Objects which are
> instances of user-defined classes are hashable by default; they all
> - compare unequal, and their hash value is their :func:`id`.
> + compare unequal (except with themselves), and their hash value is their
> + :func:`id`.
Python 3.3.0+ (3.3:127abd16168a, Sep 29 2012, 18:46:33)
[GCC 4.5.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> o = object()
>>> hash(o) == id(o)
False
Regards
Antoine.
On 1 Feb 2013 13:22, "ezio.melotti" <python-checkins(a)python.org> wrote:
>
> http://hg.python.org/cpython/rev/79a021beaf58
> changeset: 81861:79a021beaf58
> branch: 2.7
> parent: 81859:8ee6d96a1019
> user: Ezio Melotti <ezio.melotti(a)gmail.com>
> date: Fri Feb 01 05:18:44 2013 +0200
> summary:
> #16128: clarify that instances of user-defined classes compare equal
with themselves.
>
> files:
> Doc/glossary.rst | 3 ++-
> 1 files changed, 2 insertions(+), 1 deletions(-)
>
>
> diff --git a/Doc/glossary.rst b/Doc/glossary.rst
> --- a/Doc/glossary.rst
> +++ b/Doc/glossary.rst
> @@ -330,7 +330,8 @@
> All of Python's immutable built-in objects are hashable, while no
mutable
> containers (such as lists or dictionaries) are. Objects which are
> instances of user-defined classes are hashable by default; they all
> - compare unequal, and their hash value is their :func:`id`.
> + compare unequal (except with themselves), and their hash value is
their
> + :func:`id`.
The hash(x) == id(x) behaviour is a CPython implementation detail. It
shouldn't be mentioned here.
>
> IDLE
> An Integrated Development Environment for Python. IDLE is a basic
editor
>
> --
> Repository URL: http://hg.python.org/cpython
>
> _______________________________________________
> Python-checkins mailing list
> Python-checkins(a)python.org
> http://mail.python.org/mailman/listinfo/python-checkins
>