Make doctest examples compatible with Python 2 and Python 3.

Existing doctests were written only for Python 2 and have not yet
been updated upstream to work with Python 3.
Last-Update: 2015-05-16

Gbp-Pq: Name 001.doctests-compatible-py2and3.patch
This commit is contained in:
Ben Finney 2022-05-14 02:47:49 +08:00 committed by openKylinBot
parent 3909b840d0
commit 49b8fc1ef3
2 changed files with 11 additions and 11 deletions

View File

@ -231,14 +231,14 @@ This example is the "hello world" for the :mod:`lockfile` package::
from lockfile import LockFile
lock = LockFile("/some/file/or/other")
with lock:
print lock.path, 'is locked.'
print(lock.path, "is locked.")
To use this with Python 2.4, you can execute::
from lockfile import LockFile
lock = LockFile("/some/file/or/other")
lock.acquire()
print lock.path, 'is locked.'
print(lock.path, "is locked.")
lock.release()
If you don't want to wait forever, you might try::
@ -251,7 +251,7 @@ If you don't want to wait forever, you might try::
except LockTimeout:
lock.break_lock()
lock.acquire()
print "I locked", lock.path
print("I locked", lock.path)
lock.release()
You can also insure that a lock is always held when appropriately decorated

View File

@ -12,23 +12,23 @@ Usage:
>>> try:
... lock.acquire()
... except AlreadyLocked:
... print 'somefile', 'is locked already.'
... print('somefile', "is locked already.")
... except LockFailed:
... print 'somefile', 'can\\'t be locked.'
... print('somefile', "can't be locked.")
... else:
... print 'got lock'
... print("got lock")
got lock
>>> print lock.is_locked()
>>> lock.is_locked()
True
>>> lock.release()
>>> lock = LockFile('somefile')
>>> print lock.is_locked()
>>> lock.is_locked()
False
>>> with lock:
... print lock.is_locked()
... lock.is_locked()
True
>>> print lock.is_locked()
>>> lock.is_locked()
False
>>> lock = LockFile('somefile')
@ -37,7 +37,7 @@ False
... lock.acquire()
...
>>> # Though no counter is kept, so you can't unlock multiple times...
>>> print lock.is_locked()
>>> lock.is_locked()
False
Exceptions: