Comprehensive improvements: Cross-platform support, bundled libraries, code quality, and extensive test coverage #26
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
📋 概述
本 PR 对 GmSSL-Python 进行了全面改进,主要包括:跨平台兼容性修复、自包含动态库支持、代码质量提升、API 优化以及大幅增强的测试覆盖率。这些改进使得 GmSSL-Python 更加健壮、易用,并且可以开箱即用。
✨ 主要改进
1. 🎁 自包含跨平台动态库支持
问题背景:
解决方案:
src/gmssl/_libs/)智能库加载策略:
用户体验提升:
pip install gmssl-python即可直接使用,无需额外安装2. 🔧 跨平台兼容性修复
Windows 平台修复
004d60a- 解决 FILE* 跨 DLL 边界问题9af3697- 添加 Windows 兼容的 PEM 工具7a293bd,bd84323- 修复指针类型处理macOS 平台修复
fflush()7e734cbLinux ARM64 支持
4734f50,324af043. 📈 测试覆盖率大幅提升
测试数量:从 19 个增加到 124 个(增长 552%)
新增测试套件:
tests/test_errors.pytests/test_edge_cases.pytests/test_additional_methods.pytests/test_pygmssl_missing.pytests/test_thread_safety.py代码覆盖率:
测试通过率:100% (124/124)
4. 🎨 代码质量提升
重构 1:引入
_GmsslProxy类问题:大量重复的错误处理代码
改进:使用代理模式自动检查错误
效果:减少约 136 行样板代码
相关提交:
1b99b31重构 2:消除 PEM 工具函数重复
问题:4 个 PEM 函数有 ~80 行重复代码
解决:提取通用逻辑到
_call_platform_pem_function()效果:
相关提交:
1d4df87其他改进
5. 🚀 API 改进
新增
Sm4.decrypt()方法问题:之前加密和解密都使用
encrypt()方法,语义不清晰改进:添加专用的
decrypt()方法特性:
decrypt()会抛出异常encrypt()方法相关提交:
cf9b0596. 📚 文档和线程安全说明
线程安全警告
Sm4Gcm不是线程安全的文档更新
7. 🔄 库更新和构建优化
🧪 测试证明
所有改进均通过完整测试验证:
覆盖率报告:
✅ 向后兼容性
Sm4.decrypt()是可选的,不影响现有代码📦 影响范围
受益用户:
包大小变化:
🔗 相关 Issue
#4 #8 #9 #12 #16 #20 #21
📝 Checklist
🙏 致谢
感谢 GmSSL 项目提供优秀的国密算法实现!