Repository navigation
Conversation
…lity Python open() uses locale-dependent encoding by default. On systems with non-UTF-8 locale (e.g. Windows cp1252), reading PID files, certificates, and auth keys can fail or produce corrupted data. Fixed 4 files in celery/production code: - platforms.py: PID file read/write (2 calls) - security/certificate.py: PEM certificate loading (1 call) - security/__init__.py: SSL key and cert loading (2 calls)
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aims to make file reads in a few Celery runtime paths deterministic across platforms by avoiding locale-dependent default encodings in open().
Changes:
- Use
encoding="utf-8"when reading X.509 certificate PEM files in the filesystem cert store. - Use
encoding="utf-8"when reading the security key/certificate files duringsetup_security(). - Use
encoding="utf-8"when reading and re-reading pidfiles for lock verification.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
celery/security/certificate.py |
Reads PEM certificate files using explicit UTF-8 decoding. |
celery/security/__init__.py |
Reads auth serializer key/cert files using explicit UTF-8 decoding. |
celery/platforms.py |
Reads pidfile contents using explicit UTF-8 decoding (including re-read verification). |
auvipy
requested changes
May 9, 2026
auvipy
left a comment
Member
There was a problem hiding this comment.
the changes seems to be useful. should we also update or improve relevant tests for the relevant changes as well?
❌ 1 Tests Failed:
View the top 1 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
Member
|
the tests are failing |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Python open() uses locale-dependent encoding by default. On systems with non-UTF-8 locale (e.g. Windows cp1252), reading PID files, certificates, and auth keys can fail or produce corrupted data.
Fixed 3 files in celery/production code: