Skip to content

Instantly share code, notes, and snippets.

View gist:7924bcebed149e176d4a0ed57afdce4b
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__")
...
View gist:ae0664b0a9ca3289b808f0620cde986c
$ 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);
^
View gist:1c9da9eb33e991f6e3c7ea8275a62318
#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>
/*
* /**
This is a doc
*/
*/
typedef struct Foo Foo;
View gist:a21fe39bfe586bfe56a112af9ad2fb50
/**
This is a doc
*/
pub enum Foo {
Bar,
}
#[no_mangle]
pub unsafe extern "C" fn a_func(foo: *const Foo) {}
View gist:daff4e7e2e4ebafbe14c
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.