diff --git a/about.html b/about.html index c5009c0..0a60fdc 100644 --- a/about.html +++ b/about.html @@ -11,7 +11,6 @@ h1:before{content:""} -

About the book

diff --git a/case-study-porting-chardet-to-python-3.html b/case-study-porting-chardet-to-python-3.html index a30e7a0..d1631e2 100644 --- a/case-study-porting-chardet-to-python-3.html +++ b/case-study-porting-chardet-to-python-3.html @@ -11,7 +11,6 @@ body{counter-reset:h1 20} -

skip to main content

  • Can’t convert 'bytes' object to str implicitly
  • Unsupported operand type(s) for +: 'int' and 'bytes'
  • ord() expected string of length 1, but int found -
  • Unorderable types: int() >= str() +
  • Unorderable types: int() >= str()
  • Global name 'reduce' is not defined
  • Summary @@ -873,7 +872,7 @@ TypeError: unsupported operand type(s) for +: 'int' and 'bytes' <class 'int'> >>> mLastChar + aBuf Traceback (most recent call last): - File "", line 1, in <module> + File "<stdin>", line 1, in <module> TypeError: unsupported operand type(s) for +: 'int' and 'bytes' >>> mLastChar = aBuf[-1:] >>> mLastChar @@ -961,14 +960,14 @@ def feed(self, aBuf):

    …and latin1prober.py… -

    skip over this code listing +

    skip over this code listing

    # latin1prober.py
     def feed(self, aBuf):
         aBuf = self.filter_with_english_letters(aBuf)
         for c in aBuf:
             charClass = Latin1_CharToClass[ord(c)]
    -

    c is iterating over aBuf, which means it is an integer, not a 1-character string. The solution is the same: change ord(c) to just plain c. +

    c is iterating over aBuf, which means it is an integer, not a 1-character string. The solution is the same: change ord(c) to just plain c.

    skip over this code listing

      # sbcharsetprober.py
    @@ -1010,7 +1009,7 @@ tests\Big5\0804.blogspot.com.xml
       File "C:\home\chardet\chardet\jpcntx.py", line 145, in feed
         order, charLen = self.get_order(aBuf[i:i+2])
       File "C:\home\chardet\chardet\jpcntx.py", line 176, in get_order
    -    if ((aStr[0] >= '\x81') and (aStr[0] <= '\x9F')) or \
    +    if ((aStr[0] >= '\x81') and (aStr[0] <= '\x9F')) or \
     TypeError: unorderable types: int() >= str()

    Did you notice? This time around, the code passed the first test case (tests\ascii\howto.diveintomark.org.xml). You're making real progress here. @@ -1036,7 +1035,7 @@ TypeError: unorderable types: int() >= str() . . i = self._mNeedToSkipCharNum - while i < aLen: + while i < aLen: order, charLen = self.get_order(aBuf[i:i+2])

    Oh look, it's our old friend, aBuf. As you might have guessed from every other issue we've encountered in this chapter, aBuf is a byte array. Here, the feed() method isn't just passing it on wholesale; it's slicing it. But as you saw earlier in this chapter, slicing a byte array returns a byte array, so the aStr parameter that gets passed to the get_order() method is still a byte array. diff --git a/index.html b/index.html index d3d678c..e3b3d78 100644 --- a/index.html +++ b/index.html @@ -14,7 +14,6 @@ li:last-child:before{content:"A. \00a0 \00a0"} li.todo{background:white;color:gainsboro} -

    Dive Into Python 3 will cover Python 3 and its differences from Python 2. Compared to the original Dive Into Python, it will be about 50% revised and 50% new material. I will publish drafts online as I go. The final version will be published on paper by Apress. The book will remain online under the CC-BY-SA-3.0 license.

    You can see the full table of contents (not finalized), or read what I’ve written so far:

    diff --git a/native-datatypes.html b/native-datatypes.html index a17fb85..7790453 100644 --- a/native-datatypes.html +++ b/native-datatypes.html @@ -11,7 +11,6 @@ body{counter-reset:h1 2} -

    skip to main content

    skip to main content

    skip to main content

    Table of contents

    diff --git a/unit-testing.html b/unit-testing.html index cfa7c0f..6a60dd0 100644 --- a/unit-testing.html +++ b/unit-testing.html @@ -11,7 +11,6 @@ body{counter-reset:h1 7} -

    skip to main content

    skip to main content