id,summary,reporter,owner,description,type,status,component,version,severity,resolution,keywords,cc,stage,has_patch,needs_docs,needs_tests,needs_better_patch,easy,ui_ux 21059,TypeError when trying to use python magic in Django shell,murphys.irish.stout@…,grue,"Running: Python version 2.7.3 Django version 1.5.2 I have a django view that indirectly makes use of python's magic library (basically a ctypes wrapper with access to libmagic) which results in the following error Traceback (most recent call last): File """", line 1, in File ""/usr/lib/python2.7/dist-packages/magic.py"", line 170, in load return _load(self._magic_t, filename) ArgumentError: argument 2: : expected CString instance instead of str In isolation the error is repeatable using the following steps: ./manage.py shell >>> import magic >>> m = magic.open(magic.MAGIC_NONE) >>> m.load(""/usr/share/file/magic.mgc"") Traceback (most recent call last): File """", line 1, in File ""/usr/lib/python2.7/dist-packages/magic.py"", line 170, in load return _load(self._magic_t, filename) ArgumentError: argument 2: : expected CString instance instead of str Issuing the same commands from a standard python shell does not result in the same error Python 2.7.3 (default, Jan 2 2013, 13:56:14) [GCC 4.7.2] on linux2 Type ""help"", ""copyright"", ""credits"" or ""license"" for more information. >>> import magic >>> m=magic.open(magic.MAGIC_NONE) >>> m.load(""/usr/share/file/magic.mgc"") 0 Google searches for the extact typeerror have proved useless, I even attempted to modify magic.py and cast the filename with a ctypes.create_string_buffer() call (AFAIK there is no ctypes.CString type) but that still failed. The same code works fine running Python v. 2.7.3 Django v. 1.4.3 Thanks in advance",Bug,closed,Uncategorized,1.5,Normal,invalid,magic django,murphys.irish.stout@…,Unreviewed,0,0,0,0,0,0