Skip to content

Conversation

@webknjaz
Copy link
Contributor

@webknjaz webknjaz commented Dec 10, 2025

It was discovered by @julianz- [1] that this works differently under *NIX and on Windows. So this patch adds a test case to demonstrate the inconsistency.

Specifically, this is how it works on my Gentoo laptop (Python 3.14.0):

# linux
>>> import http
>>> str(http.HTTPStatus.CONTINUE), str(http.HTTPStatus.CONTINUE.value)
('100', '100')

However, a CI job in Cheroot revealed that on Windows, it's not the number that's returned but the enum name:

# windows
>>> import http
>>> str(http.HTTPStatus.BAD_REQUEST)
'HTTPStatus.BAD_REQUEST'

The added test seeks to show this cross-platform difference.

@bedevere-app bedevere-app bot added the tests Tests in the Lib/test dir label Dec 10, 2025
@webknjaz webknjaz changed the title Test HTTPStatus items are stringified as values gh-142536: Test HTTPStatus items are stringified as values Dec 10, 2025
@webknjaz
Copy link
Contributor Author

@julianz- I don't see this reproducing the inconsistency you've hit in that PR.. Ideas?

It was discovered by @julianz- [[1]] that this works differently under
*NIX and on Windows. So this patch adds a test case to demonstrate the
inconsistency.

[1]: cherrypy/cheroot#800 (comment)
@webknjaz webknjaz force-pushed the reproducers/httpstatus-str-as-value branch from d26912a to bd2d16d Compare December 10, 2025 21:03
@julianz-
Copy link

julianz- commented Dec 11, 2025

@webknjaz Maybe because of a difference in the CI? The failure I saw was in Windows 2022.

Update: Oh I see there was a change in Python 3.11 to the way enums are stringified:

In https://docs.python.org/3/library/enum.html#enum.IntEnum it says:

"Changed in version 3.11: str() is now int.str()"

The error was occurring when running with Python 3.10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants