4914f5562d357582e9af010f479c5208ea887454
max
  Tue Jul 4 06:13:51 2023 -0700
on hgwbeta, we got '_io.BufferedWriter' object has no attribute 'buffer' when accessing stdout.buffer, not on hgwdev, see #31591. No idea why this happens but just in case, using the old-school way to wrap stdout now, as a file-like object, refs #31563

diff --git src/hg/hgGeneGraph/hgGeneGraph src/hg/hgGeneGraph/hgGeneGraph
index 8da2754..ead7043 100755
--- src/hg/hgGeneGraph/hgGeneGraph
+++ src/hg/hgGeneGraph/hgGeneGraph
@@ -2013,30 +2013,30 @@
 def main():
     cgiSetup()
 
     format = getCgiVar("format")
     if format in ["pdf", "svg", "sif", "json"]:
         conn = sqlConnect(GGDB)
         gene, alg, addNeighbors, sortByCount, geneCount = parseGraphArgs()
         graphLinks, lowLinks = buildGraph(conn, gene, geneCount, MINSUPP, addNeighbors)
         weightedLinks, minAbsCount = flattenLink(graphLinks)
         printGraph(conn, weightedLinks, alg, addNeighbors, gene, format)
         sys.exit(0)
 
 
     # Apache doesn't set LANG, so the default encoding of stdout is ASCII: Change it to utf8
     import codecs
-    sys.stdout = codecs.getwriter('utf8')(sys.stdout.buffer)
+    sys.stdout = open(1, 'w', encoding='utf-8', closefd=False)
 
     printContentType()
 
     if cgiString("debug") is not None:
         global DEBUG
         DEBUG = True
 
     htmlHeader()
     printInlineAndStyles()
     htmlMiddle()
     jsInlineFinish()
     htmlPageEnd()
 
 main()