Python Forum
ReferenceError: weakly-referenced object no longer exists
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ReferenceError: weakly-referenced object no longer exists
#16
You don't show how you call your functions, but I assume you call search_book() in order to display the GUI.
You declare cur as global but actually it does not exists in the global scope. Once it complete the execution of the search_book, there are no references to cur and it is destroyed.

So, why do you create cur in search_book in the first place. Why not create it in submit() where it is actually needed and used.
Ideally you should refactor your spaghetti code and not use globals at all. As you see it's terrible to debug problem in such code.

The other "solution" is to initialize cur in the global namespace, e.g. cur = None at the top, after the imports.

As a side note - you use GUI, but print result in stdout??? Not to mention mixing pyautogui and tkinter???
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
RE: ReferenceError: weakly-referenced object no longer exists - by buran - Dec-14-2020, 07:11 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Beginner: Code not work when longer list raiviscoding 2 882 May-19-2023, 11:19 AM
Last Post: deanhystad
  local varible referenced before assignment SC4R 6 1,599 Jan-10-2023, 10:58 PM
Last Post: snippsat
  a longer docstring Skaperen 8 1,735 Aug-25-2022, 11:21 PM
Last Post: Skaperen
  UnboundLocalError: local variable 'wmi' referenced before assignment ilknurg 2 1,970 Feb-10-2022, 07:36 PM
Last Post: deanhystad
  Referenced before assignment finndude 3 3,333 Mar-02-2021, 08:11 PM
Last Post: finndude
  IDLE editing window no longer works chris1 2 2,283 Feb-06-2021, 07:59 AM
Last Post: chris1
  Code no longer working yk303 14 10,407 Dec-21-2020, 10:58 PM
Last Post: bowlofred
  UnboundLocalError: local variable 'figure_perso' referenced before assignment mederic39 2 2,305 Jun-11-2020, 12:45 PM
Last Post: Yoriz
  p]Why os.path.exists("abc/d") and os.path.exists("abc/D") treat same rajeev1729 1 2,205 May-27-2020, 08:34 AM
Last Post: DeaD_EyE
  local variable 'marks' referenced before assignment Calli 3 2,364 May-25-2020, 03:15 PM
Last Post: Calli

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020