8000 Check attrs in m_copy. · python/cpython@e832631 · GitHub
[go: up one dir, main page]

Skip to content

Commit e832631

Browse files
Check attrs in m_copy.
1 parent c5aced3 commit e832631

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

Lib/test/test_imp.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,12 @@ def clean_up():
294294
if lookedup is not _testsinglephase:
295295
raise Exception((_testsinglephase, lookedup))
296296
297+
# Attrs set in the module init func are in m_copy.
298+
_initialized = _testsinglephase._initialized
299+
initialized = _testsinglephase.initialized()
300+
if _initialized != initialized:
301+
raise Exception((_initialized, initialized))
302+
297303
# Attrs set after loading are not in m_copy.
298304
if hasattr(_testsinglephase, 'spam'):
299305
raise Exception(_testsinglephase.spam)

Modules/_testsinglephase.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,16 @@ init_module(PyObject *module, module_state *state)
134134
if (PyModule_AddObjectRef(module, "str_const", state->str_const) != 0) {
135135
return -1;
136136
}
137+
138+
double d = _PyTime_AsSecondsDouble(state->initialized);
139+
PyObject *initialized = PyFloat_FromDouble(d);
140+
if (initialized == NULL) {
141+
return -1;
142+
}
143+
if (PyModule_AddObjectRef(module, "_initialized", initialized) != 0) {
144+
return -1;
145+
}
146+
137147
return 0;
138148
}
139149

0 commit comments

Comments
 (0)
0