Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c0aab89 commit dc8a108Copy full SHA for dc8a108
1 file changed
Python/bltinmodule.c
@@ -78,20 +78,27 @@ builtin_dir(self, v)
78
object *d;
79
if (v == NULL) {
80
d = getlocals();
81
+ INCREF(d);
82
}
83
else {
- if (!is_moduleobject(v)) {
84
+ d = getattr(v, "__dict__");
85
+ if (d == NULL) {
86
err_setstr(TypeError,
- "dir() argument must be module or absent");
87
+ "dir() argument has no variable attributes");
88
return NULL;
89
- d = getmoduledict(v);
90
- v = getdictkeys(d);
91
- if (sortlist(v) != 0) {
92
- DECREF(v);
93
- v = NULL;
+ if (!is_dictobject(d)) { /* Assume it is None */
+ v = newlistobject(0);
94
+ else {
95
+ v = getdictkeys(d);
96
+ if (sortlist(v) != 0) {
97
+ DECREF(v);
98
+ v = NULL;
99
+ }
100
101
+ DECREF(d);
102
return v;
103
104
0 commit comments