为什么 google 应用程序引擎告诉我 windows 上的 python 中没有实现 umask?

Why does google app engine tell me that umask is not implemented in python on windows?

google应用引擎不支持umask吗?我可以在 windows 上的 anaconda 中使用它,但是当我在 google 应用程序引擎(运行 本地)中尝试它时,它不起作用。

此代码:

import webapp2
import os

class MainHandler(webapp2.RequestHandler):
    def get(self):
        mask = os.umask(0o177)
        self.response.write(mask)

app = webapp2.WSGIApplication([
    ('/', MainHandler)
], debug=True)

给我以下错误:

Traceback (most recent call last):

File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 1535, in __call__
rv = self.handle_exception(request, response, e)

File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 1529, in __call__
rv = self.router.dispatch(request, response)

File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 1278, in default_dispatcher
return route.handler_adapter(request, response)

File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 1102, in __call__
return handler.dispatch()

File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 572, in dispatch
return self.handle_exception(e, self.app.debug)

File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 570, in dispatch
return method(*args, **kwargs)

File "C:\Users\Dan\Documents\Apps\test\main.py", line 22, in get
mask = os.umask(0o177)

File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\python\stubs.py", line 40, in os_error_not_implemented
raise OSError(errno.ENOSYS, 'Function not implemented')

OSError: [Errno 40] Function not implemented

dev_appserver(您用于 "run locally" GAE 应用程序的程序)尽最大努力重现您在 "sandbox" 部署和 运行 在生产中(即在 appspot.com 上)——毕竟,它是一种开发工具,旨在让您更轻松地编写代码和调试应用程序以部署到 appspot.com。

dev_appserver 并没有完美地完成这个模拟,但它做得很好——特别是,禁止您的应用程序使用生产沙箱中不支持的标准库模块,或标准库模块中仅部分支持的特定非提供功能。 os.umask 只是后一种情况的一个例子。