# Buggy code
def screenID(self):
    """Returns the screen ID or device context (depending on the platform)
    for the current Window
    """
    if sys.platform == "win32":
        scrBytes = self.winHandle._dc
        if constants.PY3:
            _screenID = 0xFFFFFFFF & int.from_bytes(scrBytes, byteorder="little")
        else:
            _screenID = 0xFFFFFFFF & scrBytes
    elif sys.platform == "darwin":
        try:
            _screenID = self.winHandle._screen.id  # pyglet1.2alpha1
        except AttributeError:
            _screenID = self.winHandle._screen._cg_display_id  # pyglet1.2
    elif sys.platform.startswith("linux"):
        _screenID = self.winHandle._x_screen_id
    return _screenID


# Traceback (TypeError)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
C:\Users\analuisa\gitrepos\cognitive_protocols\visual_protocols\retinotopy\retinoto.py in <module>()
275         fixation_callback, pref_color = get_retino_fixation(number)
276
--> 277         window = visual.Window(fullscr=False)
278         show_init_screen(
279             window, u"Chargement... \n", wait_key=None, with_fixation=False)

C:\Users\analuisa\Anaconda2\lib\site-packages\psychopy\visual\window.pyc in __init__(self, size, pos, color, colorSpace, rgb, dkl, lms, fullscr, allowGUI, monitor, bitsMode, winType, units, gamma, blendMode, screen, viewScale, viewPos, viewOri, waitBlanking, allowStencil, multiSample, numSamples, stereo, name, checkTiming, useFBO, useRetina, autoLog, *args, **kwargs)
373
374         # setup the context
--> 375         self.backend = backends.getBackend(win=self, *args, **kwargs)
376         self.winHandle = self.backend.winHandle
377         global GL

C:\Users\analuisa\Anaconda2\lib\site-packages\psychopy\visual\backends\__init__.pyc in getBackend(win, *args, **kwargs)
30                              "there is no backend definition to match that "
31                              "winType.".format(win.winType))
---> 32     return Backend(win, *args, **kwargs)
33

C:\Users\analuisa\Anaconda2\lib\site-packages\psychopy\visual\backends\pygletbackend.pyc in __init__(self, win, *args, **kwargs)
221         # store properties of the system
222         self._driver = pyglet.gl.gl_info.get_renderer()
--> 223         self._origGammaRamp = self.getGammaRamp()
224         self._rampSize = getGammaRampSize(self.screenID, self.xDisplay)
225         self._TravisTesting = (os.environ.get('TRAVIS') == 'true')

C:\Users\analuisa\Anaconda2\lib\site-packages\psychopy\visual\backends\pygletbackend.pyc in getGammaRamp(self)
320
321     def getGammaRamp(self):
--> 322         return getGammaRamp(self.screenID, self.xDisplay)
323
324     @property

C:\Users\analuisa\Anaconda2\lib\site-packages\psychopy\visual\backends\pygletbackend.pyc in screenID(self)
332                 _screenID = 0xFFFFFFFF &amp; int.from_bytes(scrBytes, byteorder='little')
333             else:
--> 334                 _screenID = 0xFFFFFFFF &amp; scrBytes
335         elif sys.platform == 'darwin':
336             try:

TypeError: unsupported operand type(s) for &amp;: 'long' and 'LP_c_void'

# Fixed code
def screenID(self):
    """Returns the screen ID or device context (depending on the platform)
    for the current Window
    """
    if sys.platform == "win32":
        scrBytes = self.winHandle._dc
        if constants.PY3:
            _screenID = 0xFFFFFFFF & int.from_bytes(scrBytes, byteorder="little")
        else:
            try:
                _screenID = 0xFFFFFFFF & scrBytes
            except TypeError:
                _screenID = scrBytes

    elif sys.platform == "darwin":
        try:
            _screenID = self.winHandle._screen.id  # pyglet1.2alpha1
        except AttributeError:
            _screenID = self.winHandle._screen._cg_display_id  # pyglet1.2
    elif sys.platform.startswith("linux"):
        _screenID = self.winHandle._x_screen_id
    return _screenID