Project

General

Profile

Actions

Bug #7659

closed

Exception is not defined in blinker

Added by Rajmund Hruška over 1 year ago. Updated 8 months ago.

Status:
Rejected
Priority:
Normal
Assignee:
-
Category:
-
Target version:
Start date:
06/05/2023
Due date:
% Done:

0%

Estimated time:
To be discussed:
No

Description

I found this error in the error log from apache2:

Exception ignored in: <function BoundMethodWeakref.__init__.<locals>.remove at 0x7f8206f62400>
Traceback (most recent call last):
  File "/var/mentat/venv/lib/python3.7/site-packages/blinker/_saferef.py", line 174, in remove
NameError: name 'Exception' is not defined

It happens on every page.

Also, the errors from /var/log/apache2/error.log are not reported, not even on mentat-hub.

Actions #1

Updated by Rajmund Hruška over 1 year ago

The only reference I have found is here - https://github.com/pallets-eco/blinker/issues/52.

Actions #2

Updated by Rajmund Hruška over 1 year ago

Here is the code where the error occurs:

def remove(weak, self=self):
    """Set self.isDead to True when method or instance is destroyed.""" 
    methods = self.deletion_methods[:]
    del self.deletion_methods[:]
    try:
        del self.__class__._all_instances[self.key]
        except KeyError:
            pass
        for function in methods:
            try:
                if callable(function):
                    function(self)
            except Exception:
                try:
                    traceback.print_exc()
                except AttributeError:
                ...

I removed the try/catch block and I found out that a similar error occurs: NameError: name 'callable' is not defined.

Then, I put dir(__builtins__) in the code, which showed this:

['__class__', '__contains__', '__delattr__', '__delitem__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__iter__', '__le__', '__len__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setitem__', '__sizeof__', '__str__', '__subclasshook__', 'clear', 'copy', 'fromkeys', 'get', 'items', 'keys', 'pop', 'popitem', 'setdefault', 'update', 'values']

For some reason, type(__builtins__) is <class 'dict'> and not <class 'module'> as I was expecting.

Actions #3

Updated by Rajmund Hruška over 1 year ago

As it is written in [1]

As an implementation detail, most modules have the name builtins made available as part of their globals. The value of builtins is normally either this module or the value of this module’s dict attribute. Since this is an implementation detail, it may not be used by alternate implementations of Python.

__builtins__ can actually be dictionary.

[1] https://docs.python.org/3/library/builtins.html

Actions #4

Updated by Rajmund Hruška 8 months ago

  • Status changed from New to Rejected
  • Target version changed from Backlog to Rejected

This in no longer an issue on the new mentat-hub.

Actions

Also available in: Atom PDF