141 Commits

Author SHA1 Message Date
Evgenii Kliuchnikov
f81d6bc7f0 Modernize tests.
Avoid file IO.
Drive-by: drop bro.py and bro_test.py; we do not support it well and likely no one uses it.
PiperOrigin-RevId: 834206605
2025-11-19 02:56:01 -08:00
Evgenii Kliuchnikov
ea5b5c10dd Drop Py 3.9- support
PiperOrigin-RevId: 830342213
2025-11-10 02:18:38 -08:00
Rui Xi
e4bc10a000 fix method name in python Decompressor docstring 2025-11-07 15:48:14 +08:00
Evgenii Kliuchnikov
ed93810e27 support multi-phase initialization
PiperOrigin-RevId: 814128632
2025-10-02 01:51:02 -07:00
Evgenii Kliuchnikov
1f6ab76bff use module-bound exception
PiperOrigin-RevId: 812739918
2025-09-29 05:12:31 -07:00
Evgenii Kliuchnikov
1406898440 Build and test with PY2.7
PiperOrigin-RevId: 811352084
2025-09-25 08:00:20 -07:00
Evgenii Kliuchnikov
9686382ff3 PY: continue renovation of extension
Fixed unchecked malloc for "tail" input data.
Fixed inconsistencies in docstrings.

Rewritten "growable buffer" to C-code, so it could run without acquiring GIL.

Breaking changes:
 - native object allocation failures now handled at object creation time
 - some lower level exceptions (e.g. OOM) are not shadowed by brotli.error

PiperOrigin-RevId: 810813664
2025-09-24 03:52:44 -07:00
Evgenii Kliuchnikov
41a22f07f2 modernize PY3 class definition
PiperOrigin-RevId: 804460135
2025-09-08 09:15:53 -07:00
Evgenii Kliuchnikov
98a89b1563 temporary rollback
PiperOrigin-RevId: 803462595
2025-09-05 07:57:59 -07:00
Evgenii Kliuchnikov
35d4992ac8 PY: reformat _brotli.c
PiperOrigin-RevId: 803412055
2025-09-05 04:42:06 -07:00
Eugene Kliuchnikov
79ea7296d4 Merge branch 'master' into master 2025-08-29 15:06:37 +02:00
Evgenii Kliuchnikov
9a4ba5932b internal change
PiperOrigin-RevId: 795452145
2025-08-15 06:18:41 -07:00
Domingo Dirutigliano
964ca075d1 fix module import in set exception + setup.py compatible with python2 2025-06-13 14:58:13 +02:00
Domingo Dirutigliano
ddb803acc3 using static function 2025-06-13 14:13:12 +02:00
Domingo Dirutigliano
998a28bde4 using module state for error handling 2025-06-13 14:09:51 +02:00
Benjamin Leff
dcc24d051d chore: fixing trailing whitespace in python/README.md 2025-05-28 14:13:46 -05:00
Benjamin Leff
9b7beb425d Merge branch 'google:master' into master 2025-05-27 08:06:30 -05:00
Christian Clauss
3487b6917d Update bro.py: Fix undefined name in Python code (#1240)
`outfile` is used before it is defined on the following line so use `options.outfile` instead.

% `ruff check`
```
Error: python/bro.py:168:64: F821 Undefined name `outfile`
```

Co-authored-by: Eugene Kliuchnikov <eustas.ru@gmail.com>
2025-05-27 09:37:03 +02:00
Domingo Dirutigliano
e45f18ccca DECREF on exception raise 2025-03-15 11:23:32 +01:00
Domingo Dirutigliano
c710db0510 enabled support to 3.12 per GIL interpeter using multistage module inizialization 2025-03-15 09:13:46 +01:00
Robert Obryk
eb3a31e2d3 add max_length to Python streaming decompression 2025-01-07 16:28:30 +01:00
Robert Obryk
28ce91caf6 add size limit to buffer 2025-01-07 16:28:30 +01:00
Brotli
d019271c8b Copybara import of the project:
--
f1bdfaa803 by Robert Obryk <robryk@google.com>:

add size limit to buffer

--
ef8922cee7 by Robert Obryk <robryk@google.com>:

add max_length to Python streaming decompression

PiperOrigin-RevId: 712463460
2025-01-06 03:05:56 -08:00
Copybara-Service
ef9e12f004 Merge pull request #1201 from robryk:sizelimit
PiperOrigin-RevId: 712456783
2025-01-06 02:37:01 -08:00
Robert Obryk
ef8922cee7 add max_length to Python streaming decompression 2025-01-06 11:26:42 +01:00
Slava Gorlov
3a444a6f2d Merge branch 'google:master' into master 2024-11-21 12:26:45 +05:00
Evgenii Kliuchnikov
2dfaadcef3 (PY) clarify compressor mode parameter values
PiperOrigin-RevId: 698023020
2024-11-19 08:15:20 -08:00
Robert Obryk
f1bdfaa803 add size limit to buffer 2024-09-17 16:54:59 +02:00
gorloffslava
2a01fd8f31 + Added ability to build Brotli Python bindings against system-provided brotli instead of vendored one 2024-07-29 20:05:34 +05:00
Thomas Fischbacher
acc265655d Small Python modernization of Brotli code.
PiperOrigin-RevId: 549289787
2023-07-19 05:44:36 -07:00
Evgenii Kliuchnikov
bc32ae12d5 add tests with UTF8/UTF16 non-ASCII text
PiperOrigin-RevId: 545424981
2023-07-05 19:15:11 +00:00
Evgenii Kliuchnikov
38e9add9d2 Fix permissions
PiperOrigin-RevId: 506096478
2023-02-01 09:20:14 +00:00
Brotli
36533a866e Internal change
PiperOrigin-RevId: 502401179
2023-01-17 13:51:00 +00:00
Ma Lin
c8df4b3049 Python: use a new output buffer code (#902)
Currently, the output buffer is a std::vector<uint8_t>.
When the buffer grows, resizing will cause unnecessary memcpy().

This change uses a list of bytes object to represent output buffer, can avoid the extra overhead of resizing.
In addition, C++ code can be removed, it's a pure C extension.
2022-12-29 14:07:16 +01:00
Evgenii Kliuchnikov
a8f5813b84 Update
Documentation:
  - add note that brotli is a "stream" format, not an archive-like
  - regenerate .1 with Pandoc
Build:
  - drop legacy "BROTLI_BUILD_PORTABLE" option
  - drop "BROTLI_SANITIZED" definition
Code:
  - c: comb includes
  - c/enc: extract encoder state into separate header
  - c/enc: drop designated q10 codepath
  - c/enc: dealing better with flushing of empty stream
  - fix MSVC compilation
API:
  - py: use library version instead of one in version.h
  - c: add plugable API to report consumed input / produced output
  - c/java: support "lean" prepared dictionaries (without copy of source)
2022-11-17 13:03:09 +00:00
Eugene Kliuchnikov
8376f72ed6 Prepare for copybara (#939)
Co-authored-by: Eugene Kliuchnikov <eustas@chromium.org>
2021-11-10 10:34:39 +01:00
Eugene Kliuchnikov
68f1b90ad0 Update (#918)
Prepare to use copybara worklow.
2021-08-18 19:15:07 +02:00
Eugene Kliuchnikov
7f740f1308 Update (#807)
- fix formatting
 - fix type conversion
 - fix no-op arithmetic with null-pointer
 - improve performance of hash_longest_match64
 - go: detect read after close
 - java decoder: support compound dictionary
 - remove executable flag on non-scripts
2020-05-15 11:06:21 +02:00
Eugene Kliuchnikov
c8b37e8fd1 Update (#762)
* put LICENSE file into .jar
 * fix typo
 * add clarification comment in PY wrapper
2019-07-17 14:39:56 +02:00
Justin Ridgewell
5805f99a53 Ensure decompression consumes all input (#730)
* Ensure decompression consumes all input

If not, it's a corrupt stream.

* Use byte strings
2018-11-12 10:36:00 +01:00
Eugene Kliuchnikov
2c03482569 Fix "memory leak" in python tests (#652)
OOMs on RPi (1GB)
2018-03-23 02:09:00 +06:00
Eugene Kliuchnikov
a629289e32 Update (#590)
* add transpiled JS decoder
 * make PY wrapper accept memview
 * fix dictionary generator
 * speedup compression of RLEish data
2017-08-28 11:31:29 +02:00
Cosimo Lupo
4f455cac32 disable buidling/deployment of python wheels (#583)
* [appveyor] remove 'deploy' stage; only test python 2.7 and 3.6

all the other python versions are being built and tested on
https://github.com/google/brotli-wheels/blob/d571d63/appveyor.yml

* remove terrify submodule as not needed any more

* [travis] just test py2.7 and 3.6 on linux; remove extra osx python builds

All the other python versions for OSX are being built/tested on:
https://github.com/google/brotli-wheels/blob/d571d63/.travis.yml

Also, there's no need to build and deploy wheels here, as that's done
in the separate repository.

* [setup.py] only rebuild if dependency are newer; fix typo in list of 'depends'

https://github.com/python/cpython/blob/v3.6.2/Lib/distutils/command/build_ext.py#L485-L500

* [ci] only run 'python setup.py test'

if we run 'python setup.py built test', the setuptools 'test' command will
forcibly re-run the build_ext subcommand because it wants to pass the --inplace
option (it ignores whether it's up to date, just re-runs it all the time).

with this we go from running built_ext twice, to running it only once per build

* [Makefile] run 'build_ext --inplace' instead of 'develop' as default target

The 'develop' command is like 'install' in the sense that it
modifies the user's python environment.
The default make target should be less intrusive, i.e. just building
the extension module in-place without modify anything in the user's
environment.

We don't need to tell make about the dependency between 'test' and
'build' target as that is baked in the `python setup.py test` command.

* [Makefile] add 'develop' target; remove unnecessary 'tests' target

`make test` is good enough

* [Makefile] `setup.py test` requires setuptools; run `python -m unittest`

This will work even if setuptools is not installed, which is unlikely
nowadays but still our `setup.py` works with plain distutils, so
we may well have our tests work without setuptools.

* [python/README.md] add ref to 'develop' target; remove 'tests', just 'make test'

* [setup.py] import modules as per nicksay's comment

https://github.com/google/brotli/pull/583#discussion_r131981049

* [Makefile] add 'develop' to .PHONY targets

remove 'tests' from .PHONY

* [appveyor] remove unused setup scripts

We don't need to install custom python versions, we are
using the pre-installed ones on Appveyor.

* [appveyor] remove unneeded setup code
2017-08-23 20:45:13 +02:00
Alex Nicksay
019091f994 Python: Update bro_test to reference script directly (#582) 2017-08-08 10:25:39 +02:00
Eugene Kliuchnikov
d63e8f75f5 Update API, and more (#581)
Update API, and more:
 * remove "custom dictionary" support
 * c/encoder: fix #580: big-endian build
 * Java: reduce jar size
 * Java: speedup decoding
 * Java: add 32-bit CPU support
 * Java: make source code JS transpiler-ready
2017-08-04 10:02:56 +02:00
Alex Nicksay
0608253110 Python: Add a "make install" command and clarify installation docs (#578)
Closes #576
2017-08-02 16:59:46 +02:00
Eugene Kliuchnikov
52441069ef Update (#574)
* Update
 * decoder: better behavior after failure
 * encoder: replace "len_x_code" with delta
 * research: add experimental dictionary generator
 * python: test combing
2017-07-21 10:07:24 +02:00
Eugene Kliuchnikov
1becbbf231 Update (#569)
* add misssing fclose in `brotli.c`
 * add basic tests for python `Decompressor` type
 * minor lint fixes in `_brotli.cc`
2017-06-30 13:09:50 +02:00
Janek
58f5c37f3b Python: Decompressor: Streaming decompression support (#546)
python-brotli has Compressor for streaming compression but nothing for
streaming decompression.
This is a straight-forward copy of the Compressor code into the new
class Decompressor.
2017-06-28 16:32:28 +02:00
Alex Nicksay
6ab0a5cee7 Python: Create Makefile for development shortcuts (#488) 2016-12-21 10:17:11 +01:00