This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Replace backticks with repr()
Type: Stage:
Components: Library (Lib) Versions: Python 2.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: anthonybaxter Nosy List: anthonybaxter, doerwalter, gerrit, rhettinger
Priority: normal Keywords: patch

Created on 2003-12-01 21:35 by doerwalter, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (10)
msg44992 - (view) Author: Walter Dörwald (doerwalter) * (Python committer) Date: 2003-12-01 21:35
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.
msg44993 - (view) Author: Walter Dörwald (doerwalter) * (Python committer) Date: 2003-12-01 21:38
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
msg44994 - (view) Author: Walter Dörwald (doerwalter) * (Python committer) Date: 2003-12-01 22:59
Logged In: YES 
user_id=89016

Updated the patch so that the test suite works again (except
for test_doctest.py)
msg44995 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2004-01-01 07:31
Logged In: YES 
user_id=80475

Any progress on getting this reviewed?
msg44996 - (view) Author: Gerrit Holl (gerrit) Date: 2004-02-01 10:10
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...)
msg44997 - (view) Author: Gerrit Holl (gerrit) Date: 2004-02-01 10:19
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
msg44998 - (view) Author: Walter Dörwald (doerwalter) * (Python committer) Date: 2004-02-06 18:29
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?
msg44999 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2004-02-06 18:52
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.
msg45000 - (view) Author: Walter Dörwald (doerwalter) * (Python committer) Date: 2004-02-12 17:41
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.
msg45001 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2004-03-13 21:20
Logged In: YES 
user_id=80475

Can this be closed?
History
Date User Action Args
2022-04-11 14:56:01adminsetgithub: 39644
2003-12-01 21:35:34doerwaltercreate