------------------------------------------------------------------------------
| 599 | |
| 600 | //------------------------------------------------------------------------------ |
| 601 | void vtkPythonInterpreter::SetProgramName(const char* programname) |
| 602 | { |
| 603 | vtkPythonPreConfig(); |
| 604 | if (programname) |
| 605 | { |
| 606 | #if PY_VERSION_HEX >= 0x03080000 |
| 607 | if (wchar_t* argv0 = vtk_Py_UTF8ToWide(programname)) |
| 608 | { |
| 609 | PythonProgramName.push_back(argv0); |
| 610 | } |
| 611 | else |
| 612 | { |
| 613 | vtk::print(stderr, |
| 614 | "Fatal vtkpython error: " |
| 615 | "unable to decode the program name\n"); |
| 616 | wchar_t* empty = (wchar_t*)PyMem_RawMalloc(sizeof(wchar_t)); |
| 617 | empty[0] = 0; |
| 618 | PythonProgramName.push_back(empty); |
| 619 | } |
| 620 | #else |
| 621 | // From Python Docs: The argument should point to a zero-terminated character |
| 622 | // string in static storage whose contents will not change for the duration of |
| 623 | // the program's execution. No code in the Python interpreter will change the |
| 624 | // contents of this storage. |
| 625 | wchar_t* argv0 = vtk_Py_UTF8ToWide(programname); |
| 626 | if (argv0 == nullptr) |
| 627 | { |
| 628 | vtk::print(stderr, |
| 629 | "Fatal vtkpython error: " |
| 630 | "unable to decode the program name\n"); |
| 631 | static wchar_t empty[1] = { 0 }; |
| 632 | argv0 = empty; |
| 633 | Py_SetProgramName(argv0); |
| 634 | } |
| 635 | else |
| 636 | { |
| 637 | static WCharStringPool wpool; |
| 638 | Py_SetProgramName(wpool.push_back(argv0)); |
| 639 | } |
| 640 | #endif |
| 641 | } |
| 642 | } |
| 643 | |
| 644 | //------------------------------------------------------------------------------ |
| 645 | void vtkPythonInterpreter::PrependPythonPath(const char* dir) |
nothing calls this directly
no test coverage detected