Show More
@@ -23,6 +23,8 | |||
|
23 | 23 | #include <unistd.h> |
|
24 | 24 | #endif |
|
25 | 25 | |
|
26 | #include "util.h" | |
|
27 | ||
|
26 | 28 | /* some platforms lack the PATH_MAX definition (eg. GNU/Hurd) */ |
|
27 | 29 | #ifndef PATH_MAX |
|
28 | 30 | #define PATH_MAX 4096 |
@@ -95,8 +97,7 static void listdir_stat_dealloc(PyObjec | |||
|
95 | 97 | } |
|
96 | 98 | |
|
97 | 99 | static PyTypeObject listdir_stat_type = { |
|
98 | PyObject_HEAD_INIT(NULL) | |
|
99 | 0, /*ob_size*/ | |
|
100 | PyVarObject_HEAD_INIT(NULL, 0) | |
|
100 | 101 | "osutil.stat", /*tp_name*/ |
|
101 | 102 | sizeof(struct listdir_stat), /*tp_basicsize*/ |
|
102 | 103 | 0, /*tp_itemsize*/ |
@@ -392,7 +393,7 static PyObject *listdir(PyObject *self, | |||
|
392 | 393 | wantstat = statobj && PyObject_IsTrue(statobj); |
|
393 | 394 | |
|
394 | 395 | if (skipobj && skipobj != Py_None) { |
|
395 |
skip = Py |
|
|
396 | skip = PyBytes_AsString(skipobj); | |
|
396 | 397 | if (!skip) |
|
397 | 398 | return NULL; |
|
398 | 399 | } |
@@ -486,12 +487,13 static PyObject *posixfile(PyObject *sel | |||
|
486 | 487 | } |
|
487 | 488 | |
|
488 | 489 | fd = _open_osfhandle((intptr_t)handle, flags); |
|
490 | ||
|
489 | 491 | if (fd == -1) { |
|
490 | 492 | CloseHandle(handle); |
|
491 | 493 | PyErr_SetFromErrnoWithFilename(PyExc_IOError, name); |
|
492 | 494 | goto bail; |
|
493 | 495 | } |
|
494 | ||
|
496 | #ifndef IS_PY3K | |
|
495 | 497 | fp = _fdopen(fd, fpmode); |
|
496 | 498 | if (fp == NULL) { |
|
497 | 499 | _close(fd); |
@@ -506,6 +508,11 static PyObject *posixfile(PyObject *sel | |||
|
506 | 508 | } |
|
507 | 509 | |
|
508 | 510 | PyFile_SetBufSize(file_obj, bufsize); |
|
511 | #else | |
|
512 | file_obj = PyFile_FromFd(fd, name, mode, bufsize, NULL, NULL, NULL, 1); | |
|
513 | if (file_obj == NULL) | |
|
514 | goto bail; | |
|
515 | #endif | |
|
509 | 516 | bail: |
|
510 | 517 | PyMem_Free(name); |
|
511 | 518 | return file_obj; |
@@ -525,6 +532,23 static PyMethodDef methods[] = { | |||
|
525 | 532 | {NULL, NULL} |
|
526 | 533 | }; |
|
527 | 534 | |
|
535 | #ifdef IS_PY3K | |
|
536 | static struct PyModuleDef osutil_module = { | |
|
537 | PyModuleDef_HEAD_INIT, | |
|
538 | "osutil", | |
|
539 | osutil_doc, | |
|
540 | -1, | |
|
541 | methods | |
|
542 | }; | |
|
543 | ||
|
544 | PyMODINIT_FUNC PyInit_osutil(void) | |
|
545 | { | |
|
546 | if (PyType_Ready(&listdir_stat_type) < 0) | |
|
547 | return NULL; | |
|
548 | ||
|
549 | return PyModule_Create(&osutil_module); | |
|
550 | } | |
|
551 | #else | |
|
528 | 552 | PyMODINIT_FUNC initosutil(void) |
|
529 | 553 | { |
|
530 | 554 | if (PyType_Ready(&listdir_stat_type) == -1) |
@@ -532,3 +556,4 PyMODINIT_FUNC initosutil(void) | |||
|
532 | 556 | |
|
533 | 557 | Py_InitModule3("osutil", methods, osutil_doc); |
|
534 | 558 | } |
|
559 | #endif |
General Comments 0
You need to be logged in to leave comments.
Login now