sock.makefile().flush has UnboundLocalError bug
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Python |
Fix Released
|
Unknown
|
|||
python2.6 (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
Binary package hint: python2.6
Sometimes calling .write/
File "/usr/lib/
del view, data # explicit free
UnboundLocalError: local variable 'view' referenced before assignment
This script demonstrates, but I've seen this with e.g. bzr's test suite too:
"""
import socket
import sys
import threading
sock_a, sock_b = socket.socketpair()
sock_a = socket.
def read_byte_
data = s.recv(1)
print >>sys.stderr, 'read:', repr(data)
s.close()
print >>sys.stderr, 'closed sock_b'
t = threading.
t.start()
file_a = sock_a.
file_a.
file_a.flush()
t.join()
"""
(It might not be a strictly minimal reproduction, but it's not too far off.)
The cause of the bug is pretty trivially obvious on inspection: the 'view' variable is indeed never defined in that method. Running pyflakes on socket.py finds that bug on line 302, and also a similar one on line 399 in the read() method.
ProblemType: Bug
DistroRelease: Ubuntu 10.10
Package: python2.6 2.6.6~rc1-1ubuntu1
ProcVersionSign
Uname: Linux 2.6.35-14-generic i686
Architecture: i386
Date: Mon Aug 9 16:55:04 2010
InstallationMedia: Ubuntu 10.04 LTS "Lucid Lynx" - Release i386 (20100429)
ProcEnviron:
LANG=en_AU.utf8
SHELL=/bin/bash
SourcePackage: python2.6
Changed in python: | |
status: | Unknown → New |
Changed in python: | |
status: | New → Fix Released |
This is from a bad merge: svn.python. org/view? view=rev& revision= 83624
http://
The original diff: svn.python. org/view/ python/ trunk/Lib/ socket. py?r1=75412& r2=75411& pathrev= 75412
http://
The merged diff: svn.python. org/view/ python/ branches/ release26- maint/Lib/ socket. py?r1=81488& r2=83624
http://
Kept the addition of 'view' even though that part of the change wasn't taken.