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

ValueError in mmap on 32-bit Python #5

Closed
jaraco opened this issue Nov 10, 2015 · 1 comment
Closed

ValueError in mmap on 32-bit Python #5

jaraco opened this issue Nov 10, 2015 · 1 comment
Labels

Comments

@jaraco
Copy link
Owner

@jaraco jaraco commented Nov 10, 2015

Originally reported by: Jason R. Coombs (Bitbucket: jaraco, GitHub: jaraco)


Using 32-bit Python causes a ValueError in the tests, implicated in paramiko 613.

C:\Users\jaraco\m\jaraco.windows [default ?1 tip]> py -2.7-32 setup.py test --addopts='-k mmap'
running pytest
Searching for path.py
Best match: path.py 8.1.2
Processing path.py-8.1.2-py2.7.egg

Using c:\users\jaraco\m\jaraco.windows\.eggs\path.py-8.1.2-py2.7.egg
Searching for jaraco.structures
Best match: jaraco.structures 1.0
Processing jaraco.structures-1.0-py2.7.egg

Using c:\users\jaraco\m\jaraco.windows\.eggs\jaraco.structures-1.0-py2.7.egg
Searching for jaraco.text
Best match: jaraco.text 1.3
Processing jaraco.text-1.3-py2.7.egg

Using c:\users\jaraco\m\jaraco.windows\.eggs\jaraco.text-1.3-py2.7.egg
Searching for jaraco.collections
Best match: jaraco.collections 1.1
Processing jaraco.collections-1.1-py2.7.egg

Using c:\users\jaraco\m\jaraco.windows\.eggs\jaraco.collections-1.1-py2.7.egg
Searching for jaraco.ui
Best match: jaraco.ui 1.3.1
Processing jaraco.ui-1.3.1-py2.7.egg

Using c:\users\jaraco\m\jaraco.windows\.eggs\jaraco.ui-1.3.1-py2.7.egg
Searching for six
Best match: six 1.10.0
Processing six-1.10.0-py2.7.egg

Using c:\users\jaraco\m\jaraco.windows\.eggs\six-1.10.0-py2.7.egg
Searching for more-itertools
Best match: more-itertools 2.2
Processing more_itertools-2.2-py2.7.egg

Using c:\users\jaraco\m\jaraco.windows\.eggs\more_itertools-2.2-py2.7.egg
Searching for jaraco.context>=1.3
Best match: jaraco.context 1.3
Processing jaraco.context-1.3-py2.7.egg

Using c:\users\jaraco\m\jaraco.windows\.eggs\jaraco.context-1.3-py2.7.egg
Searching for jaraco.functools
Best match: jaraco.functools 1.3
Processing jaraco.functools-1.3-py2.7.egg

Using c:\users\jaraco\m\jaraco.windows\.eggs\jaraco.functools-1.3-py2.7.egg
Searching for jaraco.classes
Best match: jaraco.classes 1.2
Processing jaraco.classes-1.2-py2.7.egg

Using c:\users\jaraco\m\jaraco.windows\.eggs\jaraco.classes-1.2-py2.7.egg
Searching for yg.lockfile
Best match: yg.lockfile 2.0
Processing yg.lockfile-2.0-py2.7.egg

Using c:\users\jaraco\m\jaraco.windows\.eggs\yg.lockfile-2.0-py2.7.egg
Searching for jaraco.apt
Best match: jaraco.apt 1.0
Processing jaraco.apt-1.0-py2.7.egg

Using c:\users\jaraco\m\jaraco.windows\.eggs\jaraco.apt-1.0-py2.7.egg
Searching for zc.lockfile
Best match: zc.lockfile 1.1.0
Processing zc.lockfile-1.1.0-py2.7.egg

Using c:\users\jaraco\m\jaraco.windows\.eggs\zc.lockfile-1.1.0-py2.7.egg
Searching for pytest
Best match: pytest 2.8.2
Processing pytest-2.8.2-py2.7.egg

Using c:\users\jaraco\m\jaraco.windows\.eggs\pytest-2.8.2-py2.7.egg
Searching for colorama
Best match: colorama 0.3.3
Processing colorama-0.3.3-py2.7.egg

Using c:\users\jaraco\m\jaraco.windows\.eggs\colorama-0.3.3-py2.7.egg
Searching for py>=1.4.29
Best match: py 1.4.30
Processing py-1.4.30-py2.7.egg

Using c:\users\jaraco\m\jaraco.windows\.eggs\py-1.4.30-py2.7.egg
running egg_info
writing requirements to jaraco.windows.egg-info\requires.txt
writing jaraco.windows.egg-info\PKG-INFO
writing namespace_packages to jaraco.windows.egg-info\namespace_packages.txt
writing top-level names to jaraco.windows.egg-info\top_level.txt
writing dependency_links to jaraco.windows.egg-info\dependency_links.txt
writing entry points to jaraco.windows.egg-info\entry_points.txt
writing manifest file 'jaraco.windows.egg-info\SOURCES.txt'
running build_ext
============================= test session starts =============================
���platform win32 -- Python 2.7.10, pytest-2.8.2, py-1.4.30, pluggy-0.3.1
���rootdir: C:\Users\jaraco\m\jaraco.windows, inifile: pytest.ini
collected 16 items / 2 errors

tests\test_mmap.py FF

=================================== 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 ===================================
______________________________ test_mmap_simple _______________________________

    def test_mmap_simple():
        map = mmap.MemoryMap('foo', 50)
        with map:
>               map.write(b'abc')

tests\test_mmap.py:6:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <jaraco.windows.mmap.MemoryMap object at 0x0341A810>, msg = 'abc'

    def write(self, msg):
            assert isinstance(msg, bytes)
            n = len(msg)
            if self.pos + n >= self.length:  # A little safety.
                    raise ValueError("Refusing to write %d bytes" % n)
            dest = self.view + self.pos
            length = ctypes.wintypes.SIZE(n)
>           ctypes.windll.kernel32.RtlMoveMemory(dest, msg, length)
���E           ValueError: Procedure probably called with too many arguments (4 bytes in excess)

jaraco\windows\mmap.py:46: ValueError
____________________________ test_mmap_null_bytes _____________________________

    def test_mmap_null_bytes():
        map = mmap.MemoryMap('foo', 50)
        with map:
>               map.write(b'abcdef')

tests\test_mmap.py:15:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <jaraco.windows.mmap.MemoryMap object at 0x0341AB30>, msg = 'abcdef'

    def write(self, msg):
            assert isinstance(msg, bytes)
            n = len(msg)
            if self.pos + n >= self.length:  # A little safety.
                    raise ValueError("Refusing to write %d bytes" % n)
            dest = self.view + self.pos
            length = ctypes.wintypes.SIZE(n)
>           ctypes.windll.kernel32.RtlMoveMemory(dest, msg, length)
���E           ValueError: Procedure probably called with too many arguments (4 bytes in excess)

jaraco\windows\mmap.py:46: ValueError
======================= 14 tests deselected by '-kmmap' =======================
============== 2 failed, 14 deselected, 2 error in 3.59 seconds ===============

@jaraco

This comment has been minimized.

Copy link
Owner Author

@jaraco jaraco commented Nov 10, 2015

Original comment by Jason R. Coombs (Bitbucket: jaraco, GitHub: jaraco):


Use ctypes.c_size_t. wintypes.SIZE is a structure with x and y attributes. Fixes #5.

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.