Closed
Description
Base info:
D:\***\***\***\***\***\***>pyarmor -v
Pyarmor 9.0.8 (group), 006040, non-profits
License Type : pyarmor-group
License No. : pyarmor-vax-006040
License To : *****
License Product : non-profits
BCC Mode : Yes
RFT Mode : Yes
CI/CD Mode : No
Notes
* Offline obfuscation
447.15
Windows 11 Enterprise Edition LTSC
Python 3.13.1
When I packaged the code after obfuscating it with Pyarmor, I can start the program normally, but when executing a specific function, an error occurs (the original code does not have this problem) with the error message shown below:
D:\***\***\***\***\***\***>main.exe
TypeError: 'builtin_function_or_method' object does not support the context manager protocol
I then replaced the obfuscated python source file with the obfuscated file in order of precedence, and found the function that had been obfuscated by Pyarmor with an error:
D:\***\***\***\***\***\***>xAries.exe
Traceback (most recent call last):
File "D:\***\***\***\***\***\***\_internal\app\poseidon\navigator\navigator_function.py", line 460, in _context_menu
self._single_selection_menu(menu, indexes)
~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
File "D:\***\***\***\***\***\***\_internal\app\poseidon\navigator\navigator_function.py", line 880, in _single_selection_menu
self._subproject_menu(menu, selected_item)
~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
File "D:\***\***\***\***\***\***\_internal\app\poseidon\navigator\navigator_function.py", line 1072, in _subproject_menu
self.subproject_rtl.rtl_menu(menu, selected_item)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
File "D:\***\***\***\***\***\***\_internal\app\poseidon\navigator\rtl\rtl.py", line 115, in rtl_menu
self.design.design_menu(menu, selected_item)
~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
File "D:\***\***\***\***\***\***\_internal\app\poseidon\navigator\rtl\desgin\design.py", line 77, in design_menu
folder_data = get_folder_data(selected_item)
TypeError: 'builtin_function_or_method' object does not support the context manager protocol
def get_catalog_item(selected_item: QStandardItem) -> QStandardItem:
current_item = selected_item
while current_item:
if current_item.data(ItemDataRole.ITEM_TYPE) == NavigatorType.CATALOG:
return current_item
current_item = current_item.parent()
return current_item if current_item else selected_item
def get_folder_data(selected_item: QStandardItem) -> dict:
"""
Retrieve folder data for the selected item.
This function collects folder data by traversing the tree structure starting
from the selected item. It includes the catalog item and its child folders.
:param selected_item: The selected item in the tree.
:type selected_item: QStandardItem
:return: A dictionary containing folder data.
:rtype: dict
"""
catalog_item = get_catalog_item(selected_item)
folder_data = {}
if catalog_item is None:
return folder_data
parent_item = selected_item.parent()
if parent_item is None:
return folder_data
if parent_item != catalog_item:
folder_data[catalog_item.text()] = catalog_item
def get_folder_data_recursive(item: QStandardItem):
"""
Recursively collect folder data.
This inner function traverses the tree structure to collect folder data
from the child items of the given item.
:param item: The current item in the tree.
:type item: QStandardItem
"""
for row in range(item.rowCount()):
child_item = item.child(row)
if child_item is None:
continue
if child_item == parent_item or child_item == selected_item:
continue
if child_item.data(ItemDataRole.ITEM_TYPE) == NavigatorType.FOLDER:
folder_data[child_item.text()] = child_item
get_folder_data_recursive(child_item)
get_folder_data_recursive(catalog_item)
return folder_data