Patchwork [3,of,5] pathencode: use hashlib.sha1 directly instead of indirecting through util

login
register
mail settings
Submitter Augie Fackler
Date June 10, 2016, 4:41 a.m.
Message ID <08f06fc43974db42a5b5.1465533676@imladris.local>
Download mbox | patch
Permalink /patch/15452/
State Accepted
Headers show

Comments

Augie Fackler - June 10, 2016, 4:41 a.m.
# HG changeset patch
# User Augie Fackler <raf@durin42.com>
# Date 1465532707 14400
#      Fri Jun 10 00:25:07 2016 -0400
# Node ID 08f06fc43974db42a5b5ba45744c584a2832ff3a
# Parent  bd2caf6762219aba40edd4dd697fee70de306940
pathencode: use hashlib.sha1 directly instead of indirecting through util

Patch

diff --git a/mercurial/pathencode.c b/mercurial/pathencode.c
--- a/mercurial/pathencode.c
+++ b/mercurial/pathencode.c
@@ -653,24 +653,24 @@  static int sha1hash(char hash[20], const
 	PyObject *shaobj, *hashobj;
 
 	if (shafunc == NULL) {
-		PyObject *util, *name = PyString_FromString("mercurial.util");
+		PyObject *hashlib, *name = PyString_FromString("hashlib");
 
 		if (name == NULL)
 			return -1;
 
-		util = PyImport_Import(name);
+		hashlib = PyImport_Import(name);
 		Py_DECREF(name);
 
-		if (util == NULL) {
-			PyErr_SetString(PyExc_ImportError, "mercurial.util");
+		if (hashlib == NULL) {
+			PyErr_SetString(PyExc_ImportError, "hashlib");
 			return -1;
 		}
-		shafunc = PyObject_GetAttrString(util, "sha1");
-		Py_DECREF(util);
+		shafunc = PyObject_GetAttrString(hashlib, "sha1");
+		Py_DECREF(hashlib);
 
 		if (shafunc == NULL) {
 			PyErr_SetString(PyExc_AttributeError,
-					"module 'mercurial.util' has no "
+					"module 'hashlib' has no "
 					"attribute 'sha1'");
 			return -1;
 		}