BQT causes AttributeError in bpy.app.translations on Blender 3.6+ with PySide2/PySide6
🐛 Bug Description
When the bqt addon is enabled in Blender 3.6+ with PySide2 or PySide6, it triggers a critical AttributeError:
AttributeError: 'bpy.app.translations_type' object has no attribute '__name__'
Important: This error only occurs when bqt is enabled. Without bqt, Blender works normally. The issue is triggered by bqt's PySide2/PySide6 imports, which cause Shiboken to introspect the bpy.app.translations object and discover missing attributes.
🔍 Root Cause Analysis
The issue stems from Blender's module registration process in bpy/__init__.py. When PySide2/PySide6 Shiboken initializes, it performs introspection on Python objects and expects standard Python object attributes like __name__, __module__, __qualname__, and _ne_.
The bpy.app.translations object lacks these attributes, causing Shiboken to fail during its introspection process.
Problematic code in Blender's bpy/__init__.py:
sys.modules.update({
"bpy.app": app,
"bpy.app.handlers": app.handlers,
"bpy.app.translations": app.translations, # ← This object lacks required attributes
"bpy.types": types,
})
📋 Environment Details
- Tested Blender Versions: 3.6, 4.1, 4.2 (confirmed affected on Windows)
- Working Blender Versions: 3.1 (confirmed working)
- Likely Affected Versions: Blender 3.6+ (exact range unknown)
- PySide Versions: PySide2 and PySide6 (both affected, versions not specified)
- Operating System: Windows (primarily tested), likely affects macOS and Linux
- Python Version: 3.10+ (bundled with Blender)
🔄 Steps to Reproduce
- Install Blender 3.6, 4.1, or 4.2 on Windows
- Install PySide2 or PySide6 (e.g.,
pip install PySide6orpip install PySide2) - Download and install the bqt addon
- Verify: Without enabling bqt, Blender works normally
- Open Blender and go to Edit > Preferences > Add-ons
- Search for "bqt" and enable the addon (this succeeds)
- Perform operations that trigger access to
bpy.app.translations(e.g., importing frombpy.app.translations) - Observe the AttributeError in the Blender console
Key Points:
- Blender 3.1: Works fine with bqt enabled
- Blender 3.6+: Error occurs only when bqt is enabled
- Without bqt: All Blender versions work normally
- Issue has been consistently reproduced across Blender 3.6, 4.1, and 4.2 on Windows platform with both PySide2 and PySide6.
📸 Error Screenshots
💡 Expected Behavior
The bqt addon should load successfully in Blender 3.6+ with PySide2/PySide6 without causing AttributeError issues when other operations access bpy.app.translations. Users should be able to create and use Qt widgets within Blender without any translation-related errors, just like it works in Blender 3.1.
🛠️ Proposed Solution
The bqt addon needs to patch the bpy.app.translations object before importing PySide2/PySide6 to add the missing attributes that Shiboken expects:
# Fix bpy.app.translations compatibility with PySide2/PySide6 Shiboken
def fix_translations_compatibility():
import bpy
translations = bpy.app.translations
# Add missing attributes for Shiboken introspection
if not hasattr(translations, '__name__'):
translations.__name__ = 'bpy.app.translations'
if not hasattr(translations, '__module__'):
translations.__module__ = 'bpy.app'
if not hasattr(translations, '__qualname__'):
translations.__qualname__ = 'translations'
if not hasattr(translations, '_ne_'):
translations._ne_ = lambda x, y: x != y
# Apply fix before importing Qt/PySide
fix_translations_compatibility()
This fix should be applied in bqt's __init__.py before any PySide2/PySide6 imports.
🎯 Impact
This issue affects:
- All bqt users who want to use Blender 3.6+ with PySide2/PySide6
- Studios and developers using either PySide2 or PySide6
- New users trying to use bqt with modern Blender versions
- Qt-based pipeline tools that depend on bqt for Blender integration
🔗 Related Information
- This is a compatibility issue between Blender's internal translation system and PySide2/PySide6's Shiboken binding layer
- The issue affects both PySide2 and PySide6, indicating it's related to Shiboken's introspection requirements
- The error occurs during bqt's initialization when PySide2/PySide6 tries to introspect Python objects
- Similar issues may affect other PySide2/PySide6-based Blender addons
📝 Additional Context
This compatibility issue is blocking users from using bqt with Blender 3.6+ and both PySide2/PySide6. Since the issue doesn't occur in Blender 3.1, this suggests a change in Blender's translation system starting from version 3.6. This fix is essential for bqt's compatibility with modern Blender versions regardless of the PySide version used.
The proposed solution involves patching the bpy.app.translations object early in bqt's initialization process to provide the missing attributes that PySide2/PySide6 Shiboken expects during introspection.