Patch when full text search does not work in GAE / Python local environment

Such an error.

  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/search/search.py", line 1121, in _DecodeUTF8
    return pb_value.decode('utf-8')
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/encodings/utf_8.py", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode bytes in position 158-159: invalid continuation byte

It looks like a bug around unicode, but it works for some reason when deployed.

Refer to this https://code.google.com/p/googleappengine/issues/detail?id=9335 However, if you keep this link, it will not work and it will look like the following (note that you have touched the library directly).

/google_appengine/google/appengine/_internal/antlr3/streams.py


 335   >.# The data being scanned
 336         data = data.encode("utf-8") #Add this
 337         self.strdata = unicode(data, errors="replace")
 338         self.data = [ord(c) for c in self.strdata]

/usr/local/google_appengine/google/appengine/api/search/search.py


 1118   #def _DecodeUTF8(pb_value):
 1119   #  """Decodes a UTF-8 encoded string into unicode."""
 1120   #  if pb_value is not None:
 1121   #    return pb_value.decode('utf-8')
 1122   #  return None
 1123   
 1124   def _DecodeUTF8(pb_value): #Replace this
 1125     """Decodes a UTF-8 encoded string into unicode."""
 1126     if pb_value is not None:
 1127       return pb_value.decode('utf-8', errors='replace') if not isinstance(pb_value, unicode) else pb_value

For the time being.

Recommended Posts

Patch when full text search does not work in GAE / Python local environment
Command when ACPI shutdown does not work in VirtualBox
[Python] Precautions when it does not work even if TimedRotatingFileHandler is set in basicConfig in python2
Parallel processing of Python joblib does not work in uWSGI environment. How to process in parallel on uWSGI?
python> does not include the letters mm> if "mm" not in text: / print "not including mm"
An error that does not work as expected when calling the tkinter module in a text editor
[VScode] autopep8 format does not work [Python]
Check items when the imported python module does not work as expected
When wildcard specification does not work with pylint
Use Search Tweets: Full Archive / Sandbox in Python
What to do when Python starts up in Anaconda does not come out unexpectedly
When "Message: session not created" occurs in Python + Selenium
Key input that does not wait for key input in Python
The story of debugging in the local environment because the compilation did not work with Read the Docs
Clustering text in Python
Text processing in Python
python bit full search
virtual environment in python
Binary search in Python (binary search)
[Python] Reason why index error does not occur in slice
Application to display and search local memos (diary) in Python
The story that `while queue` did not work in python