Fixed #9433 - File locking broken on AFP mounts.

Updated version of the original patch using Python 3 wrapper for StringIO import.

Original patch:
https://code.djangoproject.com/attachment/ticket/9433/inject_locks_Django-1.5a1.2.patch