_recursion_to_deep_message.py 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #-----------------------------------------------------------------------------
  2. # Copyright (c) 2013-2022, PyInstaller Development Team.
  3. #
  4. # Distributed under the terms of the GNU General Public License (version 2
  5. # or later) with exception for distributing the bootloader.
  6. #
  7. # The full license is in the file COPYING.txt, distributed with this software.
  8. #
  9. # SPDX-License-Identifier: (GPL-2.0-or-later WITH Bootloader-exception)
  10. #-----------------------------------------------------------------------------
  11. msg = """
  12. =============================================================
  13. A RecursionError (maximum recursion depth exceeded) occurred.
  14. For working around please follow these instructions
  15. =============================================================
  16. 1. In your program's .spec file add this line near the top::
  17. import sys ; sys.setrecursionlimit(sys.getrecursionlimit() * 5)
  18. 2. Build your program by running PyInstaller with the .spec file as
  19. argument::
  20. pyinstaller myprog.spec
  21. 3. If this fails, you most probably hit an endless recursion in
  22. PyInstaller. Please try to track this down has far as possible,
  23. create a minimal example so we can reproduce and open an issue at
  24. https://github.com/pyinstaller/pyinstaller/issues following the
  25. instructions in the issue template. Many thanks.
  26. Explanation: Python's stack-limit is a safety-belt against endless recursion,
  27. eating up memory. PyInstaller imports modules recursively. If the structure
  28. how modules are imported within your program is awkward, this leads to the
  29. nesting being too deep and hitting Python's stack-limit.
  30. With the default recursion limit (1000), the recursion error occurs at about
  31. 115 nested imported, with limit 2000 at about 240, with limit 5000 at about
  32. 660.
  33. """
  34. def raise_with_msg():
  35. raise SystemExit(msg)