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.

Author John Hagen
Recipients John Hagen
Date 2017-02-22.16:35:21
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1487781321.4.0.45367640243.issue29621@psf.upfronthosting.co.za>
In-reply-to
Content
I was recently helping someone learn Python 3 from Python 2 and they were confused by error resulting from the following easy-to-make mistake:

import telnetlib

tn = telnetlib.Telnet('localhost')
tn.write('hello')

Traceback (most recent call last):
  File "/Users/user/PycharmProjects/python-test/main.py", line 4, in <module>
    tn.write('hello')
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/telnetlib.py", line 287, in write
    if IAC in buffer:
TypeError: 'in <string>' requires string as left operand, not bytes

What is confusing is that the solution is to pass in `bytes`, not a `str`, but the place where this manifests is in an `in` operator with the first argument as a `bytes` (telnetlib.IAC).

Perhaps a simple isinstance(buffer, bytes) could be used to throw a `TypeError` or something a bit more helpful.

It also doesn't help that for some reason Googling "python telnet" only seems to bring up the Python 2 docs link, rather than Python 3 or both.
History
Date User Action Args
2017-02-22 16:35:21John Hagensetrecipients: + John Hagen
2017-02-22 16:35:21John Hagensetmessageid: <1487781321.4.0.45367640243.issue29621@psf.upfronthosting.co.za>
2017-02-22 16:35:21John Hagenlinkissue29621 messages
2017-02-22 16:35:21John Hagencreate