Open mgedmin opened 4 years ago
I happened to be looking at http.py because its use of basestring on Python 3 intrigued me. I think I discovered a bug, or at least an inconsistency in setStatus: https://github.com/zopefoundation/zope.publisher/blob/69902a756c425bac12b73c19323c46d9ef671411/src/zope/publisher/http.py#L695-L707
basestring
This checks if status is a basestring (defined as (str, bytes) on Python 3), then looks it up in the status_codes dict. The dict is initialized by https://github.com/zopefoundation/zope.publisher/blob/69902a756c425bac12b73c19323c46d9ef671411/src/zope/publisher/http.py#L182-L198
status
(str, bytes)
which puts int and str keys in the global, but no bytestring keys.
On Python 2 u'ok' == b'ok', so you can look up either byte or unicode strings. On Python 3 that's no longer true.
u'ok' == b'ok'
I don't know if we want to support byte-strings as statuses, but if we don't, we should ... actually I no longer care about this issue.
I happened to be looking at http.py because its use of
basestring
on Python 3 intrigued me. I think I discovered a bug, or at least an inconsistency in setStatus: https://github.com/zopefoundation/zope.publisher/blob/69902a756c425bac12b73c19323c46d9ef671411/src/zope/publisher/http.py#L695-L707This checks if
status
is abasestring
(defined as(str, bytes)
on Python 3), then looks it up in the status_codes dict. The dict is initialized by https://github.com/zopefoundation/zope.publisher/blob/69902a756c425bac12b73c19323c46d9ef671411/src/zope/publisher/http.py#L182-L198which puts int and str keys in the global, but no bytestring keys.
On Python 2
u'ok' == b'ok'
, so you can look up either byte or unicode strings. On Python 3 that's no longer true.I don't know if we want to support byte-strings as statuses, but if we don't, we should ... actually I no longer care about this issue.