Skip to content

Instantly share code, notes, and snippets.

Python 3.8.3 (default, May 14 2020, 11:03:12)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> class A:
... def __init__(self):
... print("A.__init__")
... raise Exception()
... def __del__(self):
... print("A.__del__")
...
$ gcc capi.h
capi.h:6:4: warning: '/*' within block comment [-Wcomment]
* /**
^
capi.h:9:3: error: expected identifier or '('
*/
^
capi.h:12:19: error: unknown type name 'Foo'
void a_func(const Foo *foo);
^
#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>
/*
* /**
This is a doc
*/
*/
typedef struct Foo Foo;
/**
This is a doc
*/
pub enum Foo {
Bar,
}
#[no_mangle]
pub unsafe extern "C" fn a_func(foo: *const Foo) {}
diff --git a/magic.py b/magic.py
index cd5ff24..10685ac 100644
--- a/magic.py
+++ b/magic.py
@@ -193,14 +193,15 @@ def coerce_filename(filename):
return None
# ctypes will implicitly convert unicode strings to bytes with
- # .encode('ascii'). A more useful default here is
- # getfilesystemencoding(). We need to leave byte-str unchanged.