python / cpython

The Python programming language
https://www.python.org/
Other
61.16k stars 29.52k forks source link

telnetlib incorrectly assumes that select.error has an errno attribute #62235

Closed gpshead closed 6 years ago

gpshead commented 11 years ago
BPO 18035
Nosy @gpshead, @phmc
PRs
  • python/cpython#5044
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields: ```python assignee = None closed_at = created_at = labels = ['type-bug'] title = 'telnetlib incorrectly assumes that select.error has an errno attribute' updated_at = user = 'https://github.com/gpshead' ``` bugs.python.org fields: ```python activity = actor = 'gregory.p.smith' assignee = 'none' closed = True closed_date = closer = 'gregory.p.smith' components = [] creation = creator = 'gregory.p.smith' dependencies = [] files = [] hgrepos = [] issue_num = 18035 keywords = ['patch'] message_count = 4.0 messages = ['189828', '189830', '189849', '309193'] nosy_count = 3.0 nosy_names = ['gregory.p.smith', 'pconnell', 'Thayu.R'] pr_nums = ['5044'] priority = 'normal' resolution = 'fixed' stage = 'resolved' status = 'closed' superseder = None type = 'behavior' url = 'https://bugs.python.org/issue18035' versions = ['Python 2.7'] ```

    gpshead commented 11 years ago

    In Python 2.7.3 through 2.7.5 the telnetlib select.poll based implementation assumes that select.error has an errno attribute when handling errors. it does not. select.error is not an EnvironmentError derived exception.

    http://hg.python.org/cpython/file/85c04fdaa404/Lib/telnetlib.py#l317

    i haven't check 3.x yet.

    gpshead commented 11 years ago

    As this is only on the select.poll code path, a workaround for code that isn't going to hit select.select file descriptor limits is to set their telnetlib.Telnet instance _has_poll attribute to False before using it.

    my_telnet = telnetlib.Telnet(...)
    my_telnet._has_poll = False
    02d06154-2ce1-48a0-80cf-fb402437d2a6 commented 11 years ago

    Just to add: select.error was made an alias of OSError following PEP-3151 from 3.3 onwards. Up to 3.2, it was a pair containing the error code and the error string.

    http://docs.python.org/3.3/library/select.html?highlight=select.error#select.error

    gpshead commented 6 years ago

    New changeset 3ceaed0dce81fd881bbaf2dbdbe827d9681887da by Gregory P. Smith (Segev Finer) in branch '2.7': bpo-18035: telnetlib: select.error doesn't have an errno attribute (bpo-5044) https://github.com/python/cpython/commit/3ceaed0dce81fd881bbaf2dbdbe827d9681887da