Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## [Unreleased]

- Improved the error message when a `.python-version` or `runtime.txt` file contains invisible Unicode whitespace characters. ([#1947](https://github.com/heroku/heroku-buildpack-python/pull/1947))

## [v315] - 2025-10-22

Expand Down
4 changes: 3 additions & 1 deletion lib/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ function utils::get_requirement_version() {
# replacement character, so they are visible in error messages. Also removes any carriage
# return characters, to prevent them interfering with the rendering of error messages that
# include the raw file contents.
# `LC_ALL=C` ensures that `[:space:]` only matches ASCII whitespace, since we want Unicode
# whitespace (such as the invisible Unicode zero width space character) to be replaced too.
function utils::read_file_with_special_chars_substituted() {
local file="${1}"
sed --regexp-extended --expression 's/[^[:print:][:space:]]/�/g' --expression 's/\r$//' "${file}"
LC_ALL=C sed --regexp-extended --expression 's/[^[:print:][:space:]]/�/g' --expression 's/\r$//' "${file}"
}

# Python bundles pip within its standard library, which we can use to install our chosen
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion spec/fixtures/runtime_txt_invalid_version/runtime.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
python-3.12.0
python-3.12.0
4 changes: 2 additions & 2 deletions spec/hatchet/python_version_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@
remote: ! isn't in the correct format.
remote: !
remote: ! The following version was found:
remote: ! �3.�12.0�
remote: ! ���3.�12.0�
remote: !
remote: ! However, the Python version must be specified as either:
remote: ! 1. The major version only, for example: #{DEFAULT_PYTHON_MAJOR_VERSION} (recommended)
Expand Down Expand Up @@ -562,7 +562,7 @@
remote: ! in the correct format.
remote: !
remote: ! The following file contents were found, which aren't valid:
remote: ! python-3.12.0�
remote: ! ���python-3.12.0�
remote: !
remote: ! However, the runtime.txt file is deprecated since it has been
remote: ! replaced by the more widely supported .python-version file:
Expand Down