Are you sure you are running the *exact same python interpreter*? Are you
using virtual environments?
On Friday, September 6, 2013 3:39:11 PM UTC-5, Edmond Murphy wrote:
>
> 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 "<console>", line 1, in <module>
> File "/usr/lib/python2.7/dist-packages/magic.py", line 170, in load
> return _load(self._magic_t, filename)
> ArgumentError: argument 2: <type 'exceptions.TypeError'>: 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 "<console>", line 1, in <module>
> File "/usr/lib/python2.7/dist-packages/magic.py", line 170, in load
> return _load(self._magic_t, filename)
> ArgumentError: argument 2: <type 'exceptions.TypeError'>: 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
>
> I am at a loss so I turn to you "django-users" for help
>
> Thanks in advance
>
>
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.