오류 메시지 "NameError : 글로벌 이름 '다음'이 정의되어 있지 않습니다. '및 update_project python 스크립트의 1.9.0 릴리스 내용을 기반으로 사용자가 Python 버전 2.6 미만을 실행 중이라고 가정합니다. 다음 함수는 파이썬 2.6 (http://docs.python.org/2/library/functions.html#next)에서 소개 된 파이썬 내장 함수입니다. 이것은 Python 2.6뿐만 아니라 Python 2.4 (CentOS 5와 6 각각 기본 Python 설치)와 호환되어야하므로 업그레이드 스크립트의 알려진 버그입니다. 이 문제를 해결하려면, 당신은 $ OSSIEHOME/빈/update_project에있는 update_project 스크립트를 수정하고 다음 함수를 정의 할 수 있습니다 : 당신은 다음 이전에 정의 된 "safe_next"기능을 제거해야합니다
if not hasattr(__builtins__, 'next'):
# Python 2.4 does not have a free-standing next() function
def next(iterator, default):
"""
Backwards compatibility next() equivalent for Python 2.4.
"""
try:
return iterator.next()
except StopIteration:
return default
.
마지막으로, 당신은 새로 빈 문자열 ''명확성을 위해
, 이러한 변화와 update_project의 DIFF의 두 번째 인수를 다음 기능을 구현하고 추가를 호출 두 통화에서 "safe_next"를 교체해야
@@ -46,16 +46,16 @@ Options:
_bulkio_re = re.compile('BULKIO_data[A-Za-z]+_In_i')
-def safe_next(item):
- """
- Returns the next value of the iterator, or an empty string if the end of
- iteration has been reached. Allows string processing to gracefully handle
- the end of a line without explicit catch statements.
- """
- try:
- return next(item)
- except StopIteration:
- return ''
+if not hasattr(__builtins__, 'next'):
+ # Python 2.4 does not have a free-standing next() function
+ def next(iterator, default):
+ """
+ Backwards compatibility next() equivalent for Python 2.4.
+ """
+ try:
+ return iterator.next()
+ except StopIteration:
+ return default
def strip_comments(source):
"""
@@ -75,7 +75,7 @@ def strip_comments(source):
# Look for end comment token; if the end of the line is reached
# ch will be an empty string
while ch == '*':
- ch = safe_next(chars)
+ ch = next(chars, '')
if ch == '/':
inComment = False
break
@@ -83,7 +83,7 @@ def strip_comments(source):
if ch == '/':
# Read the next character to see if it matches a comment token
# (if it does not, both characters will be added to the output)
- ch += safe_next(chars)
+ ch += next(chars, '')
if ch == '/*':
# Comment, start discarding
inComment = True
update_project python 스크립트가 Python 2.4.3 버전과 호환되지 않는 것으로 나타났습니다. 이 버전의 python은 반복기에서 다음 명령을 인식하지 못하는 것으로 보입니다. 최신 버전의 Python을 시도 할 때 업그레이드 스크립트가 예상대로 작동했습니다. –
파이썬 2.4.3 버전과 함께 제공되는 CentOS 5.3을 사용하고있었습니다. –