2

我只是第二次想知道哪个版本的 Python 用于 Google Appengine Python 2.7 运行时。

这是自 2.6 以来绝对有效的 Python,我希望 query_string 之后是“测试”:

query_string = "(test)"
query_string = query_string.translate(None, "()")

但是在 Google Appengine 上,它会导致 TypeError translate() 只需要一个参数(给定 2 个)

上周,我们遇到了另一种奇怪的行为,一个函数 a 调用了另一个函数 b,它可能会引发 ValueError。我可以在函数 b 中捕获异常,但不能在函数 a 中捕获异常,因为异常的传播,后端刚刚崩溃。几个小时后,这个错误(?)被修复了。

编辑:我正在使用 Python 2.7 运行时并sys.version返回2.7.3 (default, Oct 15 2012, 11:27:13)

应用程序.yaml:

application: test
version: 1
runtime: python27
api_version: 1
threadsafe: no
4

2 回答 2

5

根据您的更新进行编辑:
这可能是也可能不是问题的根本原因,但您app.yaml的说法不正确。的允许threadsafe值为truefalse。链接到文档的相应部分:https ://developers.google.com/appengine/docs/python/config/appconfig


原始答案:
发生这种情况的唯一方法是,如果您没有指定 GAE 应该为您的应用程序使用 Python 2.7 运行时app.yaml。以下是优秀文档中的一个示例

application: helloworld
version: 1
#        vvvvvvvv
runtime: python27
api_version: 1
threadsafe: true

handlers:
- url: /.*
  script: helloworld.app

如果不指定python27GAEruntime将使用 Python 2.5

于 2013-02-26T22:02:52.287 回答
2

这有点尴尬,GAE 是行为绝对正常,我使用的字符串是 unicode 对象,而不是 str。

于 2013-02-27T06:47:13.323 回答