Skip to content

Commit addea38

Browse files
author
Bob Farrell
committed
scapy expecting file-like methods that don't exist
scapy seems to have a bug in it in that it expects stdout to have a flush() method, which is not specified in the documentation for the sys module (it specifies that it requires only a write() method to be acceptable). So this is a hack to fix it, it's harmless though. committer: Bob Farrell <bob@keys.(none)>
1 parent 8b71e41 commit addea38

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

‎bpython.py‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def writetb( self, l ):
134134
map( self.write, [ "\x01y\x03%s" % i for i in l ] )
135135

136136

137-
class Repl:
137+
class Repl( object ):
138138
"""Implements the necessary guff for a Python-repl-alike interface
139139
140140
The execution of the code entered and all that stuff was taken from the
@@ -755,6 +755,20 @@ def write( self, s ):
755755
self.echo( s )
756756
self.s_hist.append( s.rstrip('\n') )
757757

758+
def flush( self ):
759+
"""Olivier Grisel brought it to my attention that the scapy
760+
module tries to call this method, since it makes assumptions
761+
about stdout that may not necessarily be true. The docs for
762+
sys.stdout say:
763+
764+
"stdout and stderr needn't be built-in file objects: any
765+
object is acceptable as long as it has a write() method
766+
that takes a string argument."
767+
768+
So I consider this to be a bug in scapy, and this is a hack
769+
to fix it, unfortunately. I'm sure they're not the only ones."""
770+
pass
771+
758772
def echo( self, s, redraw=True ):
759773
"""Parse and echo a formatted string with appropriate attributes. It uses the
760774
formatting method as defined in formatter.py to parse the srings. It won't update
@@ -1071,7 +1085,7 @@ def get_line( self ):
10711085
if self.p_key() is None:
10721086
return self.s
10731087

1074-
class Statusbar:
1088+
class Statusbar( object ):
10751089
"""This class provides the status bar at the bottom of the screen.
10761090
It has message() and prompt() methods for user interactivity, as
10771091
well as settext() and clear() methods for changing its appearance.

0 commit comments

Comments
 (0)