diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d9bbda..4c5b751 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +### 1.1.7 (2024-09-24) +1. fix `utils.code_inline` gzip compress `mtime` to 0 +2. + ### 1.1.6 (2024-09-09) 1. add filename_filter to utils.format_error 2. add `functools.get_function` to find function from entrypoint diff --git a/doc.md b/doc.md index 2aa249a..4c48dea 100644 --- a/doc.md +++ b/doc.md @@ -225,11 +225,17 @@ ```python - >>> code1 = '' - >>> code2 = code_inline("variable=12345") - >>> # import base64,gzip;exec(gzip.decompress(base64.b85decode("ABzY8mBl+`0{<&ZEXqtw%1N~~G%_|Z1ptx!(o_xr000".encode("u8")))) + >>> code1 = code_inline('def test_code1(): return 12345') + >>> code1 + 'import base64,gzip;exec(gzip.decompress(base64.b85decode("ABzY8000000t!n>O;adIEiQ>q&QD1-)X=n2C`v6UEy`0cG%_|Z1psqiSP>oo000".encode("u8"))))' + >>> exec(code1) + >>> test_code1() + 12345 + >>> code2 = code_inline("v=12345") + >>> code2 + 'import base64,gzip;exec(gzip.decompress(base64.b85decode("ABzY8000000tzd$H8e6dF$Dk}>> exec(code2) - >>> variable + >>> v 12345 Args: diff --git a/morebuiltins/utils.py b/morebuiltins/utils.py index 3116403..c924e20 100644 --- a/morebuiltins/utils.py +++ b/morebuiltins/utils.py @@ -414,11 +414,17 @@ def code_inline( ) -> str: """Minifies Python source code into a single line. - >>> code1 = '' - >>> code2 = code_inline("variable=12345") - >>> # import base64,gzip;exec(gzip.decompress(base64.b85decode("ABzY8mBl+`0{<&ZEXqtw%1N~~G%_|Z1ptx!(o_xr000".encode("u8")))) + >>> code1 = code_inline('def test_code1(): return 12345') + >>> code1 + 'import base64,gzip;exec(gzip.decompress(base64.b85decode("ABzY8000000t!n>O;adIEiQ>q&QD1-)X=n2C`v6UEy`0cG%_|Z1psqiSP>oo000".encode("u8"))))' + >>> exec(code1) + >>> test_code1() + 12345 + >>> code2 = code_inline("v=12345") + >>> code2 + 'import base64,gzip;exec(gzip.decompress(base64.b85decode("ABzY8000000tzd$H8e6dF$Dk}>> exec(code2) - >>> variable + >>> v 12345 Args: @@ -429,7 +435,7 @@ def code_inline( """ _encoder = getattr(base64, f"{encoder}encode") _source = source_code.encode(encoding="u8") - _source = gzip.compress(_source) + _source = gzip.compress(_source, mtime=0) _source = _encoder(_source) code = _source.decode("u8") result = (