PythonKit
PythonKit copied to clipboard
windows: Fix insecure CRT warning about getenv.
Building on Windows, I saw:
PS jeffdav\PythonKit> swift build
Building for debugging...
C:\Users\jeffdav\PythonKit\PythonKit\PythonLibrary.swift:287:33: warning: 'getenv' is deprecated: This function or variable may be unsafe. Consider using _dupenv_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [#DeprecatedDeclaration]
285 |
286 | var value: String? {
287 | guard let cString = getenv(key) else { return nil }
| `- warning: 'getenv' is deprecated: This function or variable may be unsafe. Consider using _dupenv_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [#DeprecatedDeclaration]
This switches the code to use _dupenv_s() instead, which is pretty straightforward.