Errata


Print Print Icon

Submit your own errata for this product.


The errata list is a list of errors and their corrections that were found after the product was released.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.


Color Key: Serious Technical Mistake Minor Technical Mistake Language or formatting error Typo Question



Version Location Description Submitted By
Safari Books Online sec. 5.5
4th capture


In the line:
>>> ans,unans=sr(IP(dst="oreilly.com", ttl=(4,25),id=RandShort())/TCP(flags=0x2))

all the stimuli and answers will look alike. Thus Scapy may mismatch an answer with the wrong stimulus. To avoid this, you can set TCP source port to a random value: TCP(sport=RandShort())
IPID being random does not help.

Philippe Biondi
O'Reilly Author 
Safari Books Online Sec. 5.5
4th capture

The capture says:
---
>>> ans,unans=sr(IP(dst="oreilly.com",
>>> ttl=(4,25),id=RandShort())/TCP(flags=0x2))
Begin emission:
..............*Finished to send 22 packets.
*...........*********.***.***.*.*.*.*.*
Received 54 packets, got 22 answers, remaining 0 packets
>>> for snd, rcv in ans:
... print snd.ttl, rcv.src, isinstance(rcv.payload, TCP)
...
[snip]
20 208.201.239.37 True
21 208.201.239.37 True
22 208.201.239.37 True
23 208.201.239.37 True
24 208.201.239.37 True
25 208.201.239.37 True
---

* the first line has been cut in 2 and ">>>" has been wrongly added
* showing some lines before hop 20 could be more didactic
* flags="S" is also possible and more human readable than 0x2

Philippe Biondi
O'Reilly Author 
Safari Books Online Sec 3.3
second capture, between Exemple 3-27 and 3-28

It seems like the capture has been truncated and is missing a <array> opening tag at the begining and </dict></array> tags at the end.

Philippe Biondi
O'Reilly Author 
Safari Books Online sec. 5.5
Before but-last capture

imagemagick is misspelled as imagemagic

Philippe Biondi
O'Reilly Author 
Safari Books Online 5.15
Chapter 5, Section 5.1.5

"Another high level library is urllib2. Urllib2 contains pretty... "

should be:

"Another high level library is urllib2. urllib2 contains pretty... "

These capitalization errors apparently occur in other areas of the book as well.

Thanks to nsheridan for pointing this out in our book forum.

Anonymous 
Printed Page 63
5th line from top (including empty line)

The "demonstrations/examples" don't work.

------My Result 1 -------
In [1]: !!ls apa*py
ls: cannot access apa*py: No such file or directory
Out[1]: SList (.p, .n, .l, .s, .grep(), .fields() available). Value:
0:

In [2]:
------- End My Result 1 ----------

The second example doesn't work either
------My Result 2 -------
In [2]: !!ls e*py
ls: cannot access e*py: No such file or directory
Out[2]: SList (.p, .n, .l, .s, .grep(), .fields() available). Value:
0:
------- End My Result 2 --------

The third example doesn't work either
-------- My Result 3 --------
In [3]: !!ls t*py
ls: cannot access t*py: No such file or directory
Out[3]: SList (.p, .n, .l, .s, .grep(), .fields() available). Value:
0:

---------
---------
Python 2.5.2 (r252:60911, Sep 30 2008, 15:42:03)
IPython 0.8.4

Anonymous 
Printed Page 141
pp 141-142, examples 4-5 and 4-6

The examples of how to set up the to, from, and subject headers for sending an email message via smtp are both (a) clumsy and hard to make sense of, and (b) incorrect.

Something like this solves both of those problems:
<pre>

email_message = "".join(
[ "From: " , from_address , "\r\n"
, "To: " , to_address , "\r\n"
, "Subject: ", subject , "\r\n"
, "\r\n" # an extra newline between the headers and message body
, message
])

</pre>

Anonymous 
Printed Page 158
4th paragraph

The text says "Another high level library is urllib2. Urllib2 contains ..."

In python the case of words matters so urllib2 and Urllib2 are two different things. It may look weird but using the proper case for Python libraries even when they start a sentence would be more technically correct. For someone new to Python this could be confusing.

This is actually just one example of this happening in the book.

Eric Lake 
PDF Page 193
Example 6-11

from diskwalk_api import diskwalk
In [2]: files = diskwalk("/tmp")
In [3]: from fnmatch import fnmatch
In [4]: for file in files:
...: if fnmatch(file,"*.txt"):
...: print file


should be files = diskwalk("/tmp").enumeratePaths(), diskwalk is not an iterable object

On page 189, Example 6-8

missing from os.path import getsize
in ipython session before invoking getsize



Anonymous 
PDF Page 295
Code Snippet

Indentation is incorrect for module subtube. However, it is correct in the python code files provided with the book. Correct indentation is as follows. In the PDF version both def run (self): methods and class Runner(BaseArgs): are incorrectly indented.

#!/usr/bin/env python
from subprocess import call
import time
import sys

"""Subtube is module that simplifies and automates some aspects of subprocess"""

class BaseArgs(object):
"""Base Argument Class that handles keyword argument parsing"""

def __init__(self, *args, **kwargs):
self.args = args
self.kwargs = kwargs
if self.kwargs.has_key("delay"):
self.delay = self.kwargs["delay"]
else:
self.delay = 0
if self.kwargs.has_key("verbose"):
self.verbose = self.kwargs["verbose"]
else:
self.verbose = False

def run (self):
"""You must implement a run method"""
raise NotImplementedError

class Runner(BaseArgs):
"""Simplifies subprocess call and runs call over a sequence of commands

Runner takes N positional arguments, and optionally:

[optional keyword parameters]
delay=1, for time delay in seconds
verbose=True for verbose output

Usage:

cmd = Runner("ls -l", "df -h", verbose=True, delay=3)
cmd.run()

"""
def run(self):
for cmd in self.args:
if self.verbose:
print "Running %s with delay=%s" % (cmd, self.delay)
time.sleep(self.delay)
call(cmd, shell=True)

Gourav Shah 
Printed Page 331
example 11-3

The example code contains an incorrect sequence of calls.
The curses.wrapper call instantiates a screen, thus the curses.initscr call in __init__ is unnecessary. Due to these problems the screen is not reset on exiting the application.

A way the problem gets solved is as follows: (note this is a file_viewer instead of a log_viewer)


#!/usr/local/bin/python3.0
'file_viewer.py - uses curses to scroll thru a file'

import curses
import sys

class Viewer(object):

def page_up(self):
self.curr_topline = self.curr_topline - (2 * curses.LINES)
if self.curr_topline < 0:
self.curr_topline = 0
self.draw_lines()

def page_down(self):
self.draw_lines()

def load_lines(self):
fd = open(self.file, 'rb')
for line_no, line in enumerate(fd):
self.lines.append(str(line_no) + str(line))
fd.close()
self.draw_lines()

def draw_lines(self):
self.screen.clear()
for y in range(curses.LINES):
try:
line = self.lines[self.curr_topline]
except IndexError:
break
self.screen.addstr(y, 0, str(line) )
self.curr_topline += 1
self.screen.refresh()

def main_loop(self, stdscr, file=None):
self.screen = stdscr # as initialised by curses.wrapper
self.curr_topline = 0
self.file = file
self.lines = []
self.load_lines()
while True:
c = self.screen.getch()
try:
c = chr(c)
except ValeError:
continue
if c == 'd':
self.page_down()
elif c == 'u':
self.page_up()
elif c == 'q':
break

if __name__ == "__main__":
file = sys.argv[1]
curses.wrapper(Viewer().main_loop, file)

The sample code also contains:
- redundant screen.clear calls
- redundant initialisation of self.loglines

Nick de Bray 
Printed Page 368
First paragraph

It looks like the author meant for part of the first sentence be shown as code output but is not formatted that way in the book as it is for content much like it on the previous page.

The part that should be formatted as code output is:


jmjones@kinkgutsy:~/code$ cat nonblock.yaml
bam:[1,2,3]
bar:b
foo:a

etank 
Printed Page 388
4th example output arrow

./sysargv.py foo

should return

['./sysargv.py', 'foo']

and not

['./sysargv.py', 'test'] as printed.

Karl J. Smith 
Printed Page 390
1st paragraph under example output

The example uses the option '--infinity'.

The paragraph's last sentence says "......entered an option, readability, that did not exist for Perl."

Two problems:

1) the option is 'infinity', not 'readability'
2) This is a book on Python, not Perl.

Karl J. Smith