Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix type errors in locks.py #27

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix type errors in locks.py
The code in locks.py called WebDAWServer.send_body(DATA, code) with strings
passed as "DATA" and "code" parameters while the underlying code expected "DATA"
to be a bytes and "code" to be an int.

See issue #26.
  • Loading branch information
ntherning committed Nov 6, 2022
commit a0545a109b29c6e5dce5d13c267535b58ffdec58
10 changes: 5 additions & 5 deletions pywebdav/lib/locks.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def do_UNLOCK(self):
if self._l_isLocked(uri):
self._l_delLock(token)

self.send_body(None, '204', 'Ok', 'Ok')
self.send_body(None, 204, 'Ok', 'Ok')
andrewleech marked this conversation as resolved.
Show resolved Hide resolved

def do_LOCK(self):
""" Locking is implemented via in-memory caches. No data is written to disk. """
Expand Down Expand Up @@ -130,12 +130,12 @@ def do_LOCK(self):
token, result = self._lock_unlock_create(uri, 'unknown', depth, data)

if result:
self.send_body(result, '207', 'Error', 'Error',
self.send_body(bytes(result, 'utf-8'), 207, 'Error', 'Error',
'text/xml; charset="utf-8"')

else:
lock = self._l_getLock(token)
self.send_body(lock.asXML(), '200', 'OK', 'OK',
self.send_body(bytes(lock.asXML(), 'utf-8'), 200, 'OK', 'OK',
'text/xml; charset="utf-8"',
{'Lock-Token' : '<opaquelocktoken:%s>' % token})

Expand All @@ -153,8 +153,8 @@ def do_LOCK(self):
lock.setTimeout(timeout) # automatically refreshes
found = 1

self.send_body(lock.asXML(),
'200', 'OK', 'OK', 'text/xml; encoding="utf-8"')
self.send_body(bytes(lock.asXML(), 'utf-8'),
200, 'OK', 'OK', 'text/xml; encoding="utf-8"')
break
if found:
break
Expand Down