[Patches] [ python-Patches-852334 ] Replace backticks with repr()

SourceForge.net noreply at sourceforge.net
Sat Mar 13 19:19:56 EST 2004


Patches item #852334, was opened at 2003-12-01 22:35
Message generated for change (Settings changed) made by doerwalter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=852334&group_id=5470

Category: Library (Lib)
Group: Python 2.4
>Status: Closed
Resolution: Fixed
Priority: 5
Submitted By: Walter Dörwald (doerwalter)
Assigned to: Anthony Baxter (anthonybaxter)
Summary: Replace backticks with repr()

Initial Comment:
This patch removes most used of backticks in the
standard library and replaces them with a call to
repr() or uses '%r' in format string. I didn't touch
the email package, the lib-old directory or
test_grammar.py.

----------------------------------------------------------------------

Comment By: Raymond Hettinger (rhettinger)
Date: 2004-03-13 22:20

Message:
Logged In: YES 
user_id=80475

Can this be closed?

----------------------------------------------------------------------

Comment By: Walter Dörwald (doerwalter)
Date: 2004-02-12 18:41

Message:
Logged In: YES 
user_id=89016

Checked in. I've got a few smtplib.SMTPServerDisconnected
exceptions when committing, but this was probably only for
the commit email.

----------------------------------------------------------------------

Comment By: Raymond Hettinger (rhettinger)
Date: 2004-02-06 19:52

Message:
Logged In: YES 
user_id=80475

If you're feeling confident, go ahead and submit it.  I
don't think Anthony has time for additional review.

----------------------------------------------------------------------

Comment By: Walter Dörwald (doerwalter)
Date: 2004-02-06 19:29

Message:
Logged In: YES 
user_id=89016

A new version of the patch that incorporates Gerrit's fixes
can be found at
http://styx.livinglogic.de/~walter/backtick2repr2.txt.

The failure in test_doctest.py has disappeared.

Is the patch ready to be checked in now?

----------------------------------------------------------------------

Comment By: Gerrit Holl (gerrit)
Date: 2004-02-01 11:19

Message:
Logged In: YES 
user_id=13298

Hmm, it doesn't seem to be possible to add an attachement to
a tracker not sumbitted by yourself. I've now uploaded the
metapatch to:
http://people.nl.linux.org/~gerrit/creaties/b2r.metadiff

----------------------------------------------------------------------

Comment By: Gerrit Holl (gerrit)
Date: 2004-02-01 11:10

Message:
Logged In: YES 
user_id=13298

Raymond Hettinger asked me if I could do a second review for
this patch, so I did. I found three errors. The first one is
in Lib/lib-old/codehack.py. It's a mistake that the change
is there at all. The second one in in
Lib/plat-mac/aetypes.py where a 'r' is missing. The third
and last one is in Tools/scripts/methfix.py. Here, a
variable is printed twice.

First one:
-   key = `co` # arbitrary but uniquely identifying string
+   key = co` # arbitrary but uniquely identifying string

Second one:
-        return "QDRectangle(%s, %s, %s, %s)" % (`self.v0`,
`self.h0`,
-                `self.v1`, `self.h1`)
+        return "QDRectangle(%r, %r, %r, %)" % (self.v0,
self.h0, self.v1, self.h1)

Third one:
-        err(tempname + ': warning: chmod failed (' + `msg`
+ ')\n')
+        err(tempname + '%s: warning: chmod failed (%r)\n' %
(tempname, msg))
     # Then make a backup of the original file as filename~
     try:
         os.rename(filename, filename + '~')
     except os.error, msg:
-        err(filename + ': warning: backup failed (' + `msg`
+ ')\n')
+        err(filename + '%s: warning: backup failed (%r)\n'
% (filename, msg))
     # Now move the temp file to the original file
     try:
         os.rename(tempname, filename)
     except os.error, msg:
-        err(filename + ': rename failed (' + `msg` + ')\n')
+        err(filename + '%s: rename failed (%r)\n' %
(filename, msg))

Attached is a meta-patch containing the differences between
the original backticks2repr.txt which contains some errors,
and the one with the errors removed.

Note that I did not run any test suite or something like
that, because I understand that had already been done.

Other things I noticed:
- sometimes this patch uses "foo %r bar" % baz, sometimes
"foo %r bar" % (baz,), and sometimes "foo " + repr(baz) + " bar"
- division needs a check as well, as '/' should be replaced
by '//' in a lot of places.
- there is one place where a (very) small behaviour change
occurs, namely in Demo/sockets/gopher.py, where "print '(Bad
line from server:', `line`, ')'" is replaced by "print '(Bad
line from server: %r)' % (line,)", which is a difference of
one whitespace character - I don't think it would cause a
lot of trouble ;-)
- it is possible that there are more errors in the patch
which I didn't see, but it's also possible that there aren't
any.
(Hmm, I don't see immediatly how to add a patch...)

----------------------------------------------------------------------

Comment By: Raymond Hettinger (rhettinger)
Date: 2004-01-01 08:31

Message:
Logged In: YES 
user_id=80475

Any progress on getting this reviewed?

----------------------------------------------------------------------

Comment By: Walter Dörwald (doerwalter)
Date: 2003-12-01 23:59

Message:
Logged In: YES 
user_id=89016

Updated the patch so that the test suite works again (except
for test_doctest.py)

----------------------------------------------------------------------

Comment By: Walter Dörwald (doerwalter)
Date: 2003-12-01 22:38

Message:
Logged In: YES 
user_id=89016

Oops, uploading the patch didn't work, as it's too big. It
can be found at
http://styx.livinglogic.de/~walter/backticks2repr.txt

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=852334&group_id=5470



More information about the Patches mailing list