public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* cygmagic-1.dll - access violation by accessing the lib via python
@ 2016-01-11 22:58 Holger Bast
  2016-01-12  9:55 ` Corinna Vinschen
  0 siblings, 1 reply; 4+ messages in thread
From: Holger Bast @ 2016-01-11 22:58 UTC (permalink / raw)
  To: cygwin

Hi there,
I'm using a python wrapper (python-magic, https://github.com/ahupp/python-magic) checking some filetypes in a small script. The wrapper works fine under Unix-like system, but I got an access violation error under cygwin. I already tried an older version of file including libmagic from the gnuwin32-project and this one works fine - aside it's completely outdated ;)
This issue was already identified on the issue tracker of the python-wrapper but I don't think that this error is a problem of the wrapper  (see https://github.com/ahupp/python-magic/issues/76). I found some python wrappers on the cygwin mirrors (python-magic-5.24-1.tar.xz) but these also produce the same error.

Ok, here the script I used:

requirements: python 2.7 and python-magic

import magic

mage = magic.Magic(mime=True)
filetype = mage.from_file("testfile.odt")
print filetype


Output:

Traceback (most recent call last):
  File "C:/Users/aronadaal/PycharmProjects/libmagic-test/magictest.py", line 3, in <module>
    mage = magic.Magic(mime=True)
  File "C:\Python27\lib\site-packages\magic.py", line 59, in __init__
    self.cookie = magic_open(self.flags)
WindowsError: exception: access violation writing 0x0000000000000000
Exception AttributeError: "Magic instance has no attribute 'cookie'" in <bound method Magic.__del__ of <magic.Magic instance at 0x00000000022CEA48>> ignored

Notice: You can ignore the last message regarding the "cookie"-variable. The filehhandler is stored inside it during the initialization. That's ok.

Bye, aronadaal

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: cygmagic-1.dll - access violation by accessing the lib via python
  2016-01-11 22:58 cygmagic-1.dll - access violation by accessing the lib via python Holger Bast
@ 2016-01-12  9:55 ` Corinna Vinschen
  2016-01-12 15:05   ` Holger Bast
  0 siblings, 1 reply; 4+ messages in thread
From: Corinna Vinschen @ 2016-01-12  9:55 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 2040 bytes --]

Hi Holger,

On Jan 11 22:31, Holger Bast wrote:
> Hi there,
> I'm using a python wrapper (python-magic,
> https://github.com/ahupp/python-magic) checking some filetypes in a
> small script. The wrapper works fine under Unix-like system, but I got
> an access violation error under cygwin. I already tried an older
> version of file including libmagic from the gnuwin32-project and this
> one works fine - aside it's completely outdated ;)
> This issue was already identified on the issue tracker of the
> python-wrapper but I don't think that this error is a problem of the
> wrapper  (see https://github.com/ahupp/python-magic/issues/76). I
> found some python wrappers on the cygwin mirrors
> (python-magic-5.24-1.tar.xz) but these also produce the same error.

This sounds weird.  Are you using Cygwin's python or some native Windows
python?  In the latter case, you can't use Cygwin DLLs from your
non-Cygwin python.  It won't work as desired and it's not supported.

As for your Cygwin installation, we need the output of `cygcheck -svr'
per http://cygwin.com/problems.html

> Ok, here the script I used:
> 
> requirements: python 2.7 and python-magic
> 
> import magic
> 
> mage = magic.Magic(mime=True)
> filetype = mage.from_file("testfile.odt")
> print filetype

I'm python illiterate but as Cygwin file maintainer I tried this myself.
The packages file-5.24-1, file-devel-5.24-1, python-magic-5.24-1, and
python-2.7.10-1 are installed.

> Output:

In my case:

  $ python2.7 magic.py
  Traceback (most recent call last):
    File "magic.py", line 1, in <module>
      import magic
    File "/home/corinna/magic.py", line 3, in <module>
      mage = magic.Magic(mime=True)
  AttributeError: 'module' object has no attribute 'Magic'

What am I doing wrong?

Anyway, I uploaded the latest file 5.25 a few minutes ago.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Re: cygmagic-1.dll - access violation by accessing the lib via python
  2016-01-12  9:55 ` Corinna Vinschen
@ 2016-01-12 15:05   ` Holger Bast
  2016-01-12 15:39     ` Corinna Vinschen
  0 siblings, 1 reply; 4+ messages in thread
From: Holger Bast @ 2016-01-12 15:05 UTC (permalink / raw)
  To: cygwin

Hey Corinna,
that are good news!

I used the official Windows-edition of python trying to access Cygwin's libmagic. So deinstalling the Windows-edition and installing Cygwin's python solved my problem!

To run my script you need the external python package, not the wrapper that is shipped with Cygwin.

1) Installing pip (The PyPA recommended tool for installing Python packages.)
see https://pip.pypa.io/en/stable/installing/
2) pip install pyhton-magic
3) run the script
 
But you don't have to do that... it works ;)

Also thanks for the new file version!
Bye, Holger
 

Gesendet: Dienstag, 12. Januar 2016 um 10:48 Uhr
Von: "Corinna Vinschen" <corinna-cygwin@cygwin.com>
An: cygwin@cygwin.com
Betreff: Re: cygmagic-1.dll - access violation by accessing the lib via python
Hi Holger,

On Jan 11 22:31, Holger Bast wrote:
> Hi there,
> I'm using a python wrapper (python-magic,
> https://github.com/ahupp/python-magic) checking some filetypes in a
> small script. The wrapper works fine under Unix-like system, but I got
> an access violation error under cygwin. I already tried an older
> version of file including libmagic from the gnuwin32-project and this
> one works fine - aside it's completely outdated ;)
> This issue was already identified on the issue tracker of the
> python-wrapper but I don't think that this error is a problem of the
> wrapper (see https://github.com/ahupp/python-magic/issues/76[https://github.com/ahupp/python-magic/issues/76]). I
> found some python wrappers on the cygwin mirrors
> (python-magic-5.24-1.tar.xz) but these also produce the same error.

This sounds weird. Are you using Cygwin's python or some native Windows
python? In the latter case, you can't use Cygwin DLLs from your
non-Cygwin python. It won't work as desired and it's not supported.

As for your Cygwin installation, we need the output of `cygcheck -svr'
per http://cygwin.com/problems.html[http://cygwin.com/problems.html]

> Ok, here the script I used:
>
> requirements: python 2.7 and python-magic
>
> import magic
>
> mage = magic.Magic(mime=True)
> filetype = mage.from_file("testfile.odt")
> print filetype

I'm python illiterate but as Cygwin file maintainer I tried this myself.
The packages file-5.24-1, file-devel-5.24-1, python-magic-5.24-1, and
python-2.7.10-1 are installed.

> Output:

In my case:

$ python2.7 magic.py
Traceback (most recent call last):
File "magic.py", line 1, in <module>
import magic
File "/home/corinna/magic.py", line 3, in <module>
mage = magic.Magic(mime=True)
AttributeError: 'module' object has no attribute 'Magic'

What am I doing wrong?

Anyway, I uploaded the latest file 5.25 a few minutes ago.


Corinna

--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Re: cygmagic-1.dll - access violation by accessing the lib via python
  2016-01-12 15:05   ` Holger Bast
@ 2016-01-12 15:39     ` Corinna Vinschen
  0 siblings, 0 replies; 4+ messages in thread
From: Corinna Vinschen @ 2016-01-12 15:39 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 898 bytes --]

Hi Holger,

On Jan 12 15:01, Holger Bast wrote:
> Hey Corinna,
> that are good news!
> 
> I used the official Windows-edition of python trying to access
> Cygwin's libmagic. So deinstalling the Windows-edition and installing
> Cygwin's python solved my problem!
> 
> To run my script you need the external python package, not the wrapper
> that is shipped with Cygwin.
> 
> 1) Installing pip (The PyPA recommended tool for installing Python packages.)
> see https://pip.pypa.io/en/stable/installing/
> 2) pip install pyhton-magic
> 3) run the script
>  
> But you don't have to do that... it works ;)

That's really good news.  Thanks for your feeedback.

> Also thanks for the new file version!

You're welcome,
Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-01-12 15:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-11 22:58 cygmagic-1.dll - access violation by accessing the lib via python Holger Bast
2016-01-12  9:55 ` Corinna Vinschen
2016-01-12 15:05   ` Holger Bast
2016-01-12 15:39     ` Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).