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

'Unsupported operand' when giving modes in 'put()' #871

bitprophet opened this issue Mar 21, 2013 · 1 comment

'Unsupported operand' when giving modes in 'put()' #871

bitprophet opened this issue Mar 21, 2013 · 1 comment


Copy link

E.g.: in a call like put(StringIO(xxx), yyy, mode="0755") (emphasis is on mode string, not the StringIO, which is incidental):

Fatal error: put() encountered an exception while uploading '<StringIO.StringIO instance at 0x9ddfa8>'

Underlying exception:                                                                                 
    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.

bitprophet added a commit that referenced this issue Mar 22, 2013
Copy link

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
+            else:
+                lmode = lmode & 07777

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

No branches or pull requests

2 participants