PythonKit icon indicating copy to clipboard operation
PythonKit copied to clipboard

windows: Fix insecure CRT warning about getenv.

Open jeffdav opened this issue 9 months ago • 0 comments

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.

jeffdav avatar Mar 28 '25 17:03 jeffdav