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

ArgumentError: int too long to convert #7

Closed
jaraco opened this issue Jul 21, 2016 · 2 comments
Closed

ArgumentError: int too long to convert #7

jaraco opened this issue Jul 21, 2016 · 2 comments

Comments

@jaraco
Copy link
Owner

@jaraco jaraco commented Jul 21, 2016

As reported in paramiko/paramiko#758, it appears as if the call to SetSecurityDescriptorOwner is failing on 64-bit Windows. Indeed, the unit tests are failing for me on my Windows 10 machine:

============================= test session starts =============================
platform win32 -- Python 3.5.0, pytest-2.9.2, py-1.4.31, pluggy-0.3.1
rootdir: C:\Users\jaraco\m\jaraco.windows, inifile: pytest.ini
collected 16 items / 2 errors

jaraco\windows\dpapi.py F.
jaraco\windows\lib.py .
jaraco\windows\timezone.py ..
jaraco\windows\filesystem\__init__.py F..
jaraco\windows\filesystem\change.py .s
tests\test_clipboard.py .
tests\test_filesystem.py ..
tests\test_mmap.py FF
tests\test_security.py F

=================================== ERRORS ====================================
_________________ ERROR collecting jaraco/windows/eventlog.py _________________
jaraco\windows\eventlog.py:5: in <module>
    import win32api
E   ImportError: No module named 'win32api'
_________________ ERROR collecting jaraco/windows/services.py _________________
jaraco\windows\services.py:12: in <module>
    import win32api
E   ImportError: No module named 'win32api'
================================== FAILURES ===================================
_______________________ [doctest] jaraco.windows.dpapi ________________________
007 >>> ciphertext = CryptProtectData(orig_data)
UNEXPECTED EXCEPTION: ArgumentError("argument 1: <class 'OverflowError'>: int too long to convert",)
Traceback (most recent call last):

  File "c:\python\lib\doctest.py", line 1320, in __run
    compileflags, 1), test.globs)

  File "<doctest jaraco.windows.dpapi[1]>", line 1, in <module>

  File "c:\users\jaraco\m\jaraco.windows\jaraco\windows\dpapi.py", line 118, in CryptProtectData
    data_out.free()

  File "c:\users\jaraco\m\jaraco.windows\jaraco\windows\dpapi.py", line 66, in free
    ctypes.windll.kernel32.LocalFree(self.data)

ctypes.ArgumentError: argument 1: <class 'OverflowError'>: int too long to convert

c:\users\jaraco\m\jaraco.windows\jaraco\windows\dpapi.py:7: UnexpectedException
_______________ [doctest] jaraco.windows.filesystem.find_files ________________
UNEXPECTED EXCEPTION: ArgumentError("argument 1: <class 'OverflowError'>: int too long to convert",)
Traceback (most recent call last):

  File "c:\python\lib\doctest.py", line 1320, in __run
    compileflags, 1), test.globs)

  File "<doctest jaraco.windows.filesystem.find_files[0]>", line 1, in <module>

  File "c:\users\jaraco\m\jaraco.windows\jaraco\windows\filesystem\__init__.py", line 139, in find_files
    windll.kernel32.FindClose(handle)

ctypes.ArgumentError: argument 1: <class 'OverflowError'>: int too long to convert

c:\users\jaraco\m\jaraco.windows\jaraco\windows\filesystem\__init__.py:114: UnexpectedException
______________________________ test_mmap_simple _______________________________

    def test_mmap_simple():
        map = mmap.MemoryMap('foo', 50)
        with map:
                map.write(b'abc')
                map.write(b'def')
                map.seek(0)
                assert map.read(4) == b'abcd'
>               assert map.read(2) == b'ef'

C:\Users\jaraco\m\jaraco.windows\tests\test_mmap.py:10:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <jaraco.windows.mmap.MemoryMap object at 0x0000024442D16320>
exc_type = <class 'ctypes.ArgumentError'>
exc_val = ArgumentError("argument 1: <class 'OverflowError'>: int too long to convert",)
tb = <traceback object at 0x0000024442F9C5C8>

    def __exit__(self, exc_type, exc_val, tb):
>           ctypes.windll.kernel32.UnmapViewOfFile(self.view)
E           ctypes.ArgumentError: argument 1: <class 'OverflowError'>: int too long to convert

c:\users\jaraco\m\jaraco.windows\jaraco\windows\mmap.py:61: ArgumentError
____________________________ test_mmap_null_bytes _____________________________

    def test_mmap_null_bytes():
        map = mmap.MemoryMap('foo', 50)
        with map:
                map.write(b'abcdef')
                map.seek(0)
>               assert map.read(10) == b'abcdef\x00\x00\x00\x00'

C:\Users\jaraco\m\jaraco.windows\tests\test_mmap.py:17:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <jaraco.windows.mmap.MemoryMap object at 0x0000024442D16EB8>
exc_type = <class 'ctypes.ArgumentError'>
exc_val = ArgumentError("argument 1: <class 'OverflowError'>: int too long to convert",)
tb = <traceback object at 0x0000024441F51DC8>

    def __exit__(self, exc_type, exc_val, tb):
>           ctypes.windll.kernel32.UnmapViewOfFile(self.view)
E           ctypes.ArgumentError: argument 1: <class 'OverflowError'>: int too long to convert

c:\users\jaraco\m\jaraco.windows\jaraco\windows\mmap.py:61: ArgumentError
____________________ test_get_security_attributes_for_user ____________________

    def test_get_security_attributes_for_user():
>       security.get_security_attributes_for_user()

C:\Users\jaraco\m\jaraco.windows\tests\test_security.py:4:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

user = <jaraco.windows.api.security.TOKEN_USER object at 0x0000024442CC2548>

    def get_security_attributes_for_user(user=None):
        """
        Return a SECURITY_ATTRIBUTES structure with the SID set to the
        specified user (uses current user if none is specified).
        """
        if user is None:
                user = get_current_user()

        assert isinstance(user, security.TOKEN_USER), "user must be TOKEN_USER instance"

        SD = security.SECURITY_DESCRIPTOR()
        SA = security.SECURITY_ATTRIBUTES()
        # by attaching the actual security descriptor, it will be garbage-
        # collected with the security attributes
        SA.descriptor = SD
        SA.bInheritHandle = 1

        ctypes.windll.advapi32.InitializeSecurityDescriptor(ctypes.byref(SD),
                security.SECURITY_DESCRIPTOR.REVISION)
        ctypes.windll.advapi32.SetSecurityDescriptorOwner(ctypes.byref(SD),
>               user.SID, 0)
E    ctypes.ArgumentError: argument 2: <class 'OverflowError'>: int too long to convert

c:\users\jaraco\m\jaraco.windows\jaraco\windows\security.py:57: ArgumentError
=========== 5 failed, 10 passed, 1 skipped, 2 error in 1.82 seconds ===========
@jaraco

This comment has been minimized.

Copy link
Owner Author

@jaraco jaraco commented Jul 21, 2016

I believe Python 24747 is relevant.

@jaraco

This comment has been minimized.

Copy link
Owner Author

@jaraco jaraco commented Jul 21, 2016

Fixes released in 3.6.1.

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

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.