AttributeError: module 'ctypes.wintypes' has no attribute 'create_unicode_buffer'

compiler-errors, ctypes, python, python-3.5

Solution

Use ctypes.create_unicode_buffer, which works in both PY2 and PY3. It was only accidentally in wintypes in PY2 due to its use of `from ctypes import *`. :D

Problem

This is a part of my code: ``` import os def _get_appdata_path(): import ctypes from ctypes import wintypes, windll CSIDL_APPDATA = 26 _SHGetFolderPath = windll.shell32.SHGetFolderPathW _SHGetFolderPath.argtypes = [wintypes.HWND, ctypes.c_int, wintypes.HANDLE, wintypes.DWORD, wintypes.LPCWSTR] path_buf = wintypes.create_unicode_buffer(wintypes.MAX_PATH) result = _SHGetFolderPath(0, CSIDL_APPDATA, 0, 0, path_buf) return path_buf.value ``` But when I call `wintypes.create_unicode_buffer()` I get the error: ``` AttributeError: module 'ctypes.wintypes' has no attribute 'create_unicode_buffer' ``` I am using Python 3.5.1. What could I do?

Original source

Related problems