summaryrefslogtreecommitdiffstats
path: root/ipapython
diff options
context:
space:
mode:
Diffstat (limited to 'ipapython')
-rw-r--r--ipapython/ipaldap.py41
1 files changed, 7 insertions, 34 deletions
diff --git a/ipapython/ipaldap.py b/ipapython/ipaldap.py
index 81d8c8dd5..bb14b4516 100644
--- a/ipapython/ipaldap.py
+++ b/ipapython/ipaldap.py
@@ -69,36 +69,6 @@ TRUNCATED_ADMIN_LIMIT = object()
DIRMAN_DN = DN(('cn', 'directory manager'))
-def unicode_from_utf8(val):
- '''
- val is a UTF-8 encoded string, return a unicode object.
- '''
- return val.decode('utf-8')
-
-
-def value_to_utf8(val):
- '''
- Coerce the val parameter to a UTF-8 encoded string representation
- of the val.
- '''
-
- # If val is not a string we need to convert it to a string
- # (specifically a unicode string). Naively we might think we need to
- # call str(val) to convert to a string. This is incorrect because if
- # val is already a unicode object then str() will call
- # encode(default_encoding) returning a str object encoded with
- # default_encoding. But we don't want to apply the default_encoding!
- # Rather we want to guarantee the val object has been converted to a
- # unicode string because from a unicode string we want to explicitly
- # encode to a str using our desired encoding (utf-8 in this case).
- #
- # Note: calling unicode on a unicode object simply returns the exact
- # same object (with it's ref count incremented). This means calling
- # unicode on a unicode object is effectively a no-op, thus it's not
- # inefficient.
-
- return unicode(val).encode('utf-8')
-
class _ServerSchema(object):
'''
Properties of a schema retrieved from an LDAP server.
@@ -877,7 +847,7 @@ class LDAPClient(object):
return 'FALSE'
elif isinstance(val, (unicode, six.integer_types, Decimal, DN,
Principal)):
- return value_to_utf8(val)
+ return six.text_type(val).encode('utf-8')
elif isinstance(val, DNSName):
return val.to_text()
elif isinstance(val, bytes):
@@ -909,9 +879,12 @@ class LDAPClient(object):
elif target_type is unicode:
return val.decode('utf-8')
elif target_type is datetime.datetime:
- return datetime.datetime.strptime(val, LDAP_GENERALIZED_TIME_FORMAT)
+ return datetime.datetime.strptime(
+ val.decode('utf-8'), LDAP_GENERALIZED_TIME_FORMAT)
elif target_type is DNSName:
- return DNSName.from_text(val)
+ return DNSName.from_text(val.decode('utf-8'))
+ elif target_type in (DN, Principal):
+ return target_type(val.decode('utf-8'))
else:
return target_type(val)
except Exception:
@@ -923,7 +896,7 @@ class LDAPClient(object):
elif isinstance(val, tuple):
return tuple(self.decode(m, attr) for m in val)
elif isinstance(val, dict):
- dct = dict((unicode_from_utf8(k), self.decode(v, k)) for k, v in val.items())
+ dct = dict((k.decode('utf-8'), self.decode(v, k)) for k, v in val.items())
return dct
elif val is None:
return None
s="hl opt">; /* 25 Min SDRAM Cycle time at CL=X-2 */ unsigned char clk_access3; /* 26 Max Access from Clock at CL=X-2 */ unsigned char trp; /* 27 Min Row Precharge Time (tRP)*/ unsigned char trrd; /* 28 Min Row Active to Row Active (tRRD) */ unsigned char trcd; /* 29 Min RAS to CAS Delay (tRCD) */ unsigned char tras; /* 30 Minimum RAS Pulse Width (tRAS) */ unsigned char row_dens; /* 31 Density of each row on module */ unsigned char ca_setup; /* 32 Cmd + Addr signal input setup time */ unsigned char ca_hold; /* 33 Cmd and Addr signal input hold time */ unsigned char data_setup; /* 34 Data signal input setup time */ unsigned char data_hold; /* 35 Data signal input hold time */ unsigned char twr; /* 36 Write Recovery time tWR */ unsigned char twtr; /* 37 Int write to read delay tWTR */ unsigned char trtp; /* 38 Int read to precharge delay tRTP */ unsigned char mem_probe; /* 39 Mem analysis probe characteristics */ unsigned char trctrfc_ext; /* 40 Extensions to trc and trfc */ unsigned char trc; /* 41 Min Active to Auto refresh time tRC */ unsigned char trfc; /* 42 Min Auto to Active period tRFC */ unsigned char tckmax; /* 43 Max device cycle time tCKmax */ unsigned char tdqsq; /* 44 Max DQS to DQ skew */ unsigned char tqhs; /* 45 Max Read DataHold skew tQHS */ unsigned char pll_relock; /* 46 PLL Relock time */ unsigned char res[15]; /* 47-xx IDD in SPD and Reserved space */ unsigned char spd_rev; /* 62 SPD Data Revision Code */ unsigned char cksum; /* 63 Checksum for bytes 0-62 */ unsigned char mid[8]; /* 64 Mfr's JEDEC ID code per JEP-108E */ unsigned char mloc; /* 72 Manufacturing Location */ unsigned char mpart[18]; /* 73 Manufacturer's Part Number */ unsigned char rev[2]; /* 91 Revision Code */ unsigned char mdate[2]; /* 93 Manufacturing Date */ unsigned char sernum[4]; /* 95 Assembly Serial Number */ unsigned char mspec[27]; /* 99 Manufacturer Specific Data */ /* * Open for Customer Use starting with byte 128. */ unsigned char freq; /* 128 Intel spec: frequency */ unsigned char intel_cas; /* 129 Intel spec: CAS# Latency support */ } spd_eeprom_t; /* * Byte 2 Fundamental Memory Types. */ #define SPD_MEMTYPE_FPM (0x01) #define SPD_MEMTYPE_EDO (0x02) #define SPD_MEMTYPE_PIPE_NIBBLE (0x03) #define SPD_MEMTYPE_SDRAM (0x04) #define SPD_MEMTYPE_ROM (0x05) #define SPD_MEMTYPE_SGRAM (0x06) #define SPD_MEMTYPE_DDR (0x07) #define SPD_MEMTYPE_DDR2 (0x08) #endif /* _SPD_H_ */