PyGObject GTK+ GLib.Date strftime()
PyGObject GTK+ GLib.Date strftime()
Poppler 中的一个方法调用 returns 我的 Python 代码中的一个 GDate
对象。我找不到如何很好地打印此对象的方法。
继 Python GI API Reference 之后,我得出以下结论:
gdate_object = annot_mapping.annot.get_date()
destination_buffer = '.' * 50
print('Output:', GLib.Date.strftime(destination_buffer, 50, '%c', gdate_object))
print('Buffer:', annot_time)
但是,这不会在缓冲区中放置任何内容,而它会输出写入的缓冲区大小。
如何访问目标缓冲区?
看起来没有人记录 API 所以它会因为内省绑定而被破坏。
我做了一个简单的补丁,但 pygobject 似乎不喜欢分配字符串缓冲区,我会与上游讨论它。
diff --git a/glib/gdate.c b/glib/gdate.c
index bea2448..bacdb93 100644
--- a/glib/gdate.c
+++ b/glib/gdate.c
@@ -2418,8 +2418,8 @@ win32_strftime_helper (const GDate *d,
/**
* g_date_strftime:
- * @s: destination buffer
- * @slen: buffer size
+ * @s: (out caller-allocates) (array length=slen): destination buffer
+ * @slen: (in): buffer size
* @format: format string
* @date: valid #GDate
*
Poppler 中的一个方法调用 returns 我的 Python 代码中的一个 GDate
对象。我找不到如何很好地打印此对象的方法。
继 Python GI API Reference 之后,我得出以下结论:
gdate_object = annot_mapping.annot.get_date()
destination_buffer = '.' * 50
print('Output:', GLib.Date.strftime(destination_buffer, 50, '%c', gdate_object))
print('Buffer:', annot_time)
但是,这不会在缓冲区中放置任何内容,而它会输出写入的缓冲区大小。
如何访问目标缓冲区?
看起来没有人记录 API 所以它会因为内省绑定而被破坏。
我做了一个简单的补丁,但 pygobject 似乎不喜欢分配字符串缓冲区,我会与上游讨论它。
diff --git a/glib/gdate.c b/glib/gdate.c
index bea2448..bacdb93 100644
--- a/glib/gdate.c
+++ b/glib/gdate.c
@@ -2418,8 +2418,8 @@ win32_strftime_helper (const GDate *d,
/**
* g_date_strftime:
- * @s: destination buffer
- * @slen: buffer size
+ * @s: (out caller-allocates) (array length=slen): destination buffer
+ * @slen: (in): buffer size
* @format: format string
* @date: valid #GDate
*