升级到Python 2.4后出现语法错误 [英] Syntax error after upgrading to Python 2.4

查看:72
本文介绍了升级到Python 2.4后出现语法错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




升级到2.4(从2.3开始)后,我收到一个奇怪的语法错误:

import themes



Traceback(最近一次调用最后一次):

文件"<互动输入>",第1行,在?

文件" themes.py",第564行

font = self.font。 makeBlackAndWhite(),

additive = self.additive,

^

语法错误:语法无效


相关代码是:


def makeBlackAndWhite(self):


返回CharStyle(names = self.names,

basedOn = self.basedOn.makeBlackAndWhite(),

font = self.font.makeBlackAndWhite(),

additive = self.additive,

prefixText = self.prefixText)


这是CharStyle类中的一个方法,它返回CharSty的新修改的

实例le。


我正在使用Windows XP和Python 2.4.1


有什么想法吗? O :-)

解决方案



< fr*@easyjob.net>在消息中写道

news:11 ********************** @ z14g2000cwz.googlegr oups.com ...

升级到2.4(从2.3开始)后,我得到一个奇怪的语法错误:

import themes

Traceback (最近一次呼叫最后一次):
文件"< interactive input>",第1行,在?
文件" themes.py",第564行
font = self.font .makeBlackAndWhite(),
additive = self.additive,
^
SyntaxError:语法无效




插入符号的位置是有时会产生误导,尤其是

比例字体......

相关代码是:

def makeBlackAndWhite(self):

返回CharStyle(names = self.names,
basedOn = self.basedOn.makeBlackAndWhite(),
fo nt = self.font.makeBlackAndWhite(),
additive = self.additive,
prefixText = self.prefixText)

这是CharStyle类中的一个方法,它返回一个新的修改了CharStyle的实例。

我正在使用Windows XP和Python 2.4.1

任何想法? O: - )




我还没有看到问题。我当然没有看到任何应该升级的因素(因为它也是来自XP上的2.3?)


检查非打印字符后,我会洗掉param-default

行来试图确定哪个是真的有问题。祝你好运,或等待

a更多有用的回复。


Terry J. Reedy


>我还没有看到问题。我肯定没有看到任何应该

受到升级影响的事情(从XP上的2.3也是吗?)


是的。

在检查非打印字符后,我会将param默认的
行洗牌以试图确定哪个是真的有问题。祝你好运,或者等待
更有帮助的回复。




我重新安装了2.3.5版本,现在一切正常。它是

肯定是与最新版本相关的东西。


< rant>

这是主要的一个我终于放弃了使用Python和

切换到Smalltalk。当有人

永久性地对你的工具进行更改时,你不能专注于你的工作。


不断为语言添加新功能可能很有趣,但它b / b
大大增加了添加错误和错误的几率,比如因为我的代码或'perlish''语法问题导致的问题

for decorators。

< / rant>


现在感觉好多了。 :-)


Fernando写道:

我重新安装了2.3.5版本,现在一切正常。这肯定是与最新版本相关的东西。


在您确实知道

解决方案是什么之前,软件中没有问题。我会怀疑2.4

本身以外的其他问题,因为否则其他人很可能已经遇到过这个问题。


由于在编译期间(导入期间)引发了SyntaxError而没有执行

,因此即使在另一台机器上也应该可以获得它

相关代码。请给我发电子邮件给我一份该文件的副本和

我会为你调查一下吗?我已经安装了2.3和2.4并且它不需要很长时间才能找出问题所在,或者在

最少证明它不是2.4问题。如果你不能这样做,请尝试删除除class之外的所有代码的
。行和

类中的一个方法。它应该仍然为同一行提供语法错误。

< rant>
这是我最终放弃使用Python并且切换到Smalltalk的主要调用之一。当某人
永久性地对您的工具进行更改时,您无法专注于您的工作。




Python拥有绝对最佳的向后兼容性记录之一在

软件的历史,恕我直言。虽然我无法与

Smalltalk进行比较,但我确实怀疑Smalltalk已经(或可能)显着地好了b
除非它根本没有改变在30年......


仍然,有人必须是第一个发现每个bug的人,也许你已经在2.4中发现了一个b $ b。让我有那个文件(或者还是会产生问题的简化版本的

)我会证明我们其中一个人错了。 :-)


-Peter


Hi,

After upgrading to 2.4 (from 2.3), I''m getting a weird syntax error:

import themes


Traceback (most recent call last):
File "<interactive input>", line 1, in ?
File "themes.py", line 564
font = self.font.makeBlackAndWhite(),
additive = self.additive,
^
SyntaxError: invalid syntax

The relevant code is:

def makeBlackAndWhite( self ):

return CharStyle( names = self.names,
basedOn = self.basedOn.makeBlackAndWhite(),
font = self.font.makeBlackAndWhite(),
additive = self.additive,
prefixText = self.prefixText )

This is a method in the CharStyle class which returns a new modified
instance of CharStyle.

I''m using Windows XP and Python 2.4.1

Any ideas? O:-)

解决方案


<fr*@easyjob.net> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...

After upgrading to 2.4 (from 2.3), I''m getting a weird syntax error:

import themes

Traceback (most recent call last):
File "<interactive input>", line 1, in ?
File "themes.py", line 564
font = self.font.makeBlackAndWhite(),
additive = self.additive,
^
SyntaxError: invalid syntax



The location of the caret is sometimes misleading, especially with
proportional fonts...
The relevant code is:

def makeBlackAndWhite( self ):

return CharStyle( names = self.names,
basedOn = self.basedOn.makeBlackAndWhite(),
font = self.font.makeBlackAndWhite(),
additive = self.additive,
prefixText = self.prefixText )

This is a method in the CharStyle class which returns a new modified
instance of CharStyle.

I''m using Windows XP and Python 2.4.1

Any ideas? O:-)



I don''t see the problem yet. I certainly do not see anything that should
have been affected by the upgrade (was it from 2.3 on XP also?)

After checking for nonprinting chars, I would shuffle the param-default
lines to try to determine which is really at fault. Good luck, or wait for
a more helpful response.

Terry J. Reedy


> I don''t see the problem yet. I certainly do not see anything that should

have been affected by the upgrade (was it from 2.3 on XP also?)
Yes.
After checking for nonprinting chars, I would shuffle the param-default
lines to try to determine which is really at fault. Good luck, or wait for
a more helpful response.



I reinstalled version 2.3.5 and everything works fine now. It''s
definately something related to the latest version.

<rant>
This is one of the main resons I finally gave up using Python and
switched to Smalltalk. You can''t concentrate on your work while someone
is permanently introducing changes to your tool.

Constantly adding new features to a language might be fun, but it
substantially increases the odds of adding bugs and misfeatures, such
as whatever was causing problems with my code or the ''perlish'' syntax
for decorators.
</rant>

Feeling much better now. :-)


Fernando wrote:

I reinstalled version 2.3.5 and everything works fine now. It''s
definately something related to the latest version.
No problem in software is definite until you actually know what the
solution is. I''d suspect something other than a simple problem in 2.4
itself, since otherwise it is highly likely others would already have
encountered it.

Since a SyntaxError is raised during compilation (during import) and not
execution, it should be possible to get that even on another machine
without all the related code. Care to email me a copy of that file and
I''ll investigate it for you? I have both 2.3 and 2.4 installed and it
shouldn''t take long for me to figure out what the problem is, or at
least to prove that it is not a 2.4 issue. If you can''t do that, try
removing all the code except the "class" line and that one method in the
class. It should still give a syntax error for the same line.
<rant>
This is one of the main resons I finally gave up using Python and
switched to Smalltalk. You can''t concentrate on your work while someone
is permanently introducing changes to your tool.



Python has one of the absolute best backwards-compatibility records in
the history of software, IMHO. While I can''t offer a comparison with
Smalltalk, I really doubt Smalltalk has been (or could be) significantly
better unless it hasn''t changed at all in 30 years...

Still, someone has to be the first to find each bug, and maybe you''ve
discovered one in 2.4. Let me have that file (or a reduced version of
it that still generates the problem) and I''ll prove one of us wrong. :-)

-Peter


这篇关于升级到Python 2.4后出现语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆