From d92018aec9f6f952d1df1ef7b68cfe025907caa1 Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Wed, 18 Nov 2026 09:32:13 +0000 Subject: [PATCH 1/2] release v2.3.2 --- AGENTS.md | 84 +++++++++++++++++++++++++----------------- HISTORY.rst | 16 ++++++++ src/MySQLdb/release.py | 4 +- 3 files changed, 69 insertions(+), 35 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index b5427a1a..67d6f0f1 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,49 +1,67 @@ -## Rule +## Checks before committing -Do `ruff format` and `ruff check` before commit. +Run commands from the repository root. Format and lint the source before +committing: -## Running the MySQL test suite in this container +```sh +ruff format src/ +ruff check src/ +git diff --check +``` -1. Install the server and test dependencies if they are not already available: +## Running the mysqlclient test suite - ```sh - apt-get update - DEBIAN_FRONTEND=noninteractive apt-get install -y mysql-server - python -m pip install --upgrade -r requirements-dev.txt - ``` +The CI configuration is in [.github/workflows/tests.yaml](.github/workflows/tests.yaml). +The package is in `src/MySQLdb/` and the tests are in `tests/`. + +1. Install a C compiler, Python development headers, `pkg-config`, and MySQL or + MariaDB client development libraries, as described in [README.md](README.md). + A running MySQL or MariaDB server is also required for database tests. -2. Keep MySQL running in a separate, long-lived terminal/session. The container - does not run systemd, so start `mysqld` directly instead of using - `systemctl`: +2. In a Python virtual environment, install the package and test dependencies: ```sh - install -d -o mysql -g mysql /run/mysqld - rm -f /run/mysqld/mysqld.sock /run/mysqld/mysqld.sock.lock \ - /run/mysqld/mysqlx.sock /run/mysqld/mysqlx.sock.lock \ - /run/mysqld/mysqld.pid - mysqld --user=mysql --local-infile=1 \ - --socket=/run/mysqld/mysqld.sock \ - --pid-file=/run/mysqld/mysqld.pid + python -m pip install -v . + python -m pip install -r requirements.txt + python -m pip install "SQLAlchemy>=2,<3" ``` -3. In another terminal/session, wait for MySQL and initialize a fresh data - directory. The SQL files create databases and users, so only run them when - `test1` does not exist: + SQLAlchemy is needed to run `tests/test_sqlalchemy.py`; those tests are + skipped if it is not installed. + +3. Start the database server using the service manager available in your + environment. In containers without a service manager, run `mysqld` in a + separate, long-lived terminal with an initialized data directory and writable + socket and PID file locations. + + Create a dedicated test database using an administrator connection, for example: ```sh - until mysqladmin ping --silent; do sleep 1; done - if ! mysql -NBe "SHOW DATABASES LIKE 'test1'" | rg -q '^test1$'; then - mysql -uroot --comments < ci/docker-entrypoint-initdb.d/init.sql - mysql -uroot --comments < ci/docker-entrypoint-initdb.d/mysql.sql - mysql -uroot --comments < ci/docker-entrypoint-initdb.d/mariadb.sql - fi - cp ci/docker.json pymysql/tests/databases.json + mysql -uroot -p -e "CREATE DATABASE IF NOT EXISTS mysqldb_test" ``` -4. Run the same test commands as CI: + Ensure the test user can create, alter, and drop tables, and create, execute, + and drop stored procedures in that database. + `tests/actions.cnf` uses `127.0.0.1:3306`, user `root`, password `root`, and + database `mysqldb_test`. For different credentials, create a separate MySQL + option file with a `[MySQLdb-tests]` group, using `tests/actions.cnf` as a + template. + +4. Run the same pytest command as CI: ```sh - pytest -v --cov --cov-config .coveragerc pymysql - pytest -v --cov-append --cov-config .coveragerc \ - --doctest-modules pymysql/converters.py + TESTDB=actions.cnf pytest --cov=MySQLdb tests ``` + + `TESTDB` selects a filename under `tests/` or an absolute path to an option + file. Without it, `tests/default.cnf` is used. The tests create and drop + tables, so use the dedicated test database. + +CI also runs the Django test suite in a separate job. Refer to +`.github/workflows/tests.yaml` for its dependencies, database setup, and +`test_mysql_executemany_multi` settings. + +## Releases + +Follow [notes/release.md](notes/release.md) for version updates, release CI, +tagging, and publication. diff --git a/HISTORY.rst b/HISTORY.rst index 1b07800a..2d1ad99b 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -1,3 +1,19 @@ +====================== + What's new in 2.3.2 +====================== + +Release: 2026-11-18 + +* Restore string and byte literal handling for subclasses of ``str``, ``bytes``, + and ``bytearray``. This fixes a regression in 2.3.1 where string-valued + ``enum.Enum`` members were serialized using their enum names instead of their + string values. (#814) + +* Free buffered results without acquiring the connection lock. This avoids + spurious ``ProgrammingError`` exceptions when another thread releases a + buffered result while the connection is in use. (#815) + + ====================== What's new in 2.3.1 ====================== diff --git a/src/MySQLdb/release.py b/src/MySQLdb/release.py index 8b54c83c..e0ccb338 100644 --- a/src/MySQLdb/release.py +++ b/src/MySQLdb/release.py @@ -1,3 +1,3 @@ __author__ = "Inada Naoki " -__version__ = "2.3.1" -version_info = (2, 3, 1, "final", 0) +__version__ = "2.3.2" +version_info = (2, 3, 2, "final", 0) From 316df14c0640e1b809a591ef4ae81d90ee535702 Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Wed, 18 Nov 2026 09:58:57 +0000 Subject: [PATCH 2/2] Document bytearray escaping in the 2.3.2 release notes --- AGENTS.md | 5 +++-- HISTORY.rst | 13 ++++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 67d6f0f1..9208c096 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -40,8 +40,9 @@ The package is in `src/MySQLdb/` and the tests are in `tests/`. mysql -uroot -p -e "CREATE DATABASE IF NOT EXISTS mysqldb_test" ``` - Ensure the test user can create, alter, and drop tables, and create, execute, - and drop stored procedures in that database. + The test user needs to create, alter, and drop tables, run `SELECT`, + `INSERT`, `UPDATE`, and `DELETE`, and create, execute, and drop stored + procedures in that database. `tests/actions.cnf` uses `127.0.0.1:3306`, user `root`, password `root`, and database `mysqldb_test`. For different credentials, create a separate MySQL option file with a `[MySQLdb-tests]` group, using `tests/actions.cnf` as a diff --git a/HISTORY.rst b/HISTORY.rst index 2d1ad99b..837f4141 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -4,14 +4,17 @@ Release: 2026-11-18 -* Restore string and byte literal handling for subclasses of ``str``, ``bytes``, - and ``bytearray``. This fixes a regression in 2.3.1 where string-valued +* Restore the use of the base type's literal conversion for subclasses of + ``str``, ``bytes``, and ``bytearray``. This fixes a regression in 2.3.1 where string-valued ``enum.Enum`` members were serialized using their enum names instead of their string values. (#814) -* Free buffered results without acquiring the connection lock. This avoids - spurious ``ProgrammingError`` exceptions when another thread releases a - buffered result while the connection is in use. (#815) +* Avoid a spurious ``ProgrammingError`` when another thread drops the last + reference to a buffered result while the connection is in use. (#815) + +* Escape the contents of ``bytearray`` query parameters the same way as + ``bytes``. Previously, passing ``bytearray(b'ab')`` sent the Python string + representation to the server. This also applies to subclasses. (#817) ======================