Hello.
I would like to report a parser bug manifesting on Python 2.5, 2.7 (but not on 2.2)
and 3.3.
Please see the attached script.
Basically this bug appeared after applying PythonTidy on a valid script.
More exactly, when running:
python -c "import iCam_GIT5_5"
I get:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "iCam_GIT5_5.py", line 60
^
SyntaxError: invalid syntax
Actually, the error reported by Python is a bug, as far as I see: the line 60
reported in the script does not actually contain the text reported in the error, and this
makes quite difficult locating the so-called error.
In fact the error is at script line 30: we should have all the code on one line, like
this
playlistToUse = youtubeClient.AddPlaylist(playlistTitle, playlistTitle,
playlist_private=False).
The "\" used in the script to break the line in 2 is a reminiscence of running
PythonTidy-1.22.python (so fixing this bug would be directly relevant when using PythonTidy).
With this occasion I would like to ask also what are the limits of the Python 2.x and
3.x parser. Where can I find what are the limits on the size/lines of the parsed script?
Best regards,
Alex
CURRENT_RELEASE_TIME = '2012_12_10_13_00_00'
NEW_BT_FORMAT_TO_ALLOW_PLAYING_FILE_EVEN_IN_INBOX = True
def SendAlarmMessageToYouTubePlaylist(message):
global youtubeClient, youtubeClientAlreadyConnected
global YOUTUBE_TEST_CLIENT_ID, googleUsername, youtubeDeveloperKey
global uploadMediaToYouTube
global deviceId
if MY_DEBUG_STDOUT:
print 'Entered SendAlarmMessageToYouTubePlaylist() at %s.' %
GetCurrentDateTimeStringWithMilliseconds()
sys.stdout.flush()
if uploadMediaToYouTube == 0:
uploadMediaToYouTube = 1
if youtubeClientAlreadyConnected == False:
if gdataModulesImported == False:
ImportGdataModules()
connResult = ConnectToYouTubeGData()
try:
playlistTitle = 'iCam_alarm_' + deviceId
if False:
playlistDescription = playlistTitle
playlistToUse = None
feed = youtubeClient.GetYouTubePlaylistFeed()
for myEntry in feed.entry:
myEntryTitle = myEntry.title.text
myEntryIdStr = myEntry.id.text.split('/')[-1]
if playlistTitle == myEntryTitle:
playlistToUse = myEntry
break
if playlistToUse is None:
playlistToUse = \
youtubeClient.AddPlaylist(playlistTitle, playlistTitle,
playlist_private=False)
playlistDescription = ''
newPlaylistDescription = 'Alarm... motion degree... audio degree...
%s.' % message
playlistToUse = None
feed = youtubeClient.GetYouTubePlaylistFeed()
for myEntry in feed.entry:
myEntryTitle = myEntry.title.text
myEntryIdStr = myEntry.id.text.split('/')[-1]
if myEntryTitle == playlistTitle:
if MY_DEBUG_STDOUT:
print 'SendAlarmMessageToYouTubePlaylist(): Feed matched
myEntry =', myEntry
print 'SendAlarmMessageToYouTubePlaylist(): myEntry.content
=', myEntry.content
print 'SendAlarmMessageToYouTubePlaylist():
myEntry.description = %s' % str(myEntry.description)
sys.stdout.flush()
playlistDescription =
str(myEntry.description).split('>')[-2].split('</')[0]
if MY_DEBUG_STDOUT:
print 'SendAlarmMessageToYouTubePlaylist():
playlistDescription =', playlistDescription
sys.stdout.flush()
playlistToUse = myEntry
break
if playlistToUse is None:
if MY_DEBUG_STDOUT:
print "SendAlarmMessageToYouTubePlaylist(): Couldn't find
YouTube playlist %s. Creating it." % playlistTitle
sys.stdout.flush()
playlistToUse = youtubeClient.AddPlaylist(playlistTitle,
newPlaylistDescription, playlist_private=False)
myEntryIdStr = playlistToUse.id.text.split('/')[-1]
else:
if len(newPlaylistDescription) + len(playlistDescription) < 5000:
playlistDescription += newPlaylistDescription
else:
playlistDescription = newPlaylistDescription
youtubeClient.UpdatePlaylist(playlist_id=myEntryIdStr,
new_playlist_title=playlistTitle, new_playlist_description=playlistDescription,
playlist_private=True, username='default')
if False:
aVideoTitle = ''
aVideoDescription = ''
playlistURI = playlistToUse.feed_link[0].href
response =
youtubeClient.AddPlaylistVideoEntryToPlaylist(playlistURI,
newVideoEntry.id.text.split('/')[-1], aVideoTitle, aVideoDescription)
except:
if MY_DEBUG_STDERR:
traceback.print_exc()
sys.stderr.flush()
if MY_DEBUG_STDOUT:
print 'Exiting SendAlarmMessageToYouTubePlaylist() at %s.' %
GetCurrentDateTimeStringWithMilliseconds()
sys.stdout.flush()
--
http://mail.python.org/mailman/listinfo/python-list