E.g.: in a call like put(StringIO(xxx), yyy, mode="0755") (emphasis is on mode string, not the StringIO, which is incidental):
put(StringIO(xxx), yyy, mode="0755")
Fatal error: put() encountered an exception while uploading '<StringIO.StringIO instance at 0x9ddfa8>'
unsupported operand type(s) for &: 'str' and 'int'
Problem is that whoever added the mode stuff is blindly doing lmode & 07777 which dies whenever lmode is a string. Casting to an int appears to work fine for me in the shell, regardless if one gives e.g. "755", "0755", "00755" etc.
lmode & 07777
New tests + fix to one of them, fixes #871
Changelogs re #870, #871
Many thanks for the fix but I think it needs to be extended to handle the case when mode is passed in as an int or a string. Sorry for posting a diff, I know bad form.
# Handle modes if necessary
if (local_is_path and mirror_local_mode) or (mode is not None):
lmode = os.stat(local_path).st_mode if mirror_local_mode else mode
- lmode = lmode & 07777
+ if type(lmode) is str:
+ lmode = int(lmode, 8) & 07777
+ lmode = lmode & 07777