This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: zlib.compress() fails with string
Type: compile error Stage:
Components: Documentation Versions: Python 3.1
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, georg.brandl, joseluisfb
Priority: normal Keywords:

Created on 2011-01-07 20:02 by joseluisfb, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (4)
msg125702 - (view) Author: Jose-Luis Fernandez-Barros (joseluisfb) Date: 2011-01-07 20:02
On "The Python Tutorial", section 10.9. Data Compression
  http://docs.python.org/py3k/tutorial/stdlib.html#data-compression

>>> import zlib
>>> s = 'witch which has which witches wrist watch'
...
>>> t = zlib.compress(s)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: must be bytes or buffer, not str

Possible solution (sorry, newbie) are:
>>> s = b'witch which has which witches wrist watch'
or
>>> s = 'witch which has which witches wrist watch'.encode("utf-8")


At "The Python Standard Library", secction 12. Data Compression and Archiving
  http://docs.python.org/py3k/library/zlib.html#module-zlib
apparently example is correct:
  zlib.compress(string[, level])
msg125767 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2011-01-08 09:17
This is already fixed in dev docs, just needs backporting.
msg125797 - (view) Author: Jose-Luis Fernandez-Barros (joseluisfb) Date: 2011-01-08 19:50
Thanks for your answer.

Error remains at development "The Python Standard Library", secction 12. Data Compression and Archiving
  http://docs.python.org/dev/py3k/library/zlib.html#module-zlib
zlib.compress(string[, level])
msg125800 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2011-01-08 21:04
Quite right, this is now fixed in r87870.
History
Date User Action Args
2022-04-11 14:57:11adminsetgithub: 55072
2011-01-08 21:04:48georg.brandlsetstatus: open -> closed
nosy: georg.brandl, docs@python, joseluisfb
resolution: fixed
2011-01-08 21:04:39georg.brandlsetnosy: georg.brandl, docs@python, joseluisfb
messages: + msg125800
2011-01-08 19:50:47joseluisfbsetstatus: closed -> open

messages: + msg125797
resolution: fixed -> (no value)
nosy: georg.brandl, docs@python, joseluisfb
2011-01-08 09:17:49georg.brandlsetstatus: open -> closed

nosy: + georg.brandl
messages: + msg125767

resolution: fixed
2011-01-07 20:02:48joseluisfbcreate