zoukankan      html  css  js  c++  java
  • ValueError: the environment variable is longer than 32767 characters On Windows, an environment variable string ("name=value" string) is limited to 32,767 characters

    https://github.com/python/cpython/blob/aa1b8a168d8b8dc1dfc426364b7b664501302958/Lib/test/test_os.py

    https://github.com/python/cpython/blob/master/Lib/test/test_os.py#L1122

    import os
    
    s=''
    for i in range(1<<24):
        s+="A"
    
    os.environ.setdefault("k",s)
    

      

    os.environ.setdefault("k",s)
    File "C:envpy382libos.py", line 712, in setdefault
    self[key] = value
    File "C:envpy382libos.py", line 681, in __setitem__
    self.putenv(key, value)
    ValueError: the environment variable is longer than 32767 characters

            if sys.platform == "win32":
                # On Windows, an environment variable string ("name=value" string)
                # is limited to 32,767 characters
                longstr = 'x' * 32_768
                self.assertRaises(ValueError, os.putenv, longstr, "1")
                self.assertRaises(ValueError, os.putenv, "X", longstr)
                self.assertRaises(ValueError, os.unsetenv, longstr)
    

      

  • 相关阅读:
    页面定制CSS代码
    记录-20190511
    Java集合
    EL表达式
    javabean
    写一篇博文介绍JSP
    编写一篇博文介绍COOKIE和Session的原理及异同
    过滤器的使用
    Java种的String
    Java包装类
  • 原文地址:https://www.cnblogs.com/rsapaper/p/14133695.html
Copyright © 2011-2022 走看看