pyobfus 0.2.2__tar.gz → 0.2.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. {pyobfus-0.2.2 → pyobfus-0.2.3}/PKG-INFO +2 -2
  2. {pyobfus-0.2.2 → pyobfus-0.2.3}/README.md +1 -1
  3. {pyobfus-0.2.2 → pyobfus-0.2.3}/pyobfus/__init__.py +1 -1
  4. {pyobfus-0.2.2 → pyobfus-0.2.3}/pyobfus/core/generator.py +13 -18
  5. {pyobfus-0.2.2 → pyobfus-0.2.3}/pyobfus.egg-info/PKG-INFO +2 -2
  6. {pyobfus-0.2.2 → pyobfus-0.2.3}/pyproject.toml +1 -1
  7. {pyobfus-0.2.2 → pyobfus-0.2.3}/tests/test_generator.py +40 -0
  8. {pyobfus-0.2.2 → pyobfus-0.2.3}/LICENSE +0 -0
  9. {pyobfus-0.2.2 → pyobfus-0.2.3}/pyobfus/cli.py +0 -0
  10. {pyobfus-0.2.2 → pyobfus-0.2.3}/pyobfus/config.py +0 -0
  11. {pyobfus-0.2.2 → pyobfus-0.2.3}/pyobfus/config_templates.py +0 -0
  12. {pyobfus-0.2.2 → pyobfus-0.2.3}/pyobfus/config_validator.py +0 -0
  13. {pyobfus-0.2.2 → pyobfus-0.2.3}/pyobfus/core/__init__.py +0 -0
  14. {pyobfus-0.2.2 → pyobfus-0.2.3}/pyobfus/core/analyzer.py +0 -0
  15. {pyobfus-0.2.2 → pyobfus-0.2.3}/pyobfus/core/export_detector.py +0 -0
  16. {pyobfus-0.2.2 → pyobfus-0.2.3}/pyobfus/core/global_table.py +0 -0
  17. {pyobfus-0.2.2 → pyobfus-0.2.3}/pyobfus/core/orchestrator.py +0 -0
  18. {pyobfus-0.2.2 → pyobfus-0.2.3}/pyobfus/core/parser.py +0 -0
  19. {pyobfus-0.2.2 → pyobfus-0.2.3}/pyobfus/core/transformer.py +0 -0
  20. {pyobfus-0.2.2 → pyobfus-0.2.3}/pyobfus/exceptions.py +0 -0
  21. {pyobfus-0.2.2 → pyobfus-0.2.3}/pyobfus/plugins/__init__.py +0 -0
  22. {pyobfus-0.2.2 → pyobfus-0.2.3}/pyobfus/plugins/base.py +0 -0
  23. {pyobfus-0.2.2 → pyobfus-0.2.3}/pyobfus/transformers/__init__.py +0 -0
  24. {pyobfus-0.2.2 → pyobfus-0.2.3}/pyobfus/transformers/all_list_updater.py +0 -0
  25. {pyobfus-0.2.2 → pyobfus-0.2.3}/pyobfus/transformers/exported_name_transformer.py +0 -0
  26. {pyobfus-0.2.2 → pyobfus-0.2.3}/pyobfus/transformers/import_rewriter.py +0 -0
  27. {pyobfus-0.2.2 → pyobfus-0.2.3}/pyobfus/transformers/imported_name_transformer.py +0 -0
  28. {pyobfus-0.2.2 → pyobfus-0.2.3}/pyobfus/transformers/local_name_transformer.py +0 -0
  29. {pyobfus-0.2.2 → pyobfus-0.2.3}/pyobfus/transformers/name_mangler.py +0 -0
  30. {pyobfus-0.2.2 → pyobfus-0.2.3}/pyobfus/transformers/string_encoder.py +0 -0
  31. {pyobfus-0.2.2 → pyobfus-0.2.3}/pyobfus/utils.py +0 -0
  32. {pyobfus-0.2.2 → pyobfus-0.2.3}/pyobfus.egg-info/SOURCES.txt +0 -0
  33. {pyobfus-0.2.2 → pyobfus-0.2.3}/pyobfus.egg-info/dependency_links.txt +0 -0
  34. {pyobfus-0.2.2 → pyobfus-0.2.3}/pyobfus.egg-info/entry_points.txt +0 -0
  35. {pyobfus-0.2.2 → pyobfus-0.2.3}/pyobfus.egg-info/requires.txt +0 -0
  36. {pyobfus-0.2.2 → pyobfus-0.2.3}/pyobfus.egg-info/top_level.txt +0 -0
  37. {pyobfus-0.2.2 → pyobfus-0.2.3}/pyobfus_pro/__init__.py +0 -0
  38. {pyobfus-0.2.2 → pyobfus-0.2.3}/pyobfus_pro/anti_debug.py +0 -0
  39. {pyobfus-0.2.2 → pyobfus-0.2.3}/pyobfus_pro/cli.py +0 -0
  40. {pyobfus-0.2.2 → pyobfus-0.2.3}/pyobfus_pro/fingerprint.py +0 -0
  41. {pyobfus-0.2.2 → pyobfus-0.2.3}/pyobfus_pro/license.py +0 -0
  42. {pyobfus-0.2.2 → pyobfus-0.2.3}/pyobfus_pro/string_aes.py +0 -0
  43. {pyobfus-0.2.2 → pyobfus-0.2.3}/setup.cfg +0 -0
  44. {pyobfus-0.2.2 → pyobfus-0.2.3}/tests/test_anti_debug.py +0 -0
  45. {pyobfus-0.2.2 → pyobfus-0.2.3}/tests/test_config_features.py +0 -0
  46. {pyobfus-0.2.2 → pyobfus-0.2.3}/tests/test_fingerprint.py +0 -0
  47. {pyobfus-0.2.2 → pyobfus-0.2.3}/tests/test_issue_4_method_obfuscation.py +0 -0
  48. {pyobfus-0.2.2 → pyobfus-0.2.3}/tests/test_issue_5_config_presets.py +0 -0
  49. {pyobfus-0.2.2 → pyobfus-0.2.3}/tests/test_issue_6_comprehensive_tests.py +0 -0
  50. {pyobfus-0.2.2 → pyobfus-0.2.3}/tests/test_issue_7_class_attributes.py +0 -0
  51. {pyobfus-0.2.2 → pyobfus-0.2.3}/tests/test_issue_8.py +0 -0
  52. {pyobfus-0.2.2 → pyobfus-0.2.3}/tests/test_license_verification.py +0 -0
  53. {pyobfus-0.2.2 → pyobfus-0.2.3}/tests/test_pro_features.py +0 -0
  54. {pyobfus-0.2.2 → pyobfus-0.2.3}/tests/test_string_aes.py +0 -0
  55. {pyobfus-0.2.2 → pyobfus-0.2.3}/tests/test_string_encoding.py +0 -0
  56. {pyobfus-0.2.2 → pyobfus-0.2.3}/tests/test_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyobfus
3
- Version: 0.2.2
3
+ Version: 0.2.3
4
4
  Summary: Modern Python Code Obfuscator with AST-based Transformations
5
5
  Author-email: Rong Zhu <zhurong0525@gmail.com>
6
6
  Maintainer-email: Rong Zhu <zhurong0525@gmail.com>
@@ -52,7 +52,7 @@ A Python code obfuscator built with AST-based transformations for Python 3.8+. P
52
52
 
53
53
  ## Features
54
54
 
55
- ### ✅ Free Edition (Current Version: v0.2.1)
55
+ ### ✅ Free Edition (Current Version: v0.2.3)
56
56
 
57
57
  The following features are **fully implemented and available** in the current version:
58
58
 
@@ -10,7 +10,7 @@ A Python code obfuscator built with AST-based transformations for Python 3.8+. P
10
10
 
11
11
  ## Features
12
12
 
13
- ### ✅ Free Edition (Current Version: v0.2.1)
13
+ ### ✅ Free Edition (Current Version: v0.2.3)
14
14
 
15
15
  The following features are **fully implemented and available** in the current version:
16
16
 
@@ -7,7 +7,7 @@ Born from Medical AI Research, pyobfus provides robust, transparent,
7
7
  and community-driven code obfuscation for Python 3.8+.
8
8
  """
9
9
 
10
- __version__ = "0.2.2"
10
+ __version__ = "0.2.3"
11
11
  __author__ = "Rong Zhu"
12
12
  __license__ = "Apache-2.0"
13
13
 
@@ -54,40 +54,35 @@ class CodeGenerator:
54
54
  @staticmethod
55
55
  def _fix_fstring_quotes(source_code: str) -> str:
56
56
  """
57
- Fix f-string quote conflicts in generated code.
57
+ Fix f-string quote conflicts in generated code for Python 3.6-3.11 compatibility.
58
58
 
59
- When an f-string uses single quotes and contains a subscript with single quotes,
60
- this causes a syntax error. This method detects and fixes such conflicts.
59
+ Python 3.12+ (PEP 701) allows f'text {d['key']}' but earlier versions don't.
60
+ This method ALWAYS normalizes f-strings to ensure backward compatibility,
61
+ regardless of whether the code compiles on the current Python version.
61
62
 
62
63
  Example:
63
- Invalid: f'Value: {data['key']}'
64
- Fixed: f'Value: {data["key"]}'
64
+ Input: f'Value: {data['key']}' (valid in 3.12+, invalid in 3.11-)
65
+ Output: f'Value: {data["key"]}' (valid in all Python 3.6+ versions)
65
66
 
66
67
  Args:
67
68
  source_code: Generated source code
68
69
 
69
70
  Returns:
70
- str: Source code with fixed f-string quotes
71
+ str: Source code with fixed f-string quotes (Python 3.6+ compatible)
71
72
  """
72
- # First, check if the code compiles without issues
73
- try:
74
- compile(source_code, "<string>", "exec")
75
- return source_code # No issues, return as-is
76
- except SyntaxError:
77
- pass # Continue to fix
78
-
79
- # Use a more robust approach: find f-strings and fix quote conflicts
80
- # within each one individually
73
+ # ALWAYS fix f-string quotes for backward compatibility with Python 3.6-3.11
74
+ # Python 3.12+ allows same quotes in f-string expressions (PEP 701),
75
+ # but we need to generate code that works on older Python versions too.
81
76
  fixed_code = CodeGenerator._fix_single_quote_fstrings(source_code)
82
77
  fixed_code = CodeGenerator._fix_double_quote_fstrings(fixed_code)
83
78
 
84
- # Verify the fix worked
79
+ # Verify the result compiles (should always work, but defensive check)
85
80
  try:
86
81
  compile(fixed_code, "<string>", "exec")
87
82
  return fixed_code
88
83
  except SyntaxError:
89
- # If still failing, return original code and let the error propagate
90
- # during actual execution
84
+ # If fixing introduced errors, return original
85
+ # (this shouldn't happen with correct fix logic)
91
86
  return source_code
92
87
 
93
88
  @staticmethod
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyobfus
3
- Version: 0.2.2
3
+ Version: 0.2.3
4
4
  Summary: Modern Python Code Obfuscator with AST-based Transformations
5
5
  Author-email: Rong Zhu <zhurong0525@gmail.com>
6
6
  Maintainer-email: Rong Zhu <zhurong0525@gmail.com>
@@ -52,7 +52,7 @@ A Python code obfuscator built with AST-based transformations for Python 3.8+. P
52
52
 
53
53
  ## Features
54
54
 
55
- ### ✅ Free Edition (Current Version: v0.2.1)
55
+ ### ✅ Free Edition (Current Version: v0.2.3)
56
56
 
57
57
  The following features are **fully implemented and available** in the current version:
58
58
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "pyobfus"
7
- version = "0.2.2"
7
+ version = "0.2.3"
8
8
  description = "Modern Python Code Obfuscator with AST-based Transformations"
9
9
  readme = {file = "README.md", content-type = "text/markdown"}
10
10
  requires-python = ">=3.8"
@@ -151,6 +151,46 @@ def process(data):
151
151
  compile(result, "<test>", "exec")
152
152
 
153
153
 
154
+ class TestPython36Compatibility:
155
+ """Test that generated code is compatible with Python 3.6-3.11."""
156
+
157
+ def test_fstring_quotes_always_normalized(self):
158
+ """f-string quotes should ALWAYS be normalized for backward compatibility.
159
+
160
+ Python 3.12+ (PEP 701) allows f'text {d['key']}' but Python 3.6-3.11 don't.
161
+ PyObfus must generate code compatible with ALL supported Python versions.
162
+ """
163
+ # Even if this code would compile on Python 3.12+, we need to normalize it
164
+ # Input simulates what ast.unparse might produce on Python 3.12+
165
+ code_with_same_quotes = """print(f'Value: {data['key']}')"""
166
+
167
+ result = CodeGenerator._fix_fstring_quotes(code_with_same_quotes)
168
+
169
+ # Should use different quotes for subscript
170
+ assert '["key"]' in result or "['key']" not in result.replace("f'", "")
171
+ # Must compile on all Python versions
172
+ compile(result, "<test>", "exec")
173
+
174
+ def test_double_quote_fstring_normalized(self):
175
+ """Double-quote f-strings with double-quote subscripts should be fixed."""
176
+ code = '''print(f"Value: {data["key"]}")'''
177
+ result = CodeGenerator._fix_fstring_quotes(code)
178
+
179
+ # Should use single quotes for subscript inside double-quoted f-string
180
+ assert "['key']" in result
181
+ compile(result, "<test>", "exec")
182
+
183
+ def test_already_compatible_code_unchanged(self):
184
+ """Code already using different quotes should remain valid."""
185
+ # This is already compatible with all Python versions
186
+ compatible_code = '''print(f"Value: {data['key']}")'''
187
+ result = CodeGenerator._fix_fstring_quotes(compatible_code)
188
+
189
+ # Should remain unchanged (or equivalent)
190
+ compile(result, "<test>", "exec")
191
+ assert "['key']" in result # Still uses single quotes for subscript
192
+
193
+
154
194
  class TestIntegrationWithObfuscation:
155
195
  """Test f-string handling with actual obfuscation pipeline."""
156
196
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes